st/mesa: Make the input_to_index array available.

The input_to_index array is already available internally
when preparing vertex programs. Store the map in
struct st_vertex_program.
Also store the bitmask of mesa vertex processing inputs in
struct st_vp_variant.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
Mathias Fröhlich 2018-04-01 20:18:36 +02:00 committed by Mathias Fröhlich
parent f24bf45210
commit 9987a072cb
3 changed files with 21 additions and 5 deletions

View File

@ -388,11 +388,11 @@ st_translate_vertex_program(struct st_context *st,
enum pipe_error error;
unsigned num_outputs = 0;
unsigned attr;
ubyte input_to_index[VERT_ATTRIB_MAX] = {0};
ubyte output_semantic_name[VARYING_SLOT_MAX] = {0};
ubyte output_semantic_index[VARYING_SLOT_MAX] = {0};
stvp->num_inputs = 0;
memset(stvp->input_to_index, ~0, sizeof(stvp->input_to_index));
if (stvp->Base.arb.IsPositionInvariant)
_mesa_insert_mvp_code(st->ctx, &stvp->Base);
@ -403,7 +403,7 @@ st_translate_vertex_program(struct st_context *st,
*/
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
if ((stvp->Base.info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
input_to_index[attr] = stvp->num_inputs;
stvp->input_to_index[attr] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = attr;
stvp->num_inputs++;
if ((stvp->Base.info.vs.double_inputs_read &
@ -415,7 +415,7 @@ st_translate_vertex_program(struct st_context *st,
}
}
/* bit of a hack, presetup potentially unused edgeflag input */
input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
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.
@ -495,7 +495,7 @@ st_translate_vertex_program(struct st_context *st,
&stvp->Base,
/* inputs */
stvp->num_inputs,
input_to_index,
stvp->input_to_index,
NULL, /* inputSlotToAttr */
NULL, /* input semantic name */
NULL, /* input semantic index */
@ -518,7 +518,7 @@ st_translate_vertex_program(struct st_context *st,
&stvp->Base,
/* inputs */
stvp->num_inputs,
input_to_index,
stvp->input_to_index,
NULL, /* input semantic name */
NULL, /* input semantic index */
NULL,
@ -598,6 +598,13 @@ st_create_vp_variant(struct st_context *st,
fprintf(stderr, "mesa: cannot emulate deprecated features\n");
}
for (unsigned index = 0; index < vpv->num_inputs; ++index) {
unsigned attr = stvp->index_to_input[index];
if (attr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
continue;
vpv->vert_attrib_mask |= 1u << attr;
}
if (ST_DEBUG & DEBUG_TGSI) {
tgsi_dump(vpv->tgsi.tokens, 0);
debug_printf("\n");

View File

@ -196,6 +196,9 @@ struct st_vp_variant
/** similar to that in st_vertex_program, but with edgeflags info too */
GLuint num_inputs;
/** Bitfield of VERT_BIT_* bits of mesa vertex processing inputs */
GLbitfield vert_attrib_mask;
};
@ -215,6 +218,8 @@ struct st_vertex_program
/** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
ubyte index_to_input[PIPE_MAX_ATTRIBS];
ubyte num_inputs;
/** Reverse mapping of the above */
ubyte input_to_index[VERT_ATTRIB_MAX];
/** Maps VARYING_SLOT_x to slot */
ubyte result_to_output[VARYING_SLOT_MAX];

View File

@ -84,6 +84,8 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
blob_write_uint32(&blob, stvp->num_inputs);
blob_write_bytes(&blob, stvp->index_to_input,
sizeof(stvp->index_to_input));
blob_write_bytes(&blob, stvp->input_to_index,
sizeof(stvp->input_to_index));
blob_write_bytes(&blob, stvp->result_to_output,
sizeof(stvp->result_to_output));
@ -206,6 +208,8 @@ st_deserialise_ir_program(struct gl_context *ctx,
stvp->num_inputs = blob_read_uint32(&blob_reader);
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->index_to_input,
sizeof(stvp->index_to_input));
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,
sizeof(stvp->result_to_output));