From ce39238210bffbfcf0361f1dd736c49a3732e7fb Mon Sep 17 00:00:00 2001 From: nmzik Date: Mon, 17 Aug 2026 09:33:11 +0200 Subject: [PATCH] renderer: preserve requested depth stencil view aspects --- .../host_gpu/renderer/image/imageView.cpp | 7 +++--- tests/ShaderRecompilerComputeTests.cpp | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/graphics/host_gpu/renderer/image/imageView.cpp b/src/graphics/host_gpu/renderer/image/imageView.cpp index 7d0e66418..2449f1a40 100644 --- a/src/graphics/host_gpu/renderer/image/imageView.cpp +++ b/src/graphics/host_gpu/renderer/image/imageView.cpp @@ -327,13 +327,12 @@ vk::ImageView Image::FindView(const ImageViewInfo& view_info) { const auto& image = backing; auto normalized = view_info; const bool is_storage = static_cast(normalized.usage & vk::ImageUsageFlagBits::eStorage); - normalized.aspect = FullAspectMask(image.format); - if (normalized.aspect & vk::ImageAspectFlagBits::eDepth && - IsDepthViewFormat(normalized.format)) { + const auto image_aspect = FullAspectMask(image.format); + if (image_aspect & vk::ImageAspectFlagBits::eDepth && IsDepthViewFormat(normalized.format)) { normalized.format = image.format; normalized.aspect = vk::ImageAspectFlagBits::eDepth; } - if (normalized.aspect & vk::ImageAspectFlagBits::eStencil && + if (image_aspect & vk::ImageAspectFlagBits::eStencil && IsStencilViewFormat(normalized.format)) { normalized.format = image.format; normalized.aspect = vk::ImageAspectFlagBits::eStencil; diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 64f8373b5..057dd5f72 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -2614,6 +2614,31 @@ public: depth_attachment != depth_array && depth.views.views.size() == 3, "unified depth view cache lost sampled/attachment identity"); + + auto depth_stencil_info = depth_info; + depth_stencil_info.pixel_format = vk::Format::eD24UnormS8Uint; + depth_stencil_info.guest_format = Prospero::BufferFormat::k16UNorm; + depth_stencil_info.bytes_per_block = 2; + Libs::Graphics::Image depth_stencil(m_runtime_context, scheduler, + depth_stencil_info); + auto depth_only_info = depth_sampled; + depth_only_info.format = depth_stencil_info.pixel_format; + const auto depth_only = depth_stencil.FindView(depth_only_info); + auto combined_info = depth_only_info; + combined_info.aspect = vk::ImageAspectFlagBits::eDepth | + vk::ImageAspectFlagBits::eStencil; + combined_info.mapping = {}; + combined_info.usage = vk::ImageUsageFlagBits::eDepthStencilAttachment; + const auto combined = depth_stencil.FindView(combined_info); + Require(name, "depth/stencil aspects", + depth_only != nullptr && combined != nullptr && + depth_only != combined && depth_stencil.views.views.size() == 2 && + depth_stencil.views.views[0].info.aspect == + vk::ImageAspectFlagBits::eDepth && + depth_stencil.views.views[1].info.aspect == + (vk::ImageAspectFlagBits::eDepth | + vk::ImageAspectFlagBits::eStencil), + "explicit depth-only and combined aspects shared one image view"); Require(name, "role-free backing", color.backing.image_type == vk::ImageType::e2D && color.backing.layers == 2 &&