lavapipe: use util_pack_color_union() for generating clear colors
this enables clamping for packed formats (e.g., RGB10_A2UI) where color values may exceed the width of the component cc: mesa-stable fixes (zink): KHR-GL45.direct_state_access.renderbuffers_storage* Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14911>
This commit is contained in:
committed by
Marge Bot
parent
6faaeca584
commit
08c2b9d7cb
@@ -3041,43 +3041,13 @@ static void handle_copy_query_pool_results(struct vk_cmd_queue_entry *cmd,
|
||||
}
|
||||
}
|
||||
|
||||
static void pack_clear_color(enum pipe_format pformat, VkClearColorValue *in_val, uint32_t col_val[4])
|
||||
{
|
||||
const struct util_format_description *desc = util_format_description(pformat);
|
||||
col_val[0] = col_val[1] = col_val[2] = col_val[3] = 0;
|
||||
for (unsigned c = 0; c < 4; c++) {
|
||||
if (desc->swizzle[c] >= 4)
|
||||
continue;
|
||||
const struct util_format_channel_description *channel = &desc->channel[desc->swizzle[c]];
|
||||
if (channel->size == 32) {
|
||||
col_val[c] = in_val->uint32[c];
|
||||
continue;
|
||||
}
|
||||
if (channel->pure_integer) {
|
||||
uint64_t v = in_val->uint32[c] & ((1u << channel->size) - 1);
|
||||
switch (channel->size) {
|
||||
case 2:
|
||||
case 8:
|
||||
case 10:
|
||||
col_val[0] |= (v << channel->shift);
|
||||
break;
|
||||
case 16:
|
||||
col_val[c / 2] |= (v << (16 * (c % 2)));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
util_pack_color(in_val->float32, pformat, (union util_color *)col_val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_clear_color_image(struct vk_cmd_queue_entry *cmd,
|
||||
struct rendering_state *state)
|
||||
{
|
||||
LVP_FROM_HANDLE(lvp_image, image, cmd->u.clear_color_image.image);
|
||||
uint32_t col_val[4];
|
||||
pack_clear_color(image->bo->format, cmd->u.clear_color_image.color, col_val);
|
||||
union util_color uc;
|
||||
uint32_t *col_val = uc.ui;
|
||||
util_pack_color_union(image->bo->format, &uc, (void*)cmd->u.clear_color_image.color);
|
||||
for (unsigned i = 0; i < cmd->u.clear_color_image.range_count; i++) {
|
||||
VkImageSubresourceRange *range = &cmd->u.clear_color_image.ranges[i];
|
||||
struct pipe_box box;
|
||||
|
||||
Reference in New Issue
Block a user