mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Don't allow calling Texture:generateMipmaps on depth/stencil textures
This commit is contained in:
@@ -233,6 +233,9 @@ Texture::Texture(const Settings &settings, const Slices *slices)
|
|||||||
if (mipmapsMode != MIPMAPS_NONE)
|
if (mipmapsMode != MIPMAPS_NONE)
|
||||||
mipmapCount = getTotalMipmapCount(pixelWidth, pixelHeight, depth);
|
mipmapCount = getTotalMipmapCount(pixelWidth, pixelHeight, depth);
|
||||||
|
|
||||||
|
if (mipmapsMode == MIPMAPS_AUTO && isPixelFormatDepthStencil(format))
|
||||||
|
throw love::Exception("Automatic mipmap generation cannot be used for depth/stencil textures.");
|
||||||
|
|
||||||
if (pixelWidth <= 0 || pixelHeight <= 0 || layers <= 0 || depth <= 0)
|
if (pixelWidth <= 0 || pixelHeight <= 0 || layers <= 0 || depth <= 0)
|
||||||
throw love::Exception("Texture dimensions must be greater than 0.");
|
throw love::Exception("Texture dimensions must be greater than 0.");
|
||||||
|
|
||||||
@@ -498,6 +501,9 @@ void Texture::generateMipmaps()
|
|||||||
if (isPixelFormatCompressed(format))
|
if (isPixelFormatCompressed(format))
|
||||||
throw love::Exception("generateMipmaps cannot be called on a compressed Texture.");
|
throw love::Exception("generateMipmaps cannot be called on a compressed Texture.");
|
||||||
|
|
||||||
|
if (isPixelFormatDepthStencil(format))
|
||||||
|
throw love::Exception("generateMipmaps cannot be called on a depth/stencil Texture.");
|
||||||
|
|
||||||
generateMipmapsInternal();
|
generateMipmapsInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -717,15 +717,12 @@ void Graphics::endPass()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generateMipmaps can't be used for depth/stencil textures.
|
||||||
for (const auto &rt : rts.colors)
|
for (const auto &rt : rts.colors)
|
||||||
{
|
{
|
||||||
if (rt.texture->getMipmapsMode() == Texture::MIPMAPS_AUTO && rt.mipmap == 0)
|
if (rt.texture->getMipmapsMode() == Texture::MIPMAPS_AUTO && rt.mipmap == 0)
|
||||||
rt.texture->generateMipmaps();
|
rt.texture->generateMipmaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
int dsmipmap = rts.depthStencil.mipmap;
|
|
||||||
if (depthstencil != nullptr && depthstencil->getMipmapsMode() == Texture::MIPMAPS_AUTO && dsmipmap == 0)
|
|
||||||
depthstencil->generateMipmaps();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth)
|
void Graphics::clear(OptionalColorf c, OptionalInt stencil, OptionalDouble depth)
|
||||||
|
|||||||
Reference in New Issue
Block a user