so->base.reference.count = 1;
so->base.context = pctx;
+ struct fd_resource_slice *slice0 = fd_resource_slice(rsc, 0);
so->tex0 =
A2XX_SQ_TEX_0_SIGN_X(fmt.sign) |
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(rsc->slices[0].pitch) |
+ A2XX_SQ_TEX_0_PITCH(slice0->pitch) |
COND(rsc->tile_mode, A2XX_SQ_TEX_0_TILED);
so->tex1 =
A2XX_SQ_TEX_1_FORMAT(fmt.format) |
struct pipe_surface *psurf = pfb->cbufs[i];
if (!psurf)
continue;
- pitch = fd_resource(psurf->texture)->slices[psurf->u.tex.level].pitch;
+ struct fd_resource_slice *slice =
+ fd_resource_slice(fd_resource(psurf->texture),
+ psurf->u.tex.level);
+ pitch = slice->pitch;
}
fd3_emit_restore(batch, ring);
*/
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
- (level > 1 && rsc->slices[level - 1].size0 > 0xf000)))
+ (level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
slice->size0 = align(blocks * rsc->cpp, alignment);
else if (level == 0 || alignment == 1)
slice->size0 = align(blocks * rsc->cpp, alignment);
else
- slice->size0 = rsc->slices[level - 1].size0;
+ slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
size += slice->size0 * depth * prsc->array_size;
struct fd3_pipe_sampler_view *so = CALLOC_STRUCT(fd3_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
unsigned lvl;
- uint32_t sz2 = 0;
if (!so)
return NULL;
A3XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl));
}
/* when emitted, A3XX_TEX_CONST_2_INDX() must be OR'd in: */
+ struct fd_resource_slice *slice = fd_resource_slice(rsc, lvl);
so->texconst2 =
- A3XX_TEX_CONST_2_PITCH(fd3_pipe2nblocksx(cso->format, rsc->slices[lvl].pitch) * rsc->cpp);
+ A3XX_TEX_CONST_2_PITCH(fd3_pipe2nblocksx(cso->format, slice->pitch) * rsc->cpp);
switch (prsc->target) {
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
so->texconst3 =
A3XX_TEX_CONST_3_DEPTH(prsc->array_size - 1) |
- A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[0].size0);
+ A3XX_TEX_CONST_3_LAYERSZ1(slice->size0);
break;
case PIPE_TEXTURE_3D:
so->texconst3 =
A3XX_TEX_CONST_3_DEPTH(u_minify(prsc->depth0, lvl)) |
- A3XX_TEX_CONST_3_LAYERSZ1(rsc->slices[lvl].size0);
- while (lvl < cso->u.tex.last_level && sz2 != rsc->slices[lvl+1].size0)
- sz2 = rsc->slices[++lvl].size0;
- so->texconst3 |= A3XX_TEX_CONST_3_LAYERSZ2(sz2);
+ A3XX_TEX_CONST_3_LAYERSZ1(slice->size0);
+ so->texconst3 |= A3XX_TEX_CONST_3_LAYERSZ2(
+ fd_resource_slice(rsc, prsc->last_level)->size0);
break;
default:
so->texconst3 = 0x00000000;
pformat = rsc->base.format;
}
- slice = &rsc->slices[psurf->u.tex.level];
+ slice = fd_resource_slice(rsc, psurf->u.tex.level);
offset = fd_resource_offset(rsc, psurf->u.tex.level,
psurf->u.tex.first_layer);
{
struct fd4_pipe_sampler_view *so = CALLOC_STRUCT(fd4_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
+ struct fd_resource_slice *slice = NULL;
enum pipe_format format = cso->format;
unsigned lvl, layers = 0;
- uint32_t sz2 = 0;
if (!so)
return NULL;
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;
so->texconst2 =
A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format)) |
A4XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(
- format, rsc->slices[lvl].pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
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(rsc->slices[lvl].size0);
- while (lvl < cso->u.tex.last_level && sz2 != rsc->slices[lvl+1].size0)
- sz2 = rsc->slices[++lvl].size0;
- so->texconst4 = A4XX_TEX_CONST_4_LAYERSZ(sz2);
+ A4XX_TEX_CONST_3_LAYERSZ(slice->size0);
+ so->texconst4 = A4XX_TEX_CONST_4_LAYERSZ(
+ fd_resource_slice(rsc, prsc->last_level)->size0);
break;
default:
so->texconst3 = 0x00000000;
enum pipe_format format = pimg->format;
struct pipe_resource *prsc = pimg->resource;
struct fd_resource *rsc = fd_resource(prsc);
+ struct fd_resource_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 = rsc->slices[lvl].pitch * rsc->cpp;
+ img->pitch = slice->pitch * rsc->cpp;
}
img->width = u_minify(prsc->width0, lvl);
img->depth = layers;
break;
case PIPE_TEXTURE_3D:
- img->array_pitch = rsc->slices[lvl].size0;
+ img->array_pitch = slice->size0;
img->depth = u_minify(prsc->depth0, lvl);
break;
default:
*/
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
- (level > 1 && rsc->slices[level - 1].size0 > 0xf000)))
+ (level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
slice->size0 = align(blocks * rsc->cpp, alignment);
else if (level == 0 || rsc->layer_first || alignment == 1)
slice->size0 = align(blocks * rsc->cpp, alignment);
else
- slice->size0 = rsc->slices[level - 1].size0;
+ slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
#if 0
debug_printf("%s: %ux%ux%u@%u: %2u: stride=%4u, size=%7u, aligned_height=%3u\n",
{
struct fd5_pipe_sampler_view *so = CALLOC_STRUCT(fd5_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
+ struct fd_resource_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;
so->texconst2 =
A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) |
A5XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(
- format, rsc->slices[lvl].pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
}
break;
case PIPE_TEXTURE_3D:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->slices[lvl].size0);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(slice->size0);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(u_minify(prsc->depth0, lvl));
break;
img->buffer = false;
unsigned lvl = pimg->u.tex.level;
+ struct fd_resource_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 = rsc->slices[lvl].pitch * rsc->cpp;
+ img->pitch = slice->pitch * rsc->cpp;
switch (prsc->target) {
case PIPE_TEXTURE_RECT:
img->depth = layers;
break;
case PIPE_TEXTURE_3D:
- img->array_pitch = rsc->slices[lvl].size0;
+ img->array_pitch = slice->size0;
img->depth = u_minify(prsc->depth0, lvl);
break;
default:
* range gets into range, we stop reducing it.
*/
if (prsc->target == PIPE_TEXTURE_3D) {
- if (level < 1 || (rsc->slices[level - 1].size0 > 0xf000)) {
+ if (level < 1 || fd_resource_slice(rsc, level - 1)->size0 > 0xf000) {
slice->size0 = align(blocks * rsc->cpp, alignment);
} else {
- slice->size0 = rsc->slices[level - 1].size0;
+ slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
}
} else {
slice->size0 = align(blocks * rsc->cpp, alignment);
{
struct fd6_pipe_sampler_view *so = CALLOC_STRUCT(fd6_pipe_sampler_view);
struct fd_resource *rsc = fd_resource(prsc);
+ struct fd_resource_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;
so->texconst2 =
A6XX_TEX_CONST_2_FETCHSIZE(fd6_pipe2fetchsize(format)) |
A6XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(
- format, rsc->slices[lvl].pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
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);
break;
case PIPE_TEXTURE_3D:
so->texconst3 =
- A6XX_TEX_CONST_3_MIN_LAYERSZ(rsc->slices[prsc->last_level].size0) |
- A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->slices[lvl].size0);
+ A6XX_TEX_CONST_3_MIN_LAYERSZ(
+ fd_resource_slice(rsc, prsc->last_level)->size0) |
+ A6XX_TEX_CONST_3_ARRAY_PITCH(slice->size0);
so->texconst5 =
A6XX_TEX_CONST_5_DEPTH(u_minify(prsc->depth0, lvl));
break;
staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
if (staging_rsc) {
+ struct fd_resource_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 = util_format_get_nblocksx(format,
- staging_rsc->slices[0].pitch) * staging_rsc->cpp;
+ staging_slice->pitch) * staging_rsc->cpp;
trans->base.layer_stride = staging_rsc->layer_first ?
- staging_rsc->layer_size : staging_rsc->slices[0].size0;
+ staging_rsc->layer_size : staging_slice->size0;
trans->staging_box = *box;
trans->staging_box.x = 0;
trans->staging_box.y = 0;
*/
staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
if (staging_rsc) {
+ struct fd_resource_slice *staging_slice =
+ fd_resource_slice(staging_rsc, 0);
trans->staging_prsc = &staging_rsc->base;
trans->base.stride = util_format_get_nblocksx(format,
- staging_rsc->slices[0].pitch) * staging_rsc->cpp;
+ staging_slice->pitch) * staging_rsc->cpp;
trans->base.layer_stride = staging_rsc->layer_first ?
- staging_rsc->layer_size : staging_rsc->slices[0].size0;
+ staging_rsc->layer_size : staging_slice->size0;
trans->staging_box = *box;
trans->staging_box.x = 0;
trans->staging_box.y = 0;
handle->modifier = fd_resource_modifier(rsc);
return fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout,
- rsc->slices[0].pitch * rsc->cpp, handle);
+ fd_resource_slice(rsc, 0)->pitch * rsc->cpp, handle);
}
static uint32_t
*/
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
- (level > 1 && rsc->slices[level - 1].size0 > 0xf000)))
+ (level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
slice->size0 = align(blocks * rsc->cpp, alignment);
else if (level == 0 || rsc->layer_first || alignment == 1)
slice->size0 = align(blocks * rsc->cpp, alignment);
else
- slice->size0 = rsc->slices[level - 1].size0;
+ slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
size += slice->size0 * depth * layers_in_level;
{
struct fd_screen *screen = fd_screen(pscreen);
struct fd_resource *rsc = CALLOC_STRUCT(fd_resource);
- struct fd_resource_slice *slice = &rsc->slices[0];
+ struct fd_resource_slice *slice = fd_resource_slice(rsc, 0);
struct pipe_resource *prsc = &rsc->base;
uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw;
dims[off + 0] = util_format_get_blocksize(img->format);
if (img->resource->target != PIPE_BUFFER) {
- unsigned lvl = img->u.tex.level;
+ struct fd_resource_slice *slice =
+ fd_resource_slice(rsc, img->u.tex.level);
/* note for 2d/cube/etc images, even if re-interpreted
* as a different color format, the pixel size should
* be the same, so use original dimensions for y and z
* stride:
*/
- dims[off + 1] = rsc->slices[lvl].pitch * rsc->cpp;
+ dims[off + 1] = slice->pitch * rsc->cpp;
/* see corresponding logic in fd_resource_offset(): */
if (rsc->layer_first) {
dims[off + 2] = rsc->layer_size;
} else {
- dims[off + 2] = rsc->slices[lvl].size0;
+ dims[off + 2] = slice->size0;
}
} else {
/* For buffer-backed images, the log2 of the format's