mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
asahi,agx: Upload constant buffers immediately
The lifetime of the constant buffer's user_buffer is not guaranteed
to last until agx_upload_uniforms.
Fixes the same ASAN issue mesa/mesa!21685 is trying to address.
Fixes: 080b05e29e ("asahi: Add Gallium driver")
Signed-off-by: Janne Grunau <j@jannau.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>
This commit is contained in:
parent
f4fd4d4d50
commit
d6ee12a4d7
2 changed files with 10 additions and 3 deletions
|
|
@ -39,6 +39,7 @@
|
|||
#include "util/u_prim.h"
|
||||
#include "util/u_resource.h"
|
||||
#include "util/u_transfer.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
#include "agx_device.h"
|
||||
#include "agx_disk_cache.h"
|
||||
#include "agx_tilebuffer.h"
|
||||
|
|
@ -1266,9 +1267,17 @@ agx_set_constant_buffer(struct pipe_context *pctx, enum pipe_shader_type shader,
|
|||
{
|
||||
struct agx_context *ctx = agx_context(pctx);
|
||||
struct agx_stage *s = &ctx->stage[shader];
|
||||
struct pipe_constant_buffer *constants = &s->cb[index];
|
||||
|
||||
util_copy_constant_buffer(&s->cb[index], cb, take_ownership);
|
||||
|
||||
/* Upload user buffer immediately */
|
||||
if (constants->user_buffer && !constants->buffer) {
|
||||
u_upload_data(ctx->base.const_uploader, 0, constants->buffer_size, 64,
|
||||
constants->user_buffer, &constants->buffer_offset,
|
||||
&constants->buffer);
|
||||
}
|
||||
|
||||
unsigned mask = (1 << index);
|
||||
|
||||
if (cb)
|
||||
|
|
|
|||
|
|
@ -15,9 +15,7 @@ agx_const_buffer_ptr(struct agx_batch *batch, struct pipe_constant_buffer *cb)
|
|||
|
||||
return rsrc->bo->ptr.gpu + cb->buffer_offset;
|
||||
} else {
|
||||
return agx_pool_upload_aligned(
|
||||
&batch->pool, ((uint8_t *)cb->user_buffer) + cb->buffer_offset,
|
||||
cb->buffer_size - cb->buffer_offset, 64);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue