From 5baf02e1454de25600eba503b768729d11b99848 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sat, 1 Feb 2025 22:19:37 -0800 Subject: [PATCH] DeviceContextVk: set dynamic rendering view mask when committing render pass --- Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp | 5 ++--- Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp | 7 ++++--- Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp b/Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp index 7b6cb7b86..a271de13b 100644 --- a/Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp +++ b/Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp @@ -81,9 +81,8 @@ class FramebufferCache struct CreateDyanmicRenderInfoAttribs { - VkExtent2D Extent = {}; - uint32_t Layers = 0; - uint32_t ViewMask = 0; + VkExtent2D Extent = {}; + uint32_t Layers = 0; VkExtent2D ShadingRateTexelSize = {}; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 7fea4cb1e..df2028c13 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -1832,6 +1832,8 @@ void DeviceContextVkImpl::CommitRenderPassAndFramebuffer(bool VerifyStates) } else if (DynamicRenderingHash != 0) { + // Set view mask now as viewports may not be set when ChooseRenderPassAndFramebuffer() is called + m_DynamicRenderingInfo->SetViewMask((1u << m_NumViewports) - 1u); m_CommandBuffer.BeginRendering(*m_DynamicRenderingInfo, DynamicRenderingHash); } } @@ -1912,9 +1914,8 @@ void DeviceContextVkImpl::ChooseRenderPassAndFramebuffer() else { FramebufferCache::CreateDyanmicRenderInfoAttribs CreateRIAttribs; - CreateRIAttribs.Extent = {m_FramebufferWidth, m_FramebufferHeight}; - CreateRIAttribs.Layers = m_FramebufferSlices; - CreateRIAttribs.ViewMask = (1u << m_NumViewports) - 1u; + CreateRIAttribs.Extent = {m_FramebufferWidth, m_FramebufferHeight}; + CreateRIAttribs.Layers = m_FramebufferSlices; if (m_pBoundDepthStencil) { const TEXTURE_FORMAT DepthStencilFmt = m_pBoundDepthStencil->GetTexture()->GetDesc().Format; diff --git a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp index 99a27193c..96522d261 100644 --- a/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp +++ b/Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp @@ -143,9 +143,8 @@ std::unique_ptr FramebufferCache::CreateD std::unique_ptr RI = std::make_unique( Key.GetHash(), Key.NumRenderTargets, Attribs.UseDepthAttachment, Attribs.UseStencilAttachment); - RI->SetRenderArea({{0, 0}, Attribs.Extent}) - .SetLayerCount(Attribs.Layers) - .SetViewMask(Attribs.ViewMask); + RI->SetRenderArea({{0, 0}, Attribs.Extent}); + RI->SetLayerCount(Attribs.Layers); auto InitAttachment = [](VkRenderingAttachmentInfoKHR& Attachment, VkImageView View, VkImageLayout Layout) { Attachment.imageView = View;