From: Boris Brezillon Date: Thu, 5 Mar 2020 18:40:15 +0000 (+0100) Subject: panfrost: Prepare attribute for builtins at state creation time X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a2ee61a22f5b408a4ac5377b735df3d9d312f50;p=mesa.git 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 Reviewed-by: Alyssa Rosenzweig Part-of: --- 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];