diff options
Diffstat (limited to 'src/gallium/drivers')
23 files changed, 57 insertions, 71 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c index 0ba2b4acb45..1d14c66b67e 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_gmem.c @@ -93,8 +93,9 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, uint32_t offset = fd_resource_offset(rsc, psurf->u.tex.level, psurf->u.tex.first_layer); enum pipe_format format = fd_gmem_restore_format(psurf->format); + uint32_t pitch = slice->pitch >> fdl_cpp_shift(&rsc->layout); - assert((slice->pitch & 31) == 0); + assert((pitch & 31) == 0); assert((offset & 0xfff) == 0); if (!rsc->valid) @@ -109,7 +110,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, uint32_t base, OUT_RING(ring, CP_REG(REG_A2XX_RB_COPY_CONTROL)); OUT_RING(ring, 0x00000000); /* RB_COPY_CONTROL */ OUT_RELOCW(ring, rsc->bo, offset, 0, 0); /* RB_COPY_DEST_BASE */ - OUT_RING(ring, slice->pitch >> 5); /* RB_COPY_DEST_PITCH */ + OUT_RING(ring, pitch >> 5); /* RB_COPY_DEST_PITCH */ OUT_RING(ring, /* RB_COPY_DEST_INFO */ A2XX_RB_COPY_DEST_INFO_FORMAT(fd2_pipe2color(format)) | COND(!rsc->layout.tile_mode, A2XX_RB_COPY_DEST_INFO_LINEAR) | @@ -245,7 +246,7 @@ emit_mem2gmem_surf(struct fd_batch *batch, uint32_t base, OUT_RING(ring, A2XX_SQ_TEX_0_CLAMP_X(SQ_TEX_WRAP) | A2XX_SQ_TEX_0_CLAMP_Y(SQ_TEX_WRAP) | A2XX_SQ_TEX_0_CLAMP_Z(SQ_TEX_WRAP) | - A2XX_SQ_TEX_0_PITCH(slice->pitch)); + A2XX_SQ_TEX_0_PITCH(slice->pitch >> fdl_cpp_shift(&rsc->layout))); OUT_RELOC(ring, rsc->bo, offset, A2XX_SQ_TEX_1_FORMAT(fd2_pipe2surface(format).format) | A2XX_SQ_TEX_1_CLAMP_POLICY(SQ_TEX_CLAMP_POLICY_OGL), 0); @@ -438,15 +439,16 @@ fd2_emit_sysmem_prep(struct fd_batch *batch) 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 = slice->pitch >> fdl_cpp_shift(&rsc->layout); - assert((slice->pitch & 31) == 0); + assert((pitch & 31) == 0); assert((offset & 0xfff) == 0); fd2_emit_restore(ctx, ring); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_SURFACE_INFO)); - OUT_RING(ring, A2XX_RB_SURFACE_INFO_SURFACE_PITCH(slice->pitch)); + OUT_RING(ring, A2XX_RB_SURFACE_INFO_SURFACE_PITCH(pitch)); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO)); diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_resource.c b/src/gallium/drivers/freedreno/a2xx/fd2_resource.c index bccce004a71..1cd3e9da884 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_resource.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_resource.c @@ -61,7 +61,7 @@ fd2_setup_slices(struct fd_resource *rsc) height = util_next_power_of_two(height); } - slice->pitch = width; + slice->pitch = util_format_get_nblocksx(format, width) * rsc->layout.cpp; slice->offset = size; blocks = util_format_get_nblocks(format, width, height); diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c index 7e25fc368d4..938fc6951d8 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_texture.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_texture.c @@ -187,7 +187,8 @@ fd2_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, A2XX_SQ_TEX_0_SIGN_Y(fmt.sign) | A2XX_SQ_TEX_0_SIGN_Z(fmt.sign) | A2XX_SQ_TEX_0_SIGN_W(fmt.sign) | - A2XX_SQ_TEX_0_PITCH(slice0->pitch) | + A2XX_SQ_TEX_0_PITCH(slice0->pitch >> fdl_cpp_shift(&rsc->layout) * + util_format_get_blockwidth(rsc->layout.format)) | COND(rsc->layout.tile_mode, A2XX_SQ_TEX_0_TILED); so->tex1 = A2XX_SQ_TEX_1_FORMAT(fmt.format) | diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index 6509435636c..ee75455c2ef 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -322,7 +322,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 * rsc->layout.cpp) | + OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(slice->pitch) | A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i)); OUT_RING(ring, 0x00000000); } diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.c b/src/gallium/drivers/freedreno/a3xx/fd3_format.c index d5e9b156ade..d83738a8989 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_format.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.c @@ -344,14 +344,6 @@ fd3_pipe2fetchsize(enum pipe_format format) } } -unsigned -fd3_pipe2nblocksx(enum pipe_format format, unsigned width) -{ - if (util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_RGTC) - format = PIPE_FORMAT_R8G8B8A8_UNORM; - return util_format_get_nblocksx(format, width); -} - enum a3xx_color_fmt fd3_fs_output_format(enum pipe_format format) { diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.h b/src/gallium/drivers/freedreno/a3xx/fd3_format.h index 48721c6d891..1e4597242eb 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_format.h +++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.h @@ -36,7 +36,6 @@ enum a3xx_tex_fetchsize fd3_pipe2fetchsize(enum pipe_format format); enum a3xx_color_fmt fd3_pipe2color(enum pipe_format format); enum a3xx_color_fmt fd3_fs_output_format(enum pipe_format format); enum a3xx_color_swap fd3_pipe2swap(enum pipe_format format); -unsigned fd3_pipe2nblocksx(enum pipe_format format, unsigned width); uint32_t fd3_tex_swiz(enum pipe_format format, unsigned swizzle_r, unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c index ff9f4357368..a0fc1d3f96e 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_gmem.c @@ -100,7 +100,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, base = bases[i]; } } else { - stride = slice->pitch * rsc->layout.cpp; + stride = slice->pitch; tile_mode = rsc->layout.tile_mode; } } else if (i < nr_bufs && bases) { @@ -345,7 +345,7 @@ emit_gmem2mem_surf(struct fd_batch *batch, A3XX_RB_COPY_CONTROL_DEPTH32_RESOLVE)); OUT_RELOCW(ring, rsc->bo, offset, 0, -1); /* RB_COPY_DEST_BASE */ - OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch * rsc->layout.cpp)); + OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(slice->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) | @@ -739,10 +739,9 @@ fd3_emit_sysmem_prep(struct fd_batch *batch) struct pipe_surface *psurf = pfb->cbufs[i]; if (!psurf) continue; - struct fdl_slice *slice = - fd_resource_slice(fd_resource(psurf->texture), - psurf->u.tex.level); - pitch = slice->pitch; + 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; } fd3_emit_restore(batch, ring); diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c index 6089ca01e40..0a58c16abc6 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_resource.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_resource.c @@ -63,6 +63,8 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma slice->pitch = width = align(width, pitchalign); blocks = util_format_get_nblocks(format, slice->pitch, height); } + slice->pitch = util_format_get_nblocksx(format, slice->pitch) * + rsc->layout.cpp; slice->offset = size; /* 1d array and 2d array textures must all have the same layer size diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_texture.c b/src/gallium/drivers/freedreno/a3xx/fd3_texture.c index 50664f1c280..bd4c57e10ad 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(fd3_pipe2nblocksx(cso->format, slice->pitch) * rsc->layout.cpp); + A3XX_TEX_CONST_2_PITCH(slice->pitch); 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 8d07ceff9bb..7394993d5a7 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -323,7 +323,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 * rsc->layout.cpp) | + OUT_RING(ring, A4XX_TEX_CONST_2_PITCH(slice->pitch) | 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 5f565e08d65..57f23a8304f 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_gmem.c @@ -103,7 +103,7 @@ emit_mrt(struct fd_ringbuffer *ring, unsigned nr_bufs, base = bases[i]; } } else { - stride = slice->pitch * rsc->layout.cpp; + stride = slice->pitch; } } else if ((i < nr_bufs) && bases) { base = bases[i]; @@ -175,7 +175,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_RELOCW(ring, rsc->bo, offset, 0, 0); /* RB_COPY_DEST_BASE */ - OUT_RING(ring, A4XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch * rsc->layout.cpp)); + OUT_RING(ring, A4XX_RB_COPY_DEST_PITCH_PITCH(slice->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 de4e2d27144..a9d7d0d43eb 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_texture.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_texture.c @@ -277,8 +277,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( - util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp); + A4XX_TEX_CONST_2_PITCH(slice->pitch); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); } diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c b/src/gallium/drivers/freedreno/a5xx/fd5_blitter.c index cffcae86a8b..bd4c35603f7 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 * src->layout.cpp; - dpitch = dslice->pitch * dst->layout.cpp; + spitch = sslice->pitch; + dpitch = dslice->pitch; /* 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 eb8b5404e86..f087e04cf9b 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 * rsc->layout.cpp; + stride = slice->pitch; size = slice->size0; tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level); @@ -145,7 +145,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, size = stride * gmem->bin_h; } else { struct fdl_slice *slice = fd_resource_slice(rsc, 0); - stride = slice->pitch * rsc->layout.cpp; + stride = slice->pitch; size = slice->size0; } @@ -192,7 +192,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, size = stride * gmem->bin_h; } else { struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0); - stride = slice->pitch * rsc->layout.cpp; + stride = slice->pitch; size = slice->size0; } @@ -491,7 +491,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 * rsc->layout.cpp)); + OUT_RING(ring, A5XX_RB_MRT_PITCH(slice->pitch)); OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(slice->size0)); OUT_RELOC(ring, rsc->bo, 0, 0, 0); /* BASE_LO/HI */ @@ -635,7 +635,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_RELOCW(ring, rsc->bo, offset, 0, 0); /* RB_BLIT_DST_LO/HI */ - OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->pitch * rsc->layout.cpp)); + OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->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 4da1f16385a..5117527b2b4 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_image.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_image.c @@ -86,7 +86,7 @@ static void translate_image(struct fd5_image *img, struct pipe_image_view *pimg) 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 * rsc->layout.cpp; + img->pitch = slice->pitch; } img->width = u_minify(prsc->width0, lvl); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c index 3fe730a99c8..e4420e68151 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_resource.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_resource.c @@ -84,14 +84,17 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma aligned_height = align(aligned_height, 32); } + unsigned pitch_pixels; if (layout == UTIL_FORMAT_LAYOUT_ASTC) - slice->pitch = + pitch_pixels = util_align_npot(width, pitchalign * util_format_get_blockwidth(format)); else - slice->pitch = align(width, pitchalign); + pitch_pixels = align(width, pitchalign); slice->offset = size; - blocks = util_format_get_nblocks(format, slice->pitch, aligned_height); + blocks = util_format_get_nblocks(format, pitch_pixels, aligned_height); + slice->pitch = util_format_get_nblocksx(format, pitch_pixels) * + rsc->layout.cpp; /* 1d array and 2d array textures must all have the same layer size * for each miplevel on a3xx. 3d textures can have different layer diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c index 5ec8e546eca..fdfb2c7d943 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_texture.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_texture.c @@ -275,8 +275,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( - util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp); + A5XX_TEX_CONST_2_PITCH(slice->pitch); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); } diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c index d129183bfae..2da8438fbc3 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blitter.c @@ -339,7 +339,6 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, enum a6xx_format sfmt, dfmt; enum a6xx_tile_mode stile, dtile; enum a3xx_color_swap sswap, dswap; - unsigned spitch, dpitch; int sx1, sy1, sx2, sy2; int dx1, dy1, dx2, dy2; @@ -371,12 +370,6 @@ emit_blit_or_clear_texture(struct fd_context *ctx, struct fd_ringbuffer *ring, sswap = fd6_resource_swap(src, info->src.format); dswap = fd6_resource_swap(dst, info->dst.format); - /* Use the underlying resource format so that we get the right block width - * for compressed textures. - */ - spitch = util_format_get_nblocksx(src->base.format, sslice->pitch) * src->layout.cpp; - dpitch = util_format_get_nblocksx(dst->base.format, dslice->pitch) * dst->layout.cpp; - uint32_t nr_samples = fd_resource_nr_samples(&dst->base); sx1 = sbox->x * nr_samples; sy1 = sbox->y; @@ -507,7 +500,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(spitch)); + OUT_RING(ring, A6XX_SP_PS_2D_SRC_PITCH_PITCH(sslice->pitch)); OUT_RING(ring, 0x00000000); OUT_RING(ring, 0x00000000); @@ -533,7 +526,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_RELOCW(ring, dst->bo, doff, 0, 0); /* RB_2D_DST_LO/HI */ - OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dpitch)); + OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dslice->pitch)); 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 b42287486a8..0ce85ea380c 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 * rsc->layout.cpp; + stride = slice->pitch; swap = fd6_resource_swap(rsc, pformat); tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level); @@ -173,7 +173,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *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 * rsc->layout.cpp; + uint32_t stride = slice->pitch; uint32_t size = slice->size0; uint32_t base = gmem ? gmem->zsbuf_base[0] : 0; uint32_t offset = fd_resource_offset(rsc, zsbuf->u.tex.level, @@ -216,7 +216,7 @@ emit_zs(struct fd_ringbuffer *ring, struct pipe_surface *zsbuf, if (rsc->stencil) { struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0); - stride = slice->pitch * rsc->stencil->layout.cpp; + stride = slice->pitch; size = slice->size0; uint32_t base = gmem ? gmem->zsbuf_base[1] : 0; @@ -949,7 +949,7 @@ 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 * rsc->layout.cpp; + uint32_t stride = slice->pitch; uint32_t size = slice->size0; enum a3xx_color_swap swap = fd6_resource_swap(rsc, pfmt); enum a3xx_msaa_samples samples = diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 6ac3cc5c4c9..0de77381d07 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -102,7 +102,7 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view 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 * rsc->layout.cpp; + img->pitch = slice->pitch; switch (prsc->target) { case PIPE_TEXTURE_RECT: diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index e0883815ca9..5fa64e1da49 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -266,8 +266,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_FETCHSIZE(fd6_pipe2fetchsize(format)) | - A6XX_TEX_CONST_2_PITCH( - util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp); + A6XX_TEX_CONST_2_PITCH(slice->pitch); 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); diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 7c61fb72911..04e0553f670 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -542,7 +542,7 @@ fd_resource_transfer_map(struct pipe_context *pctx, ptrans->level = level; ptrans->usage = usage; ptrans->box = *box; - ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp; + ptrans->stride = slice->pitch; ptrans->layer_stride = fd_resource_layer_stride(rsc, level); /* we always need a staging texture for tiled buffers: @@ -560,8 +560,7 @@ fd_resource_transfer_map(struct pipe_context *pctx, 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 = util_format_get_nblocksx(format, - staging_slice->pitch) * staging_rsc->layout.cpp; + trans->base.stride = staging_slice->pitch; trans->base.layer_stride = fd_resource_layer_stride(staging_rsc, 0); trans->staging_box = *box; trans->staging_box.x = 0; @@ -661,8 +660,7 @@ fd_resource_transfer_map(struct pipe_context *pctx, struct fdl_slice *staging_slice = fd_resource_slice(staging_rsc, 0); trans->staging_prsc = &staging_rsc->base; - trans->base.stride = util_format_get_nblocksx(format, - staging_slice->pitch) * staging_rsc->layout.cpp; + trans->base.stride = staging_slice->pitch; trans->base.layer_stride = fd_resource_layer_stride(staging_rsc, 0); trans->staging_box = *box; @@ -759,7 +757,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 * rsc->layout.cpp, handle); + fd_resource_slice(rsc, 0)->pitch, handle); } static uint32_t @@ -783,10 +781,10 @@ setup_slices(struct fd_resource *rsc, uint32_t alignment, enum pipe_format forma uint32_t blocks; if (layout == UTIL_FORMAT_LAYOUT_ASTC) - slice->pitch = width = - util_align_npot(width, pitchalign * util_format_get_blockwidth(format)); + width = util_align_npot(width, pitchalign * util_format_get_blockwidth(format)); else - slice->pitch = width = align(width, pitchalign); + width = align(width, pitchalign); + slice->pitch = util_format_get_nblocksx(format, width) * rsc->layout.cpp; slice->offset = size; blocks = util_format_get_nblocks(format, width, height); /* 1d array and 2d array textures must all have the same layer size @@ -1051,7 +1049,7 @@ fd_resource_from_handle(struct pipe_screen *pscreen, struct fd_resource *rsc = CALLOC_STRUCT(fd_resource); struct fdl_slice *slice = fd_resource_slice(rsc, 0); struct pipe_resource *prsc = &rsc->base; - uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw; + uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw * rsc->layout.cpp; DBG("target=%d, format=%s, %ux%ux%u, array_size=%u, last_level=%u, " "nr_samples=%u, usage=%u, bind=%x, flags=%x", @@ -1077,11 +1075,11 @@ fd_resource_from_handle(struct pipe_screen *pscreen, goto fail; rsc->internal_format = tmpl->format; - slice->pitch = handle->stride / rsc->layout.cpp; + slice->pitch = handle->stride; slice->offset = handle->offset; slice->size0 = handle->stride * prsc->height0; - if ((slice->pitch < align(prsc->width0, pitchalign)) || + if ((slice->pitch < align(prsc->width0 * rsc->layout.cpp, pitchalign)) || (slice->pitch & (pitchalign - 1))) goto fail; diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c index 158869a6101..04474097f55 100644 --- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c +++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c @@ -369,7 +369,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 * rsc->layout.cpp; + dims[off + 1] = slice->pitch; /* see corresponding logic in fd_resource_offset(): */ if (rsc->layout.layer_first) { dims[off + 2] = rsc->layout.layer_size; |