We just need the mask of used vertex attribs.
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11370>
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
stvp->num_inputs = 0;
+ stvp->vert_attrib_mask = 0;
memset(stvp->input_to_index, ~0, sizeof(stvp->input_to_index));
memset(stvp->result_to_output, ~0, sizeof(stvp->result_to_output));
for (unsigned attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
if ((stp->Base.info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
stvp->input_to_index[attr] = stvp->num_inputs;
- stvp->index_to_input[stvp->num_inputs] = attr;
+ stvp->vert_attrib_mask |= BITFIELD_BIT(attr);
stvp->num_inputs++;
}
}
+
/* pre-setup potentially unused edgeflag input */
stvp->input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
- stvp->index_to_input[stvp->num_inputs] = VERT_ATTRIB_EDGEFLAG;
/* Compute mapping of vertex program outputs to slots. */
unsigned num_outputs = 0;
if (stp->Base.info.stage == MESA_SHADER_VERTEX) {
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
- unsigned num_inputs = stvp->num_inputs + key->passthrough_edgeflags;
- for (unsigned index = 0; index < num_inputs; ++index) {
- unsigned attr = stvp->index_to_input[index];
- v->vert_attrib_mask |= 1u << attr;
- }
+
+ v->vert_attrib_mask =
+ stvp->vert_attrib_mask |
+ (key->passthrough_edgeflags ? VERT_BIT_EDGEFLAG : 0);
}
st_add_variant(&stp->variants, &v->base);
{
struct st_program Base;
- /** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
- ubyte index_to_input[PIPE_MAX_ATTRIBS];
+ uint32_t vert_attrib_mask; /**< mask of sourced vertex attribs */
+
ubyte num_inputs;
- /** Reverse mapping of the above */
+ /** Map a vertex attrib to a gallium vertex element index. */
ubyte input_to_index[VERT_ATTRIB_MAX];
/** Maps VARYING_SLOT_x to slot */
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
blob_write_uint32(&blob, stvp->num_inputs);
- blob_write_bytes(&blob, stvp->index_to_input,
- sizeof(stvp->index_to_input));
+ blob_write_uint32(&blob, stvp->vert_attrib_mask);
blob_write_bytes(&blob, stvp->input_to_index,
sizeof(stvp->input_to_index));
blob_write_bytes(&blob, stvp->result_to_output,
if (prog->info.stage == MESA_SHADER_VERTEX) {
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
stvp->num_inputs = blob_read_uint32(&blob_reader);
- blob_copy_bytes(&blob_reader, (uint8_t *) stvp->index_to_input,
- sizeof(stvp->index_to_input));
+ stvp->vert_attrib_mask = blob_read_uint32(&blob_reader);
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->input_to_index,
sizeof(stvp->input_to_index));
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->result_to_output,