From: Jonathan Marek Date: Wed, 19 Jun 2019 21:16:27 +0000 (-0400) Subject: etnaviv: reduce rs alignment requirement for two pixel pipes GPU X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a9e78a44d1edc39df99bbf71e5e1d8d762438ceb;p=mesa.git etnaviv: reduce rs alignment requirement for two pixel pipes GPU The rs alignment doesn't have to be multiplied by # of pixel pipes. This works on GC2000 which doesn't have the SINGLE_BUFFER feature. This fixes some cubemaps (NPOT / small mipmap levels) because aligning by 8 breaks the expected alignment of 4 for tiled format. We don't want to mess with the alignment of tiled formats. Signed-off-by: Jonathan Marek Reviewed-by: Christian Gmeiner --- diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c index 44da60a22b1..d5abe3adf70 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c @@ -253,8 +253,8 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, paddingY = 1; } - if (!screen->specs.use_blt && templat->target != PIPE_BUFFER) - etna_adjust_rs_align(screen->specs.pixel_pipes, NULL, &paddingY); + if (!screen->specs.use_blt && templat->target != PIPE_BUFFER && layout == ETNA_LAYOUT_LINEAR) + paddingY = align(paddingY, ETNA_RS_HEIGHT_MASK + 1); if (templat->bind & PIPE_BIND_SCANOUT && screen->ro->kms_fd >= 0) { struct pipe_resource scanout_templat = *templat; @@ -262,8 +262,10 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, struct winsys_handle handle; /* pad scanout buffer size to be compatible with the RS */ - if (!screen->specs.use_blt && modifier == DRM_FORMAT_MOD_LINEAR) - etna_adjust_rs_align(screen->specs.pixel_pipes, &paddingX, &paddingY); + if (!screen->specs.use_blt && modifier == DRM_FORMAT_MOD_LINEAR) { + paddingX = align(paddingX, ETNA_RS_WIDTH_MASK + 1); + paddingY = align(paddingY, ETNA_RS_HEIGHT_MASK + 1); + } scanout_templat.width0 = align(scanout_templat.width0, paddingX); scanout_templat.height0 = align(scanout_templat.height0, paddingY); @@ -559,8 +561,8 @@ etna_resource_from_handle(struct pipe_screen *pscreen, is_rs_align(screen, tmpl), &paddingX, &paddingY, &rsc->halign); - if (!screen->specs.use_blt) - etna_adjust_rs_align(screen->specs.pixel_pipes, NULL, &paddingY); + if (!screen->specs.use_blt && rsc->layout == ETNA_LAYOUT_LINEAR) + paddingY = align(paddingY, ETNA_RS_HEIGHT_MASK + 1); level->padded_width = align(level->width, paddingX); level->padded_height = align(level->height, paddingY); diff --git a/src/gallium/drivers/etnaviv/etnaviv_rs.c b/src/gallium/drivers/etnaviv/etnaviv_rs.c index 2653fc21335..013563185b5 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_rs.c +++ b/src/gallium/drivers/etnaviv/etnaviv_rs.c @@ -105,23 +105,21 @@ etna_compile_rs_state(struct etna_context *ctx, struct compiled_rs_state *cs, COND(rs->dest_tiling & 2, VIVS_RS_DEST_STRIDE_TILING) | COND(dest_multi, VIVS_RS_DEST_STRIDE_MULTI); - if (ctx->specs.pixel_pipes == 1 || ctx->specs.single_buffer) { - cs->RS_WINDOW_SIZE = VIVS_RS_WINDOW_SIZE_WIDTH(rs->width) | - VIVS_RS_WINDOW_SIZE_HEIGHT(rs->height); - } else if (ctx->specs.pixel_pipes == 2) { - assert((rs->height & 7) == 0); /* GPU hangs happen if height not 8-aligned */ - if (source_multi) - cs->source[1].offset = rs->source_offset + rs->source_stride * rs->source_padded_height / 2; + if (source_multi) + cs->source[1].offset = rs->source_offset + rs->source_stride * rs->source_padded_height / 2; + + if (dest_multi) + cs->dest[1].offset = rs->dest_offset + rs->dest_stride * rs->dest_padded_height / 2; - if (dest_multi) - cs->dest[1].offset = rs->dest_offset + rs->dest_stride * rs->dest_padded_height / 2; + cs->RS_WINDOW_SIZE = VIVS_RS_WINDOW_SIZE_WIDTH(rs->width) | + VIVS_RS_WINDOW_SIZE_HEIGHT(rs->height); + /* use dual pipe mode when required */ + if (!ctx->specs.single_buffer && ctx->specs.pixel_pipes == 2 && !(rs->height & 7)) { cs->RS_WINDOW_SIZE = VIVS_RS_WINDOW_SIZE_WIDTH(rs->width) | - VIVS_RS_WINDOW_SIZE_HEIGHT(rs->height / 2); + VIVS_RS_WINDOW_SIZE_HEIGHT(rs->height / 2); cs->RS_PIPE_OFFSET[1] = VIVS_RS_PIPE_OFFSET_X(0) | VIVS_RS_PIPE_OFFSET_Y(rs->height / 2); - } else { - abort(); } cs->RS_DITHER[0] = rs->dither[0]; @@ -526,14 +524,13 @@ etna_get_rs_alignment_mask(const struct etna_context *ctx, unsigned int h_align, w_align; if (layout & ETNA_LAYOUT_BIT_SUPER) { - w_align = h_align = 64; + w_align = 64; + h_align = 64 * ctx->specs.pixel_pipes; } else { w_align = ETNA_RS_WIDTH_MASK + 1; h_align = ETNA_RS_HEIGHT_MASK + 1; } - h_align *= ctx->screen->specs.pixel_pipes; - *width_mask = w_align - 1; *height_mask = h_align -1; } @@ -645,7 +642,7 @@ etna_try_rs_blit(struct pipe_context *pctx, unsigned int width = blit_info->src.box.width * msaa_xscale; unsigned int height = blit_info->src.box.height * msaa_yscale; unsigned int w_align = ETNA_RS_WIDTH_MASK + 1; - unsigned int h_align = (ETNA_RS_HEIGHT_MASK + 1) * ctx->specs.pixel_pipes; + unsigned int h_align = ETNA_RS_HEIGHT_MASK + 1; if (width & (w_align - 1) && width >= src_lev->width * msaa_xscale && width >= dst_lev->width) width = align(width, w_align); diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c index d875803bde2..78face1ee90 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c +++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c @@ -265,21 +265,19 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, unsigned w_align, h_align; if (rsc->layout & ETNA_LAYOUT_BIT_SUPER) { - w_align = h_align = 64; + 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; } - h_align *= ctx->screen->specs.pixel_pipes; 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) * - ctx->screen->specs.pixel_pipes); + ptrans->box.height = align(ptrans->box.height, ETNA_RS_HEIGHT_MASK + 1); } if (!(usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)) diff --git a/src/gallium/drivers/etnaviv/etnaviv_translate.h b/src/gallium/drivers/etnaviv/etnaviv_translate.h index 99822715411..72a96ec8391 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_translate.h +++ b/src/gallium/drivers/etnaviv/etnaviv_translate.h @@ -413,18 +413,6 @@ etna_layout_multiple(unsigned layout, unsigned pixel_pipes, bool rs_align, } } -static inline void etna_adjust_rs_align(unsigned num_pixelpipes, - unsigned *paddingX, unsigned *paddingY) -{ - unsigned alignX = ETNA_RS_WIDTH_MASK + 1; - unsigned alignY = (ETNA_RS_HEIGHT_MASK + 1) * num_pixelpipes; - - if (paddingX) - *paddingX = align(*paddingX, alignX); - if (paddingY) - *paddingY = align(*paddingY, alignY); -} - static inline uint32_t translate_clear_depth_stencil(enum pipe_format format, float depth, unsigned stencil)