vulkan: cache depthStencilFormat

This commit is contained in:
niki
2023-02-12 14:52:30 +01:00
parent dc6e080d18
commit 4f321d69e7
2 changed files with 7 additions and 8 deletions
+6 -8
View File
@@ -1448,6 +1448,7 @@ void Graphics::pickPhysicalDevice()
deviceApiVersion = properties.apiVersion;
msaaSamples = getMsaaCount(requestedMsaa);
depthStencilFormat = findDepthFormat();
}
bool Graphics::checkDeviceExtensionSupport(VkPhysicalDevice device)
@@ -2181,7 +2182,6 @@ VkRenderPass Graphics::createRenderPass(RenderPassConfiguration &configuration)
return renderPass;
}
VkRenderPass Graphics::getRenderPass(RenderPassConfiguration &configuration)
{
VkRenderPass renderPass;
@@ -2362,7 +2362,7 @@ void Graphics::setDefaultRenderPass()
RenderPassConfiguration renderPassConfiguration{};
renderPassConfiguration.colorAttachments.push_back({ swapChainImageFormat, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples });
renderPassConfiguration.staticData.depthStencilAttachment = { findDepthFormat(), VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples };
renderPassConfiguration.staticData.depthStencilAttachment = { depthStencilFormat, VK_ATTACHMENT_LOAD_OP_LOAD, VK_ATTACHMENT_LOAD_OP_LOAD, msaaSamples };
if (msaaSamples & VK_SAMPLE_COUNT_1_BIT)
renderPassConfiguration.staticData.resolve = false;
else
@@ -2384,8 +2384,8 @@ void Graphics::setDefaultRenderPass()
framebufferConfiguration.staticData.resolveView = swapChainImageViews.at(imageIndex);
}
renderPassState.renderPassConfiguration = renderPassConfiguration;
renderPassState.framebufferConfiguration = framebufferConfiguration;
renderPassState.renderPassConfiguration = std::move(renderPassConfiguration);
renderPassState.framebufferConfiguration = std::move(framebufferConfiguration);
if (renderPassState.windowClearRequested)
clear(renderPassState.mainWindowClearColorValue, renderPassState.mainWindowClearStencilValue, renderPassState.mainWindowClearDepthValue);
@@ -2890,12 +2890,10 @@ VkFormat Graphics::findDepthFormat()
void Graphics::createDepthResources()
{
VkFormat depthAttachment = findDepthFormat();
VkImageCreateInfo imageInfo{};
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
imageInfo.imageType = VK_IMAGE_TYPE_2D;
imageInfo.format = depthAttachment;
imageInfo.format = depthStencilFormat;
imageInfo.extent.width = swapChainExtent.width;
imageInfo.extent.height = swapChainExtent.height;
imageInfo.extent.depth = 1;
@@ -2918,7 +2916,7 @@ void Graphics::createDepthResources()
imageViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
imageViewInfo.image = depthImage;
imageViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D;
imageViewInfo.format = depthAttachment;
imageViewInfo.format = depthStencilFormat;
imageViewInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY;
imageViewInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY;
imageViewInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY;
+1
View File
@@ -402,6 +402,7 @@ private:
Matrix4 displayRotation;
std::vector<VkImage> swapChainImages;
VkFormat swapChainImageFormat = VK_FORMAT_UNDEFINED;
VkFormat depthStencilFormat = VK_FORMAT_UNDEFINED;
VkExtent2D swapChainExtent = VkExtent2D();
std::vector<VkImageView> swapChainImageViews;
VkSampleCountFlagBits msaaSamples = VK_SAMPLE_COUNT_1_BIT;