From 78f37fe331cedfd049e589131fcccc0dfb39a261 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 25 Jun 2024 11:05:24 +0200 Subject: [PATCH] Vulkan: Fix incorrect image aspect When clearing only the depth of a depth/stencil only the depth part of the image aspect was stored in the node. This is invalid when the image needed to be transitioned. Pull Request: https://projects.blender.org/blender/blender/pulls/123713 --- source/blender/gpu/vulkan/vk_texture.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/gpu/vulkan/vk_texture.cc b/source/blender/gpu/vulkan/vk_texture.cc index 0215eb8ad30..10f9ca04d3c 100644 --- a/source/blender/gpu/vulkan/vk_texture.cc +++ b/source/blender/gpu/vulkan/vk_texture.cc @@ -140,9 +140,10 @@ void VKTexture::clear_depth_stencil(const eGPUFrameBufferBits buffers, uint clear_stencil) { BLI_assert(buffers & (GPU_DEPTH_BIT | GPU_STENCIL_BIT)); + VkImageAspectFlags vk_image_aspect_device = to_vk_image_aspect_flag_bits(device_format_get()); VkImageAspectFlags vk_image_aspect = to_vk_image_aspect_flag_bits( buffers & (GPU_DEPTH_BIT | GPU_STENCIL_BIT)) & - to_vk_image_aspect_flag_bits(device_format_get()); + vk_image_aspect_device; if (vk_image_aspect == VK_IMAGE_ASPECT_NONE) { /* Early exit: texture doesn't have any aspect that needs to be cleared. */ return; @@ -150,11 +151,10 @@ void VKTexture::clear_depth_stencil(const eGPUFrameBufferBits buffers, render_graph::VKClearDepthStencilImageNode::CreateInfo clear_depth_stencil_image = {}; clear_depth_stencil_image.node_data.vk_image = vk_image_handle(); - clear_depth_stencil_image.vk_image_aspects = vk_image_aspect; + clear_depth_stencil_image.vk_image_aspects = vk_image_aspect_device; clear_depth_stencil_image.node_data.vk_clear_depth_stencil_value.depth = clear_depth; clear_depth_stencil_image.node_data.vk_clear_depth_stencil_value.stencil = clear_stencil; - clear_depth_stencil_image.node_data.vk_image_subresource_range.aspectMask = - to_vk_image_aspect_flag_bits(buffers & (GPU_DEPTH_BIT | GPU_STENCIL_BIT)); + clear_depth_stencil_image.node_data.vk_image_subresource_range.aspectMask = vk_image_aspect; clear_depth_stencil_image.node_data.vk_image_subresource_range.layerCount = VK_REMAINING_ARRAY_LAYERS; clear_depth_stencil_image.node_data.vk_image_subresource_range.levelCount =