Fix an issue when calculating the number of mipmaps for a volume/3D texture.

This commit is contained in:
Alex Szpakowski
2018-01-06 01:55:09 -04:00
parent 08b3635e4e
commit 6808968893
4 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ Canvas::Canvas(const Settings &settings)
if (settings.mipmaps != MIPMAPS_NONE)
{
mipmapCount = getMipmapCount(pixelWidth, pixelHeight);
mipmapCount = getTotalMipmapCount(pixelWidth, pixelHeight, depth);
filter.mipmap = defaultMipmapFilter;
}
+3 -2
View File
@@ -91,7 +91,7 @@ void Image::init(PixelFormat fmt, int w, int h, const Settings &settings)
if (isCompressed() && mipmapsType == MIPMAPS_GENERATED)
mipmapsType = MIPMAPS_NONE;
mipmapCount = mipmapsType == MIPMAPS_NONE ? 1 : getMipmapCount(w, h);
mipmapCount = mipmapsType == MIPMAPS_NONE ? 1 : getTotalMipmapCount(w, h);
if (mipmapCount > 1)
filter.mipmap = defaultMipmapFilter;
@@ -280,9 +280,10 @@ Image::MipmapsType Image::Slices::validate() const
int w = firstdata->getWidth();
int h = firstdata->getHeight();
int depth = textureType == TEXTURE_VOLUME ? slicecount : 1;
PixelFormat format = firstdata->getFormat();
int expectedmips = Texture::getMipmapCount(w, h);
int expectedmips = Texture::getTotalMipmapCount(w, h, depth);
if (mipcount != expectedmips && mipcount != 1)
throw love::Exception("Image does not have all required mipmap levels (expected %d, got %d)", expectedmips, mipcount);
+2 -2
View File
@@ -307,12 +307,12 @@ bool Texture::validateFilter(const Filter &f, bool mipmapsAllowed)
return true;
}
int Texture::getMipmapCount(int w, int h)
int Texture::getTotalMipmapCount(int w, int h)
{
return (int) log2(std::max(w, h)) + 1;
}
int Texture::getMipmapCount(int w, int h, int d)
int Texture::getTotalMipmapCount(int w, int h, int d)
{
return (int) log2(std::max(std::max(w, h), d)) + 1;
}
+2 -2
View File
@@ -148,8 +148,8 @@ public:
static bool validateFilter(const Filter &f, bool mipmapsAllowed);
static int getMipmapCount(int w, int h);
static int getMipmapCount(int w, int h, int d);
static int getTotalMipmapCount(int w, int h);
static int getTotalMipmapCount(int w, int h, int d);
static bool getConstant(const char *in, TextureType &out);
static bool getConstant(TextureType in, const char *&out);