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@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Juan A. Suarez <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14370>
This commit is contained in:
Alyssa Rosenzweig 2022-01-04 16:41:33 -05:00 committed by Marge Bot
parent 6f07159a1d
commit b550b3c89c

View file

@ -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;