mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 05:38:16 +02:00
asahi,ail: fix multi-plane imports
We need to handle plane offsets everywhere. I noticed this broken before but
didn't realize it was a GL driver issue. Fix is easy, wrote this on my sofa
while waking up in the morning.
Fixes gst-launch-1.0 v4l2src ! glimagesink
Note that cheese & snapshot both still hang for some reason due to
libgstpipewire, but the Mesa side should be fine now.
Closes: #14217
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Cc: mesa-stable
(cherry picked from commit aa9f937116)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38268>
This commit is contained in:
parent
55a37838b9
commit
3dab73159b
9 changed files with 37 additions and 30 deletions
|
|
@ -674,7 +674,7 @@
|
|||
"description": "asahi,ail: fix multi-plane imports",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": null,
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ ail_initialize_linear(struct ail_layout *layout)
|
|||
layout->layer_stride_B = align64(
|
||||
(uint64_t)layout->linear_stride_B * layout->height_px, AIL_CACHELINE);
|
||||
|
||||
layout->size_B = layout->layer_stride_B * layout->depth_px;
|
||||
layout->size_B =
|
||||
layout->level_offsets_B[0] + (layout->layer_stride_B * layout->depth_px);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -341,6 +342,7 @@ ail_make_miptree(struct ail_layout *layout)
|
|||
assert(layout->linear_stride_B == 0 && "Invalid nonlinear layout");
|
||||
assert(layout->levels >= 1 && "Invalid dimensions");
|
||||
assert(layout->sample_count_sa >= 1 && "Invalid sample count");
|
||||
assert(layout->level_offsets_B[0] == 0 && "Invalid offset");
|
||||
}
|
||||
|
||||
assert(!(layout->writeable_image && layout->compressed) &&
|
||||
|
|
|
|||
|
|
@ -634,8 +634,8 @@ asahi_add_attachment(struct attachments *att, struct agx_resource *rsrc)
|
|||
assert(att->count < MAX_ATTACHMENTS);
|
||||
|
||||
att->list[att->count++] = (struct drm_asahi_attachment){
|
||||
.size = rsrc->layout.size_B,
|
||||
.pointer = rsrc->bo->va->addr,
|
||||
.size = rsrc->layout.size_B - rsrc->layout.level_offsets_B[0],
|
||||
.pointer = agx_map_gpu(rsrc),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -210,13 +210,13 @@ agx_resource_from_handle(struct pipe_screen *pscreen,
|
|||
|
||||
if (rsc->layout.tiling == AIL_TILING_LINEAR) {
|
||||
rsc->layout.linear_stride_B = whandle->stride;
|
||||
} else if (whandle->stride != ail_get_wsi_stride_B(&rsc->layout, 0)) {
|
||||
rsc->layout.level_offsets_B[0] = whandle->offset;
|
||||
} else if (whandle->stride != ail_get_wsi_stride_B(&rsc->layout, 0) ||
|
||||
whandle->offset != 0) {
|
||||
FREE(rsc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert(whandle->offset == 0);
|
||||
|
||||
ail_make_miptree(&rsc->layout);
|
||||
|
||||
if (prsc->target == PIPE_BUFFER) {
|
||||
|
|
@ -301,7 +301,8 @@ agx_resource_get_param(struct pipe_screen *pscreen, struct pipe_context *pctx,
|
|||
enum pipe_resource_param param, unsigned usage,
|
||||
uint64_t *value)
|
||||
{
|
||||
struct agx_resource *rsrc = (struct agx_resource *)prsc;
|
||||
struct agx_resource *rsrc =
|
||||
(struct agx_resource *)util_resource_at_index(prsc, plane);
|
||||
|
||||
switch (param) {
|
||||
case PIPE_RESOURCE_PARAM_STRIDE:
|
||||
|
|
@ -1292,7 +1293,7 @@ agx_cmdbuf(struct agx_device *dev, struct drm_asahi_cmd_render *c,
|
|||
|
||||
if (zres->layout.compressed) {
|
||||
c->depth.comp_base =
|
||||
agx_map_texture_gpu(zres, 0) + zres->layout.metadata_offset_B +
|
||||
agx_map_gpu(zres) + zres->layout.metadata_offset_B +
|
||||
(first_layer * zres->layout.compression_layer_stride_B) +
|
||||
zres->layout.level_offsets_compressed_B[level];
|
||||
|
||||
|
|
@ -1329,7 +1330,7 @@ agx_cmdbuf(struct agx_device *dev, struct drm_asahi_cmd_render *c,
|
|||
|
||||
if (sres->layout.compressed) {
|
||||
c->stencil.comp_base =
|
||||
agx_map_texture_gpu(sres, 0) + sres->layout.metadata_offset_B +
|
||||
agx_map_gpu(sres) + sres->layout.metadata_offset_B +
|
||||
(first_layer * sres->layout.compression_layer_stride_B) +
|
||||
sres->layout.level_offsets_compressed_B[level];
|
||||
|
||||
|
|
|
|||
|
|
@ -503,7 +503,7 @@ agx_get_query_result_resource_gpu(struct agx_context *ctx,
|
|||
: 0;
|
||||
|
||||
libagx_copy_query_gl(batch, agx_1d(1), AGX_BARRIER_ALL, query->ptr.gpu,
|
||||
rsrc->bo->va->addr + offset, result_type, bool_size);
|
||||
agx_map_gpu(rsrc) + offset, result_type, bool_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -726,7 +726,7 @@ agx_pack_texture(void *out, struct agx_resource *rsrc,
|
|||
|
||||
if (rsrc->layout.compressed) {
|
||||
cfg.acceleration_buffer =
|
||||
agx_map_texture_gpu(rsrc, 0) + rsrc->layout.metadata_offset_B +
|
||||
agx_map_gpu(rsrc) + rsrc->layout.metadata_offset_B +
|
||||
(first_layer * rsrc->layout.compression_layer_stride_B);
|
||||
}
|
||||
|
||||
|
|
@ -1262,7 +1262,7 @@ agx_batch_upload_pbe(struct agx_batch *batch, struct agx_pbe_packed *out,
|
|||
cfg.extended = true;
|
||||
|
||||
cfg.acceleration_buffer =
|
||||
agx_map_texture_gpu(tex, 0) + tex->layout.metadata_offset_B +
|
||||
agx_map_gpu(tex) + tex->layout.metadata_offset_B +
|
||||
(layer * tex->layout.compression_layer_stride_B);
|
||||
}
|
||||
|
||||
|
|
@ -3756,8 +3756,9 @@ agx_index_buffer_rsrc_ptr(struct agx_batch *batch,
|
|||
struct agx_resource *rsrc = agx_resource(info->index.resource);
|
||||
agx_batch_reads(batch, rsrc);
|
||||
|
||||
*extent = ALIGN_POT(rsrc->layout.size_B, 4);
|
||||
return rsrc->bo->va->addr;
|
||||
*extent =
|
||||
ALIGN_POT(rsrc->layout.size_B - rsrc->layout.level_offsets_B[0], 4);
|
||||
return agx_map_gpu(rsrc);
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
|
|
@ -3948,7 +3949,7 @@ agx_batch_geometry_params(struct agx_batch *batch, uint64_t input_index_buffer,
|
|||
params.xfb_size[i] = size;
|
||||
|
||||
if (rsrc) {
|
||||
params.xfb_offs_ptrs[i] = rsrc->bo->va->addr;
|
||||
params.xfb_offs_ptrs[i] = agx_map_gpu(rsrc);
|
||||
agx_batch_writes(batch, rsrc, 0);
|
||||
batch->incoherent_writes = true;
|
||||
}
|
||||
|
|
@ -4054,7 +4055,7 @@ agx_indirect_buffer_ptr(struct agx_batch *batch,
|
|||
|
||||
struct agx_resource *rsrc = agx_resource(indirect->buffer);
|
||||
agx_batch_reads(batch, rsrc);
|
||||
return rsrc->bo->va->addr + indirect->offset;
|
||||
return agx_map_gpu(rsrc) + indirect->offset;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -5388,7 +5389,7 @@ agx_launch_grid(struct pipe_context *pipe, const struct pipe_grid_info *info)
|
|||
if (info->indirect) {
|
||||
struct agx_resource *rsrc = agx_resource(info->indirect);
|
||||
agx_batch_reads(batch, rsrc);
|
||||
indirect = rsrc->bo->va->addr + info->indirect_offset;
|
||||
indirect = agx_map_gpu(rsrc) + info->indirect_offset;
|
||||
}
|
||||
|
||||
/* Increment the pipeline stats query.
|
||||
|
|
@ -5493,7 +5494,7 @@ agx_set_global_binding(struct pipe_context *pipe, unsigned first,
|
|||
struct agx_resource *rsrc = agx_resource(resources[i]);
|
||||
|
||||
memcpy(&addr, handles[i], sizeof(addr));
|
||||
addr += rsrc->bo->va->addr;
|
||||
addr += agx_map_gpu(rsrc);
|
||||
memcpy(handles[i], &addr, sizeof(addr));
|
||||
} else {
|
||||
pipe_resource_reference(res, NULL);
|
||||
|
|
@ -5534,7 +5535,7 @@ agx_decompress_inplace(struct agx_batch *batch, struct pipe_surface *surf,
|
|||
surf->last_layer - surf->first_layer + 1);
|
||||
|
||||
libagx_decompress(batch, grid, AGX_BARRIER_ALL, layout, surf->first_layer,
|
||||
level, agx_map_texture_gpu(rsrc, 0), images.gpu);
|
||||
level, agx_map_gpu(rsrc), images.gpu);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -970,10 +970,16 @@ agx_map_texture_cpu(struct agx_resource *rsrc, unsigned level, unsigned z)
|
|||
ail_get_layer_level_B(&rsrc->layout, z, level);
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
agx_map_gpu(struct agx_resource *rsrc)
|
||||
{
|
||||
return rsrc->bo->va->addr + rsrc->layout.level_offsets_B[0];
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
agx_map_texture_gpu(struct agx_resource *rsrc, unsigned z)
|
||||
{
|
||||
return rsrc->bo->va->addr +
|
||||
return agx_map_gpu(rsrc) +
|
||||
(uint64_t)ail_get_layer_offset_B(&rsrc->layout, z);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ agx_batch_get_so_address(struct agx_batch *batch, unsigned buffer,
|
|||
target->buffer_size);
|
||||
|
||||
*size = target->buffer_size;
|
||||
return rsrc->bo->va->addr + target->buffer_offset;
|
||||
return agx_map_gpu(rsrc) + target->buffer_offset;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -3,12 +3,9 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "asahi/genxml/agx_pack.h"
|
||||
#include "pipe/p_state.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/half_float.h"
|
||||
#include "util/macros.h"
|
||||
#include "agx_abi.h"
|
||||
#include "agx_device.h"
|
||||
#include "agx_state.h"
|
||||
#include "pool.h"
|
||||
|
|
@ -19,8 +16,7 @@ agx_const_buffer_ptr(struct agx_batch *batch, struct pipe_constant_buffer *cb)
|
|||
if (cb->buffer) {
|
||||
struct agx_resource *rsrc = agx_resource(cb->buffer);
|
||||
agx_batch_reads(batch, rsrc);
|
||||
|
||||
return rsrc->bo->va->addr + cb->buffer_offset;
|
||||
return agx_map_gpu(rsrc) + cb->buffer_offset;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -42,8 +38,9 @@ agx_upload_vbos(struct agx_batch *batch)
|
|||
struct agx_resource *rsrc = agx_resource(vb.buffer.resource);
|
||||
agx_batch_reads(batch, rsrc);
|
||||
|
||||
buffers[vbo] = rsrc->bo->va->addr + vb.buffer_offset;
|
||||
buf_sizes[vbo] = rsrc->layout.size_B - vb.buffer_offset;
|
||||
buffers[vbo] = agx_map_gpu(rsrc) + vb.buffer_offset;
|
||||
buf_sizes[vbo] = rsrc->layout.size_B - vb.buffer_offset -
|
||||
rsrc->layout.level_offsets_B[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +141,7 @@ agx_set_ssbo_uniforms(struct agx_batch *batch, mesa_shader_stage stage)
|
|||
agx_batch_reads(batch, rsrc);
|
||||
}
|
||||
|
||||
unif->ssbo_base[cb] = rsrc->bo->va->addr + sb->buffer_offset;
|
||||
unif->ssbo_base[cb] = agx_map_gpu(rsrc) + sb->buffer_offset;
|
||||
unif->ssbo_size[cb] = st->ssbo[cb].buffer_size;
|
||||
} else {
|
||||
/* Invalid, so use the sink */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue