diff options
author | Brian <[email protected]> | 2007-10-03 14:43:57 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-10-03 14:43:57 -0600 |
commit | 635c4c41bdf111462939da292d65328595d314e8 (patch) | |
tree | 99753f7b6d8ad6d8f90d08e8076c2fecd3cf9e7c /src/mesa/state_tracker | |
parent | 65996f27f48e2212bf36e515aba82b6876398bfd (diff) |
Add outputs_written bitfield to pipe_shader_state, use it to determine if fragment shader writes Z.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 807cd8cb052..86aaaad6bb3 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -160,6 +160,8 @@ st_translate_vertex_program(struct st_context *st, defaultOutputMapping[attr] = slot; } + vs.outputs_written |= (1 << slot); + /* printf("Output %u -> slot %u\n", attr, slot); */ @@ -346,21 +348,40 @@ st_translate_fragment_program(struct st_context *st, /* * Semantics for outputs */ - for (attr = 0; attr < FRAG_RESULT_MAX; attr++) { - if (stfp->Base.Base.OutputsWritten & (1 << attr)) { - switch (attr) { - case FRAG_RESULT_DEPR: - fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION; - outputMapping[attr] = fs.num_outputs; - break; - case FRAG_RESULT_COLR: - fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR; - outputMapping[attr] = fs.num_outputs; - break; - default: - assert(0); + { + uint numColors = 0; + GLbitfield outputsWritten = stfp->Base.Base.OutputsWritten; + + /* output[0] is always Z, but may not really be written */ + fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_POSITION; + fs.output_semantic_index[fs.num_outputs] = 0; + outputMapping[FRAG_RESULT_DEPR] = fs.num_outputs; + fs.num_outputs++; + + if (outputsWritten & (1 << FRAG_RESULT_DEPR)) { + fs.outputs_written |= 0x1; + outputsWritten &= ~(1 << FRAG_RESULT_DEPR); + } + + /* color outputs begin at output [1] */ + for (attr = 0; attr < FRAG_RESULT_MAX; attr++) { + if (outputsWritten & (1 << attr)) { + switch (attr) { + case FRAG_RESULT_DEPR: + assert(0); + break; + case FRAG_RESULT_COLR: + fs.output_semantic_name[fs.num_outputs] = TGSI_SEMANTIC_COLOR; + fs.output_semantic_index[fs.num_outputs] = numColors; + outputMapping[attr] = fs.num_outputs; + fs.outputs_written |= (0x2 << numColors); + numColors++; + break; + default: + assert(0); + } + fs.num_outputs++; } - fs.num_outputs++; } } |