radv: Add asserts to vk_format_depth/stencil_only

It doesn't make sense to ask for the depth-only or stencil-only format
if there is no depth or stencil.  One bit of radv_image.c did seem to
take advantage of the default case in vk_format_depth_only so throw an
`if (vk_format_has_depth(format))` around it.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12023>
This commit is contained in:
Jason Ekstrand 2021-07-30 12:40:09 -05:00 committed by Marge Bot
parent 3b00696117
commit 7878d516c6
2 changed files with 5 additions and 1 deletions

View file

@ -1389,6 +1389,8 @@ radv_image_reset_layout(struct radv_image *image)
for (unsigned i = 0; i < image->plane_count; ++i) {
VkFormat format = vk_format_get_plane_format(image->vk_format, i);
if (vk_format_has_depth(format))
format = vk_format_depth_only(format);
uint64_t flags = image->planes[i].surface.flags;
uint64_t modifier = image->planes[i].surface.modifier;
@ -1398,7 +1400,7 @@ radv_image_reset_layout(struct radv_image *image)
image->planes[i].surface.modifier = modifier;
image->planes[i].surface.blk_w = vk_format_get_blockwidth(format);
image->planes[i].surface.blk_h = vk_format_get_blockheight(format);
image->planes[i].surface.bpe = vk_format_get_blocksize(vk_format_depth_only(format));
image->planes[i].surface.bpe = vk_format_get_blocksize(format);
/* align byte per element on dword */
if (image->planes[i].surface.bpe == 3) {

View file

@ -124,6 +124,7 @@ vk_format_is_subsampled(VkFormat format)
static inline VkFormat
vk_format_depth_only(VkFormat format)
{
assert(vk_format_has_depth(format));
switch (format) {
case VK_FORMAT_D16_UNORM_S8_UINT:
return VK_FORMAT_D16_UNORM;
@ -209,6 +210,7 @@ vk_format_no_srgb(VkFormat format)
static inline VkFormat
vk_format_stencil_only(VkFormat format)
{
assert(vk_format_has_stencil(format));
return VK_FORMAT_S8_UINT;
}