Mesa (staging/22.0): lavapipe: use util_pack_color_union() for generating clear colors

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Feb 25 02:23:18 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 4ed93de64aaef4a030e5bd6746554eb93b6e89c6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ed93de64aaef4a030e5bd6746554eb93b6e89c6

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Mon Feb  7 12:37:32 2022 -0500

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 at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14911>
(cherry picked from commit 08c2b9d7cbc2b60233c3d3ed411ceb9649fe5c9f)

---

 .pick_status.json                            |  2 +-
 src/gallium/frontends/lavapipe/lvp_execute.c | 36 +++-------------------------
 2 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b3a35357d8b..0c9f01916db 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4927,7 +4927,7 @@
         "description": "lavapipe: use util_pack_color_union() for generating clear colors",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
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;



More information about the mesa-commit mailing list