vulkan: fix crashes

in isPixelFormatSupported and setStencilMode
This commit is contained in:
niki
2022-09-20 14:49:56 +02:00
parent a4f654c809
commit b0fb00c54f
2 changed files with 12 additions and 3 deletions
+6 -1
View File
@@ -869,7 +869,7 @@ void Graphics::setStencilMode(StencilAction action, CompareMode compare, int val
if (!isRenderTargetActive() && !windowHasStencil)
throw love::Exception("The window must have stenciling enabled to draw to the main screen's stencil buffer");
if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && dsTexture == nullptr || !isPixelFormatStencil(dsTexture->getPixelFormat()))
else if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dsTexture == nullptr || !isPixelFormatStencil(dsTexture->getPixelFormat())))
throw love::Exception("drawing to the stencil buffer with a render target active requires either stencil=true or a custom stencil-type to be used, in setRenderTarget");
}
@@ -942,6 +942,11 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
{
(void)sRGB; // fixme: sRGB
bool rendertarget = (usage & PIXELFORMATUSAGEFLAGS_RENDERTARGET) != 0;
bool readable = (usage & PIXELFORMATUSAGEFLAGS_SAMPLE) != 0;
format = getSizedFormat(format, rendertarget, readable);
auto vulkanFormat = Vulkan::getTextureFormat(format);
VkFormatProperties formatProperties;