Mesa (main): vc4: Use u_box_pixels_to_blocks helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 10 23:44:42 UTC 2022


Module: Mesa
Branch: main
Commit: b550b3c89c15f20367b4bebb5939e08022d80e0e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b550b3c89c15f20367b4bebb5939e08022d80e0e

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Jan  4 16:41:33 2022 -0500

vc4: Use u_box_pixels_to_blocks helper

Eliminates a ETC1 special case. In fact this unit conversion applies to
all formats; the original code path works since ETC1 is the only format
with blocks bigger than 1x1 supported by vc4 (I assume).

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Reviewed-by: Emma Anholt <emma at anholt.net>
Reviewed-by: Juan A. Suarez <jasuarez at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14370>

---

 src/gallium/drivers/vc4/vc4_resource.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c
index 052588e49f6..84c36bbc30a 100644
--- a/src/gallium/drivers/vc4/vc4_resource.c
+++ b/src/gallium/drivers/vc4/vc4_resource.c
@@ -187,19 +187,8 @@ vc4_resource_transfer_map(struct pipe_context *pctx,
                 if (usage & PIPE_MAP_DIRECTLY)
                         return NULL;
 
-                if (format == PIPE_FORMAT_ETC1_RGB8) {
-                        /* ETC1 is arranged as 64-bit blocks, where each block
-                         * is 4x4 pixels.  Texture tiling operates on the
-                         * 64-bit block the way it would an uncompressed
-                         * pixels.
-                         */
-                        assert(!(ptrans->box.x & 3));
-                        assert(!(ptrans->box.y & 3));
-                        ptrans->box.x >>= 2;
-                        ptrans->box.y >>= 2;
-                        ptrans->box.width = (ptrans->box.width + 3) >> 2;
-                        ptrans->box.height = (ptrans->box.height + 3) >> 2;
-                }
+                /* Our load/store routines work on entire compressed blocks. */
+                u_box_pixels_to_blocks(&ptrans->box, &ptrans->box, format);
 
                 ptrans->stride = ptrans->box.width * rsc->cpp;
                 ptrans->layer_stride = ptrans->stride * ptrans->box.height;



More information about the mesa-commit mailing list