mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
st/mesa: handle front/back-face +1/-1 vs. 1/0 conversion
Fixes progs/glsl/twoside.c demo.
This commit is contained in:
parent
a1b9c4e22a
commit
7725744433
1 changed files with 29 additions and 0 deletions
|
|
@ -675,6 +675,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
|
||||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue