gallium: Refactor some single-pixel util_format_read/writes.
authorEric Anholt <eric@anholt.net>
Fri, 8 Nov 2019 22:56:07 +0000 (14:56 -0800)
committerMarge Bot <eric+marge@anholt.net>
Tue, 4 Feb 2020 19:02:59 +0000 (19:02 +0000)
We can use the new row helpers to cut down on the noise.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2744>

src/gallium/auxiliary/util/u_pack_color.h
src/gallium/state_trackers/xvmc/subpicture.c
src/gallium/tests/trivial/compute.c

index 7b59538461a8db60b9e092954f953a71b1f2832d..6eea87ef38c34a68010554515af68bd274dbbb3c 100644 (file)
@@ -430,7 +430,7 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color *
    /* Handle other cases with a generic function.
     */
    default:
-      util_format_write_4f(format, rgba, 0, uc, 0, 0, 0, 1, 1);
+      util_format_pack_rgba(format, uc, rgba, 1);
    }
 }
 
index f29bfcd7eee47026ca1543d6a913bbe56dcab169..42eefe74e698d452de95cb4e39e52418a16a1c17 100644 (file)
@@ -385,9 +385,7 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh
       return XvMCBadSubpicture;
 
    /* Convert color to float */
-   util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM,
-                       uc.f, 1, &color, 4,
-                       0, 0, 1, 1);
+   util_format_unpack_rgba(PIPE_FORMAT_B8G8R8A8_UNORM, uc.f, &color, 1);
 
    subpicture_priv = subpicture->privData;
    context_priv = subpicture_priv->context->privData;
index 2047a524112b3f13ba11e75ca4fc22bddea5abfc..cfdbdf1cc8dc29b3f3f9a416116c955db465b98c 100644 (file)
@@ -1072,7 +1072,7 @@ static void test_surface_ld_init0f(void *p, int s, int x, int y)
         float v[] = { 1.0, -.75, .50, -.25 };
         int i = 0;
 
-        util_format_write_4f(surface_fmts[i], v, 0, p, 0, 0, 0, 1, 1);
+        util_format_pack_rgba(surface_fmts[i], p, v, 1);
 }
 
 static void test_surface_ld_init0i(void *p, int s, int x, int y)
@@ -1080,7 +1080,7 @@ static void test_surface_ld_init0i(void *p, int s, int x, int y)
         int v[] = { 0xffffffff, 0xffff, 0xff, 0xf };
         int i = 0;
 
-        util_format_write_4i(surface_fmts[i], v, 0, p, 0, 0, 0, 1, 1);
+        util_format_pack_rgba(surface_fmts[i], p, v, 1);
 }
 
 static void test_surface_ld_expectf(void *p, int s, int x, int y)
@@ -1089,7 +1089,7 @@ static void test_surface_ld_expectf(void *p, int s, int x, int y)
         int i = 0;
 
         test_surface_ld_init0f(v, s, x / 4, y);
-        util_format_read_4f(surface_fmts[i], w, 0, v, 0, 0, 0, 1, 1);
+        util_format_unpack_rgba(surface_fmts[i], w, v, 1);
         *(float *)p = w[x % 4];
 }
 
@@ -1099,7 +1099,7 @@ static void test_surface_ld_expecti(void *p, int s, int x, int y)
         int i = 0;
 
         test_surface_ld_init0i(v, s, x / 4, y);
-        util_format_read_4i(surface_fmts[i], w, 0, v, 0, 0, 0, 1, 1);
+        util_format_unpack_rgba(surface_fmts[i], w, v, 1);
         *(uint32_t *)p = w[x % 4];
 }
 
@@ -1180,7 +1180,7 @@ static void test_surface_st_expectf(void *p, int s, int x, int y)
 
         for (j = 0; j < 4; j++)
                 test_surface_st_init0f(&vf[j], s, 4 * x + j, y);
-        util_format_write_4f(surface_fmts[i], vf, 0, p, 0, 0, 0, 1, 1);
+        util_format_pack_rgba(surface_fmts[i], p, vf, 1);
 }
 
 static void test_surface_st_expects(void *p, int s, int x, int y)
@@ -1190,7 +1190,7 @@ static void test_surface_st_expects(void *p, int s, int x, int y)
 
         for (j = 0; j < 4; j++)
                 test_surface_st_init0i(&v[j], s, 4 * x + j, y);
-        util_format_write_4i(surface_fmts[i], v, 0, p, 0, 0, 0, 1, 1);
+        util_format_pack_rgba(surface_fmts[i], p, v, 1);
 }
 
 static void test_surface_st_expectu(void *p, int s, int x, int y)
@@ -1200,7 +1200,7 @@ static void test_surface_st_expectu(void *p, int s, int x, int y)
 
         for (j = 0; j < 4; j++)
                 test_surface_st_init0i(&v[j], s, 4 * x + j, y);
-        util_format_write_4ui(surface_fmts[i], v, 0, p, 0, 0, 0, 1, 1);
+        util_format_pack_rgba(surface_fmts[i], p, v, 1);
 }
 
 static bool test_surface_st_check(void *x, void *y, int sz)