OUT_RING(ring, slice->pitch >> 5); /* RB_COPY_DEST_PITCH */
OUT_RING(ring, /* RB_COPY_DEST_INFO */
A2XX_RB_COPY_DEST_INFO_FORMAT(fd2_pipe2color(format)) |
- COND(!rsc->tile_mode, A2XX_RB_COPY_DEST_INFO_LINEAR) |
+ COND(!rsc->layout.tile_mode, A2XX_RB_COPY_DEST_INFO_LINEAR) |
A2XX_RB_COPY_DEST_INFO_WRITE_RED |
A2XX_RB_COPY_DEST_INFO_WRITE_GREEN |
A2XX_RB_COPY_DEST_INFO_WRITE_BLUE |
OUT_PKT3(ring, CP_SET_CONSTANT, 2);
OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_INFO));
OUT_RELOCW(ring, rsc->bo, offset,
- COND(!rsc->tile_mode, A2XX_RB_COLOR_INFO_LINEAR) |
+ COND(!rsc->layout.tile_mode, A2XX_RB_COLOR_INFO_LINEAR) |
A2XX_RB_COLOR_INFO_SWAP(fmt2swap(psurf->format)) |
A2XX_RB_COLOR_INFO_FORMAT(fd2_pipe2color(psurf->format)), 0);
blocks = util_format_get_nblocks(format, width, height);
/* 4k aligned size */
- slice->size0 = align(blocks * rsc->cpp, 4096);
+ slice->size0 = align(blocks * rsc->layout.cpp, 4096);
size += slice->size0 * depth * prsc->array_size;
A2XX_SQ_TEX_0_SIGN_Z(fmt.sign) |
A2XX_SQ_TEX_0_SIGN_W(fmt.sign) |
A2XX_SQ_TEX_0_PITCH(slice0->pitch) |
- COND(rsc->tile_mode, A2XX_SQ_TEX_0_TILED);
+ COND(rsc->layout.tile_mode, A2XX_SQ_TEX_0_TILED);
so->tex1 =
A2XX_SQ_TEX_1_FORMAT(fmt.format) |
A2XX_SQ_TEX_1_CLAMP_POLICY(SQ_TEX_CLAMP_POLICY_OGL);
debug_assert(psurf[i]->u.tex.first_layer == psurf[i]->u.tex.last_layer);
- OUT_RING(ring, A3XX_TEX_CONST_0_TILE_MODE(rsc->tile_mode) |
+ OUT_RING(ring, A3XX_TEX_CONST_0_TILE_MODE(rsc->layout.tile_mode) |
A3XX_TEX_CONST_0_FMT(fd3_pipe2tex(format)) |
A3XX_TEX_CONST_0_TYPE(A3XX_TEX_2D) |
fd3_tex_swiz(format, PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y,
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->cpp) |
+ OUT_RING(ring, A3XX_TEX_CONST_2_PITCH(slice->pitch * rsc->layout.cpp) |
A3XX_TEX_CONST_2_INDX(BASETABLE_SZ * i));
OUT_RING(ring, 0x00000000);
}
offset = fd_resource_offset(rsc, psurf->u.tex.level,
psurf->u.tex.first_layer);
- swap = rsc->tile_mode ? WZYX : fd3_pipe2swap(pformat);
+ swap = rsc->layout.tile_mode ? WZYX : fd3_pipe2swap(pformat);
if (bin_w) {
- stride = bin_w * rsc->cpp;
+ stride = bin_w * rsc->layout.cpp;
if (bases) {
base = bases[i];
}
} else {
- stride = slice->pitch * rsc->cpp;
- tile_mode = rsc->tile_mode;
+ stride = slice->pitch * rsc->layout.cpp;
+ tile_mode = rsc->layout.tile_mode;
}
} else if (i < nr_bufs && bases) {
base = bases[i];
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->cpp));
- OUT_RING(ring, A3XX_RB_COPY_DEST_INFO_TILE(rsc->tile_mode) |
+ OUT_RING(ring, A3XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch * rsc->layout.cpp));
+ 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) |
A3XX_RB_COPY_DEST_INFO_ENDIAN(ENDIAN_NONE) |
OUT_RING(ring, reg);
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
- OUT_RING(ring, A3XX_RB_DEPTH_PITCH(rsc->cpp * gmem->bin_w));
+ OUT_RING(ring, A3XX_RB_DEPTH_PITCH(rsc->layout.cpp * gmem->bin_w));
if (rsc->stencil) {
OUT_PKT0(ring, REG_A3XX_RB_STENCIL_INFO, 2);
OUT_RING(ring, A3XX_RB_STENCIL_INFO_STENCIL_BASE(gmem->zsbuf_base[1]));
- OUT_RING(ring, A3XX_RB_STENCIL_PITCH(rsc->stencil->cpp * gmem->bin_w));
+ OUT_RING(ring, A3XX_RB_STENCIL_PITCH(rsc->stencil->layout.cpp * gmem->bin_w));
}
} else {
OUT_RING(ring, 0x00000000);
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t blocks;
- if (rsc->tile_mode) {
+ if (rsc->layout.tile_mode) {
if (prsc->target != PIPE_TEXTURE_CUBE) {
if (level == 0) {
width = util_next_power_of_two(width);
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
(level > 1 && fd_resource_slice(rsc, level - 1)->size0 > 0xf000)))
- slice->size0 = align(blocks * rsc->cpp, alignment);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
else if (level == 0 || alignment == 1)
- slice->size0 = align(blocks * rsc->cpp, alignment);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
else
slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
so->base.context = pctx;
so->texconst0 =
- A3XX_TEX_CONST_0_TILE_MODE(rsc->tile_mode) |
+ A3XX_TEX_CONST_0_TILE_MODE(rsc->layout.tile_mode) |
A3XX_TEX_CONST_0_TYPE(tex_type(prsc->target)) |
A3XX_TEX_CONST_0_FMT(fd3_pipe2tex(cso->format)) |
fd3_tex_swiz(cso->format, cso->swizzle_r, cso->swizzle_g,
/* 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->cpp);
+ A3XX_TEX_CONST_2_PITCH(fd3_pipe2nblocksx(cso->format, slice->pitch) * rsc->layout.cpp);
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->cpp) |
+ OUT_RING(ring, A4XX_TEX_CONST_2_PITCH(slice->pitch * rsc->layout.cpp) |
A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format)));
OUT_RING(ring, 0x00000000);
OUT_RELOC(ring, rsc->bo, offset, 0, 0);
psurf->u.tex.first_layer);
if (bin_w) {
- stride = bin_w * rsc->cpp;
+ stride = bin_w * rsc->layout.cpp;
if (bases) {
base = bases[i];
}
} else {
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
}
} 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->cpp));
+ OUT_RING(ring, A4XX_RB_COPY_DEST_PITCH_PITCH(slice->pitch * rsc->layout.cpp));
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) |
if (pfb->zsbuf) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
- uint32_t cpp = rsc->cpp;
+ uint32_t cpp = rsc->layout.cpp;
OUT_PKT0(ring, REG_A4XX_RB_DEPTH_INFO, 3);
OUT_RING(ring, A4XX_RB_DEPTH_INFO_DEPTH_BASE(gmem->zsbuf_base[0]) |
if (rsc->stencil) {
OUT_RING(ring, A4XX_RB_STENCIL_INFO_SEPARATE_STENCIL |
A4XX_RB_STENCIL_INFO_STENCIL_BASE(gmem->zsbuf_base[1]));
- OUT_RING(ring, A4XX_RB_STENCIL_PITCH(rsc->stencil->cpp * gmem->bin_w));
+ OUT_RING(ring, A4XX_RB_STENCIL_PITCH(rsc->stencil->layout.cpp * gmem->bin_w));
} else {
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
A4XX_TEX_CONST_1_HEIGHT(1);
so->texconst2 =
A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format)) |
- A4XX_TEX_CONST_2_PITCH(elements * rsc->cpp);
+ A4XX_TEX_CONST_2_PITCH(elements * rsc->layout.cpp);
so->offset = cso->u.buf.offset;
} else {
unsigned miplevels;
so->texconst2 =
A4XX_TEX_CONST_2_FETCHSIZE(fd4_pipe2fetchsize(format)) |
A4XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp);
so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
}
case PIPE_TEXTURE_2D_ARRAY:
so->texconst3 =
A4XX_TEX_CONST_3_DEPTH(layers) |
- A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
+ A4XX_TEX_CONST_3_LAYERSZ(rsc->layout.layer_size);
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
so->texconst3 =
A4XX_TEX_CONST_3_DEPTH(layers / 6) |
- A4XX_TEX_CONST_3_LAYERSZ(rsc->layer_size);
+ A4XX_TEX_CONST_3_LAYERSZ(rsc->layout.layer_size);
break;
case PIPE_TEXTURE_3D:
so->texconst3 =
* untiling by setting both src and dst COLOR_SWAP=WZYX, but that
* means the formats must match:
*/
- if ((fd_resource(info->dst.resource)->tile_mode ||
- fd_resource(info->src.resource)->tile_mode) &&
+ if ((fd_resource(info->dst.resource)->layout.tile_mode ||
+ fd_resource(info->src.resource)->layout.tile_mode) &&
info->dst.format != info->src.format)
return false;
src = fd_resource(info->src.resource);
dst = fd_resource(info->dst.resource);
- debug_assert(src->cpp == 1);
- debug_assert(dst->cpp == 1);
+ debug_assert(src->layout.cpp == 1);
+ debug_assert(dst->layout.cpp == 1);
debug_assert(info->src.resource->format == info->dst.resource->format);
debug_assert((sbox->y == 0) && (sbox->height == 1));
debug_assert((dbox->y == 0) && (dbox->height == 1));
sswap = fd5_pipe2swap(info->src.format);
dswap = fd5_pipe2swap(info->dst.format);
- spitch = sslice->pitch * src->cpp;
- dpitch = dslice->pitch * dst->cpp;
+ spitch = sslice->pitch * src->layout.cpp;
+ dpitch = dslice->pitch * dst->layout.cpp;
/* 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
if (info->src.resource->target == PIPE_TEXTURE_3D)
ssize = sslice->size0;
else
- ssize = src->layer_size;
+ ssize = src->layout.layer_size;
if (info->dst.resource->target == PIPE_TEXTURE_3D)
dsize = dslice->size0;
else
- dsize = dst->layer_size;
+ dsize = dst->layout.layer_size;
for (unsigned i = 0; i < info->dst.box.depth; i++) {
unsigned soff = fd_resource_offset(src, info->src.level, sbox->z + i);
if ((info->src.resource->target == PIPE_BUFFER) &&
(info->dst.resource->target == PIPE_BUFFER)) {
- assert(fd_resource(info->src.resource)->tile_mode == TILE5_LINEAR);
- assert(fd_resource(info->dst.resource)->tile_mode == TILE5_LINEAR);
+ assert(fd_resource(info->src.resource)->layout.tile_mode == TILE5_LINEAR);
+ assert(fd_resource(info->dst.resource)->layout.tile_mode == TILE5_LINEAR);
emit_blit_buffer(batch->draw, info);
} else {
/* I don't *think* we need to handle blits between buffer <-> !buffer */
enum a5xx_tile_mode tile_mode = TILE5_LINEAR;
if (view->base.texture)
- tile_mode = fd_resource(view->base.texture)->tile_mode;
+ tile_mode = fd_resource(view->base.texture)->layout.tile_mode;
OUT_RING(ring, view->texconst0 |
A5XX_TEX_CONST_0_TILE_MODE(tile_mode));
size = stride * gmem->bin_h;
base = gmem->cbuf_base[i];
} else {
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level);
if (zsbuf) {
struct fd_resource *rsc = fd_resource(zsbuf->texture);
enum a5xx_depth_format fmt = fd5_pipe2depth(zsbuf->format);
- uint32_t cpp = rsc->cpp;
+ uint32_t cpp = rsc->layout.cpp;
uint32_t stride = 0;
uint32_t size = 0;
size = stride * gmem->bin_h;
} else {
struct fdl_slice *slice = fd_resource_slice(rsc, 0);
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
}
size = stride * gmem->bin_h;
} else {
struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0);
- stride = slice->pitch * rsc->cpp;
+ stride = slice->pitch * rsc->layout.cpp;
size = slice->size0;
}
OUT_PKT4(ring, REG_A5XX_RB_MRT_BUF_INFO(0), 5);
OUT_RING(ring, A5XX_RB_MRT_BUF_INFO_COLOR_FORMAT(format) |
- A5XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(rsc->tile_mode) |
+ 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->cpp));
+ OUT_RING(ring, A5XX_RB_MRT_PITCH(slice->pitch * rsc->layout.cpp));
OUT_RING(ring, A5XX_RB_MRT_ARRAY_PITCH(slice->size0));
OUT_RELOC(ring, rsc->bo, 0, 0, 0); /* BASE_LO/HI */
buf = BLIT_MRT0;
}
- stride = gmem->bin_w * rsc->cpp;
+ stride = gmem->bin_w * rsc->layout.cpp;
size = stride * gmem->bin_h;
OUT_PKT4(ring, REG_A5XX_RB_BLIT_FLAG_DST_LO, 4);
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->cpp));
+ OUT_RING(ring, A5XX_RB_BLIT_DST_PITCH(slice->pitch * rsc->layout.cpp));
OUT_RING(ring, A5XX_RB_BLIT_DST_ARRAY_PITCH(slice->size0));
OUT_PKT4(ring, REG_A5XX_RB_BLIT_CNTL, 1);
img->fetchsize = fd5_pipe2fetchsize(format);
img->type = fd5_tex_type(prsc->target);
img->srgb = util_format_is_srgb(format);
- img->cpp = rsc->cpp;
+ img->cpp = rsc->layout.cpp;
img->bo = rsc->bo;
if (prsc->target == PIPE_BUFFER) {
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->cpp;
+ img->pitch = slice->pitch * rsc->layout.cpp;
}
img->width = u_minify(prsc->width0, lvl);
case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = 1;
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = layers;
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = layers;
break;
case PIPE_TEXTURE_3D:
/* in layer_first layout, the level (slice) contains just one
* layer (since in fact the layer contains the slices)
*/
- uint32_t layers_in_level = rsc->layer_first ? 1 : prsc->array_size;
+ uint32_t layers_in_level = rsc->layout.layer_first ? 1 : prsc->array_size;
- heightalign = tile_alignment[rsc->cpp].heightalign;
+ heightalign = tile_alignment[rsc->layout.cpp].heightalign;
for (level = 0; level <= prsc->last_level; level++) {
struct fdl_slice *slice = fd_resource_slice(rsc, level);
uint32_t blocks;
if (fd_resource_tile_mode(prsc, level)) {
- pitchalign = tile_alignment[rsc->cpp].pitchalign;
+ pitchalign = tile_alignment[rsc->layout.cpp].pitchalign;
aligned_height = align(aligned_height, heightalign);
} else {
pitchalign = 64;
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
(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);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
+ else if (level == 0 || rsc->layout.layer_first || alignment == 1)
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
else
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",
util_format_name(prsc->format),
- prsc->width0, prsc->height0, prsc->depth0, rsc->cpp,
- level, slice->pitch * rsc->cpp,
+ prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp,
+ level, slice->pitch * rsc->layout.cpp,
slice->size0 * depth * layers_in_level,
aligned_height);
#endif
switch (rsc->base.target) {
case PIPE_TEXTURE_3D:
- rsc->layer_first = false;
+ rsc->layout.layer_first = false;
alignment = 4096;
break;
default:
- rsc->layer_first = true;
+ rsc->layout.layer_first = true;
alignment = 1;
break;
}
A5XX_TEX_CONST_1_HEIGHT(1);
so->texconst2 =
A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) |
- A5XX_TEX_CONST_2_PITCH(elements * rsc->cpp);
+ A5XX_TEX_CONST_2_PITCH(elements * rsc->layout.cpp);
so->offset = cso->u.buf.offset;
} else {
unsigned miplevels;
so->texconst2 =
A5XX_TEX_CONST_2_FETCHSIZE(fd5_pipe2fetchsize(format)) |
A5XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp);
so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer);
}
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(1);
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(layers);
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
so->texconst3 =
- A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A5XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A5XX_TEX_CONST_5_DEPTH(layers / 6);
break;
src = fd_resource(info->src.resource);
dst = fd_resource(info->dst.resource);
- debug_assert(src->cpp == 1);
- debug_assert(dst->cpp == 1);
+ debug_assert(src->layout.cpp == 1);
+ debug_assert(dst->layout.cpp == 1);
debug_assert(info->src.resource->format == info->dst.resource->format);
debug_assert((sbox->y == 0) && (sbox->height == 1));
debug_assert((dbox->y == 0) && (dbox->height == 1));
nelements = (dst->base.nr_samples ? dst->base.nr_samples : 1);
}
- spitch = DIV_ROUND_UP(sslice->pitch, blockwidth) * src->cpp;
- dpitch = DIV_ROUND_UP(dslice->pitch, blockwidth) * dst->cpp;
+ spitch = DIV_ROUND_UP(sslice->pitch, blockwidth) * src->layout.cpp;
+ dpitch = DIV_ROUND_UP(dslice->pitch, blockwidth) * dst->layout.cpp;
sx1 = sbox->x / blockwidth * nelements;
sy1 = sbox->y / blockheight;
if (subwc_enabled) {
OUT_PKT4(ring, REG_A6XX_SP_PS_2D_SRC_FLAGS_LO, 6);
OUT_RELOC(ring, src->bo, subwcoff, 0, 0);
- OUT_RING(ring, A6XX_SP_PS_2D_SRC_FLAGS_PITCH_PITCH(src->ubwc_pitch) |
- A6XX_SP_PS_2D_SRC_FLAGS_PITCH_ARRAY_PITCH(src->ubwc_size));
+ OUT_RING(ring, A6XX_SP_PS_2D_SRC_FLAGS_PITCH_PITCH(src->layout.ubwc_pitch) |
+ A6XX_SP_PS_2D_SRC_FLAGS_PITCH_ARRAY_PITCH(src->layout.ubwc_size));
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
if (dubwc_enabled) {
OUT_PKT4(ring, REG_A6XX_RB_2D_DST_FLAGS_LO, 6);
OUT_RELOCW(ring, dst->bo, dubwcoff, 0, 0);
- OUT_RING(ring, A6XX_RB_2D_DST_FLAGS_PITCH_PITCH(dst->ubwc_pitch) |
- A6XX_RB_2D_DST_FLAGS_PITCH_ARRAY_PITCH(dst->ubwc_size));
+ OUT_RING(ring, A6XX_RB_2D_DST_FLAGS_PITCH_PITCH(dst->layout.ubwc_pitch) |
+ A6XX_RB_2D_DST_FLAGS_PITCH_ARRAY_PITCH(dst->layout.ubwc_size));
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
if ((info->src.resource->target == PIPE_BUFFER) &&
(info->dst.resource->target == PIPE_BUFFER)) {
- assert(fd_resource(info->src.resource)->tile_mode == TILE6_LINEAR);
- assert(fd_resource(info->dst.resource)->tile_mode == TILE6_LINEAR);
+ assert(fd_resource(info->src.resource)->layout.tile_mode == TILE6_LINEAR);
+ assert(fd_resource(info->dst.resource)->layout.tile_mode == TILE6_LINEAR);
emit_blit_buffer(ctx, batch->draw, info);
} else {
/* I don't *think* we need to handle blits between buffer <-> !buffer */
OUT_RINGP(state, A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D) |
A6XX_TEX_CONST_2_FETCHSIZE(TFETCH6_2_BYTE),
&ctx->batch->fb_read_patches);
- OUT_RING(state, A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size));
+ OUT_RING(state, A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size));
OUT_RING(state, A6XX_TEX_CONST_4_BASE_LO(ctx->screen->gmem_base));
OUT_RING(state, A6XX_TEX_CONST_5_BASE_HI(ctx->screen->gmem_base >> 32) |
texconst0 |= A6XX_TEX_CONST_0_SRGB;
}
- if (rsc->tile_mode && !fd_resource_level_linear(prsc, level)) {
- texconst0 |= A6XX_TEX_CONST_0_TILE_MODE(rsc->tile_mode);
+ if (rsc->layout.tile_mode && !fd_resource_level_linear(prsc, level)) {
+ texconst0 |= A6XX_TEX_CONST_0_TILE_MODE(rsc->layout.tile_mode);
swap = WZYX;
} else {
swap = fd6_pipe2swap(format);
psurf->u.tex.first_layer);
ubwc_enabled = fd_resource_ubwc_enabled(rsc, psurf->u.tex.level);
- stride = slice->pitch * rsc->cpp * pfb->samples;
- swap = rsc->tile_mode ? WZYX : fd6_pipe2swap(pformat);
+ stride = slice->pitch * rsc->layout.cpp * pfb->samples;
+ swap = rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(pformat);
tile_mode = fd_resource_tile_mode(psurf->texture, psurf->u.tex.level);
OUT_PKT4(ring, REG_A6XX_RB_MRT_FLAG_BUFFER(i), 3);
if (ubwc_enabled) {
OUT_RELOCW(ring, rsc->bo, ubwc_offset, 0, 0); /* BASE_LO/HI */
- OUT_RING(ring, A6XX_RB_MRT_FLAG_BUFFER_PITCH_PITCH(rsc->ubwc_pitch) |
- A6XX_RB_MRT_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->ubwc_size));
+ OUT_RING(ring, A6XX_RB_MRT_FLAG_BUFFER_PITCH_PITCH(rsc->layout.ubwc_pitch) |
+ A6XX_RB_MRT_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->layout.ubwc_size));
} else {
OUT_RING(ring, 0x00000000); /* RB_MRT_FLAG_BUFFER[i].ADDR_LO */
OUT_RING(ring, 0x00000000); /* RB_MRT_FLAG_BUFFER[i].ADDR_HI */
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->cpp;
+ uint32_t stride = slice->pitch * rsc->layout.cpp;
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,
OUT_PKT4(ring, REG_A6XX_RB_DEPTH_FLAG_BUFFER_BASE_LO, 3);
if (ubwc_enabled) {
OUT_RELOCW(ring, rsc->bo, ubwc_offset, 0, 0); /* BASE_LO/HI */
- OUT_RING(ring, A6XX_RB_DEPTH_FLAG_BUFFER_PITCH_PITCH(rsc->ubwc_pitch) |
- A6XX_RB_DEPTH_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->ubwc_size));
+ OUT_RING(ring, A6XX_RB_DEPTH_FLAG_BUFFER_PITCH_PITCH(rsc->layout.ubwc_pitch) |
+ A6XX_RB_DEPTH_FLAG_BUFFER_PITCH_ARRAY_PITCH(rsc->layout.ubwc_size));
} else {
OUT_RING(ring, 0x00000000); /* RB_DEPTH_FLAG_BUFFER_BASE_LO */
OUT_RING(ring, 0x00000000); /* RB_DEPTH_FLAG_BUFFER_BASE_HI */
if (rsc->stencil) {
struct fdl_slice *slice = fd_resource_slice(rsc->stencil, 0);
- stride = slice->pitch * rsc->stencil->cpp;
+ stride = slice->pitch * rsc->stencil->layout.cpp;
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_color_fmt format = fd6_pipe2color(pfmt);
- uint32_t stride = slice->pitch * rsc->cpp;
+ uint32_t stride = slice->pitch * rsc->layout.cpp;
uint32_t size = slice->size0;
- enum a3xx_color_swap swap = rsc->tile_mode ? WZYX : fd6_pipe2swap(pfmt);
+ enum a3xx_color_swap swap = rsc->layout.tile_mode ? WZYX : fd6_pipe2swap(pfmt);
enum a3xx_msaa_samples samples =
fd_msaa_samples(rsc->base.nr_samples);
uint32_t tile_mode = fd_resource_tile_mode(&rsc->base, psurf->u.tex.level);
if (ubwc_enabled) {
OUT_PKT4(ring, REG_A6XX_RB_BLIT_FLAG_DST_LO, 3);
OUT_RELOCW(ring, rsc->bo, ubwc_offset, 0, 0);
- OUT_RING(ring, A6XX_RB_BLIT_FLAG_DST_PITCH_PITCH(rsc->ubwc_pitch) |
- A6XX_RB_BLIT_FLAG_DST_PITCH_ARRAY_PITCH(rsc->ubwc_size));
+ OUT_RING(ring, A6XX_RB_BLIT_FLAG_DST_PITCH_PITCH(rsc->layout.ubwc_pitch) |
+ A6XX_RB_BLIT_FLAG_DST_PITCH_ARRAY_PITCH(rsc->layout.ubwc_size));
}
fd6_emit_blit(batch, ring);
img->fetchsize = fd6_pipe2fetchsize(format);
img->type = fd6_tex_type(prsc->target);
img->srgb = util_format_is_srgb(format);
- img->cpp = rsc->cpp;
+ img->cpp = rsc->layout.cpp;
img->bo = rsc->bo;
/* Treat cube textures as 2d-array: */
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->cpp;
+ img->pitch = slice->pitch * rsc->layout.cpp;
switch (prsc->target) {
case PIPE_TEXTURE_RECT:
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
img->depth = 1;
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
- img->array_pitch = rsc->layer_size;
+ img->array_pitch = rsc->layout.layer_size;
// TODO the CUBE/CUBE_ARRAY might need to be layers/6 for tex state,
// but empirically for ibo state it shouldn't be divided.
img->depth = layers;
img->fetchsize = fd6_pipe2fetchsize(format);
img->type = fd6_tex_type(prsc->target);
img->srgb = util_format_is_srgb(format);
- img->cpp = rsc->cpp;
+ img->cpp = rsc->layout.cpp;
img->bo = rsc->bo;
img->buffer = true;
if (ubwc_enabled) {
OUT_RELOC(ring, rsc->bo, img->ubwc_offset, 0, 0);
- OUT_RING(ring, A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->ubwc_size));
- OUT_RING(ring, A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->ubwc_pitch));
+ OUT_RING(ring, A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size));
+ OUT_RING(ring, A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch));
} else {
OUT_RING(ring, 0x00000000); /* texconst7 */
OUT_RING(ring, 0x00000000); /* texconst8 */
if (ubwc_enabled) {
OUT_RELOCW(ring, rsc->bo, img->ubwc_offset, 0, 0);
- OUT_RING(ring, A6XX_IBO_9_FLAG_BUFFER_ARRAY_PITCH(rsc->ubwc_size));
- OUT_RING(ring, A6XX_IBO_10_FLAG_BUFFER_PITCH(rsc->ubwc_pitch));
+ OUT_RING(ring, A6XX_IBO_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size));
+ OUT_RING(ring, A6XX_IBO_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch));
} else {
OUT_RING(ring, 0x00000000);
OUT_RING(ring, 0x00000000);
/* in layer_first layout, the level (slice) contains just one
* layer (since in fact the layer contains the slices)
*/
- uint32_t layers_in_level = rsc->layer_first ? 1 : prsc->array_size;
- int ta = rsc->cpp;
+ uint32_t layers_in_level = rsc->layout.layer_first ? 1 : prsc->array_size;
+ int ta = rsc->layout.cpp;
/* The z16/r16 formats seem to not play by the normal tiling rules: */
- if ((rsc->cpp == 2) && (util_format_get_nr_components(format) == 1))
+ if ((rsc->layout.cpp == 2) && (util_format_get_nr_components(format) == 1))
ta = 0;
debug_assert(ta < ARRAY_SIZE(tile_alignment));
*/
if (prsc->target == PIPE_TEXTURE_3D) {
if (level < 1 || fd_resource_slice(rsc, level - 1)->size0 > 0xf000) {
- slice->size0 = align(blocks * rsc->cpp, alignment);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
} else {
slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
}
} else {
- slice->size0 = align(blocks * rsc->cpp, alignment);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
}
size += slice->size0 * depth * layers_in_level;
#if 0
fprintf(stderr, "%s: %ux%ux%u@%u:\t%2u: stride=%4u, size=%6u,%7u, aligned_height=%3u, blocks=%u, offset=0x%x tiling=%d\n",
util_format_name(prsc->format),
- width, height, depth, rsc->cpp,
- level, slice->pitch * rsc->cpp,
+ width, height, depth, rsc->layout.cpp,
+ level, slice->pitch * rsc->layout.cpp,
slice->size0, size, aligned_height, blocks,
slice->offset, fd_resource_tile_mode(prsc, level));
#endif
return 0;
uint32_t block_width, block_height;
- switch (rsc->cpp) {
+ switch (rsc->layout.cpp) {
case 2:
case 4:
block_width = 16;
* because it is what the kernel expects for scanout. For non-2D we
* could just use a separate UBWC buffer..
*/
- rsc->ubwc_offset = 0;
- rsc->offset = meta_size;
- rsc->ubwc_pitch = meta_stride;
- rsc->ubwc_size = meta_size >> 2; /* in dwords??? */
- rsc->tile_mode = TILE6_3;
+ rsc->layout.ubwc_offset = 0;
+ rsc->layout.offset = meta_size;
+ rsc->layout.ubwc_pitch = meta_stride;
+ rsc->layout.ubwc_size = meta_size >> 2; /* in dwords??? */
+ rsc->layout.tile_mode = TILE6_3;
return meta_size;
}
fd6_validate_format(struct fd_context *ctx, struct fd_resource *rsc,
enum pipe_format format)
{
- if (!rsc->ubwc_size)
+ if (!rsc->layout.ubwc_size)
return;
if (ok_ubwc_format(format))
switch (rsc->base.target) {
case PIPE_TEXTURE_3D:
- rsc->layer_first = false;
+ rsc->layout.layer_first = false;
alignment = 4096;
break;
default:
- rsc->layer_first = true;
+ rsc->layout.layer_first = true;
alignment = 1;
break;
}
so->texconst2 =
A6XX_TEX_CONST_2_FETCHSIZE(fd6_pipe2fetchsize(format)) |
A6XX_TEX_CONST_2_PITCH(
- util_format_get_nblocksx(format, slice->pitch) * rsc->cpp);
+ util_format_get_nblocksx(format, slice->pitch) * rsc->layout.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);
cso->swizzle_b, cso->swizzle_a);
if (so->ubwc_enabled) {
- so->texconst9 |= A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->ubwc_size);
- so->texconst10 |= A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->ubwc_pitch);
+ so->texconst9 |= A6XX_TEX_CONST_9_FLAG_BUFFER_ARRAY_PITCH(rsc->layout.ubwc_size);
+ so->texconst10 |= A6XX_TEX_CONST_10_FLAG_BUFFER_PITCH(rsc->layout.ubwc_pitch);
}
so->texconst2 |= A6XX_TEX_CONST_2_TYPE(fd6_tex_type(cso->target));
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
so->texconst3 =
- A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A6XX_TEX_CONST_5_DEPTH(1);
break;
case PIPE_TEXTURE_1D_ARRAY:
case PIPE_TEXTURE_2D_ARRAY:
so->texconst3 =
- A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A6XX_TEX_CONST_5_DEPTH(layers);
break;
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_CUBE_ARRAY:
so->texconst3 =
- A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layer_size);
+ A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size);
so->texconst5 =
A6XX_TEX_CONST_5_DEPTH(layers / 6);
break;
if (has_zs) {
struct fd_resource *rsc = fd_resource(pfb->zsbuf->texture);
- zsbuf_cpp[0] = rsc->cpp;
+ zsbuf_cpp[0] = rsc->layout.cpp;
if (rsc->stencil)
- zsbuf_cpp[1] = rsc->stencil->cpp;
+ zsbuf_cpp[1] = rsc->stencil->layout.cpp;
} else {
/* we might have a zsbuf, but it isn't used */
batch->restore &= ~(FD_BUFFER_DEPTH | FD_BUFFER_STENCIL);
fd_bo_del(rsc->bo);
rsc->bo = fd_bo_new(screen->dev, size, flags, "%ux%ux%u@%u:%x",
- prsc->width0, prsc->height0, prsc->depth0, rsc->cpp, prsc->bind);
+ prsc->width0, prsc->height0, prsc->depth0, rsc->layout.cpp, prsc->bind);
rsc->seqno = p_atomic_inc_return(&screen->rsc_seqno);
util_range_set_empty(&rsc->valid_buffer_range);
fd_bc_invalidate_resource(rsc, true);
/* TODO valid_buffer_range?? */
swap(rsc->bo, shadow->bo);
swap(rsc->write_batch, shadow->write_batch);
- swap(rsc->offset, shadow->offset);
- swap(rsc->ubwc_offset, shadow->ubwc_offset);
- swap(rsc->ubwc_pitch, shadow->ubwc_pitch);
- swap(rsc->ubwc_size, shadow->ubwc_size);
+ swap(rsc->layout.offset, shadow->layout.offset);
+ swap(rsc->layout.ubwc_offset, shadow->layout.ubwc_offset);
+ swap(rsc->layout.ubwc_pitch, shadow->layout.ubwc_pitch);
+ swap(rsc->layout.ubwc_size, shadow->layout.ubwc_size);
rsc->seqno = p_atomic_inc_return(&ctx->screen->rsc_seqno);
/* at this point, the newly created shadow buffer is not referenced
ptrans->level = level;
ptrans->usage = usage;
ptrans->box = *box;
- ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->cpp;
+ ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->layout.cpp;
ptrans->layer_stride = fd_resource_layer_stride(rsc, level);
/* we always need a staging texture for tiled buffers:
* splitting a batch.. for ex, mid-frame texture uploads to a tiled
* texture.
*/
- if (rsc->tile_mode) {
+ if (rsc->layout.tile_mode) {
struct fd_resource *staging_rsc;
staging_rsc = fd_alloc_staging(ctx, rsc, level, box);
// 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->cpp;
+ staging_slice->pitch) * staging_rsc->layout.cpp;
trans->base.layer_stride = fd_resource_layer_stride(staging_rsc, 0);
trans->staging_box = *box;
trans->staging_box.x = 0;
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->cpp;
+ staging_slice->pitch) * staging_rsc->layout.cpp;
trans->base.layer_stride =
fd_resource_layer_stride(staging_rsc, 0);
trans->staging_box = *box;
buf = fd_bo_map(rsc->bo);
offset =
box->y / util_format_get_blockheight(format) * ptrans->stride +
- box->x / util_format_get_blockwidth(format) * rsc->cpp +
+ box->x / util_format_get_blockwidth(format) * rsc->layout.cpp +
fd_resource_offset(rsc, level, box->z);
if (usage & PIPE_TRANSFER_WRITE)
static uint64_t
fd_resource_modifier(struct fd_resource *rsc)
{
- if (!rsc->tile_mode)
+ if (!rsc->layout.tile_mode)
return DRM_FORMAT_MOD_LINEAR;
- if (rsc->ubwc_size)
+ if (rsc->layout.ubwc_size)
return DRM_FORMAT_MOD_QCOM_COMPRESSED;
/* TODO invent a modifier for tiled but not UBWC buffers: */
handle->modifier = fd_resource_modifier(rsc);
return fd_screen_bo_get_handle(pscreen, rsc->bo, rsc->scanout,
- fd_resource_slice(rsc, 0)->pitch * rsc->cpp, handle);
+ fd_resource_slice(rsc, 0)->pitch * rsc->layout.cpp, handle);
}
static uint32_t
/* in layer_first layout, the level (slice) contains just one
* layer (since in fact the layer contains the slices)
*/
- uint32_t layers_in_level = rsc->layer_first ? 1 : prsc->array_size;
+ uint32_t layers_in_level = rsc->layout.layer_first ? 1 : prsc->array_size;
for (level = 0; level <= prsc->last_level; level++) {
struct fdl_slice *slice = fd_resource_slice(rsc, level);
if (prsc->target == PIPE_TEXTURE_3D && (
level == 1 ||
(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);
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
+ else if (level == 0 || rsc->layout.layer_first || alignment == 1)
+ slice->size0 = align(blocks * rsc->layout.cpp, alignment);
else
slice->size0 = fd_resource_slice(rsc, level - 1)->size0;
if (is_a4xx(screen)) {
switch (rsc->base.target) {
case PIPE_TEXTURE_3D:
- rsc->layer_first = false;
+ rsc->layout.layer_first = false;
break;
default:
- rsc->layer_first = true;
+ rsc->layout.layer_first = true;
alignment = 1;
break;
}
}
}
+static void
+fd_resource_layout_init(struct pipe_resource *prsc)
+{
+ struct fd_resource *rsc = fd_resource(prsc);
+ struct fdl_layout *layout = &rsc->layout;
+
+ layout->width0 = prsc->width0;
+ layout->height0 = prsc->height0;
+ layout->depth0 = prsc->depth0;
+
+ layout->cpp = util_format_get_blocksize(prsc->format);
+ layout->cpp *= fd_resource_nr_samples(prsc);
+}
+
/**
* Create a new texture object, using the given template info.
*/
return NULL;
*prsc = *tmpl;
+ fd_resource_layout_init(prsc);
#define LINEAR \
(PIPE_BIND_SCANOUT | \
if (screen->tile_mode &&
(tmpl->target != PIPE_BUFFER) &&
!linear) {
- rsc->tile_mode = screen->tile_mode(prsc);
+ rsc->layout.tile_mode = screen->tile_mode(prsc);
}
util_range_init(&rsc->valid_buffer_range);
rsc->internal_format = format;
- rsc->cpp = util_format_get_blocksize(format);
- rsc->cpp *= fd_resource_nr_samples(prsc);
-
- assert(rsc->cpp);
// XXX probably need some extra work if we hit rsc shadowing path w/ lrz..
if ((is_a5xx(screen) || is_a6xx(screen)) &&
size = screen->setup_slices(rsc);
- if (allow_ubwc && screen->fill_ubwc_buffer_sizes && rsc->tile_mode)
+ if (allow_ubwc && screen->fill_ubwc_buffer_sizes && rsc->layout.tile_mode)
size += screen->fill_ubwc_buffer_sizes(rsc);
/* special case for hw-query buffer, which we need to allocate before we
return prsc;
}
- if (rsc->layer_first) {
- rsc->layer_size = align(size, 4096);
- size = rsc->layer_size * prsc->array_size;
+ if (rsc->layout.layer_first) {
+ rsc->layout.layer_size = align(size, 4096);
+ size = rsc->layout.layer_size * prsc->array_size;
}
realloc_bo(rsc, size);
return NULL;
*prsc = *tmpl;
+ fd_resource_layout_init(prsc);
pipe_reference_init(&prsc->reference, 1);
goto fail;
rsc->internal_format = tmpl->format;
- rsc->cpp = util_format_get_blocksize(tmpl->format);
- rsc->cpp *= fd_resource_nr_samples(prsc);
- slice->pitch = handle->stride / rsc->cpp;
+ slice->pitch = handle->stride / rsc->layout.cpp;
slice->offset = handle->offset;
slice->size0 = handle->stride * prsc->height0;
goto fail;
}
- assert(rsc->cpp);
+ assert(rsc->layout.cpp);
if (screen->ro) {
rsc->scanout =
struct fd_resource {
struct pipe_resource base;
struct fd_bo *bo;
- uint32_t cpp;
enum pipe_format internal_format;
- bool layer_first; /* see above description */
- uint32_t layer_size;
- struct fdl_slice slices[MAX_MIP_LEVELS];
+ struct fdl_layout layout;
+
/* buffer range that has been initialized */
struct util_range valid_buffer_range;
bool valid;
/* TODO rename to secondary or auxiliary? */
struct fd_resource *stencil;
- uint32_t offset;
- uint32_t ubwc_offset;
- uint32_t ubwc_pitch;
- uint32_t ubwc_size;
-
/* bitmask of in-flight batches which reference this resource. Note
* that the batch doesn't hold reference to resources (but instead
* the fd_ringbuffer holds refs to the underlying fd_bo), but in case
/* Sequence # incremented each time bo changes: */
uint16_t seqno;
- unsigned tile_mode : 2;
-
/*
* LRZ
+ *
+ * TODO lrz width/height/pitch should probably also move to
+ * fdl_layout
*/
bool lrz_valid : 1;
uint16_t lrz_width; // for lrz clear, does this differ from lrz_pitch?
return (struct fd_resource *)ptex;
}
+static inline const struct fd_resource *
+fd_resource_const(const struct pipe_resource *ptex)
+{
+ return (const struct fd_resource *)ptex;
+}
+
static inline bool
pending(struct fd_resource *rsc, bool write)
{
fd_resource_slice(struct fd_resource *rsc, unsigned level)
{
assert(level <= rsc->base.last_level);
- return &rsc->slices[level];
+ return &rsc->layout.slices[level];
}
static inline uint32_t
fd_resource_layer_stride(struct fd_resource *rsc, unsigned level)
{
- if (rsc->layer_first)
- return rsc->layer_size;
- else
- return fd_resource_slice(rsc, level)->size0;
+ return fdl_layer_stride(&rsc->layout, level);
}
/* 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)
{
- struct fdl_slice *slice = fd_resource_slice(rsc, level);
- unsigned offset = slice->offset;
- offset += fd_resource_layer_stride(rsc, level) * layer;
+ uint32_t offset = fdl_surface_offset(&rsc->layout, level, layer);
debug_assert(offset < fd_bo_size(rsc->bo));
- return offset + rsc->offset;
+ return offset;
}
static inline uint32_t
fd_resource_ubwc_offset(struct fd_resource *rsc, unsigned level, unsigned layer)
{
- /* for now this doesn't do anything clever, but when UBWC is enabled
- * for multi layer/level images, it will.
- */
- if (rsc->ubwc_size) {
- debug_assert(level == 0);
- debug_assert(layer == 0);
- }
- return rsc->ubwc_offset;
+ return fdl_ubwc_offset(&rsc->layout, level, layer);
}
/* This might be a5xx specific, but higher mipmap levels are always linear: */
struct fd_screen *screen = fd_screen(prsc->screen);
debug_assert(!is_a3xx(screen));
- unsigned w = u_minify(prsc->width0, level);
- if (w < 16)
- return true;
- return false;
+ return fdl_level_linear(&fd_resource_const(prsc)->layout, level);
}
static inline uint32_t
fd_resource_tile_mode(struct pipe_resource *prsc, int level)
{
- struct fd_resource *rsc = fd_resource(prsc);
- if (rsc->tile_mode && fd_resource_level_linear(&rsc->base, level))
- return 0; /* linear */
- else
- return rsc->tile_mode;
+ return fdl_tile_mode(&fd_resource(prsc)->layout, level);
}
static inline bool
fd_resource_ubwc_enabled(struct fd_resource *rsc, int level)
{
- return rsc->ubwc_size && fd_resource_tile_mode(&rsc->base, level);
+ return fdl_ubwc_enabled(&rsc->layout, level);
}
/* access # of samples, with 0 normalized to 1 (which is what we care about
* be the same, so use original dimensions for y and z
* stride:
*/
- dims[off + 1] = slice->pitch * rsc->cpp;
+ dims[off + 1] = slice->pitch * rsc->layout.cpp;
/* see corresponding logic in fd_resource_offset(): */
- if (rsc->layer_first) {
- dims[off + 2] = rsc->layer_size;
+ if (rsc->layout.layer_first) {
+ dims[off + 2] = rsc->layout.layer_size;
} else {
dims[off + 2] = slice->size0;
}