/* 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);
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);
}
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;
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);
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) {
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);
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) |
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);
/* 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:
/* 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
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);
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;
bases++;
}
- slice = fd_resource_slice(rsc, psurf->u.tex.level);
format = fd4_pipe2color(pformat);
swap = fd4_pipe2swap(pformat);
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];
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;
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);
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) |
{
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;
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;
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);
}
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;
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
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);
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);
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);
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 */
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;
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);
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);
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) {
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);
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:
{
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;
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;
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);
}
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;
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;
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);
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);
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);
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);
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);
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,
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;
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);
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);
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:
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:
{
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;
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;
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);
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;
{
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;
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:
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;
*/
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;
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.. */
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)
* 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;