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>
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
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.
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));
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 */
};
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);
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;
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)
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) |
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);
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));
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);
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) |
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);
}
}
}
-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)
{
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);
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) {
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) |
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);
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
/* 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:
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);
base = bases[i];
}
} else {
- stride = slice->pitch * rsc->layout.cpp;
+ stride = slice->pitch;
}
} else if ((i < nr_bufs) && bases) {
base = bases[i];
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) |
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);
}
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
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);
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;
}
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;
}
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 */
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);
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);
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
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);
}
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;
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;
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);
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);
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);
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,
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;
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 =
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:
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);
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:
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;
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;
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
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
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",
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;
* 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;