diff options
author | Boris Brezillon <[email protected]> | 2020-03-05 19:40:15 +0100 |
---|---|---|
committer | Boris Brezillon <[email protected]> | 2020-03-10 12:47:34 +0100 |
commit | 4a2ee61a22f5b408a4ac5377b735df3d9d312f50 (patch) | |
tree | 24926b1ff0d2c13022eae1ee952fab92505f4462 | |
parent | b692ab076a72be97bea6bc527ea1c2e55c5f4d3c (diff) |
panfrost: Prepare attribute for builtins at state creation time
The attribute meta slots reserved for gl_VertexID and gl_InstanceID
can be pre-filled at state creation time. Only the index needs to be
adjusted when attributes are generated.
Signed-off-by: Boris Brezillon <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4083>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_attributes.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 21 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 1 |
3 files changed, 9 insertions, 18 deletions
diff --git a/src/gallium/drivers/panfrost/pan_attributes.c b/src/gallium/drivers/panfrost/pan_attributes.c index ada95d181c7..31bdd2c16f3 100644 --- a/src/gallium/drivers/panfrost/pan_attributes.c +++ b/src/gallium/drivers/panfrost/pan_attributes.c @@ -118,8 +118,9 @@ panfrost_emit_vertex_data(struct panfrost_batch *batch) /* Add special gl_VertexID/gl_InstanceID buffers */ panfrost_vertex_id(ctx->padded_count, &attrs[k]); - so->vertexid_index = k++; - panfrost_instance_id(ctx->padded_count, &attrs[k++]); + so->hw[PAN_VERTEX_ID].index = k++; + panfrost_instance_id(ctx->padded_count, &attrs[k]); + so->hw[PAN_INSTANCE_ID].index = k++; /* Upload whatever we emitted and go */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index fda7b3fcb3d..4fea5f507b3 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -244,21 +244,6 @@ panfrost_stage_attributes(struct panfrost_context *ctx) target[i].src_offset = src_offset; } - /* Let's also include vertex builtins */ - - struct mali_attr_meta builtin = { - .format = MALI_R32UI, - .swizzle = panfrost_get_default_swizzle(1) - }; - - /* See mali_attr_meta specification for the magic number */ - - builtin.index = so->vertexid_index; - memcpy(&target[PAN_VERTEX_ID], &builtin, 4); - - builtin.index = so->vertexid_index + 1; - memcpy(&target[PAN_INSTANCE_ID], &builtin, 4); - ctx->payloads[PIPE_SHADER_VERTEX].postfix.attribute_meta = transfer.gpu; } @@ -724,6 +709,12 @@ panfrost_create_vertex_elements_state( so->hw[i].format = panfrost_find_format(desc); } + /* Let's also prepare vertex builtins */ + so->hw[PAN_VERTEX_ID].format = MALI_R32UI; + so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1); + so->hw[PAN_INSTANCE_ID].format = MALI_R32UI; + so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1); + return so; } diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index b73883df322..9c26b012493 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -244,7 +244,6 @@ struct panfrost_shader_variants { struct panfrost_vertex_state { unsigned num_elements; - unsigned vertexid_index; struct pipe_vertex_element pipe[PIPE_MAX_ATTRIBS]; struct mali_attr_meta hw[PIPE_MAX_ATTRIBS]; |