fmt(VK_FORMAT_R11G11B10_UFLOAT, R11G11B10_FLOAT, .cpp = 4, .num_channels = 3),
fmt(VK_FORMAT_R9G9B9E5_UFLOAT, R9G9B9E5_SHAREDEXP, .cpp = 4, .num_channels = 3),
- /* For depth/stencil formats, the .format and .cpp fields describe the
- * depth format. The field .has_stencil indicates whether or not there's a
- * stencil buffer.
- */
fmt(VK_FORMAT_D16_UNORM, R16_UNORM, .cpp = 2, .num_channels = 1, .depth_format = D16_UNORM),
fmt(VK_FORMAT_D24_UNORM, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 1, .depth_format = D24_UNORM_X8_UINT),
fmt(VK_FORMAT_D32_SFLOAT, R32_FLOAT, .cpp = 4, .num_channels = 1, .depth_format = D32_FLOAT),
- fmt(VK_FORMAT_S8_UINT, UNSUPPORTED, .cpp = 0, .num_channels = 1, .has_stencil = true),
+ fmt(VK_FORMAT_S8_UINT, UNSUPPORTED, .cpp = 1, .num_channels = 1, .has_stencil = true),
fmt(VK_FORMAT_D16_UNORM_S8_UINT, R16_UNORM, .cpp = 2, .num_channels = 2, .depth_format = D16_UNORM, .has_stencil = true),
fmt(VK_FORMAT_D24_UNORM_S8_UINT, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 2, .depth_format = D24_UNORM_X8_UINT, .has_stencil = true),
fmt(VK_FORMAT_D32_SFLOAT_S8_UINT, R32_FLOAT, .cpp = 4, .num_channels = 2, .depth_format = D32_FLOAT, .has_stencil = true),
const struct anv_format *format_info =
anv_format_for_vk_format(pCreateInfo->format);
- assert(format_info->cpp > 0 || format_info->has_stencil);
uint32_t image_stride = 0;
uint32_t image_size = 0;
uint32_t stencil_offset = 0;
uint32_t stencil_stride = 0;
- /* First allocate space for the color or depth buffer. info->cpp gives us
- * the cpp of the color or depth in case of depth/stencil formats. Stencil
- * only (VK_FORMAT_S8_UINT) has info->cpp == 0 and doesn't allocate
- * anything here.
- */
- if (format_info->cpp > 0) {
+ if (!format_info->has_stencil || format_info->depth_format) {
+ /* The format has a color or depth component. Calculate space for it. */
uint32_t aligned_height;
image_stride = ALIGN_I32(extent->width * format_info->cpp,
image_size = image_stride * aligned_height;
}
- /* Formats with a stencil buffer (either combined depth/stencil or
- * VK_FORMAT_S8_UINT) have info->has_stencil == true. The stencil buffer is
- * placed after the depth buffer and is a separate buffer from the GPU
- * point of view, but as far as the API is concerned, depth and stencil are
- * in the same image.
- */
if (format_info->has_stencil) {
+ /* From the GPU's perspective, the depth buffer and stencil buffer are
+ * separate buffers. From Vulkan's perspective, though, depth and
+ * stencil reside in the same image. To satisfy Vulkan and the GPU, we
+ * place the depth and stencil buffers in the same bo.
+ */
const struct anv_tile_info *w_info = &anv_tile_info_table[WMAJOR];
uint32_t aligned_height;
uint32_t stencil_size;