mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
panfrost: Avoid reading GPU memory when packing vertices
These occurred unintentionally as a byproduct of bitfields, etc. Whoops. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3838>
This commit is contained in:
parent
4c52e16c9c
commit
027944c7c8
1 changed files with 18 additions and 17 deletions
|
|
@ -359,15 +359,6 @@ panfrost_default_shader_backend(struct panfrost_context *ctx)
|
||||||
memcpy(&ctx->fragment_shader_core, &shader, sizeof(shader));
|
memcpy(&ctx->fragment_shader_core, &shader, sizeof(shader));
|
||||||
}
|
}
|
||||||
|
|
||||||
mali_ptr
|
|
||||||
panfrost_vertex_buffer_address(struct panfrost_context *ctx, unsigned i)
|
|
||||||
{
|
|
||||||
struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[i];
|
|
||||||
struct panfrost_resource *rsrc = (struct panfrost_resource *) (buf->buffer.resource);
|
|
||||||
|
|
||||||
return rsrc->bo->gpu + buf->buffer_offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
panfrost_writes_point_size(struct panfrost_context *ctx)
|
panfrost_writes_point_size(struct panfrost_context *ctx)
|
||||||
{
|
{
|
||||||
|
|
@ -419,25 +410,35 @@ panfrost_stage_attributes(struct panfrost_context *ctx)
|
||||||
for (unsigned i = 0; i < so->num_elements; ++i) {
|
for (unsigned i = 0; i < so->num_elements; ++i) {
|
||||||
unsigned vbi = so->pipe[i].vertex_buffer_index;
|
unsigned vbi = so->pipe[i].vertex_buffer_index;
|
||||||
struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
|
struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
|
||||||
mali_ptr addr = panfrost_vertex_buffer_address(ctx, vbi);
|
struct panfrost_resource *rsrc = (struct panfrost_resource *) (buf->buffer.resource);
|
||||||
|
mali_ptr addr = rsrc->bo->gpu + buf->buffer_offset;
|
||||||
|
|
||||||
/* Adjust by the masked off bits of the offset */
|
/* Adjust by the masked off bits of the offset. Make sure we
|
||||||
target[i].src_offset += (addr & 63);
|
* read src_offset from so->hw (which is not GPU visible)
|
||||||
|
* rather than target (which is) due to caching effects */
|
||||||
|
|
||||||
|
unsigned src_offset = so->hw[i].src_offset;
|
||||||
|
src_offset += (addr & 63);
|
||||||
|
|
||||||
/* Also, somewhat obscurely per-instance data needs to be
|
/* Also, somewhat obscurely per-instance data needs to be
|
||||||
* offset in response to a delayed start in an indexed draw */
|
* offset in response to a delayed start in an indexed draw */
|
||||||
|
|
||||||
if (so->pipe[i].instance_divisor && ctx->instance_count > 1 && start)
|
if (so->pipe[i].instance_divisor && ctx->instance_count > 1 && start)
|
||||||
target[i].src_offset -= buf->stride * start;
|
src_offset -= buf->stride * start;
|
||||||
|
|
||||||
|
target[i].src_offset = src_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's also include vertex builtins */
|
/* Let's also include vertex builtins */
|
||||||
|
|
||||||
target[PAN_VERTEX_ID].format = MALI_R32UI;
|
struct mali_attr_meta builtin = {
|
||||||
target[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1);
|
.format = MALI_R32UI,
|
||||||
|
.swizzle = panfrost_get_default_swizzle(1)
|
||||||
|
};
|
||||||
|
|
||||||
target[PAN_INSTANCE_ID].format = MALI_R32UI;
|
/* See mali_attr_meta specification for the magic number */
|
||||||
target[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1);
|
memcpy(&target[PAN_VERTEX_ID], &builtin, 4);
|
||||||
|
memcpy(&target[PAN_INSTANCE_ID], &builtin, 4);
|
||||||
|
|
||||||
ctx->payloads[PIPE_SHADER_VERTEX].postfix.attribute_meta = transfer.gpu;
|
ctx->payloads[PIPE_SHADER_VERTEX].postfix.attribute_meta = transfer.gpu;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue