diff options
author | Kristian Høgsberg Kristensen <[email protected]> | 2015-06-11 22:07:16 -0700 |
---|---|---|
committer | Kristian Høgsberg Kristensen <[email protected]> | 2015-06-11 22:07:16 -0700 |
commit | 00494c6cb7ec0ffd3fe12c0b450744627564f8be (patch) | |
tree | 13b442d00d4507b93bed48fc58ab39c03a76f38c | |
parent | fbc9fe3c92580208896d2799f117f23d477896f7 (diff) |
vk: Document how depth/stencil formats work in anv_image_create()
This reverts commits
e17ed04 * vk/image: Don't double-allocate stencil buffers
1ee2d1c * vk/image: Teach anv_image_choose_tile_mode about WMAJOR
and instead adds a comment to describe the subtlety of how we create
images for stencil only formats.
-rw-r--r-- | src/vulkan/image.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/vulkan/image.c b/src/vulkan/image.c index b8a15a1aa59..eaa0f24f732 100644 --- a/src/vulkan/image.c +++ b/src/vulkan/image.c @@ -73,16 +73,9 @@ anv_image_choose_tile_mode(const VkImageCreateInfo *vk_info, switch (vk_info->tiling) { case VK_IMAGE_TILING_LINEAR: - if (unlikely(vk_info->format == VK_FORMAT_S8_UINT)) { - anv_abortf("requested linear stencil buffer"); - } return LINEAR; case VK_IMAGE_TILING_OPTIMAL: - if (unlikely(vk_info->format == VK_FORMAT_S8_UINT)) { - return WMAJOR; - } else { - return YMAJOR; - } + return YMAJOR; default: assert(!"bad VKImageTiling"); return LINEAR; @@ -139,6 +132,11 @@ VkResult anv_image_create( info = anv_format_for_vk_format(pCreateInfo->format); assert(info->cpp > 0 || info->has_stencil); + /* 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 (info->cpp > 0) { image->stride = ALIGN_I32(image->extent.width * info->cpp, tile_info->width); @@ -149,7 +147,13 @@ VkResult anv_image_create( image->stride = 0; } - if (info->has_stencil && pCreateInfo->format != VK_FORMAT_S8_UINT) { + /* 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 (info->has_stencil) { const struct anv_tile_info *w_info = &anv_tile_info_table[WMAJOR]; image->stencil_offset = ALIGN_U32(image->size, w_info->surface_alignment); image->stencil_stride = ALIGN_I32(image->extent.width, w_info->width); |