From: Chad Versace Date: Fri, 28 Aug 2015 15:04:59 +0000 (-0700) Subject: vk/image: Linear stencil buffers are illegal X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=053d32d2a5906057519e12ffd8bc946bee2f5c60;p=mesa.git vk/image: Linear stencil buffers are illegal The hardware requires that stencil buffer memory be W-tiled. From the Sandybridge PRM: This buffer is supported only in Tile W memory. --- diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 656193f774e..736a76881ff 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -103,20 +103,32 @@ static const struct anv_tile_info { [WMAJOR] = { 128, 32, 4096 }, }; -static uint32_t +/** + * Return -1 on failure. + */ +static int8_t anv_image_choose_tile_mode(const struct anv_image_create_info *anv_info) { if (anv_info->force_tile_mode) return anv_info->tile_mode; - if (anv_info->vk_info->format == VK_FORMAT_S8_UINT) - return WMAJOR; + /* The Sandybridge PRM says that the stencil buffer "is supported + * only in Tile W memory". + */ switch (anv_info->vk_info->tiling) { case VK_IMAGE_TILING_LINEAR: - return LINEAR; + if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) { + return -1; + } else { + return LINEAR; + } case VK_IMAGE_TILING_OPTIMAL: - return YMAJOR; + if (unlikely(anv_info->vk_info->format == VK_FORMAT_S8_UINT)) { + return WMAJOR; + } else { + return YMAJOR; + } default: assert(!"bad VKImageTiling"); return LINEAR; @@ -143,7 +155,9 @@ anv_image_make_surface(const struct anv_image_create_info *create_info, const uint32_t levels = create_info->vk_info->mipLevels; const uint32_t array_size = create_info->vk_info->arraySize; - const uint8_t tile_mode = anv_image_choose_tile_mode(create_info); + const int8_t tile_mode = anv_image_choose_tile_mode(create_info); + if (tile_mode == -1) + return vk_error(VK_ERROR_INVALID_IMAGE); const struct anv_tile_info *tile_info = &anv_tile_info_table[tile_mode];