From 08c2b9d7cbc2b60233c3d3ed411ceb9649fe5c9f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 7 Feb 2022 12:37:32 -0500 Subject: [PATCH] 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 Part-of: --- src/gallium/frontends/lavapipe/lvp_execute.c | 36 ++------------------ 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/gallium/frontends/lavapipe/lvp_execute.c b/src/gallium/frontends/lavapipe/lvp_execute.c index 496a2458a34..d47f3ad4ba4 100644 --- a/src/gallium/frontends/lavapipe/lvp_execute.c +++ b/src/gallium/frontends/lavapipe/lvp_execute.c @@ -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;