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