From b481b63c786cf72555f8ff56340cee434d6e8899 Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Sat, 14 Oct 2023 14:31:59 +0200 Subject: [PATCH] Removed no longer required pipeline duplicatiion --- README.md | 2 +- .../variablerateshading/variablerateshading.cpp | 16 ++++------------ .../variablerateshading/variablerateshading.h | 5 +---- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ea7f6541..94fb039a 100644 --- a/README.md +++ b/README.md @@ -429,7 +429,7 @@ An updated version using ```VK_EXT_debug_utils``` along with an in-depth tutoria Shows how to render a scene using a negative viewport height, making the Vulkan render setup more similar to other APIs like OpenGL. Also has several options for changing relevant pipeline state, and displaying meshes with OpenGL or Vulkan style coordinates. Details can be found in [this tutorial](https://www.saschawillems.de/tutorials/vulkan/flipping-viewport). -#### [Variable rate shading (VK_NV_shading_rate_image)](examples/variablerateshading/) +#### [Variable rate shading (VK_KHR_fragment_shading_rate)](examples/variablerateshading/) Uses a special image that contains variable shading rates to vary the number of fragment shader invocations across the framebuffer. This makes it possible to lower fragment shader invocations for less important/less noisy parts of the framebuffer. diff --git a/examples/variablerateshading/variablerateshading.cpp b/examples/variablerateshading/variablerateshading.cpp index 5a767db4..50f66300 100644 --- a/examples/variablerateshading/variablerateshading.cpp +++ b/examples/variablerateshading/variablerateshading.cpp @@ -25,10 +25,8 @@ VulkanExample::VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION) VulkanExample::~VulkanExample() { - vkDestroyPipeline(device, basePipelines.masked, nullptr); - vkDestroyPipeline(device, basePipelines.opaque, nullptr); - vkDestroyPipeline(device, shadingRatePipelines.masked, nullptr); - vkDestroyPipeline(device, shadingRatePipelines.opaque, nullptr); + vkDestroyPipeline(device, pipelines.masked, nullptr); + vkDestroyPipeline(device, pipelines.opaque, nullptr); vkDestroyPipelineLayout(device, pipelineLayout, nullptr); vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr); vkDestroyImageView(device, shadingRateImage.view, nullptr); @@ -263,7 +261,6 @@ void VulkanExample::buildCommandBuffers() vkCmdSetFragmentShadingRateKHR(drawCmdBuffers[i], &fragmentSize, combinerOps); // Render the scene - Pipelines& pipelines = enableShadingRate ? shadingRatePipelines : basePipelines; vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.opaque); scene.draw(drawCmdBuffers[i], vkglTF::RenderFlags::BindImages | vkglTF::RenderFlags::RenderOpaqueNodes, pipelineLayout); vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.masked); @@ -543,17 +540,12 @@ void VulkanExample::preparePipelines() shaderStages[1].pSpecializationInfo = &specializationInfo; // Create pipeline without shading rate - VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &basePipelines.opaque)); + VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.opaque)); specializationData.alphaMask = true; rasterizationStateCI.cullMode = VK_CULL_MODE_NONE; - VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &basePipelines.masked)); + VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.masked)); rasterizationStateCI.cullMode = VK_CULL_MODE_BACK_BIT; specializationData.alphaMask = false; - - VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &shadingRatePipelines.opaque)); - specializationData.alphaMask = true; - rasterizationStateCI.cullMode = VK_CULL_MODE_NONE; - VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &shadingRatePipelines.masked)); } void VulkanExample::prepareUniformBuffers() diff --git a/examples/variablerateshading/variablerateshading.h b/examples/variablerateshading/variablerateshading.h index 4d522218..c634bcf3 100644 --- a/examples/variablerateshading/variablerateshading.h +++ b/examples/variablerateshading/variablerateshading.h @@ -40,10 +40,7 @@ public: struct Pipelines { VkPipeline opaque; VkPipeline masked; - }; - - Pipelines basePipelines; - Pipelines shadingRatePipelines; + } pipelines; VkPipelineLayout pipelineLayout; VkDescriptorSet descriptorSet;