Skip to content

Fix depth-stencil image aspect masks - #440

Open
swayam8624 wants to merge 2 commits into
KhronosGroup:mainfrom
swayam8624:fix/depth-stencil-aspect
Open

Fix depth-stencil image aspect masks#440
swayam8624 wants to merge 2 commits into
KhronosGroup:mainfrom
swayam8624:fix/depth-stencil-aspect

Conversation

@swayam8624

Copy link
Copy Markdown

Summary

  • derive the depth image aspect mask from the selected depth format
  • use the mask for the image view and both layout-transition barriers

Root cause

The tutorial can select a depth/stencil format such as VK_FORMAT_D32_SFLOAT_S8_UINT, while the attachment sample hardcodes VK_IMAGE_ASPECT_DEPTH_BIT. Validation then reports VUID-VkImageMemoryBarrier2-image-03320 because the stencil aspect is omitted.

Validation

  • Reproduced on macOS Apple Silicon (M2 Pro) with the Khronos validation layer.
  • cmake -S attachments -B build/tutorial -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=arm64 -DENABLE_CPP20_MODULE=OFF -DKTX_INCLUDE_DIR=... -DKTX_LIBRARY=...
  • cmake --build build/tutorial --target 32_ecosystem_utilities -j4
  • standalone C++20 syntax check passed with Vulkan-Hpp defines
  • git diff --check passed

The executable initializes Vulkan but exits in this checkout because the required tutorial asset file is not found from the build layout.

@CLAassistant

CLAassistant commented Jul 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@swayam8624
swayam8624 marked this pull request as ready for review July 29, 2026 05:50

@asuessenbach asuessenbach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An important fix.
Just one issue:

Comment thread attachments/32_ecosystem_utilities.cpp Outdated
{
vk::Format depthFormat = findDepthFormat();
depthImageAspect = vk::ImageAspectFlagBits::eDepth;
if (hasStencilComponent(depthFormat))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the potentially being removed Renderer::hasStencilComponent (see #427), you might use the more general vk::hasStencilComponent from vulkan_format_traits.hpp.

@swayam8624

Copy link
Copy Markdown
Author

Addressed in commit f2b8e25. I added the explicit vulkan/vulkan_format_traits.hpp include, replaced the attachment-local helper with vk::hasStencilComponent, and removed the duplicate helper. The 32_ecosystem_utilities target builds successfully on macOS arm64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants