Browse Source

vulkan: fix a crash when the window has no depth or stencil.

Sasha Szpakowski 11 months ago
parent
commit
8e6efac595
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/modules/graphics/vulkan/Graphics.cpp

+ 4 - 1
src/modules/graphics/vulkan/Graphics.cpp

@@ -2426,8 +2426,11 @@ void Graphics::setDefaultRenderPass()
 	renderPassState.transitionImages.clear();
 
 	RenderPassConfiguration renderPassConfiguration{};
+
 	renderPassConfiguration.colorAttachments.push_back({ swapChainImageFormat, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples });
-	renderPassConfiguration.staticData.depthStencilAttachment = { depthStencilFormat, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples };
+
+	VkFormat dsformat = backbufferHasDepth || backbufferHasStencil ? depthStencilFormat : VK_FORMAT_UNDEFINED;
+	renderPassConfiguration.staticData.depthStencilAttachment = { dsformat, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples };
 	if (msaaSamples & VK_SAMPLE_COUNT_1_BIT)
 		renderPassConfiguration.staticData.resolve = false;
 	else