From 108758c3d38cd42d9441eeb37afd0364c87c5406 Mon Sep 17 00:00:00 2001 From: slime Date: Thu, 22 Sep 2022 23:01:31 -0300 Subject: [PATCH] vulkan: fix stencil buffer having undefined contents note: there are still other issues with draws using stencils. --- src/modules/graphics/vulkan/Graphics.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index 6493d574c..84d204fcb 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -555,7 +555,6 @@ bool Graphics::setMode(void *context, int width, int height, int pixelwidth, int void Graphics::initCapabilities() { - // fixme: unsure what the first few features are for. capabilities.features[FEATURE_MULTI_RENDER_TARGET_FORMATS] = true; capabilities.features[FEATURE_CLAMP_ZERO] = true; capabilities.features[FEATURE_CLAMP_ONE] = true; @@ -2189,8 +2188,11 @@ VkRenderPass Graphics::createRenderPass(RenderPassConfiguration &configuration) else depthStencilAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; depthStencilAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; - depthStencilAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - depthStencilAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; + if (configuration.staticData.depthAttachment.discard) + depthStencilAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; + else + depthStencilAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; + depthStencilAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; depthStencilAttachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; depthStencilAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; attachments.push_back(depthStencilAttachment);