panfrost: Add an offset field so we can attach a sub-buffer to an image
Needed for Vulkan. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10033>
This commit is contained in:
committed by
Marge Bot
parent
8bd70ea6ea
commit
1c7e8a1692
@@ -80,11 +80,11 @@ panfrost_get_index_buffer_bounded(struct panfrost_context *ctx,
|
||||
|
||||
if (!info->has_user_indices) {
|
||||
/* Only resources can be directly mapped */
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED |
|
||||
PAN_BO_ACCESS_READ |
|
||||
PAN_BO_ACCESS_VERTEX_TILER);
|
||||
out = rsrc->image.bo->ptr.gpu + offset;
|
||||
out = rsrc->image.data.bo->ptr.gpu + offset;
|
||||
|
||||
/* Check the cache */
|
||||
needs_indices = !panfrost_minmax_cache_get(rsrc->index_cache,
|
||||
@@ -629,18 +629,19 @@ mali_ptr
|
||||
panfrost_emit_compute_shader_meta(struct panfrost_batch *batch, enum pipe_shader_type stage)
|
||||
{
|
||||
struct panfrost_shader_state *ss = panfrost_get_shader_state(batch->ctx, stage);
|
||||
struct panfrost_resource *rsrc = pan_resource(ss->upload.rsrc);
|
||||
|
||||
panfrost_batch_add_bo(batch, ss->bo,
|
||||
PAN_BO_ACCESS_PRIVATE |
|
||||
PAN_BO_ACCESS_READ |
|
||||
PAN_BO_ACCESS_VERTEX_TILER);
|
||||
|
||||
panfrost_batch_add_bo(batch, pan_resource(ss->upload.rsrc)->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_PRIVATE |
|
||||
PAN_BO_ACCESS_READ |
|
||||
PAN_BO_ACCESS_VERTEX_TILER);
|
||||
|
||||
return pan_resource(ss->upload.rsrc)->image.bo->ptr.gpu + ss->upload.offset;
|
||||
return rsrc->image.data.bo->ptr.gpu + ss->upload.offset;
|
||||
}
|
||||
|
||||
mali_ptr
|
||||
@@ -760,14 +761,14 @@ panfrost_map_constant_buffer_gpu(struct panfrost_batch *batch,
|
||||
struct panfrost_resource *rsrc = pan_resource(cb->buffer);
|
||||
|
||||
if (rsrc) {
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED |
|
||||
PAN_BO_ACCESS_READ |
|
||||
panfrost_bo_access_for_stage(st));
|
||||
|
||||
/* Alignment gauranteed by
|
||||
* PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT */
|
||||
return rsrc->image.bo->ptr.gpu + cb->buffer_offset;
|
||||
return rsrc->image.data.bo->ptr.gpu + cb->buffer_offset;
|
||||
} else if (cb->user_buffer) {
|
||||
return panfrost_pool_upload_aligned(&batch->pool,
|
||||
cb->user_buffer +
|
||||
@@ -892,7 +893,7 @@ panfrost_upload_ssbo_sysval(struct panfrost_batch *batch,
|
||||
struct pipe_shader_buffer sb = ctx->ssbo[st][ssbo_id];
|
||||
|
||||
/* Compute address */
|
||||
struct panfrost_bo *bo = pan_resource(sb.buffer)->image.bo;
|
||||
struct panfrost_bo *bo = pan_resource(sb.buffer)->image.data.bo;
|
||||
|
||||
panfrost_batch_add_bo(batch, bo,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_RW |
|
||||
@@ -1074,11 +1075,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.bo);
|
||||
panfrost_flush_batches_accessing_bo(ctx, rsrc->image.bo, false);
|
||||
panfrost_bo_wait(rsrc->image.bo, INT64_MAX, false);
|
||||
panfrost_bo_mmap(rsrc->image.data.bo);
|
||||
panfrost_flush_batches_accessing_bo(ctx, rsrc->image.data.bo, false);
|
||||
panfrost_bo_wait(rsrc->image.data.bo, INT64_MAX, false);
|
||||
|
||||
return rsrc->image.bo->ptr.cpu + cb->buffer_offset;
|
||||
return rsrc->image.data.bo->ptr.cpu + cb->buffer_offset;
|
||||
} else if (cb->user_buffer) {
|
||||
return cb->user_buffer + cb->buffer_offset;
|
||||
} else
|
||||
@@ -1235,7 +1236,7 @@ panfrost_get_tex_desc(struct panfrost_batch *batch,
|
||||
|
||||
/* Add the BO to the job so it's retained until the job is done. */
|
||||
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ |
|
||||
panfrost_bo_access_for_stage(st));
|
||||
|
||||
@@ -1251,7 +1252,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.bo->ptr.gpu ||
|
||||
if (view->texture_bo != rsrc->image.data.bo->ptr.gpu ||
|
||||
view->modifier != rsrc->image.layout.modifier) {
|
||||
panfrost_bo_unreference(view->bo);
|
||||
panfrost_create_sampler_view_bo(view, pctx, &rsrc->base);
|
||||
@@ -1286,7 +1287,7 @@ panfrost_emit_texture_descriptors(struct panfrost_batch *batch,
|
||||
|
||||
/* Add the BOs to the job so they are retained until the job is done. */
|
||||
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ |
|
||||
panfrost_bo_access_for_stage(stage));
|
||||
|
||||
@@ -1392,16 +1393,16 @@ emit_image_attribs(struct panfrost_batch *batch, enum pipe_shader_type shader,
|
||||
unsigned level = is_buffer ? 0 : image->u.tex.level;
|
||||
rsrc->state.slices[level].data_valid = true;
|
||||
}
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo, flags);
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags);
|
||||
|
||||
pan_pack(bufs + (k * 2), ATTRIBUTE_BUFFER, cfg) {
|
||||
cfg.type = is_linear ?
|
||||
MALI_ATTRIBUTE_TYPE_3D_LINEAR :
|
||||
MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED;
|
||||
|
||||
cfg.pointer = rsrc->image.bo->ptr.gpu + offset;
|
||||
cfg.pointer = rsrc->image.data.bo->ptr.gpu + offset;
|
||||
cfg.stride = util_format_get_blocksize(image->format);
|
||||
cfg.size = rsrc->image.bo->size;
|
||||
cfg.size = rsrc->image.data.bo->size;
|
||||
}
|
||||
|
||||
pan_pack(bufs + (k * 2) + 1, ATTRIBUTE_BUFFER_CONTINUATION_3D, cfg) {
|
||||
@@ -1534,13 +1535,13 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch,
|
||||
continue;
|
||||
|
||||
/* Add a dependency of the batch on the vertex buffer */
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED |
|
||||
PAN_BO_ACCESS_READ |
|
||||
PAN_BO_ACCESS_VERTEX_TILER);
|
||||
|
||||
/* Mask off lower bits, see offset fixup below */
|
||||
mali_ptr raw_addr = rsrc->image.bo->ptr.gpu + buf->buffer_offset;
|
||||
mali_ptr raw_addr = rsrc->image.data.bo->ptr.gpu + buf->buffer_offset;
|
||||
mali_ptr addr = raw_addr & ~63;
|
||||
|
||||
/* Since we advanced the base pointer, we shrink the buffer
|
||||
@@ -1732,7 +1733,7 @@ panfrost_emit_streamout(struct panfrost_batch *batch,
|
||||
unsigned expected_size = stride * count;
|
||||
|
||||
/* Grab the BO and bind it to the batch */
|
||||
struct panfrost_bo *bo = pan_resource(target->buffer)->image.bo;
|
||||
struct panfrost_bo *bo = pan_resource(target->buffer)->image.data.bo;
|
||||
|
||||
/* Varyings are WRITE from the perspective of the VERTEX but READ from
|
||||
* the perspective of the TILER and FRAGMENT.
|
||||
@@ -1744,7 +1745,8 @@ panfrost_emit_streamout(struct panfrost_batch *batch,
|
||||
PAN_BO_ACCESS_FRAGMENT);
|
||||
|
||||
/* We will have an offset applied to get alignment */
|
||||
mali_ptr addr = bo->ptr.gpu + target->buffer_offset + (pan_so_target(target)->offset * stride);
|
||||
mali_ptr addr = bo->ptr.gpu + target->buffer_offset +
|
||||
(pan_so_target(target)->offset * stride);
|
||||
|
||||
pan_pack(slot, ATTRIBUTE_BUFFER, cfg) {
|
||||
cfg.pointer = (addr & ~63);
|
||||
|
||||
@@ -185,11 +185,11 @@ panfrost_set_global_binding(struct pipe_context *pctx,
|
||||
for (unsigned i = first; i < first + count; ++i) {
|
||||
struct panfrost_resource *rsrc = pan_resource(resources[i]);
|
||||
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo,
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_RW);
|
||||
|
||||
/* The handle points to uint32_t, but space is allocated for 64 bits */
|
||||
memcpy(handles[i], &rsrc->image.bo->ptr.gpu, sizeof(mali_ptr));
|
||||
memcpy(handles[i], &rsrc->image.data.bo->ptr.gpu, sizeof(mali_ptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -653,7 +653,7 @@ panfrost_indirect_draw(struct panfrost_context *ctx,
|
||||
|
||||
if (info->index_size) {
|
||||
assert(!info->has_user_indices);
|
||||
index_buf = pan_resource(info->index.resource)->image.bo;
|
||||
index_buf = pan_resource(info->index.resource)->image.data.bo;
|
||||
panfrost_batch_add_bo(batch,
|
||||
index_buf,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ |
|
||||
@@ -707,13 +707,13 @@ panfrost_indirect_draw(struct panfrost_context *ctx,
|
||||
vs->info.attribute_count -
|
||||
util_bitcount(ctx->image_mask[PIPE_SHADER_VERTEX]);
|
||||
|
||||
panfrost_batch_add_bo(batch, draw_buf->image.bo,
|
||||
panfrost_batch_add_bo(batch, draw_buf->image.data.bo,
|
||||
PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_READ |
|
||||
PAN_BO_ACCESS_VERTEX_TILER);
|
||||
|
||||
struct pan_indirect_draw_info draw_info = {
|
||||
.last_indirect_draw = batch->indirect_draw_job_id,
|
||||
.draw_buf = draw_buf->image.bo->ptr.gpu + indirect->offset,
|
||||
.draw_buf = draw_buf->image.data.bo->ptr.gpu + indirect->offset,
|
||||
.index_buf = index_buf ? index_buf->ptr.gpu : 0,
|
||||
.vertex_job = vertex.gpu,
|
||||
.tiler_job = tiler.gpu,
|
||||
@@ -1237,7 +1237,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||
struct panfrost_device *device = pan_device(pctx->screen);
|
||||
struct panfrost_resource *prsrc = (struct panfrost_resource *)texture;
|
||||
enum pipe_format format = so->base.format;
|
||||
assert(prsrc->image.bo);
|
||||
assert(prsrc->image.data.bo);
|
||||
|
||||
/* Format to access the stencil portion of a Z32_S8 texture */
|
||||
if (format == PIPE_FORMAT_X32_S8X24_UINT) {
|
||||
@@ -1259,7 +1259,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||
desc = util_format_description(format);
|
||||
}
|
||||
|
||||
so->texture_bo = prsrc->image.bo->ptr.gpu;
|
||||
so->texture_bo = prsrc->image.data.bo->ptr.gpu;
|
||||
so->modifier = prsrc->image.layout.modifier;
|
||||
|
||||
unsigned char user_swizzle[4] = {
|
||||
@@ -1330,7 +1330,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
|
||||
first_layer, last_layer,
|
||||
texture->nr_samples,
|
||||
user_swizzle,
|
||||
prsrc->image.bo->ptr.gpu + offset,
|
||||
prsrc->image.data.bo->ptr.gpu + offset,
|
||||
&payload);
|
||||
}
|
||||
|
||||
|
||||
@@ -559,13 +559,13 @@ panfrost_batch_add_resource_bos(struct panfrost_batch *batch,
|
||||
struct panfrost_resource *rsrc,
|
||||
uint32_t flags)
|
||||
{
|
||||
panfrost_batch_add_bo(batch, rsrc->image.bo, flags);
|
||||
panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags);
|
||||
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_batch_add_bo(batch, rsrc->checksum_bo, flags);
|
||||
|
||||
if (rsrc->separate_stencil)
|
||||
panfrost_batch_add_bo(batch, rsrc->separate_stencil->image.bo, flags);
|
||||
panfrost_batch_add_bo(batch, rsrc->separate_stencil->image.data.bo, flags);
|
||||
}
|
||||
|
||||
/* Adds the BO backing surface to a batch if the surface is non-null */
|
||||
|
||||
@@ -262,10 +262,12 @@ panfrost_mfbd_zs_crc_ext_set_bufs(struct panfrost_batch *batch,
|
||||
*checksum_slice = &rsrc->state.slices[level];
|
||||
|
||||
ext->crc_row_stride = slice->crc.stride;
|
||||
if (rsrc->checksum_bo)
|
||||
if (rsrc->checksum_bo) {
|
||||
ext->crc_base = rsrc->checksum_bo->ptr.gpu;
|
||||
else
|
||||
ext->crc_base = rsrc->image.bo->ptr.gpu + slice->crc.offset;
|
||||
} else {
|
||||
ext->crc_base = rsrc->image.data.bo->ptr.gpu +
|
||||
slice->crc.offset;
|
||||
}
|
||||
|
||||
if ((batch->clear & PIPE_CLEAR_COLOR0) && dev->arch >= 7) {
|
||||
ext->crc_clear_color = batch->clear_color[0][0] |
|
||||
|
||||
@@ -78,7 +78,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
||||
pipe_reference_init(&prsc->reference, 1);
|
||||
prsc->screen = pscreen;
|
||||
|
||||
rsc->image.bo = panfrost_bo_import(dev, whandle->handle);
|
||||
rsc->image.data.bo = panfrost_bo_import(dev, whandle->handle);
|
||||
rsc->image.layout.format = templat->format;
|
||||
rsc->image.layout.modifier = (whandle->modifier == DRM_FORMAT_MOD_INVALID) ?
|
||||
DRM_FORMAT_MOD_LINEAR : whandle->modifier;
|
||||
@@ -91,7 +91,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen,
|
||||
rsc->image.layout.depth = prsc->depth0;
|
||||
rsc->image.layout.nr_samples = prsc->nr_samples;
|
||||
rsc->image.layout.array_size = prsc->array_size;
|
||||
rsc->image.layout.data_size = rsc->image.bo->size;
|
||||
rsc->image.layout.data_size = rsc->image.data.bo->size;
|
||||
|
||||
if (rsc->image.layout.modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED ||
|
||||
drm_is_afbc(rsc->image.layout.modifier)) {
|
||||
@@ -182,7 +182,7 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
|
||||
if (renderonly_get_handle(scanout, handle))
|
||||
return true;
|
||||
|
||||
handle->handle = rsrc->image.bo->gem_handle;
|
||||
handle->handle = rsrc->image.data.bo->gem_handle;
|
||||
handle->stride = rsrc->image.layout.slices[0].line_stride;
|
||||
handle->offset = rsrc->image.layout.slices[0].offset;
|
||||
return TRUE;
|
||||
@@ -202,7 +202,7 @@ panfrost_resource_get_handle(struct pipe_screen *pscreen,
|
||||
|
||||
return true;
|
||||
} else {
|
||||
int fd = panfrost_bo_export(rsrc->image.bo);
|
||||
int fd = panfrost_bo_export(rsrc->image.data.bo);
|
||||
|
||||
if (fd < 0)
|
||||
return false;
|
||||
@@ -652,7 +652,7 @@ panfrost_resource_setup(struct panfrost_device *dev, struct panfrost_resource *p
|
||||
static void
|
||||
panfrost_resource_init_afbc_headers(struct panfrost_resource *pres)
|
||||
{
|
||||
panfrost_bo_mmap(pres->image.bo);
|
||||
panfrost_bo_mmap(pres->image.data.bo);
|
||||
|
||||
unsigned nr_samples = MAX2(pres->base.nr_samples, 1);
|
||||
|
||||
@@ -661,7 +661,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.bo->ptr.cpu +
|
||||
void *ptr = pres->image.data.bo->ptr.cpu +
|
||||
(i * pres->image.layout.array_stride) +
|
||||
slice->offset +
|
||||
(s * slice->afbc.surface_stride);
|
||||
@@ -749,7 +749,7 @@ panfrost_resource_create_with_modifier(struct pipe_screen *screen,
|
||||
|
||||
/* We create a BO immediately but don't bother mapping, since we don't
|
||||
* care to map e.g. FBOs which the CPU probably won't touch */
|
||||
so->image.bo = panfrost_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
|
||||
so->image.data.bo = panfrost_bo_create(dev, bo_size, PAN_BO_DELAY_MMAP);
|
||||
|
||||
if (drm_is_afbc(so->image.layout.modifier))
|
||||
panfrost_resource_init_afbc_headers(so);
|
||||
@@ -802,8 +802,8 @@ panfrost_resource_destroy(struct pipe_screen *screen,
|
||||
if (rsrc->scanout)
|
||||
renderonly_scanout_destroy(rsrc->scanout, dev->ro);
|
||||
|
||||
if (rsrc->image.bo)
|
||||
panfrost_bo_unreference(rsrc->image.bo);
|
||||
if (rsrc->image.data.bo)
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_bo_unreference(rsrc->checksum_bo);
|
||||
@@ -914,7 +914,7 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||
struct panfrost_device *dev = pan_device(pctx->screen);
|
||||
struct panfrost_resource *rsrc = pan_resource(resource);
|
||||
int bytes_per_pixel = util_format_get_blocksize(rsrc->image.layout.format);
|
||||
struct panfrost_bo *bo = rsrc->image.bo;
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
|
||||
/* Can't map tiled/compressed directly */
|
||||
if ((usage & PIPE_MAP_DIRECTLY) && rsrc->image.layout.modifier != DRM_FORMAT_MOD_LINEAR)
|
||||
@@ -951,16 +951,16 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||
/* TODO: Eliminate this flush. It's only there to determine if
|
||||
* we're initialized or not, when the initialization could come
|
||||
* from a pending batch XXX */
|
||||
panfrost_flush_batches_accessing_bo(ctx, rsrc->image.bo, true);
|
||||
panfrost_flush_batches_accessing_bo(ctx, rsrc->image.data.bo, true);
|
||||
|
||||
if ((usage & PIPE_MAP_READ) && rsrc->state.slices[level].data_valid) {
|
||||
pan_blit_to_staging(pctx, transfer);
|
||||
panfrost_flush_batches_accessing_bo(ctx, staging->image.bo, true);
|
||||
panfrost_bo_wait(staging->image.bo, INT64_MAX, false);
|
||||
panfrost_flush_batches_accessing_bo(ctx, staging->image.data.bo, true);
|
||||
panfrost_bo_wait(staging->image.data.bo, INT64_MAX, false);
|
||||
}
|
||||
|
||||
panfrost_bo_mmap(staging->image.bo);
|
||||
return staging->image.bo->ptr.cpu;
|
||||
panfrost_bo_mmap(staging->image.data.bo);
|
||||
return staging->image.data.bo->ptr.cpu;
|
||||
}
|
||||
|
||||
/* If we haven't already mmaped, now's the time */
|
||||
@@ -1013,10 +1013,10 @@ panfrost_ptr_map(struct pipe_context *pctx,
|
||||
|
||||
if (newbo) {
|
||||
if (copy_resource)
|
||||
memcpy(newbo->ptr.cpu, rsrc->image.bo->ptr.cpu, bo->size);
|
||||
memcpy(newbo->ptr.cpu, rsrc->image.data.bo->ptr.cpu, bo->size);
|
||||
|
||||
panfrost_bo_unreference(bo);
|
||||
rsrc->image.bo = newbo;
|
||||
rsrc->image.data.bo = newbo;
|
||||
|
||||
if (!copy_resource &&
|
||||
drm_is_afbc(rsrc->image.layout.modifier))
|
||||
@@ -1132,12 +1132,12 @@ pan_resource_modifier_convert(struct panfrost_context *ctx,
|
||||
panfrost_blit(&ctx->base, &blit);
|
||||
}
|
||||
|
||||
panfrost_bo_unreference(rsrc->image.bo);
|
||||
panfrost_bo_unreference(rsrc->image.data.bo);
|
||||
if (rsrc->checksum_bo)
|
||||
panfrost_bo_unreference(rsrc->checksum_bo);
|
||||
|
||||
rsrc->image.bo = tmp_rsrc->image.bo;
|
||||
panfrost_bo_reference(rsrc->image.bo);
|
||||
rsrc->image.data.bo = tmp_rsrc->image.data.bo;
|
||||
panfrost_bo_reference(rsrc->image.data.bo);
|
||||
|
||||
panfrost_resource_setup(pan_device(ctx->base.screen), rsrc, NULL, modifier);
|
||||
pipe_resource_reference(&tmp_prsrc, NULL);
|
||||
@@ -1197,17 +1197,17 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
if (panfrost_should_linear_convert(prsrc, transfer)) {
|
||||
|
||||
panfrost_bo_unreference(prsrc->image.bo);
|
||||
panfrost_bo_unreference(prsrc->image.data.bo);
|
||||
if (prsrc->checksum_bo)
|
||||
panfrost_bo_unreference(prsrc->checksum_bo);
|
||||
|
||||
panfrost_resource_setup(dev, prsrc, NULL, DRM_FORMAT_MOD_LINEAR);
|
||||
|
||||
prsrc->image.bo = pan_resource(trans->staging.rsrc)->image.bo;
|
||||
panfrost_bo_reference(prsrc->image.bo);
|
||||
prsrc->image.data.bo = pan_resource(trans->staging.rsrc)->image.data.bo;
|
||||
panfrost_bo_reference(prsrc->image.data.bo);
|
||||
} else {
|
||||
pan_blit_from_staging(pctx, trans);
|
||||
panfrost_flush_batches_accessing_bo(pan_context(pctx), pan_resource(trans->staging.rsrc)->image.bo, true);
|
||||
panfrost_flush_batches_accessing_bo(pan_context(pctx), pan_resource(trans->staging.rsrc)->image.data.bo, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,7 +1216,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
||||
|
||||
/* Tiling will occur in software from a staging cpu buffer */
|
||||
if (trans->map) {
|
||||
struct panfrost_bo *bo = prsrc->image.bo;
|
||||
struct panfrost_bo *bo = prsrc->image.data.bo;
|
||||
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
prsrc->state.slices[transfer->level].data_valid = true;
|
||||
@@ -1230,7 +1230,7 @@ panfrost_ptr_unmap(struct pipe_context *pctx,
|
||||
panfrost_resource_setup(dev, prsrc, &bo_size, DRM_FORMAT_MOD_LINEAR);
|
||||
if (bo_size > bo->size) {
|
||||
panfrost_bo_unreference(bo);
|
||||
bo = prsrc->image.bo = panfrost_bo_create(dev, bo_size, 0);
|
||||
bo = prsrc->image.data.bo = panfrost_bo_create(dev, bo_size, 0);
|
||||
assert(bo);
|
||||
}
|
||||
|
||||
@@ -1318,7 +1318,7 @@ panfrost_generate_mipmap(
|
||||
* explicit so we don't try to wallpaper them back and end up with
|
||||
* u_blitter recursion */
|
||||
|
||||
assert(rsrc->image.bo);
|
||||
assert(rsrc->image.data.bo);
|
||||
for (unsigned l = base_level + 1; l <= last_level; ++l)
|
||||
rsrc->state.slices[l].data_valid = false;
|
||||
|
||||
@@ -1343,7 +1343,7 @@ panfrost_get_texture_address(struct panfrost_resource *rsrc,
|
||||
bool is_3d = rsrc->base.target == PIPE_TEXTURE_3D;
|
||||
unsigned array_idx = is_3d ? 0 : layer;
|
||||
unsigned surface_idx = is_3d ? layer : sample;
|
||||
return rsrc->image.bo->ptr.gpu +
|
||||
return rsrc->image.data.bo->ptr.gpu +
|
||||
panfrost_texture_offset(&rsrc->image.layout, level,
|
||||
array_idx, surface_idx);
|
||||
}
|
||||
@@ -1358,13 +1358,13 @@ panfrost_get_afbc_pointers(struct panfrost_resource *rsrc,
|
||||
struct pan_image_slice_layout *slice = &rsrc->image.layout.slices[level];
|
||||
|
||||
if (rsrc->base.target == PIPE_TEXTURE_3D) {
|
||||
*header = rsrc->image.bo->ptr.gpu + slice->offset +
|
||||
*header = rsrc->image.data.bo->ptr.gpu + slice->offset +
|
||||
(layer * slice->afbc.surface_stride);
|
||||
*body = rsrc->image.bo->ptr.gpu + slice->offset +
|
||||
*body = rsrc->image.data.bo->ptr.gpu + slice->offset +
|
||||
slice->afbc.header_size +
|
||||
(slice->surface_stride * layer);
|
||||
} else {
|
||||
*header = rsrc->image.bo->ptr.gpu +
|
||||
*header = rsrc->image.data.bo->ptr.gpu +
|
||||
panfrost_texture_offset(&rsrc->image.layout,
|
||||
level, layer, 0);
|
||||
*body = *header + slice->afbc.header_size;
|
||||
|
||||
@@ -114,7 +114,8 @@ panfrost_sfbd_set_zsbuf(
|
||||
unsigned level = surf->u.tex.level;
|
||||
assert(surf->u.tex.first_layer == 0);
|
||||
|
||||
fb->zs_writeback.base = rsrc->image.bo->ptr.gpu + rsrc->image.layout.slices[level].offset;
|
||||
fb->zs_writeback.base = rsrc->image.data.bo->ptr.gpu +
|
||||
rsrc->image.layout.slices[level].offset;
|
||||
fb->zs_writeback.row_stride = rsrc->image.layout.slices[level].row_stride;
|
||||
|
||||
if (rsrc->image.layout.modifier == DRM_FORMAT_MOD_LINEAR)
|
||||
@@ -222,7 +223,7 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
|
||||
if (batch->key.nr_cbufs && batch->key.cbufs[0]) {
|
||||
struct pipe_surface *surf = batch->key.cbufs[0];
|
||||
struct panfrost_resource *rsrc = pan_resource(surf->texture);
|
||||
struct panfrost_bo *bo = rsrc->image.bo;
|
||||
struct panfrost_bo *bo = rsrc->image.data.bo;
|
||||
|
||||
panfrost_sfbd_set_cbuf(¶ms, surf);
|
||||
|
||||
|
||||
@@ -343,7 +343,8 @@ midgard_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
|
||||
0, 0,
|
||||
iview->image->layout.nr_samples,
|
||||
swizzle,
|
||||
iview->image->bo->ptr.gpu + offset, &payload);
|
||||
iview->image->data.bo->ptr.gpu + offset,
|
||||
&payload);
|
||||
|
||||
pan_pack(sampler.cpu, MIDGARD_SAMPLER, cfg)
|
||||
cfg.normalized_coordinates = false;
|
||||
@@ -518,7 +519,8 @@ bifrost_load_emit_texture(struct pan_pool *pool, struct MALI_DRAW *draw,
|
||||
0, 0,
|
||||
iview->image->layout.nr_samples,
|
||||
swizzle,
|
||||
iview->image->bo->ptr.gpu + offset, &payload);
|
||||
iview->image->data.bo->ptr.gpu + offset,
|
||||
&payload);
|
||||
|
||||
pan_pack(sampler.cpu, BIFROST_SAMPLER, cfg) {
|
||||
cfg.seamless_cube_map = false;
|
||||
|
||||
@@ -96,8 +96,13 @@ struct pan_image_state {
|
||||
struct pan_image_slice_state slices[MAX_MIP_LEVELS];
|
||||
};
|
||||
|
||||
struct pan_image {
|
||||
struct pan_image_mem {
|
||||
struct panfrost_bo *bo;
|
||||
unsigned offset;
|
||||
};
|
||||
|
||||
struct pan_image {
|
||||
struct pan_image_mem data;
|
||||
struct pan_image_layout layout;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user