diff options
author | Brian Paul <[email protected]> | 2009-11-30 08:56:47 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-11-30 08:57:04 -0700 |
commit | 7725744433827509d1da1cf1b27cda4bc8012ef3 (patch) | |
tree | d109301fc77e26a7ff03f3bd0b0c7d3e22425f2d /src | |
parent | a1b9c4e22a83d2125f66c3a3af3143bc0daee9a4 (diff) |
st/mesa: handle front/back-face +1/-1 vs. 1/0 conversion
Fixes progs/glsl/twoside.c demo.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index d84832f5392..5e8e61135e6 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -676,6 +676,31 @@ emit_inverted_wpos( struct st_translate *t, /** + * OpenGL's fragment gl_FrontFace input is 1 for front-facing, 0 for back. + * TGSI uses +1 for front, -1 for back. + * This function converts the TGSI value to the GL value. Simply clamping/ + * saturating the value to [0,1] does the job. + */ +static void +emit_face_var( struct st_translate *t, + const struct gl_program *program ) +{ + struct ureg_program *ureg = t->ureg; + struct ureg_dst face_temp = ureg_DECL_temporary( ureg ); + struct ureg_src face_input = t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]]; + + /* MOV_SAT face_temp, input[face] + */ + face_temp = ureg_saturate( face_temp ); + ureg_MOV( ureg, face_temp, face_input ); + + /* Use face_temp as face input from here on: + */ + t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]] = ureg_src(face_temp); +} + + +/** * Translate Mesa program to TGSI format. * \param program the program to translate * \param numInputs number of input registers used @@ -746,6 +771,10 @@ st_translate_mesa_program( emit_inverted_wpos( t, program ); } + if (program->InputsRead & FRAG_BIT_FACE) { + emit_face_var( t, program ); + } + /* * Declare output attributes. */ |