From a44916beab60f1f86372386b0e996eb95be75aa1 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 19 Jun 2018 08:52:56 -0700 Subject: Fixed layout transition for depth textures in Vulkan --- Graphics/GraphicsEngine/include/TextureViewBase.h | 5 +++++ Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngine/include/TextureViewBase.h b/Graphics/GraphicsEngine/include/TextureViewBase.h index 0b8ddc45..25c2c436 100644 --- a/Graphics/GraphicsEngine/include/TextureViewBase.h +++ b/Graphics/GraphicsEngine/include/TextureViewBase.h @@ -92,6 +92,11 @@ public: return m_pTexture; } + const ITexture* GetTexture()const + { + return m_pTexture; + } + protected: /// Strong reference to the sampler Diligent::RefCntAutoPtr m_pSampler; diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp index b63c106c..9f548fa4 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderResourceCacheVk.cpp @@ -266,7 +266,15 @@ VkDescriptorImageInfo ShaderResourceCacheVk::Resource::GetImageDescriptorWriteIn // If descriptorType is VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, for each descriptor that will be accessed // via load or store operations the imageLayout member for corresponding elements of pImageInfo // MUST be VK_IMAGE_LAYOUT_GENERAL (13.2.4) - DescrImgInfo.imageLayout = IsStorageImage ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + if(IsStorageImage) + DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL; + else + { + if(ValidatedCast(pTexViewVk->GetTexture())->GetDesc().BindFlags & BIND_DEPTH_STENCIL) + DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + else + DescrImgInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + } return DescrImgInfo; } -- cgit v1.2.3