summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe/sp_setup.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-04-18 09:46:25 -0600
committerBrian Paul <brianp@vmware.com>2010-04-18 10:02:11 -0600
commit10e4ec448e8011e8d446d83fc8bd61c7ba2d74be (patch)
tree27003aca721c84be2a45349f6c4abe622c6c7833 /src/gallium/drivers/softpipe/sp_setup.c
parent6756c07b66164a2f8c769ad5725b95115eb7a6e6 (diff)
softpipe: fix computation of fragment[FACE] attribute
In TGSI, front facing is +1 and back-facing is -1. We were computing this attribute as +1 and 0 before. However, the value isn't actually used anywhere because we machine->Face attribute overrides it in tgsi_exec.c. That could be changed, removing some special-case code...
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_setup.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index 61be55cdd3..7e2b5802ec 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -387,6 +387,7 @@ setup_sort_vertices(struct setup_context *setup,
/* We need to know if this is a front or back-facing triangle for:
* - the GLSL gl_FrontFacing fragment attribute (bool)
* - two-sided stencil test
+ * 0 = front-facing, 1 = back-facing
*/
setup->facing =
((det > 0.0) ^
@@ -664,7 +665,8 @@ setup_tri_coefficients(struct setup_context *setup)
}
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
- setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+ /* convert 0 to 1.0 and 1 to -1.0 */
+ setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
setup->coef[fragSlot].dadx[0] = 0.0;
setup->coef[fragSlot].dady[0] = 0.0;
}
@@ -1019,7 +1021,8 @@ setup_line_coefficients(struct setup_context *setup,
}
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
- setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+ /* convert 0 to 1.0 and 1 to -1.0 */
+ setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
setup->coef[fragSlot].dadx[0] = 0.0;
setup->coef[fragSlot].dady[0] = 0.0;
}
@@ -1265,7 +1268,8 @@ sp_setup_point(struct setup_context *setup,
}
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
- setup->coef[fragSlot].a0[0] = 1.0f - setup->facing;
+ /* convert 0 to 1.0 and 1 to -1.0 */
+ setup->coef[fragSlot].a0[0] = setup->facing * -2.0f + 1.0f;
setup->coef[fragSlot].dadx[0] = 0.0;
setup->coef[fragSlot].dady[0] = 0.0;
}