diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c b/src/gallium/drivers/etnaviv/etnaviv_rs.c index 6177de8e5ea..854e49d69e2 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c @@ -905,6 +905,23 @@ manual: return false; } +void +etna_align_box_for_rs(const struct etna_context *ctx, + const struct etna_resource *rsc, + struct pipe_box *box) +{ + unsigned w_align, h_align; + + etna_get_rs_alignment_mask(ctx, rsc->layout, &w_align, &h_align); + + box->width += box->x & w_align; + box->x = box->x & ~w_align; + box->width = align(box->width, (ETNA_RS_WIDTH_MASK + 1)); + box->height += box->y & h_align; + box->y = box->y & ~h_align; + box->height = align(box->height, ETNA_RS_HEIGHT_MASK + 1); +} + void etna_clear_blit_rs_init(struct pipe_context *pctx) { diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.h b/src/gallium/drivers/etnaviv/etnaviv_rs.h index 09456fb349b..7e21de31c66 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_rs.h +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.h @@ -87,6 +87,11 @@ void etna_compile_rs_state(struct etna_context *ctx, struct compiled_rs_state *cs, const struct rs_state *rs); +void +etna_align_box_for_rs(const struct etna_context *ctx, + const struct etna_resource *rsc, + struct pipe_box *box); + /* Context initialization for RS clear_blit functions. */ void etna_clear_blit_rs_init(struct pipe_context *pctx); diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c index 6d20c7a1697..de5ed08eeb0 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c @@ -29,6 +29,7 @@ #include "etnaviv_context.h" #include "etnaviv_debug.h" #include "etnaviv_etc2.h" +#include "etnaviv_rs.h" #include "etnaviv_screen.h" #include "pipe/p_defines.h" @@ -297,22 +298,7 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, /* Need to align the transfer region to satisfy RS restrictions, as we * really want to hit the RS blit path here. */ - unsigned w_align, h_align; - - if (rsc->layout & ETNA_LAYOUT_BIT_SUPER) { - w_align = 64; - h_align = 64 * ctx->screen->specs.pixel_pipes; - } else { - w_align = ETNA_RS_WIDTH_MASK + 1; - h_align = ETNA_RS_HEIGHT_MASK + 1; - } - - ptrans->box.width += ptrans->box.x & (w_align - 1); - ptrans->box.x = ptrans->box.x & ~(w_align - 1); - ptrans->box.width = align(ptrans->box.width, (ETNA_RS_WIDTH_MASK + 1)); - ptrans->box.height += ptrans->box.y & (h_align - 1); - ptrans->box.y = ptrans->box.y & ~(h_align - 1); - ptrans->box.height = align(ptrans->box.height, ETNA_RS_HEIGHT_MASK + 1); + etna_align_box_for_rs(ctx, rsc, &ptrans->box); } if ((usage & PIPE_MAP_READ) || !(usage & ETNA_PIPE_MAP_DISCARD_LEVEL))