Skip to content

Commit 235fabe

Browse files
DeviceContextVk: support read-only depth with dynamic rendering
1 parent 43352e0 commit 235fabe

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Graphics/GraphicsEngineVulkan/include/FramebufferCache.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class FramebufferCache
8989

9090
bool UseDepthAttachment = false;
9191
bool UseStencilAttachment = false;
92+
bool ReadOnlyDepthStencil = false;
9293
};
9394
static std::unique_ptr<VulkanUtilities::RenderingInfoWrapper> CreateDyanmicRenderInfo(
9495
const FramebufferCacheKey& Key,

Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,7 @@ void DeviceContextVkImpl::ChooseRenderPassAndFramebuffer()
19221922

19231923
CreateRIAttribs.UseDepthAttachment = true;
19241924
CreateRIAttribs.UseStencilAttachment = FmtAttribs.ComponentType == COMPONENT_TYPE_DEPTH_STENCIL;
1925+
CreateRIAttribs.ReadOnlyDepthStencil = (m_pBoundDepthStencil->GetDesc().ViewType == TEXTURE_VIEW_READ_ONLY_DEPTH_STENCIL);
19251926
}
19261927
if (m_pBoundShadingRateMap)
19271928
{

Graphics/GraphicsEngineVulkan/src/FramebufferCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ std::unique_ptr<VulkanUtilities::RenderingInfoWrapper> FramebufferCache::CreateD
167167
if (Attribs.UseDepthAttachment)
168168
{
169169
VkRenderingAttachmentInfoKHR& DepthAttachment = RI->GetDepthAttachment();
170-
InitAttachment(DepthAttachment, Key.DSV, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
170+
InitAttachment(DepthAttachment, Key.DSV, Attribs.ReadOnlyDepthStencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
171171
}
172172

173173
if (Attribs.UseStencilAttachment)
174174
{
175175
VkRenderingAttachmentInfoKHR& StencilAttachment = RI->GetStencilAttachment();
176-
InitAttachment(StencilAttachment, Key.DSV, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
176+
InitAttachment(StencilAttachment, Key.DSV, Attribs.ReadOnlyDepthStencil ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
177177
}
178178

179179
if (Key.ShadingRate)

0 commit comments

Comments
 (0)