From 1d367c3aa57da54f5dbd6871a38b9fc1d6cbcc45 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Fri, 8 Nov 2019 14:56:07 -0800 Subject: [PATCH] gallium: Refactor some single-pixel util_format_read/writes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We can use the new row helpers to cut down on the noise. Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_pack_color.h | 2 +- src/gallium/state_trackers/xvmc/subpicture.c | 4 +--- src/gallium/tests/trivial/compute.c | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 7b59538461a..6eea87ef38c 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -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); } } diff --git a/src/gallium/state_trackers/xvmc/subpicture.c b/src/gallium/state_trackers/xvmc/subpicture.c index f29bfcd7eee..42eefe74e69 100644 --- a/src/gallium/state_trackers/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xvmc/subpicture.c @@ -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; diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c index 2047a524112..cfdbdf1cc8d 100644 --- a/src/gallium/tests/trivial/compute.c +++ b/src/gallium/tests/trivial/compute.c @@ -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) -- 2.30.2