diff options
author | Mathias Fröhlich <[email protected]> | 2018-04-01 20:18:36 +0200 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2018-05-10 07:06:15 +0200 |
commit | 9987a072cbc00306eb4d34409f6325ae29728a2f (patch) | |
tree | d4424499925dabfdcb69ddfd95aab90dc1da93ba /src/mesa | |
parent | f24bf4521023658012b2636a24cf2387fd55695a (diff) |
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 <[email protected]>
Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.h | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_shader_cache.c | 4 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index fe72ddaf2c0..f256e2e8625 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -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"); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index a520ffbecb4..f67ea5eb208 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -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]; diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index 3ca3fef1df2..17f84180cae 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -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)); |