vulkan: Fix incorrect bpcs value for padded formats
Skip padding channels and only consider valid color channels. Add and use a common helper for this. Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Signed-off-by: Valentine Burley <valentine.burley@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30821>
This commit is contained in:

committed by
Marge Bot

parent
9eb315ff98
commit
c8a8543af7
@@ -358,9 +358,7 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
|
||||
y_format = format_ycbcr_info->planes[p].format;
|
||||
}
|
||||
assert(y_format != VK_FORMAT_UNDEFINED);
|
||||
const struct util_format_description *y_format_desc =
|
||||
util_format_description(vk_format_to_pipe_format(y_format));
|
||||
uint8_t y_bpc = y_format_desc->channel[0].size;
|
||||
uint8_t y_bpc = vk_format_get_bpc(y_format);
|
||||
|
||||
/* |ycbcr_comp| holds components in the order : Cr-Y-Cb */
|
||||
nir_def *zero = nir_imm_float(b, 0.0f);
|
||||
@@ -399,7 +397,9 @@ lower_ycbcr_tex_instr(nir_builder *b, nir_instr *instr, void *_state)
|
||||
|
||||
/* Also compute the number of bits for each component. */
|
||||
const struct util_format_description *plane_format_desc =
|
||||
util_format_description(vk_format_to_pipe_format(format_plane->format));
|
||||
vk_format_description(format_plane->format);
|
||||
if (plane_format_desc->channel[pc].type == UTIL_FORMAT_TYPE_VOID)
|
||||
continue;
|
||||
ycbcr_bpcs[ycbcr_component] = plane_format_desc->channel[pc].size;
|
||||
}
|
||||
}
|
||||
|
@@ -222,6 +222,22 @@ vk_format_get_blocksizebits(VkFormat format)
|
||||
return util_format_get_blocksizebits(vk_format_to_pipe_format(format));
|
||||
}
|
||||
|
||||
static inline unsigned
|
||||
vk_format_get_bpc(VkFormat format)
|
||||
{
|
||||
const struct util_format_description *desc =
|
||||
vk_format_description(format);
|
||||
unsigned bpc = 0;
|
||||
for (unsigned i = 0; i < desc->nr_channels; i++) {
|
||||
if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID)
|
||||
continue;
|
||||
|
||||
assert(bpc == 0 || bpc == desc->channel[i].size);
|
||||
bpc = desc->channel[i].size;
|
||||
}
|
||||
return bpc;
|
||||
}
|
||||
|
||||
VkFormat
|
||||
vk_format_get_plane_format(VkFormat format, unsigned plane_id);
|
||||
|
||||
@@ -266,7 +282,7 @@ vk_format_get_plane_width(VkFormat format, unsigned plane, unsigned width)
|
||||
const struct vk_format_ycbcr_info *ycbcr_info =
|
||||
vk_format_get_ycbcr_info(format);
|
||||
const uint8_t width_scale = ycbcr_info ?
|
||||
ycbcr_info->planes[plane].denominator_scales[0] : 1;
|
||||
ycbcr_info->planes[plane].denominator_scales[0] : 1;
|
||||
return width / width_scale;
|
||||
}
|
||||
|
||||
@@ -276,7 +292,7 @@ vk_format_get_plane_height(VkFormat format, unsigned plane, unsigned height)
|
||||
const struct vk_format_ycbcr_info *ycbcr_info =
|
||||
vk_format_get_ycbcr_info(format);
|
||||
const uint8_t height_scale = ycbcr_info ?
|
||||
ycbcr_info->planes[plane].denominator_scales[1] : 1;
|
||||
ycbcr_info->planes[plane].denominator_scales[1] : 1;
|
||||
return height / height_scale;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user