panfrost: Make pan_texture.{c,h} panfrost_bo agnostic
All the helpers use pan_image_mem::bo just to get the base address. So let's just store this information here, and let the user keep track of the BO that's attached to the image resource. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Constantine Shablya <constantine.shablya@collabora.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26698>
This commit is contained in:

committed by
Marge Bot

parent
2d07926df1
commit
f94889d079
@@ -821,7 +821,7 @@ panfrost_emit_vertex_buffers(struct panfrost_batch *batch)
|
||||
panfrost_batch_read_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
|
||||
|
||||
pan_pack(buffers + i, BUFFER, cfg) {
|
||||
cfg.address = rsrc->image.data.bo->ptr.gpu + vb.buffer_offset;
|
||||
cfg.address = rsrc->image.data.base + vb.buffer_offset;
|
||||
|
||||
cfg.size = prsrc->width0 - vb.buffer_offset;
|
||||
}
|
||||
@@ -909,7 +909,7 @@ panfrost_map_constant_buffer_gpu(struct panfrost_batch *batch,
|
||||
|
||||
/* Alignment gauranteed by
|
||||
* PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT */
|
||||
return rsrc->image.data.bo->ptr.gpu + cb->buffer_offset;
|
||||
return rsrc->image.data.base + cb->buffer_offset;
|
||||
} else if (cb->user_buffer) {
|
||||
return pan_pool_upload_aligned(&batch->pool.base,
|
||||
cb->user_buffer + cb->buffer_offset,
|
||||
@@ -1038,7 +1038,7 @@ panfrost_upload_ssbo_sysval(struct panfrost_batch *batch,
|
||||
|
||||
/* Compute address */
|
||||
struct panfrost_resource *rsrc = pan_resource(sb.buffer);
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
struct panfrost_bo *bo = rsrc->bo;
|
||||
|
||||
panfrost_batch_write_rsrc(batch, rsrc, st);
|
||||
|
||||
@@ -1205,7 +1205,7 @@ panfrost_upload_sysvals(struct panfrost_batch *batch, void *ptr_cpu,
|
||||
|
||||
panfrost_batch_write_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
|
||||
|
||||
uniforms[i].du[0] = rsrc->image.data.bo->ptr.gpu + offset;
|
||||
uniforms[i].du[0] = rsrc->image.data.base + offset;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1269,11 +1269,11 @@ panfrost_map_constant_buffer_cpu(struct panfrost_context *ctx,
|
||||
struct panfrost_resource *rsrc = pan_resource(cb->buffer);
|
||||
|
||||
if (rsrc) {
|
||||
panfrost_bo_mmap(rsrc->image.data.bo);
|
||||
panfrost_bo_mmap(rsrc->bo);
|
||||
panfrost_flush_writer(ctx, rsrc, "CPU constant buffer mapping");
|
||||
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
|
||||
panfrost_bo_wait(rsrc->bo, INT64_MAX, false);
|
||||
|
||||
return rsrc->image.data.bo->ptr.cpu + cb->buffer_offset;
|
||||
return rsrc->bo->ptr.cpu + cb->buffer_offset;
|
||||
} else if (cb->user_buffer) {
|
||||
return cb->user_buffer + cb->buffer_offset;
|
||||
} else
|
||||
@@ -1491,7 +1491,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||
struct panfrost_context *ctx = pan_context(pctx);
|
||||
struct panfrost_resource *prsrc = (struct panfrost_resource *)texture;
|
||||
enum pipe_format format = so->base.format;
|
||||
assert(prsrc->image.data.bo);
|
||||
assert(prsrc->bo);
|
||||
|
||||
/* Format to access the stencil/depth portion of a Z32_S8 texture */
|
||||
if (format == PIPE_FORMAT_X32_S8X24_UINT) {
|
||||
@@ -1503,7 +1503,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||
format = PIPE_FORMAT_Z32_FLOAT;
|
||||
}
|
||||
|
||||
so->texture_bo = prsrc->image.data.bo->ptr.gpu;
|
||||
so->texture_bo = prsrc->image.data.base;
|
||||
so->modifier = prsrc->image.layout.modifier;
|
||||
|
||||
/* MSAA only supported for 2D textures */
|
||||
@@ -1585,7 +1585,7 @@ panfrost_update_sampler_view(struct panfrost_sampler_view *view,
|
||||
struct pipe_context *pctx)
|
||||
{
|
||||
struct panfrost_resource *rsrc = pan_resource(view->base.texture);
|
||||
if (view->texture_bo != rsrc->image.data.bo->ptr.gpu ||
|
||||
if (view->texture_bo != rsrc->image.data.base ||
|
||||
view->modifier != rsrc->image.layout.modifier) {
|
||||
panfrost_bo_unreference(view->state.bo);
|
||||
panfrost_create_sampler_view_bo(view, pctx, &rsrc->base);
|
||||
@@ -1787,9 +1787,9 @@ emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader,
|
||||
|
||||
pan_pack(bufs + (i * 2), ATTRIBUTE_BUFFER, cfg) {
|
||||
cfg.type = pan_modifier_to_attr_type(rsrc->image.layout.modifier);
|
||||
cfg.pointer = rsrc->image.data.bo->ptr.gpu + offset;
|
||||
cfg.pointer = rsrc->image.data.base + offset;
|
||||
cfg.stride = util_format_get_blocksize(image->format);
|
||||
cfg.size = panfrost_bo_size(rsrc->image.data.bo) - offset;
|
||||
cfg.size = panfrost_bo_size(rsrc->bo) - offset;
|
||||
}
|
||||
|
||||
if (is_buffer) {
|
||||
@@ -1927,7 +1927,7 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch, mali_ptr *buffers)
|
||||
panfrost_batch_read_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
|
||||
|
||||
/* Mask off lower bits, see offset fixup below */
|
||||
mali_ptr raw_addr = rsrc->image.data.bo->ptr.gpu + buf->buffer_offset;
|
||||
mali_ptr raw_addr = rsrc->image.data.base + buf->buffer_offset;
|
||||
mali_ptr addr = raw_addr & ~63;
|
||||
|
||||
/* Since we advanced the base pointer, we shrink the buffer
|
||||
@@ -3124,7 +3124,7 @@ panfrost_afbc_size(struct panfrost_batch *batch, struct panfrost_resource *src,
|
||||
struct pan_image_slice_layout *slice = &src->image.layout.slices[level];
|
||||
struct panfrost_afbc_size_info consts = {
|
||||
.src =
|
||||
src->image.data.bo->ptr.gpu + src->image.data.offset + slice->offset,
|
||||
src->image.data.base + src->image.data.offset + slice->offset,
|
||||
.metadata = metadata->ptr.gpu + offset,
|
||||
};
|
||||
|
||||
@@ -3143,7 +3143,7 @@ panfrost_afbc_pack(struct panfrost_batch *batch, struct panfrost_resource *src,
|
||||
{
|
||||
struct pan_image_slice_layout *src_slice = &src->image.layout.slices[level];
|
||||
struct panfrost_afbc_pack_info consts = {
|
||||
.src = src->image.data.bo->ptr.gpu + src->image.data.offset +
|
||||
.src = src->image.data.base + src->image.data.offset +
|
||||
src_slice->offset,
|
||||
.dst = dst->ptr.gpu + dst_slice->offset,
|
||||
.metadata = metadata->ptr.gpu + metadata_offset,
|
||||
|
@@ -684,10 +684,10 @@ panfrost_get_query_result(struct pipe_context *pipe, struct pipe_query *q,
|
||||
case PIPE_QUERY_OCCLUSION_PREDICATE:
|
||||
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
|
||||
panfrost_flush_writer(ctx, rsrc, "Occlusion query");
|
||||
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
|
||||
panfrost_bo_wait(rsrc->bo, INT64_MAX, false);
|
||||
|
||||
/* Read back the query results */
|
||||
uint64_t *result = (uint64_t *)rsrc->image.data.bo->ptr.cpu;
|
||||
uint64_t *result = (uint64_t *)rsrc->bo->ptr.cpu;
|
||||
|
||||
if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) {
|
||||
uint64_t passed = 0;
|
||||
@@ -829,7 +829,7 @@ panfrost_set_global_binding(struct pipe_context *pctx, unsigned first,
|
||||
static_assert(sizeof(addr) == 8, "size out of sync");
|
||||
|
||||
memcpy(&addr, handles[i], sizeof(addr));
|
||||
addr += rsrc->image.data.bo->ptr.gpu;
|
||||
addr += rsrc->image.data.base;
|
||||
|
||||
memcpy(handles[i], &addr, sizeof(addr));
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ panfrost_get_index_buffer(struct panfrost_batch *batch,
|
||||
if (!info->has_user_indices) {
|
||||
/* Only resources can be directly mapped */
|
||||
panfrost_batch_read_rsrc(batch, rsrc, PIPE_SHADER_VERTEX);
|
||||
return rsrc->image.data.bo->ptr.gpu + offset;
|
||||
return rsrc->image.data.base + offset;
|
||||
} else {
|
||||
/* Otherwise, we need to upload to transient memory */
|
||||
const uint8_t *ibuf8 = (const uint8_t *)info->index.user;
|
||||
|
@@ -338,7 +338,7 @@ GENX(jm_launch_grid)(struct panfrost_batch *batch,
|
||||
struct panfrost_device *dev = pan_device(batch->ctx->base.screen);
|
||||
struct pan_indirect_dispatch_info indirect = {
|
||||
.job = t.gpu,
|
||||
.indirect_dim = pan_resource(info->indirect)->image.data.bo->ptr.gpu +
|
||||
.indirect_dim = pan_resource(info->indirect)->image.data.base +
|
||||
info->indirect_offset,
|
||||
.num_wg_sysval =
|
||||
{
|
||||
@@ -485,7 +485,7 @@ jm_emit_tiler_draw(void *out, struct panfrost_batch *batch, bool fs_required,
|
||||
|
||||
struct panfrost_resource *rsrc =
|
||||
pan_resource(ctx->occlusion_query->rsrc);
|
||||
cfg.occlusion = rsrc->image.data.bo->ptr.gpu;
|
||||
cfg.occlusion = rsrc->image.data.base;
|
||||
panfrost_batch_write_rsrc(ctx->batch, rsrc, PIPE_SHADER_FRAGMENT);
|
||||
}
|
||||
|
||||
|
@@ -300,7 +300,7 @@ panfrost_batch_uses_resource(struct panfrost_batch *batch,
|
||||
struct panfrost_resource *rsrc)
|
||||
{
|
||||
/* A resource is used iff its current BO is used */
|
||||
uint32_t handle = panfrost_bo_handle(rsrc->image.data.bo);
|
||||
uint32_t handle = panfrost_bo_handle(rsrc->bo);
|
||||
unsigned size = util_dynarray_num_elements(&batch->bos, pan_bo_access);
|
||||
|
||||
/* If out of bounds, certainly not used */
|
||||
@@ -364,11 +364,10 @@ panfrost_batch_read_rsrc(struct panfrost_batch *batch,
|
||||
{
|
||||
uint32_t access = PAN_BO_ACCESS_READ | panfrost_access_for_stage(stage);
|
||||
|
||||
panfrost_batch_add_bo_old(batch, rsrc->image.data.bo, access);
|
||||
panfrost_batch_add_bo_old(batch, rsrc->bo, access);
|
||||
|
||||
if (rsrc->separate_stencil)
|
||||
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->image.data.bo,
|
||||
access);
|
||||
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->bo, access);
|
||||
|
||||
panfrost_batch_update_access(batch, rsrc, false);
|
||||
}
|
||||
@@ -380,11 +379,10 @@ panfrost_batch_write_rsrc(struct panfrost_batch *batch,
|
||||
{
|
||||
uint32_t access = PAN_BO_ACCESS_WRITE | panfrost_access_for_stage(stage);
|
||||
|
||||
panfrost_batch_add_bo_old(batch, rsrc->image.data.bo, access);
|
||||
panfrost_batch_add_bo_old(batch, rsrc->bo, access);
|
||||
|
||||
if (rsrc->separate_stencil)
|
||||
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->image.data.bo,
|
||||
access);
|
||||
panfrost_batch_add_bo_old(batch, rsrc->separate_stencil->bo, access);
|
||||
|
||||
panfrost_batch_update_access(batch, rsrc, true);
|
||||
}
|
||||
|
@@ -143,15 +143,16 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rsc->image.data.bo = panfrost_bo_import(dev, whandle->handle);
|
||||
rsc->bo = panfrost_bo_import(dev, whandle->handle);
|
||||
/* Sometimes an import can fail e.g. on an invalid buffer fd, out of
|
||||
* memory space to mmap it etc.
|
||||
*/
|
||||
if (!rsc->image.data.bo) {
|
||||
if (!rsc->bo) {
|
||||
FREE(rsc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rsc->image.data.base = rsc->bo->ptr.gpu;
|
||||
rsc->modifier_constant = true;
|
||||
|
||||
BITSET_SET(rsc->valid.data, 0);
|
||||
@@ -194,9 +195,9 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
|
||||
if (handle->type == WINSYS_HANDLE_TYPE_KMS && dev->ro) {
|
||||
return renderonly_get_handle(scanout, handle);
|
||||
} else if (handle->type == WINSYS_HANDLE_TYPE_KMS) {
|
||||
handle->handle = panfrost_bo_handle(rsrc->image.data.bo);
|
||||
handle->handle = panfrost_bo_handle(rsrc->bo);
|
||||
} else if (handle->type == WINSYS_HANDLE_TYPE_FD) {
|
||||
int fd = panfrost_bo_export(rsrc->image.data.bo);
|
||||
int fd = panfrost_bo_export(rsrc->bo);
|
||||
|
||||
if (fd < 0)
|
||||
return false;
|
||||
@@ -512,7 +513,7 @@ panfrost_resource_setup(struct panfrost_device *dev,
|
||||
static void
|
||||
panfrost_resource_init_afbc_headers(struct panfrost_resource *pres)
|
||||
{
|
||||
panfrost_bo_mmap(pres->image.data.bo);
|
||||
panfrost_bo_mmap(pres->bo);
|
||||
|
||||
unsigned nr_samples = MAX2(pres->base.nr_samples, 1);
|
||||
|
||||
@@ -521,7 +522,7 @@ panfrost_resource_init_afbc_headers(struct panfrost_resource *pres)
|
||||
struct pan_image_slice_layout *slice = &pres->image.layout.slices[l];
|
||||
|
||||
for (unsigned s = 0; s < nr_samples; ++s) {
|
||||
void *ptr = pres->image.data.bo->ptr.cpu +
|
||||
void *ptr = pres->bo->ptr.cpu +
|
||||
(i * pres->image.layout.array_stride) + slice->offset +
|
||||
(s * slice->afbc.surface_stride);
|
||||
|
||||
@@ -728,10 +729,11 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen,
|
||||
return NULL;
|
||||
}
|
||||
assert(handle.type == WINSYS_HANDLE_TYPE_FD);
|
||||
so->image.data.bo = panfrost_bo_import(dev, handle.handle);
|
||||
so->bo = panfrost_bo_import(dev, handle.handle);
|
||||
so->image.data.base = so->bo->ptr.gpu;
|
||||
close(handle.handle);
|
||||
|
||||
if (!so->image.data.bo) {
|
||||
if (!so->bo) {
|
||||
free(so);
|
||||
return NULL;
|
||||
}
|
||||
@@ -744,8 +746,9 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen,
|
||||
if (template->bind & PIPE_BIND_SHARED)
|
||||
flags |= PAN_BO_SHAREABLE;
|
||||
|
||||
so->image.data.bo =
|
||||
so->bo =
|
||||
panfrost_bo_create(dev, so->image.layout.data_size, flags, label);
|
||||
so->image.data.base = so->bo->ptr.gpu;
|
||||
|
||||
so->constant_stencil = true;
|
||||
}
|
||||
@@ -800,8 +803,8 @@ panfrost_resource_destroy(struct pipe_screen *screen, struct pipe_resource *pt)
|
||||
if (rsrc->scanout)
|
||||
renderonly_scanout_destroy(rsrc->scanout, dev->ro);
|
||||
|
||||
if (rsrc->image.data.bo)
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
if (rsrc->bo)
|
||||
panfrost_bo_unreference(rsrc->bo);
|
||||
|
||||
free(rsrc->index_cache);
|
||||
free(rsrc->damage.tile_map.data);
|
||||
@@ -901,7 +904,7 @@ panfrost_load_tiled_images(struct panfrost_transfer *transfer,
|
||||
if (!BITSET_TEST(rsrc->valid.data, level))
|
||||
return;
|
||||
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
struct panfrost_bo *bo = rsrc->bo;
|
||||
unsigned stride = panfrost_get_layer_stride(&rsrc->image.layout, level);
|
||||
|
||||
/* Otherwise, load each layer separately, required to load from 3D and
|
||||
@@ -957,9 +960,9 @@ get_superblock_size(uint32_t *hdr, unsigned uncompressed_size)
|
||||
static void
|
||||
dump_block(struct panfrost_resource *rsrc, uint32_t idx)
|
||||
{
|
||||
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
|
||||
panfrost_bo_wait(rsrc->bo, INT64_MAX, false);
|
||||
|
||||
uint8_t *ptr = rsrc->image.data.bo->ptr.cpu;
|
||||
uint8_t *ptr = rsrc->bo->ptr.cpu;
|
||||
uint32_t *header = (uint32_t *)(ptr + (idx * AFBC_HEADER_BYTES_PER_TILE));
|
||||
uint32_t body_base_ptr = header[0];
|
||||
uint32_t *body = (uint32_t *)(ptr + body_base_ptr);
|
||||
@@ -1017,8 +1020,8 @@ pan_dump_resource(struct panfrost_context *ctx, struct panfrost_resource *rsc)
|
||||
}
|
||||
|
||||
panfrost_flush_writer(ctx, linear, "dump image");
|
||||
panfrost_bo_wait(linear->image.data.bo, INT64_MAX, false);
|
||||
panfrost_bo_mmap(linear->image.data.bo);
|
||||
panfrost_bo_wait(linear->bo, INT64_MAX, false);
|
||||
panfrost_bo_mmap(linear->bo);
|
||||
|
||||
static unsigned frame_count = 0;
|
||||
frame_count++;
|
||||
@@ -1027,7 +1030,7 @@ pan_dump_resource(struct panfrost_context *ctx, struct panfrost_resource *rsc)
|
||||
debug_dump_image(buffer, rsc->base.format, 0 /* UNUSED */, rsc->base.width0,
|
||||
rsc->base.height0,
|
||||
linear->image.layout.slices[0].row_stride,
|
||||
linear->image.data.bo->ptr.cpu);
|
||||
linear->bo->ptr.cpu);
|
||||
|
||||
if (plinear)
|
||||
pipe_resource_reference(&plinear, NULL);
|
||||
@@ -1049,7 +1052,7 @@ static void
|
||||
panfrost_store_tiled_images(struct panfrost_transfer *transfer,
|
||||
struct panfrost_resource *rsrc)
|
||||
{
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
struct panfrost_bo *bo = rsrc->bo;
|
||||
struct pipe_transfer *ptrans = &transfer->base;
|
||||
unsigned level = ptrans->level;
|
||||
unsigned stride = panfrost_get_layer_stride(&rsrc->image.layout, level);
|
||||
@@ -1090,7 +1093,7 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
struct panfrost_resource *rsrc = pan_resource(resource);
|
||||
enum pipe_format format = rsrc->image.layout.format;
|
||||
int bytes_per_block = util_format_get_blocksize(format);
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
struct panfrost_bo *bo = rsrc->bo;
|
||||
|
||||
/* Can't map tiled/compressed directly */
|
||||
if ((usage & PIPE_MAP_DIRECTLY) &&
|
||||
@@ -1136,11 +1139,11 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
(valid || panfrost_any_batch_writes_rsrc(ctx, rsrc))) {
|
||||
pan_blit_to_staging(pctx, transfer);
|
||||
panfrost_flush_writer(ctx, staging, "AFBC read staging blit");
|
||||
panfrost_bo_wait(staging->image.data.bo, INT64_MAX, false);
|
||||
panfrost_bo_wait(staging->bo, INT64_MAX, false);
|
||||
}
|
||||
|
||||
panfrost_bo_mmap(staging->image.data.bo);
|
||||
return staging->image.data.bo->ptr.cpu;
|
||||
panfrost_bo_mmap(staging->bo);
|
||||
return staging->bo->ptr.cpu;
|
||||
}
|
||||
|
||||
/* If we haven't already mmaped, now's the time */
|
||||
@@ -1165,7 +1168,7 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
if ((usage & PIPE_MAP_DISCARD_RANGE) && !(usage & PIPE_MAP_UNSYNCHRONIZED) &&
|
||||
!(resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) &&
|
||||
panfrost_box_covers_resource(resource, box) &&
|
||||
!(rsrc->image.data.bo->flags & PAN_BO_SHARED)) {
|
||||
!(rsrc->bo->flags & PAN_BO_SHARED)) {
|
||||
|
||||
usage |= PIPE_MAP_DISCARD_WHOLE_RESOURCE;
|
||||
}
|
||||
@@ -1222,16 +1225,16 @@ panfrost_ptr_map(struct pipe_context *pctx, struct pipe_resource *resource,
|
||||
|
||||
if (newbo) {
|
||||
if (copy_resource) {
|
||||
memcpy(newbo->ptr.cpu, rsrc->image.data.bo->ptr.cpu,
|
||||
panfrost_bo_size(bo));
|
||||
memcpy(newbo->ptr.cpu, rsrc->bo->ptr.cpu, panfrost_bo_size(bo));
|
||||
}
|
||||
|
||||
/* Swap the pointers, dropping a reference to
|
||||
* the old BO which is no long referenced from
|
||||
* the resource.
|
||||
*/
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
rsrc->image.data.bo = newbo;
|
||||
panfrost_bo_unreference(rsrc->bo);
|
||||
rsrc->bo = newbo;
|
||||
rsrc->image.data.base = newbo->ptr.gpu;
|
||||
|
||||
if (!copy_resource && drm_is_afbc(rsrc->image.layout.modifier))
|
||||
panfrost_resource_init_afbc_headers(rsrc);
|
||||
@@ -1336,11 +1339,9 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
if (BITSET_TEST(rsrc->valid.data, i)) {
|
||||
blit.dst.level = blit.src.level = i;
|
||||
|
||||
u_box_3d(0, 0, 0,
|
||||
u_minify(rsrc->base.width0, i),
|
||||
u_box_3d(0, 0, 0, u_minify(rsrc->base.width0, i),
|
||||
u_minify(rsrc->base.height0, i),
|
||||
util_num_layers(&rsrc->base, i),
|
||||
&blit.dst.box);
|
||||
util_num_layers(&rsrc->base, i), &blit.dst.box);
|
||||
blit.src.box = blit.dst.box;
|
||||
|
||||
panfrost_blit_no_afbc_legalization(&ctx->base, &blit);
|
||||
@@ -1352,10 +1353,11 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
*/
|
||||
panfrost_flush_writer(ctx, tmp_rsrc, "AFBC decompressing blit");
|
||||
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
panfrost_bo_unreference(rsrc->bo);
|
||||
|
||||
rsrc->image.data.bo = tmp_rsrc->image.data.bo;
|
||||
panfrost_bo_reference(rsrc->image.data.bo);
|
||||
rsrc->bo = tmp_rsrc->bo;
|
||||
rsrc->image.data.base = rsrc->bo->ptr.gpu;
|
||||
panfrost_bo_reference(rsrc->bo);
|
||||
|
||||
panfrost_resource_setup(pan_device(ctx->base.screen), rsrc, modifier,
|
||||
blit.dst.format);
|
||||
@@ -1537,7 +1539,7 @@ panfrost_pack_afbc(struct panfrost_context *ctx,
|
||||
}
|
||||
|
||||
unsigned new_size = ALIGN_POT(total_size, 4096); // FIXME
|
||||
unsigned old_size = panfrost_bo_size(prsrc->image.data.bo);
|
||||
unsigned old_size = panfrost_bo_size(prsrc->bo);
|
||||
unsigned ratio = 100 * new_size / old_size;
|
||||
|
||||
if (ratio > screen->max_afbc_packing_ratio)
|
||||
@@ -1561,8 +1563,9 @@ panfrost_pack_afbc(struct panfrost_context *ctx,
|
||||
panfrost_flush_batches_accessing_rsrc(ctx, prsrc, "AFBC compaction flush");
|
||||
|
||||
prsrc->image.layout.modifier = dst_modifier;
|
||||
panfrost_bo_unreference(prsrc->image.data.bo);
|
||||
prsrc->image.data.bo = dst;
|
||||
panfrost_bo_unreference(prsrc->bo);
|
||||
prsrc->bo = dst;
|
||||
prsrc->image.data.base = dst->ptr.gpu;
|
||||
panfrost_bo_unreference(metadata_bo);
|
||||
}
|
||||
|
||||
@@ -1589,14 +1592,14 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer)
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
if (panfrost_should_linear_convert(dev, prsrc, transfer)) {
|
||||
|
||||
panfrost_bo_unreference(prsrc->image.data.bo);
|
||||
panfrost_bo_unreference(prsrc->bo);
|
||||
|
||||
panfrost_resource_setup(dev, prsrc, DRM_FORMAT_MOD_LINEAR,
|
||||
prsrc->image.layout.format);
|
||||
|
||||
prsrc->image.data.bo =
|
||||
pan_resource(trans->staging.rsrc)->image.data.bo;
|
||||
panfrost_bo_reference(prsrc->image.data.bo);
|
||||
prsrc->bo = pan_resource(trans->staging.rsrc)->bo;
|
||||
prsrc->image.data.base = prsrc->bo->ptr.gpu;
|
||||
panfrost_bo_reference(prsrc->bo);
|
||||
} else {
|
||||
pan_blit_from_staging(pctx, trans);
|
||||
panfrost_flush_batches_accessing_rsrc(
|
||||
@@ -1615,7 +1618,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer)
|
||||
|
||||
/* Tiling will occur in software from a staging cpu buffer */
|
||||
if (trans->map) {
|
||||
struct panfrost_bo *bo = prsrc->image.data.bo;
|
||||
struct panfrost_bo *bo = prsrc->bo;
|
||||
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
BITSET_SET(prsrc->valid.data, transfer->level);
|
||||
@@ -1628,8 +1631,9 @@ panfrost_ptr_unmap(struct pipe_context *pctx, struct pipe_transfer *transfer)
|
||||
if (prsrc->image.layout.data_size > panfrost_bo_size(bo)) {
|
||||
const char *label = bo->label;
|
||||
panfrost_bo_unreference(bo);
|
||||
bo = prsrc->image.data.bo = panfrost_bo_create(
|
||||
bo = prsrc->bo = panfrost_bo_create(
|
||||
dev, prsrc->image.layout.data_size, 0, label);
|
||||
prsrc->image.data.base = prsrc->bo->ptr.gpu;
|
||||
assert(bo);
|
||||
}
|
||||
|
||||
@@ -1728,7 +1732,7 @@ panfrost_generate_mipmap(struct pipe_context *pctx, struct pipe_resource *prsrc,
|
||||
* explicit so we don't try to wallpaper them back and end up with
|
||||
* u_blitter recursion */
|
||||
|
||||
assert(rsrc->image.data.bo);
|
||||
assert(rsrc->bo);
|
||||
for (unsigned l = base_level + 1; l <= last_level; ++l)
|
||||
BITSET_CLEAR(rsrc->valid.data, l);
|
||||
|
||||
|
@@ -58,6 +58,8 @@ struct panfrost_resource {
|
||||
/* Description of the resource layout */
|
||||
struct pan_image image;
|
||||
|
||||
struct panfrost_bo *bo;
|
||||
|
||||
struct {
|
||||
/* Is the checksum for this image valid? Implicitly refers to
|
||||
* the first slice; we only checksum non-mipmapped 2D images */
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "genxml/gen_macros.h"
|
||||
|
||||
#include "pan_bo.h"
|
||||
#include "pan_desc.h"
|
||||
#include "pan_encoder.h"
|
||||
#include "pan_texture.h"
|
||||
@@ -279,7 +280,7 @@ pan_prepare_crc(const struct pan_fb_info *fb, int rt_crc,
|
||||
&image->layout.slices[rt->first_level];
|
||||
|
||||
ext->crc_base =
|
||||
image->data.bo->ptr.gpu + image->data.offset + slice->crc.offset;
|
||||
image->data.base + image->data.offset + slice->crc.offset;
|
||||
ext->crc_row_stride = slice->crc.stride;
|
||||
|
||||
#if PAN_ARCH >= 7
|
||||
@@ -886,7 +887,7 @@ GENX(pan_emit_fbd)(const struct pan_fb_info *fb, const struct pan_tls_info *tls,
|
||||
|
||||
cfg.crc_buffer.row_stride = slice->crc.stride;
|
||||
cfg.crc_buffer.base =
|
||||
image->data.bo->ptr.gpu + image->data.offset + slice->crc.offset;
|
||||
image->data.base + image->data.offset + slice->crc.offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/macros.h"
|
||||
#include "util/u_math.h"
|
||||
#include "pan_texture.h"
|
||||
@@ -488,7 +489,7 @@ pan_iview_get_surface(const struct pan_image_view *iview, unsigned level,
|
||||
|
||||
bool is_3d = image->layout.dim == MALI_TEXTURE_DIMENSION_3D;
|
||||
const struct pan_image_slice_layout *slice = &image->layout.slices[level];
|
||||
mali_ptr base = image->data.bo->ptr.gpu + image->data.offset;
|
||||
mali_ptr base = image->data.base + image->data.offset;
|
||||
|
||||
if (drm_is_afbc(image->layout.modifier)) {
|
||||
assert(!sample);
|
||||
|
@@ -544,7 +544,7 @@ panfrost_emit_surface(const struct pan_image_view *iview, unsigned level,
|
||||
break;
|
||||
}
|
||||
|
||||
mali_ptr base = base_image->data.bo->ptr.gpu + base_image->data.offset;
|
||||
mali_ptr base = base_image->data.base + base_image->data.offset;
|
||||
|
||||
if (iview->buf.size) {
|
||||
assert(iview->dim == MALI_TEXTURE_DIMENSION_1D);
|
||||
|
@@ -35,8 +35,8 @@
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
#include "genxml/gen_macros.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "pan_bo.h"
|
||||
#include "pan_format.h"
|
||||
#include "pan_pool.h"
|
||||
#include "pan_util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -115,7 +115,7 @@ struct pan_image_layout {
|
||||
};
|
||||
|
||||
struct pan_image_mem {
|
||||
struct panfrost_bo *bo;
|
||||
mali_ptr base;
|
||||
unsigned offset;
|
||||
};
|
||||
|
||||
|
@@ -1225,12 +1225,12 @@ panvk_BindImageMemory2(VkDevice device, uint32_t bindInfoCount,
|
||||
VK_FROM_HANDLE(panvk_device_memory, mem, pBindInfos[i].memory);
|
||||
|
||||
if (mem) {
|
||||
image->pimage.data.bo = mem->bo;
|
||||
image->bo = mem->bo;
|
||||
image->pimage.data.base = mem->bo->ptr.gpu;
|
||||
image->pimage.data.offset = pBindInfos[i].memoryOffset;
|
||||
/* Reset the AFBC headers */
|
||||
if (drm_is_afbc(image->pimage.layout.modifier)) {
|
||||
void *base =
|
||||
image->pimage.data.bo->ptr.cpu + image->pimage.data.offset;
|
||||
void *base = image->bo->ptr.cpu + image->pimage.data.offset;
|
||||
|
||||
for (unsigned layer = 0; layer < image->pimage.layout.array_size;
|
||||
layer++) {
|
||||
@@ -1245,7 +1245,7 @@ panvk_BindImageMemory2(VkDevice device, uint32_t bindInfoCount,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
image->pimage.data.bo = NULL;
|
||||
image->bo = NULL;
|
||||
image->pimage.data.offset = pBindInfos[i].memoryOffset;
|
||||
}
|
||||
}
|
||||
|
@@ -896,6 +896,7 @@ struct panvk_pipeline {
|
||||
|
||||
struct panvk_image {
|
||||
struct vk_image vk;
|
||||
struct panfrost_bo *bo;
|
||||
|
||||
struct pan_image pimage;
|
||||
};
|
||||
|
@@ -251,9 +251,12 @@ panvk_per_arch(queue_submit)(struct vk_queue *vk_queue,
|
||||
|
||||
if (batch->fb.info) {
|
||||
for (unsigned i = 0; i < batch->fb.info->attachment_count; i++) {
|
||||
const struct pan_image *image = pan_image_view_get_plane(
|
||||
&batch->fb.info->attachments[i].iview->pview, 0);
|
||||
bos[bo_idx++] = panfrost_bo_handle(image->data.bo);
|
||||
struct panvk_image_view *iview =
|
||||
batch->fb.info->attachments[i].iview;
|
||||
struct panvk_image *img =
|
||||
container_of(iview->vk.image, struct panvk_image, vk);
|
||||
|
||||
bos[bo_idx++] = panfrost_bo_handle(img->bo);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -141,9 +141,9 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
|
||||
cfg.type = image->pimage.layout.modifier == DRM_FORMAT_MOD_LINEAR
|
||||
? MALI_ATTRIBUTE_TYPE_3D_LINEAR
|
||||
: MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED;
|
||||
cfg.pointer = image->pimage.data.bo->ptr.gpu + offset;
|
||||
cfg.pointer = image->pimage.data.base + offset;
|
||||
cfg.stride = util_format_get_blocksize(view->pview.format);
|
||||
cfg.size = panfrost_bo_size(image->pimage.data.bo) - offset;
|
||||
cfg.size = panfrost_bo_size(image->bo) - offset;
|
||||
}
|
||||
|
||||
attrib_buf += pan_size(ATTRIBUTE_BUFFER);
|
||||
|
@@ -29,7 +29,9 @@
|
||||
|
||||
static void
|
||||
panvk_meta_blit(struct panvk_cmd_buffer *cmdbuf,
|
||||
const struct pan_blit_info *blitinfo)
|
||||
const struct pan_blit_info *blitinfo,
|
||||
const struct panvk_image *src_img,
|
||||
const struct panvk_image *dst_img)
|
||||
{
|
||||
struct panfrost_device *pdev = &cmdbuf->device->physical_device->pdev;
|
||||
struct pan_fb_info *fbinfo = &cmdbuf->state.fb.info;
|
||||
@@ -122,8 +124,8 @@ panvk_meta_blit(struct panvk_cmd_buffer *cmdbuf,
|
||||
|
||||
views[0].first_layer = views[0].last_layer = ctx.dst.cur_layer;
|
||||
views[1].first_layer = views[1].last_layer = views[0].first_layer;
|
||||
batch->blit.src = blitinfo->src.planes[0].image->data.bo;
|
||||
batch->blit.dst = blitinfo->dst.planes[0].image->data.bo;
|
||||
batch->blit.src = src_img->bo;
|
||||
batch->blit.dst = dst_img->bo;
|
||||
panvk_per_arch(cmd_alloc_tls_desc)(cmdbuf, true);
|
||||
panvk_per_arch(cmd_alloc_fb_desc)(cmdbuf);
|
||||
panvk_per_arch(cmd_prepare_tiler_context)(cmdbuf);
|
||||
@@ -208,7 +210,7 @@ panvk_per_arch(CmdBlitImage2)(VkCommandBuffer commandBuffer,
|
||||
info.dst.planes[0].format =
|
||||
util_format_get_depth_only(info.dst.planes[0].format);
|
||||
|
||||
panvk_meta_blit(cmdbuf, &info);
|
||||
panvk_meta_blit(cmdbuf, &info, src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -672,8 +672,8 @@ panvk_meta_copy_img2img(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_batch *batch = panvk_cmd_open_batch(cmdbuf);
|
||||
|
||||
dstview.first_layer = dstview.last_layer = l + first_dst_layer;
|
||||
batch->blit.src = src->pimage.data.bo;
|
||||
batch->blit.dst = dst->pimage.data.bo;
|
||||
batch->blit.src = src->bo;
|
||||
batch->blit.dst = dst->bo;
|
||||
panvk_per_arch(cmd_alloc_tls_desc)(cmdbuf, true);
|
||||
panvk_per_arch(cmd_alloc_fb_desc)(cmdbuf);
|
||||
panvk_per_arch(cmd_prepare_tiler_context)(cmdbuf);
|
||||
@@ -1110,7 +1110,7 @@ panvk_meta_copy_buf2img(struct panvk_cmd_buffer *cmdbuf,
|
||||
|
||||
view.first_layer = view.last_layer = l + first_layer;
|
||||
batch->blit.src = buf->bo;
|
||||
batch->blit.dst = img->pimage.data.bo;
|
||||
batch->blit.dst = img->bo;
|
||||
panvk_per_arch(cmd_alloc_tls_desc)(cmdbuf, true);
|
||||
panvk_per_arch(cmd_alloc_fb_desc)(cmdbuf);
|
||||
panvk_per_arch(cmd_prepare_tiler_context)(cmdbuf);
|
||||
@@ -1528,7 +1528,7 @@ panvk_meta_copy_img2buf(struct panvk_cmd_buffer *cmdbuf,
|
||||
|
||||
struct pan_tls_info tlsinfo = {0};
|
||||
|
||||
batch->blit.src = img->pimage.data.bo;
|
||||
batch->blit.src = img->bo;
|
||||
batch->blit.dst = buf->bo;
|
||||
batch->tls = pan_pool_alloc_desc(&cmdbuf->desc_pool.base, LOCAL_STORAGE);
|
||||
GENX(pan_emit_tls)(&tlsinfo, batch->tls.cpu);
|
||||
|
Reference in New Issue
Block a user