The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

comp: Fix depth-stencil image validation warning

Depth-only formats must use *only* VK_IMAGE_ASPECT_DEPTH_BIT.
Depth-stencil formats must use both VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT.

+37 -2
+37 -2
src/xrt/compositor/main/comp_swapchain.c
··· 109 109 return sc; 110 110 } 111 111 112 + static bool 113 + is_depth_only_format(VkFormat format) 114 + { 115 + return format == VK_FORMAT_D16_UNORM || format == VK_FORMAT_D32_SFLOAT; 116 + } 117 + 118 + static bool 119 + is_depth_stencil_format(VkFormat format) 120 + { 121 + 122 + return format == VK_FORMAT_D16_UNORM_S8_UINT || 123 + format == VK_FORMAT_D24_UNORM_S8_UINT || 124 + format == VK_FORMAT_D32_SFLOAT_S8_UINT; 125 + } 126 + 127 + static bool 128 + is_stencil_only_format(VkFormat format) 129 + { 130 + return format == VK_FORMAT_S8_UINT; 131 + } 132 + 112 133 static void 113 134 do_post_create_vulkan_setup(struct comp_compositor *c, 114 135 const struct xrt_swapchain_create_info *info, ··· 125 146 }; 126 147 127 148 bool depth = (info->bits & XRT_SWAPCHAIN_USAGE_DEPTH_STENCIL) != 0; 128 - VkImageAspectFlagBits aspect = 129 - depth ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT; 149 + 150 + VkImageAspectFlagBits aspect = 0; 151 + if (depth) { 152 + if (is_depth_only_format(info->format)) { 153 + aspect |= VK_IMAGE_ASPECT_DEPTH_BIT; 154 + } 155 + if (is_depth_stencil_format(info->format)) { 156 + aspect |= VK_IMAGE_ASPECT_DEPTH_BIT | 157 + VK_IMAGE_ASPECT_STENCIL_BIT; 158 + } 159 + if (is_stencil_only_format(info->format)) { 160 + aspect |= VK_IMAGE_ASPECT_STENCIL_BIT; 161 + } 162 + } else { 163 + aspect |= VK_IMAGE_ASPECT_COLOR_BIT; 164 + } 130 165 131 166 VkFormat format = info->format; 132 167 #if defined(XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER)