From 10e4ec448e8011e8d446d83fc8bd61c7ba2d74be Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sun, 18 Apr 2010 09:46:25 -0600 Subject: 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... --- src/gallium/drivers/softpipe/sp_setup.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers/softpipe/sp_setup.c') 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; } -- cgit v1.2.3