diff options
author | Jonathan Marek <[email protected]> | 2020-07-07 13:38:18 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-07-08 20:46:08 +0000 |
commit | 4b290b759a8c85c7d493f1ddd7d38b322bbe1276 (patch) | |
tree | da54058e3c1ba7c10b0e762a73ad421a78b32bbb /src/gallium/drivers/freedreno | |
parent | 344e764b01202d9894c793d393d060dc5530145b (diff) |
freedreno: add a fd_resource_pitch helper
Signed-off-by: Jonathan Marek <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5796>
Diffstat (limited to 'src/gallium/drivers/freedreno')
17 files changed, 56 insertions, 76 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index 90edacb6f9a..e31acc01655 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -336,7 +336,6 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, /* note: PIPE_BUFFER disallowed for surfaces */ unsigned lvl = psurf[i]->u.tex.level; - struct fdl_slice *slice = fd_resource_slice(rsc, lvl); debug_assert(psurf[i]->u.tex.first_layer == psurf[i]->u.tex.last_layer); @@ -348,7 +347,7 @@ fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring, OUT_RING(ring, A3XX_TEX_CONST_1_FETCHSIZE(TFETCH_DISABLE) | A3XX_TEX_CONST_1_WIDTH(psurf[i]->width) | A3XX_TEX_CONST_1_HEIGHT(psurf[i]->height)); - OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(slice->pitch) | + OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)) | A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i)); OUT_RING(ring, 0x00000000); } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index 6bc37189108..09f5c86b662 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -55,7 +55,6 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, enum a3xx_color_swap swap = WZYX; bool srgb = false; struct fd_resource *rsc = NULL; - struct fdl_slice *slice = NULL; uint32_t stride = 0; uint32_t base = 0; uint32_t offset = 0; @@ -80,7 +79,6 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, if (bases) bases++; } - slice = fd_resource_slice(rsc, psurf->u.tex.level); format = fd3_pipe2color(pformat); if (decode_srgb) srgb = util_format_is_srgb(pformat); @@ -100,7 +98,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, base = bases[i]; } } else { - stride = slice->pitch; + stride = fd_resource_pitch(rsc, psurf->u.tex.level); tile_mode = rsc->layout.tile_mode; } } else if (i < nr_bufs && bases) { @@ -327,9 +325,9 @@ emit_gmem2mem_surf(struct fd_batch *batch, format = rsc->base.format; } - struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level); uint32_t offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); + uint32_t pitch = fd_resource_pitch(rsc, psurf->u.tex.level); debug_assert(psurf->u.tex.first_layer == psurf->u.tex.last_layer); @@ -342,7 +340,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, A3XX_RB_COPY_CONTROL_DEPTH32_RESOLVE)); OUT_RELOC(ring, rsc->bo, offset, 0, -1); /* RB_COPY_DEST_BASE */ - OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch)); + OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(pitch)); OUT_RING(ring, A3XX_RB_COPY_DEST_INFO_TILE(rsc->layout.tile_mode) | A3XX_RB_COPY_DEST_INFO_FORMAT(fd3_pipe2color(format)) | A3XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE(0xf) | @@ -729,8 +727,7 @@ fd3_emit_sysmem_prep(struct fd_batch *batch) if (!psurf) continue; struct fd_resource *rsc = fd_resource(psurf->texture); - struct fdl_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level); - pitch = slice->pitch / rsc->layout.cpp; + pitch = fd_resource_pitch(rsc, psurf->u.tex.level) / rsc->layout.cpp; } fd3_emit_restore(batch, ring); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index bd4c57e10ad..de1ab392bf5 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c @@ -265,7 +265,7 @@ fd3_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, /* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */ struct fdl_slice *slice = fd_resource_slice(rsc, lvl); so->texconst2 = - A3XX_TEX_CONST_2_PITCH(slice->pitch); + A3XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)); switch (prsc->target) { case PIPE_TEXTURE_1D_ARRAY: case PIPE_TEXTURE_2D_ARRAY: diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index 256167298e6..9fe94395328 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -327,7 +327,6 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs, /* note: PIPE_BUFFER disallowed for surfaces */ unsigned lvl = bufs[i]->u.tex.level; - struct fdl_slice *slice = fd_resource_slice(rsc, lvl); unsigned offset = fd_resource_offset(rsc, lvl, bufs[i]->u.tex.first_layer); /* z32 restore is accomplished using depth write. If there is @@ -349,7 +348,7 @@ fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W)); OUT_RING(ring, A4XX_TEX_CONST_1_WIDTH(bufs[i]->width) | A4XX_TEX_CONST_1_HEIGHT(bufs[i]->height)); - OUT_RING(ring, A4XX_TEX_CONST_2_PITCH(slice->pitch) | + OUT_RING(ring, A4XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)) | A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format))); OUT_RING(ring, 0x00000000); OUT_RELOC(ring, rsc->bo, offset, 0, 0); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c index facee57d273..de1b40528db 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c @@ -61,7 +61,6 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, enum a3xx_color_swap swap = WZYX; bool srgb = false; struct fd_resource *rsc = NULL; - struct fdl_slice *slice = NULL; uint32_t stride = 0; uint32_t base = 0; uint32_t offset = 0; @@ -82,7 +81,6 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, bases++; } - slice = fd_resource_slice(rsc, psurf->u.tex.level); format = fd4_pipe2color(pformat); swap = fd4_pipe2swap(pformat); @@ -103,7 +101,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, base = bases[i]; } } else { - stride = slice->pitch; + stride = fd_resource_pitch(rsc, psurf->u.tex.level); } } else if ((i < nr_bufs) && bases) { base = bases[i]; @@ -152,8 +150,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, bool stencil, struct fd_ringbuffer *ring = batch->gmem; struct fd_resource *rsc = fd_resource(psurf->texture); enum pipe_format pformat = psurf->format; - struct fdl_slice *slice; - uint32_t offset; + uint32_t offset, pitch; if (!rsc->valid) return; @@ -164,9 +161,9 @@ emit_gmem2mem_surf(struct fd_batch *batch, bool stencil, pformat = rsc->base.format; } - slice = fd_resource_slice(rsc, psurf->u.tex.level); offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); + pitch = fd_resource_pitch(rsc, psurf->u.tex.level); debug_assert(psurf->u.tex.first_layer == psurf->u.tex.last_layer); @@ -175,7 +172,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, bool stencil, A4XX_RB_COPY_CONTROL_MODE(RB_COPY_RESOLVE) | A4XX_RB_COPY_CONTROL_GMEM_BASE(base)); OUT_RELOC(ring, rsc->bo, offset, 0, 0); /* RB_COPY_DEST_BASE */ - OUT_RING(ring, A4XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch)); + OUT_RING(ring, A4XX_RB_COPY_DEST_PITCH_PITCH(pitch)); OUT_RING(ring, A4XX_RB_COPY_DEST_INFO_TILE(TILE4_LINEAR) | A4XX_RB_COPY_DEST_INFO_FORMAT(fd4_pipe2color(pformat)) | A4XX_RB_COPY_DEST_INFO_COMPONENT_ENABLE(0xf) | diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c index a9d7d0d43eb..45444e995d1 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c @@ -222,7 +222,6 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, { struct fd4_pipe_sampler_view *so = CALLOC_STRUCT(fd4_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); - struct fdl_slice *slice = NULL; enum pipe_format format = cso->format; unsigned lvl, layers = 0; @@ -267,7 +266,6 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, unsigned miplevels; lvl = fd_sampler_first_level(cso); - slice = fd_resource_slice(rsc, lvl); miplevels = fd_sampler_last_level(cso) - lvl; layers = cso->u.tex.last_layer - cso->u.tex.first_layer + 1; @@ -277,7 +275,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, A4XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl)); so->texconst2 = A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format)) | - A4XX_TEX_CONST_2_PITCH(slice->pitch); + A4XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); } @@ -309,7 +307,7 @@ fd4_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, case PIPE_TEXTURE_3D: so->texconst3 = A4XX_TEX_CONST_3_DEPTH(u_minify(prsc->depth0, lvl)) | - A4XX_TEX_CONST_3_LAYERSZ(slice->size0); + A4XX_TEX_CONST_3_LAYERSZ(fd_resource_slice(rsc, lvl)->size0); so->texconst4 = A4XX_TEX_CONST_4_LAYERSZ( fd_resource_slice(rsc, prsc->last_level)->size0); break; diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c index a1d846c68c5..9bcfa7af82b 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c @@ -348,8 +348,8 @@ emit_blit(struct fd_ringbuffer *ring, const struct pipe_blit_info *info) sswap = fd5_pipe2swap(info->src.format); dswap = fd5_pipe2swap(info->dst.format); - spitch = sslice->pitch; - dpitch = dslice->pitch; + spitch = fd_resource_pitch(src, info->src.level); + dpitch = fd_resource_pitch(dst, info->dst.level); /* if dtile, then dswap ignored by hw, and likewise if stile then sswap * ignored by hw.. but in this case we have already rejected the blit diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c index c2181ebb820..61bc443c724 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_gmem.c @@ -89,7 +89,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, size = stride * gmem->bin_h; base = gmem->cbuf_base[i]; } else { - stride = slice->pitch; + stride = fd_resource_pitch(rsc, psurf->u.tex.level); size = slice->size0; tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level); @@ -144,9 +144,8 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, stride = cpp * gmem->bin_w; size = stride * gmem->bin_h; } else { - struct fdl_slice *slice = fd_resource_slice(rsc, 0); - stride = slice->pitch; - size = slice->size0; + stride = fd_resource_pitch(rsc, 0); + size = fd_resource_slice(rsc, 0)->size0; } OUT_PKT4(ring, REG_A5XX_RB_DEPTH_BUFFER_INFO, 5); @@ -191,9 +190,8 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, stride = 1 * gmem->bin_w; size = stride * gmem->bin_h; } else { - struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0); - stride = slice->pitch; - size = slice->size0; + stride = fd_resource_pitch(rsc->stencil, 0); + size = fd_resource_slice(rsc->stencil, 0)->size0; } OUT_PKT4(ring, REG_A5XX_RB_STENCIL_INFO, 5); @@ -491,7 +489,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base, OUT_RING(ring, A5XX_RB_MRT_BUF_INFO_COLOR_FORMAT(format) | A5XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(rsc->layout.tile_mode) | A5XX_RB_MRT_BUF_INFO_COLOR_SWAP(WZYX)); - OUT_RING(ring, A5XX_RB_MRT_PITCH(slice->pitch)); + OUT_RING(ring, A5XX_RB_MRT_PITCH(fd_resource_pitch(rsc, 0))); OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(slice->size0)); OUT_RELOC(ring, rsc->bo, 0, 0, 0); /* BASE_LO/HI */ @@ -609,7 +607,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, struct fd_resource *rsc = fd_resource(psurf->texture); struct fdl_slice *slice; bool tiled; - uint32_t offset; + uint32_t offset, pitch; if (!rsc->valid) return; @@ -620,6 +618,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, slice = fd_resource_slice(rsc, psurf->u.tex.level); offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); + pitch = fd_resource_pitch(rsc, psurf->u.tex.level); debug_assert(psurf->u.tex.first_layer == psurf->u.tex.last_layer); @@ -635,7 +634,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, OUT_RING(ring, 0x00000004 | /* XXX RB_RESOLVE_CNTL_3 */ COND(tiled, A5XX_RB_RESOLVE_CNTL_3_TILED)); OUT_RELOC(ring, rsc->bo, offset, 0, 0); /* RB_BLIT_DST_LO/HI */ - OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->pitch)); + OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(pitch)); OUT_RING(ring, A5XX_RB_BLIT_DST_ARRAY_PITCH(slice->size0)); OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_image.c b/src/gallium/drivers/freedreno/a5xx/fd5_image.c index 5fc1537d0ed..d49215ee55e 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_image.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_image.c @@ -62,7 +62,6 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg) enum pipe_format format = pimg->format; struct pipe_resource *prsc = pimg->resource; struct fd_resource *rsc = fd_resource(prsc); - struct fdl_slice *slice = NULL; unsigned lvl; if (!pimg->resource) { @@ -84,9 +83,8 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg) img->pitch = pimg->u.buf.size; } else { lvl = pimg->u.tex.level; - slice = fd_resource_slice(rsc, lvl); img->offset = fd_resource_offset(rsc, lvl, pimg->u.tex.first_layer); - img->pitch = slice->pitch; + img->pitch = fd_resource_pitch(rsc, lvl); } img->width = u_minify(prsc->width0, lvl); @@ -112,7 +110,7 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg) img->depth = layers; break; case PIPE_TEXTURE_3D: - img->array_pitch = slice->size0; + img->array_pitch = fd_resource_slice(rsc, lvl)->size0; img->depth = u_minify(prsc->depth0, lvl); break; default: diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c index ca7bafb0c7a..f411cffc1c7 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c @@ -207,7 +207,6 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, { struct fd5_pipe_sampler_view *so = CALLOC_STRUCT(fd5_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); - struct fdl_slice *slice = NULL; enum pipe_format format = cso->format; unsigned lvl, layers = 0; @@ -265,7 +264,6 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, unsigned miplevels; lvl = fd_sampler_first_level(cso); - slice = fd_resource_slice(rsc, lvl); miplevels = fd_sampler_last_level(cso) - lvl; layers = cso->u.tex.last_layer - cso->u.tex.first_layer + 1; @@ -275,7 +273,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, A5XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl)); so->texconst2 = A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) | - A5XX_TEX_CONST_2_PITCH(slice->pitch); + A5XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); } @@ -308,7 +306,7 @@ fd5_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, so->texconst3 = A5XX_TEX_CONST_3_MIN_LAYERSZ( fd_resource_slice(rsc, prsc->last_level)->size0) | - A5XX_TEX_CONST_3_ARRAY_PITCH(slice->size0); + A5XX_TEX_CONST_3_ARRAY_PITCH(fd_resource_slice(rsc, lvl)->size0); so->texconst5 = A5XX_TEX_CONST_5_DEPTH(u_minify(prsc->depth0, lvl)); break; diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index 54f1592ecba..feb2b44d4a4 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -338,7 +338,7 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, const struct pipe_box *sbox = &info->src.box; const struct pipe_box *dbox = &info->dst.box; struct fd_resource *src, *dst; - struct fdl_slice *sslice, *dslice; + uint32_t spitch, dpitch; enum a6xx_format sfmt, dfmt; enum a6xx_tile_mode stile, dtile; enum a3xx_color_swap sswap, dswap; @@ -358,8 +358,8 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, src = fd_resource(info->src.resource); dst = fd_resource(info->dst.resource); - sslice = fd_resource_slice(src, info->src.level); - dslice = fd_resource_slice(dst, info->dst.level); + spitch = fd_resource_pitch(src, info->src.level); + dpitch = fd_resource_pitch(dst, info->dst.level); sfmt = fd6_pipe2color(info->src.format); dfmt = fd6_pipe2color(info->dst.format); @@ -503,7 +503,7 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, OUT_RING(ring, A6XX_SP_PS_2D_SRC_SIZE_WIDTH(width) | A6XX_SP_PS_2D_SRC_SIZE_HEIGHT(height)); /* SP_PS_2D_SRC_SIZE */ OUT_RELOC(ring, src->bo, soff, 0, 0); /* SP_PS_2D_SRC_LO/HI */ - OUT_RING(ring, A6XX_SP_PS_2D_SRC_PITCH_PITCH(sslice->pitch)); + OUT_RING(ring, A6XX_SP_PS_2D_SRC_PITCH_PITCH(spitch)); OUT_RING(ring, 0x00000000); OUT_RING(ring, 0x00000000); @@ -529,7 +529,7 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, COND(util_format_is_srgb(info->dst.format), A6XX_RB_2D_DST_INFO_SRGB) | COND(dubwc_enabled, A6XX_RB_2D_DST_INFO_FLAGS)); OUT_RELOC(ring, dst->bo, doff, 0, 0); /* RB_2D_DST_LO/HI */ - OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dslice->pitch)); + OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dpitch)); OUT_RING(ring, 0x00000000); OUT_RING(ring, 0x00000000); OUT_RING(ring, 0x00000000); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c index 606206665e1..4e9b81a98ed 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_gmem.c @@ -112,7 +112,7 @@ emit_mrt(struct fd_ringbuffer *ring, struct pipe_framebuffer_state *pfb, offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); - stride = slice->pitch; + stride = fd_resource_pitch(rsc, psurf->u.tex.level); swap = fd6_resource_swap(rsc, pformat); tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level); @@ -172,9 +172,8 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, if (zsbuf) { struct fd_resource *rsc = fd_resource(zsbuf->texture); enum a6xx_depth_format fmt = fd6_pipe2depth(zsbuf->format); - struct fdl_slice *slice = fd_resource_slice(rsc, 0); - uint32_t stride = slice->pitch; - uint32_t size = slice->size0; + uint32_t stride = fd_resource_pitch(rsc, 0); + uint32_t size = fd_resource_slice(rsc, 0)->size0; uint32_t base = gmem ? gmem->zsbuf_base[0] : 0; uint32_t offset = fd_resource_offset(rsc, zsbuf->u.tex.level, zsbuf->u.tex.first_layer); @@ -215,9 +214,8 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, OUT_RING(ring, CP_EVENT_WRITE_0_EVENT(UNK_25)); if (rsc->stencil) { - struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0); - stride = slice->pitch; - size = slice->size0; + stride = fd_resource_pitch(rsc->stencil, 0); + size = fd_resource_slice(rsc->stencil, 0)->size0; uint32_t base = gmem ? gmem->zsbuf_base[1] : 0; OUT_REG(ring, @@ -859,7 +857,6 @@ emit_blit(struct fd_batch *batch, struct pipe_surface *psurf, bool stencil) { - struct fdl_slice *slice; struct fd_resource *rsc = fd_resource(psurf->texture); enum pipe_format pfmt = psurf->format; uint32_t offset; @@ -873,7 +870,6 @@ emit_blit(struct fd_batch *batch, pfmt = rsc->base.format; } - slice = fd_resource_slice(rsc, psurf->u.tex.level); offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); ubwc_enabled = fd_resource_ubwc_enabled(rsc, psurf->u.tex.level); @@ -881,8 +877,8 @@ emit_blit(struct fd_batch *batch, debug_assert(psurf->u.tex.first_layer == psurf->u.tex.last_layer); enum a6xx_format format = fd6_pipe2color(pfmt); - uint32_t stride = slice->pitch; - uint32_t size = slice->size0; + uint32_t stride = fd_resource_pitch(rsc, psurf->u.tex.level); + uint32_t size = fd_resource_slice(rsc, psurf->u.tex.level)->size0; enum a3xx_color_swap swap = fd6_resource_swap(rsc, pfmt); enum a3xx_msaa_samples samples = fd_msaa_samples(rsc->base.nr_samples); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index b7999aacf9a..13b0923a90f 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -95,12 +95,11 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view img->buffer = false; unsigned lvl = pimg->u.tex.level; - struct fdl_slice *slice = fd_resource_slice(rsc, lvl); unsigned layers = pimg->u.tex.last_layer - pimg->u.tex.first_layer + 1; img->ubwc_offset = fd_resource_ubwc_offset(rsc, lvl, pimg->u.tex.first_layer); img->offset = fd_resource_offset(rsc, lvl, pimg->u.tex.first_layer); - img->pitch = slice->pitch; + img->pitch = fd_resource_pitch(rsc, lvl); switch (prsc->target) { case PIPE_TEXTURE_RECT: @@ -119,7 +118,7 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view img->depth = layers; break; case PIPE_TEXTURE_3D: - img->array_pitch = slice->size0; + img->array_pitch = fd_resource_slice(rsc, lvl)->size0; img->depth = u_minify(prsc->depth0, lvl); break; default: diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index 19402290565..19b3716a3d6 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -220,7 +220,6 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, { struct fd6_pipe_sampler_view *so = CALLOC_STRUCT(fd6_pipe_sampler_view); struct fd_resource *rsc = fd_resource(prsc); - struct fdl_slice *slice = NULL; enum pipe_format format = cso->format; unsigned lvl, layers = 0; @@ -256,7 +255,6 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, unsigned miplevels; lvl = fd_sampler_first_level(cso); - slice = fd_resource_slice(rsc, lvl); miplevels = fd_sampler_last_level(cso) - lvl; layers = cso->u.tex.last_layer - cso->u.tex.first_layer + 1; @@ -266,7 +264,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, A6XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl)); so->texconst2 = A6XX_TEX_CONST_2_PITCHALIGN(rsc->layout.pitchalign) | - A6XX_TEX_CONST_2_PITCH(slice->pitch); + A6XX_TEX_CONST_2_PITCH(fd_resource_pitch(rsc, lvl)); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); so->ubwc_offset = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer); so->ubwc_enabled = fd_resource_ubwc_enabled(rsc, lvl); @@ -305,7 +303,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, so->texconst3 = A6XX_TEX_CONST_3_MIN_LAYERSZ( fd_resource_slice(rsc, prsc->last_level)->size0) | - A6XX_TEX_CONST_3_ARRAY_PITCH(slice->size0); + A6XX_TEX_CONST_3_ARRAY_PITCH(fd_resource_slice(rsc, lvl)->size0); so->texconst5 = A6XX_TEX_CONST_5_DEPTH(u_minify(prsc->depth0, lvl)); break; diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index faafd6fe82d..f5a72887582 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -557,7 +557,6 @@ fd_resource_transfer_map(struct pipe_context *pctx, { struct fd_context *ctx = fd_context(pctx); struct fd_resource *rsc = fd_resource(prsc); - struct fdl_slice *slice = fd_resource_slice(rsc, level); struct fd_transfer *trans; struct pipe_transfer *ptrans; enum pipe_format format = prsc->format; @@ -586,7 +585,7 @@ fd_resource_transfer_map(struct pipe_context *pctx, ptrans->level = level; ptrans->usage = usage; ptrans->box = *box; - ptrans->stride = slice->pitch; + ptrans->stride = fd_resource_pitch(rsc, level); ptrans->layer_stride = fd_resource_layer_stride(rsc, level); /* we always need a staging texture for tiled buffers: @@ -600,11 +599,9 @@ fd_resource_transfer_map(struct pipe_context *pctx, staging_rsc = fd_alloc_staging(ctx, rsc, level, box); if (staging_rsc) { - struct fdl_slice *staging_slice = - fd_resource_slice(staging_rsc, 0); // TODO for PIPE_TRANSFER_READ, need to do untiling blit.. trans->staging_prsc = &staging_rsc->base; - trans->base.stride = staging_slice->pitch; + trans->base.stride = fd_resource_pitch(staging_rsc, 0); trans->base.layer_stride = fd_resource_layer_stride(staging_rsc, 0); trans->staging_box = *box; trans->staging_box.x = 0; @@ -702,10 +699,8 @@ fd_resource_transfer_map(struct pipe_context *pctx, */ staging_rsc = fd_alloc_staging(ctx, rsc, level, box); if (staging_rsc) { - struct fdl_slice *staging_slice = - fd_resource_slice(staging_rsc, 0); trans->staging_prsc = &staging_rsc->base; - trans->base.stride = staging_slice->pitch; + trans->base.stride = fd_resource_pitch(staging_rsc, 0); trans->base.layer_stride = fd_resource_layer_stride(staging_rsc, 0); trans->staging_box = *box; @@ -803,7 +798,7 @@ fd_resource_get_handle(struct pipe_screen *pscreen, handle->modifier = fd_resource_modifier(rsc); return fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout, - fd_resource_slice(rsc, 0)->pitch, handle); + fd_resource_pitch(rsc, 0), handle); } /* special case to resize query buf after allocated.. */ diff --git a/src/gallium/drivers/freedreno/freedreno_resource.h b/src/gallium/drivers/freedreno/freedreno_resource.h index 10b7f40f36f..0e8502a493d 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.h +++ b/src/gallium/drivers/freedreno/freedreno_resource.h @@ -197,6 +197,13 @@ fd_resource_layer_stride(struct fd_resource *rsc, unsigned level) return fdl_layer_stride(&rsc->layout, level); } +/* get pitch (in bytes) for specified mipmap level */ +static inline uint32_t +fd_resource_pitch(struct fd_resource *rsc, unsigned level) +{ + return fd_resource_slice(rsc, level)->pitch; +} + /* get offset for specified mipmap level and texture/array layer */ static inline uint32_t fd_resource_offset(struct fd_resource *rsc, unsigned level, unsigned layer) diff --git a/src/gallium/drivers/freedreno/ir3/ir3_const.h b/src/gallium/drivers/freedreno/ir3/ir3_const.h index 1bb19b63cea..aa5208184e7 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_const.h +++ b/src/gallium/drivers/freedreno/ir3/ir3_const.h @@ -228,7 +228,7 @@ ir3_emit_image_dims(struct fd_screen *screen, const struct ir3_shader_variant *v * be the same, so use original dimensions for y and z * stride: */ - dims[off + 1] = slice->pitch; + dims[off + 1] = fd_resource_pitch(rsc, img->u.tex.level); /* see corresponding logic in fd_resource_offset(): */ if (rsc->layout.layer_first) { dims[off + 2] = rsc->layout.layer_size; |