From fe642def49743ae885619fc239a44fdf5e0fa32d Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:29:52 -0400 Subject: [PATCH] [Vulkan] Fix pipeline rasterizationSamples mismatch with renderpass --- lib/ivis_opengl/gfx_api_vk.cpp | 11 +++++++---- lib/ivis_opengl/gfx_api_vk.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ivis_opengl/gfx_api_vk.cpp b/lib/ivis_opengl/gfx_api_vk.cpp index f6c6903499a..931e861f489 100644 --- a/lib/ivis_opengl/gfx_api_vk.cpp +++ b/lib/ivis_opengl/gfx_api_vk.cpp @@ -2515,7 +2515,7 @@ gfx_api::pipeline_state_object * VkRoot::build_pipeline(gfx_api::pipeline_state_ // build a pipeline, return an indirect VkPSOId (to enable rebuilding pipelines if needed) VkPSO* pipeline = nullptr; try { - pipeline = new VkPSO(dev, physDeviceProps.limits, createInfo, currentRenderPass().rp, currentRenderPass().rp_compat_info, msaaSamples, vkDynLoader, *this); + pipeline = new VkPSO(dev, physDeviceProps.limits, createInfo, currentRenderPass().rp, currentRenderPass().rp_compat_info, currentRenderPass().msaaSamples, vkDynLoader, *this); } catch (const std::exception& e) { @@ -2576,7 +2576,7 @@ void VkRoot::rebuildPipelinesIfNecessary() if (!renderPass.rp_compat_info->isCompatibleWith(*pipeline->renderpass_compat)) { delete pipeline; - pipelineInfo.renderPassPSO[renderPassId] = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, msaaSamples, vkDynLoader, *this); + pipelineInfo.renderPassPSO[renderPassId] = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, renderPass.msaaSamples, vkDynLoader, *this); } } } @@ -2777,6 +2777,7 @@ void VkRoot::createDefaultRenderpass(vk::Format swapchainFormat, vk::Format dept renderPasses[DEFAULT_RENDER_PASS_ID].rp_compat_info = std::make_shared(createInfo); renderPasses[DEFAULT_RENDER_PASS_ID].rp = dev.createRenderPass(createInfo, nullptr, vkDynLoader); + renderPasses[DEFAULT_RENDER_PASS_ID].msaaSamples = msaaSamples; // createFramebuffers for default render pass ASSERT(!swapchainImageView.empty(), "No swapchain image views?"); @@ -2953,6 +2954,7 @@ void VkRoot::createDepthPasses(vk::Format depthFormat) renderPasses[DEPTH_RENDER_PASS_ID].rp_compat_info = std::make_shared(createInfo); renderPasses[DEPTH_RENDER_PASS_ID].rp = dev.createRenderPass(createInfo, nullptr, vkDynLoader); + renderPasses[DEPTH_RENDER_PASS_ID].msaaSamples = vk::SampleCountFlagBits::e1; if (debugUtilsExtEnabled) { @@ -3131,6 +3133,7 @@ void VkRoot::createSceneRenderpass(vk::Format sceneFormat, vk::Format depthForma renderPasses[SCENE_RENDER_PASS_ID].rp_compat_info = std::make_shared(createInfo); renderPasses[SCENE_RENDER_PASS_ID].rp = dev.createRenderPass(createInfo, nullptr, vkDynLoader); + renderPasses[SCENE_RENDER_PASS_ID].msaaSamples = msaaSamples; if (debugUtilsExtEnabled) { @@ -5402,7 +5405,7 @@ void VkRoot::bind_pipeline(gfx_api::pipeline_state_object* pso, bool /*notexture { // Must build this pipeline for a different render pass auto& renderPass = renderPasses[currentRenderPassId]; - newPSO = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, msaaSamples, vkDynLoader, *this); + newPSO = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, renderPass.msaaSamples, vkDynLoader, *this); pipelineInfo.renderPassPSO[currentRenderPassId] = newPSO; } if (currentPSO != newPSO) @@ -6031,7 +6034,7 @@ bool VkRoot::setShadowConstants(gfx_api::shadow_constants newValues) if (pipeline->hasSpecializationConstant_ShadowConstants) { buffering_mechanism::get_current_resources().pso_to_delete.emplace_back(pipeline); - pipelineInfo.renderPassPSO[renderPassId] = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, msaaSamples, vkDynLoader, *this); + pipelineInfo.renderPassPSO[renderPassId] = new VkPSO(dev, physDeviceProps.limits, pipelineInfo.createInfo, renderPass.rp, renderPass.rp_compat_info, renderPass.msaaSamples, vkDynLoader, *this); } } } diff --git a/lib/ivis_opengl/gfx_api_vk.h b/lib/ivis_opengl/gfx_api_vk.h index c002782494e..1e51757c78a 100644 --- a/lib/ivis_opengl/gfx_api_vk.h +++ b/lib/ivis_opengl/gfx_api_vk.h @@ -668,6 +668,7 @@ struct VkRoot final : gfx_api::context vk::RenderPass rp; std::shared_ptr rp_compat_info; std::vector fbo; + vk::SampleCountFlagBits msaaSamples = vk::SampleCountFlagBits::e1; size_t identifier; RenderPassDetails(size_t _identifier)