Output correct number of mipmaps.
Fix nvtt, remove deprecated attributes.
This commit is contained in:
parent
9cfbb22d73
commit
6fa15f4e5b
@ -12,7 +12,7 @@
|
||||
#define NV_STDCALL __stdcall
|
||||
#define NV_FASTCALL __fastcall
|
||||
#define NV_FORCEINLINE __forceinline
|
||||
#define NV_DEPRECATED __deprecated
|
||||
#define NV_DEPRECATED
|
||||
|
||||
#define NV_PURE
|
||||
#define NV_CONST
|
||||
|
@ -433,7 +433,7 @@ void DDSHeader::setDepth(uint d)
|
||||
|
||||
void DDSHeader::setMipmapCount(uint count)
|
||||
{
|
||||
if (count == 0)
|
||||
if (count == 0 || count == 1)
|
||||
{
|
||||
this->flags &= ~DDSD_MIPMAPCOUNT;
|
||||
this->mipmapcount = 0;
|
||||
|
@ -110,7 +110,7 @@ static void outputHeader(const InputOptions::Private & inputOptions, const Outpu
|
||||
int mipmapCount = inputOptions.realMipmapCount();
|
||||
nvDebugCheck(mipmapCount > 0);
|
||||
|
||||
header.setMipmapCount(mipmapCount - 1);
|
||||
header.setMipmapCount(mipmapCount);
|
||||
|
||||
if (inputOptions.textureType == TextureType_2D) {
|
||||
header.setTexture2D();
|
||||
@ -472,14 +472,16 @@ private:
|
||||
// Find the first mipmap provided that is greater or equal to the target image size.
|
||||
static int findMipmap(const InputOptions::Private & inputOptions, uint f, int firstMipmap, uint w, uint h, uint d)
|
||||
{
|
||||
nvDebugCheck(firstMipmap >= 0);
|
||||
|
||||
int bestIdx = -1;
|
||||
|
||||
for (int m = firstMipmap; m < inputOptions.mipmapCount; m++)
|
||||
for (int m = firstMipmap; m < int(inputOptions.mipmapCount); m++)
|
||||
{
|
||||
int idx = f * inputOptions.mipmapCount + m;
|
||||
const InputOptions::Private::Image & mipmap = inputOptions.images[idx];
|
||||
|
||||
if (mipmap.width >= w && mipmap.height >= h && mipmap.depth >= d)
|
||||
if (mipmap.width >= int(w) && mipmap.height >= int(h) && mipmap.depth >= int(d))
|
||||
{
|
||||
if (mipmap.data != NULL)
|
||||
{
|
||||
@ -501,7 +503,7 @@ static int findMipmap(const InputOptions::Private & inputOptions, uint f, int fi
|
||||
static int findImage(const InputOptions::Private & inputOptions, uint f, uint w, uint h, uint d, int inputImageIdx, ImagePair * pair)
|
||||
{
|
||||
nvDebugCheck(w > 0 && h > 0);
|
||||
nvDebugCheck(inputImageIdx >= 0 && inputImageIdx < inputOptions.mipmapCount);
|
||||
nvDebugCheck(inputImageIdx >= 0 && inputImageIdx < int(inputOptions.mipmapCount));
|
||||
nvDebugCheck(pair != NULL);
|
||||
|
||||
int bestIdx = findMipmap(inputOptions, f, inputImageIdx, w, h, d);
|
||||
@ -552,6 +554,9 @@ static int findImage(const InputOptions::Private & inputOptions, uint f, uint w,
|
||||
pair->setFloatImage(createMipmap(pair->floatImage(), inputOptions));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return bestIdx; // @@ ???
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#define NVTT_CLASS
|
||||
#endif
|
||||
|
||||
#define NVTT_DEPRECATED NVTT_API NV_DEPRECATED
|
||||
#define NVTT_DEPRECATED NVTT_API /*NV_DEPRECATED*/
|
||||
|
||||
|
||||
// Public interface.
|
||||
@ -270,9 +270,9 @@ namespace nvtt
|
||||
NVTT_API void setErrorHandler(ErrorHandler * errorHandler);
|
||||
NVTT_API void setOutputHeader(bool outputHeader);
|
||||
|
||||
NVTT_DEPRECATED OutputHandler * outputHandler;
|
||||
NVTT_DEPRECATED ErrorHandler * errorHandler;
|
||||
NVTT_DEPRECATED bool outputHeader;
|
||||
OutputHandler * outputHandler;
|
||||
ErrorHandler * errorHandler;
|
||||
bool outputHeader;
|
||||
|
||||
//private:
|
||||
struct Private;
|
||||
|
Loading…
Reference in New Issue
Block a user