freedreno: add a fd_resource_pitch helper
authorJonathan Marek <jonathan@marek.ca>
Tue, 7 Jul 2020 17:38:18 +0000 (13:38 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 8 Jul 2020 20:46:08 +0000 (20:46 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5796>

17 files changed:
src/gallium/drivers/freedreno/a3xx/fd3_emit.c
src/gallium/drivers/freedreno/a3xx/fd3_gmem.c
src/gallium/drivers/freedreno/a3xx/fd3_texture.c
src/gallium/drivers/freedreno/a4xx/fd4_emit.c
src/gallium/drivers/freedreno/a4xx/fd4_gmem.c
src/gallium/drivers/freedreno/a4xx/fd4_texture.c
src/gallium/drivers/freedreno/a5xx/fd5_blitter.c
src/gallium/drivers/freedreno/a5xx/fd5_gmem.c
src/gallium/drivers/freedreno/a5xx/fd5_image.c
src/gallium/drivers/freedreno/a5xx/fd5_texture.c
src/gallium/drivers/freedreno/a6xx/fd6_blitter.c
src/gallium/drivers/freedreno/a6xx/fd6_gmem.c
src/gallium/drivers/freedreno/a6xx/fd6_image.c
src/gallium/drivers/freedreno/a6xx/fd6_texture.c
src/gallium/drivers/freedreno/freedreno_resource.c
src/gallium/drivers/freedreno/freedreno_resource.h
src/gallium/drivers/freedreno/ir3/ir3_const.h

index 90edacb6f9aab373cc23371e5e4d34a8d05b5c00..e31acc01655f6a5f129f9fa6fa308d3d27675dc1 100644 (file)
@@ -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);
        }
index 6bc37189108f2b60b845a693bae2d33f107e8710..09f5c86b662e8f2da30490a2b4b2861657bed8eb 100644 (file)
@@ -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);
index bd4c57e10ad8e610b0f26bd4674a51c8f3c5d49c..de1ab392bf52e0a21870c1fba1bbc49c2355847d 100644 (file)
@@ -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:
index 256167298e6d67588894899230cad9ad36a05054..9fe94395328a632c1e5dda446869a6562a3620be 100644 (file)
@@ -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);
index facee57d2738eeba42c2ee60c9a2b33fc84743f9..de1b40528db18e8a530052bb7e29b10bb0f01239 100644 (file)
@@ -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) |
index a9d7d0d43ebc2da6ddf083dcfaa5b3df3a0f1052..45444e995d1fb682611a06c6472c410f1e8ef9c9 100644 (file)
@@ -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;
index a1d846c68c5606214062398c20389eb635719537..9bcfa7af82bc672096b79514ed64c11f4f169248 100644 (file)
@@ -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
index c2181ebb8206e2ab56114654223ac7ad57dd3283..61bc443c724f85b0574f5560757f011e9906ec1b 100644 (file)
@@ -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);
index 5fc1537d0ede2d973770b24db622fd8ab75bbaf3..d49215ee55e5be92f7725dda7ac324196ddc03f7 100644 (file)
@@ -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:
index ca7bafb0c7a0b115e511921b8a2e83319397c6df..f411cffc1c74827e0938717af8490349246e10e3 100644 (file)
@@ -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;
index 54f1592ecba5e76dd7e0513da0266cfda6e9872c..feb2b44d4a4113b050a393dab7510a08fe3b56e0 100644 (file)
@@ -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);
index 606206665e1596b3fbe02489bc304db4bf16d450..4e9b81a98ed5c6dc4a253d8e57573e05f0311ff2 100644 (file)
@@ -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);
index b7999aacf9a51b90d8dae5851c7c1935fc6c7a69..13b0923a90f463a5de2d94e84e3a21d2de04b0c8 100644 (file)
@@ -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:
index 19402290565d720bf492a48e78c52c4013ea03a9..19b3716a3d6b81e48f7a947f0fe8405a3043473c 100644 (file)
@@ -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;
index faafd6fe82db09d42b3ae51c7f79e76251df7bd7..f5a7288758282ac9ea799ecf517b5f371e7d515a 100644 (file)
@@ -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.. */
index 10b7f40f36f8c7df981f51ad252dd271ec128333..0e8502a493d43682356919b54b46eed3eac7aab7 100644 (file)
@@ -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)
index 1bb19b63cea6ea1dca9aa937ae75c23033e3743e..aa5208184e7c71400c898ab57321454d23348a86 100644 (file)
@@ -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;