freedreno: Make the slice pitch be bytes, not pixels.
Back in a2xx, HW pitches were in pixels, so storing that was reasonable. Ever since then, the HW wants pitches in bytes, and we have only one instance of using pitch in pixels in the code (a3xx sysmem path). Flip things around so that only a2xx has to worry about the cpp for looking at pitches. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4558>
This commit is contained in:
parent
bd76a24fd1
commit
5a8718f01b
|
@ -155,12 +155,15 @@ fdl6_layout(struct fdl_layout *layout,
|
|||
if (level == mip_levels - 1)
|
||||
height = align(height, 32);
|
||||
|
||||
slice->pitch = util_align_npot(u_minify(pitch0, level),
|
||||
uint32_t pitch_pixels = util_align_npot(u_minify(pitch0, level),
|
||||
fdl6_pitchalign(layout, ta, level));
|
||||
|
||||
slice->offset = layout->size;
|
||||
uint32_t blocks = util_format_get_nblocks(format,
|
||||
slice->pitch, height);
|
||||
pitch_pixels, height);
|
||||
|
||||
slice->pitch = util_format_get_nblocksx(format, pitch_pixels) *
|
||||
layout->cpp;
|
||||
|
||||
/* 1d array and 2d array textures must all have the same layer size
|
||||
* for each miplevel on a6xx. 3d textures can have different layer
|
||||
|
|
|
@ -400,12 +400,6 @@ static bool test_layout(const struct testcase *testcase)
|
|||
MAX2(testcase->array_size, 1),
|
||||
testcase->is_3d);
|
||||
|
||||
/* Our pitch values in the testcases[] layouts are in bytes straight out
|
||||
* of the traces, while fdl is in pixels. Rescale now.
|
||||
*/
|
||||
for (int l = 0; l < mip_levels; l++)
|
||||
layout.slices[l].pitch *= layout.cpp;
|
||||
|
||||
/* fdl lays out UBWC data before the color data, while all we have
|
||||
* recorded in this testcase are the color offsets. Shift the fdl layout
|
||||
* down so we can compare color offsets.
|
||||
|
|
|
@ -56,9 +56,9 @@ fdl_dump_layout(struct fdl_layout *layout)
|
|||
u_minify(layout->depth0, level),
|
||||
layout->cpp, layout->nr_samples,
|
||||
level,
|
||||
slice->pitch * layout->cpp,
|
||||
slice->pitch,
|
||||
slice->size0, ubwc_slice->size0,
|
||||
slice->size0 / (slice->pitch * layout->cpp),
|
||||
slice->size0 / slice->pitch,
|
||||
slice->offset, ubwc_slice->offset,
|
||||
layout->layer_size, layout->ubwc_layer_size,
|
||||
fdl_tile_mode(layout, level));
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
|
||||
struct fdl_slice {
|
||||
uint32_t offset; /* offset of first layer in slice */
|
||||
uint32_t pitch;
|
||||
uint32_t pitch; /* pitch in bytes between rows. */
|
||||
uint32_t size0; /* size of first layer in slice */
|
||||
};
|
||||
|
||||
|
|
|
@ -282,8 +282,7 @@ tu_image_view_init(struct tu_image_view *iview,
|
|||
uint64_t ubwc_addr = image->bo->iova + image->bo_offset +
|
||||
fdl_ubwc_offset(layout, range->baseMipLevel, range->baseArrayLayer);
|
||||
|
||||
uint32_t pitch = layout->slices[range->baseMipLevel].pitch * layout->cpp /
|
||||
util_format_get_blockwidth(layout->format);
|
||||
uint32_t pitch = layout->slices[range->baseMipLevel].pitch;
|
||||
uint32_t ubwc_pitch = layout->ubwc_slices[range->baseMipLevel].pitch;
|
||||
uint32_t layer_size = fdl_layer_stride(layout, range->baseMipLevel);
|
||||
|
||||
|
@ -513,7 +512,7 @@ tu_GetImageSubresourceLayout(VkDevice _device,
|
|||
pSubresource->arrayLayer);
|
||||
pLayout->size = slice->size0;
|
||||
pLayout->rowPitch =
|
||||
slice->pitch * vk_format_get_blocksize(image->vk_format);
|
||||
slice->pitch * vk_format_get_blockheight(image->vk_format);
|
||||
pLayout->arrayPitch = image->layout.layer_size;
|
||||
pLayout->depthPitch = slice->size0;
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) |
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) |
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue