mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Fix an issue when calculating the number of mipmaps for a volume/3D texture.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user