Mesa (master): llvmpipe: fix frontface behavior again

Zack Rusin zack at kemper.freedesktop.org
Mon Aug 5 16:09:01 UTC 2013


Module: Mesa
Branch: master
Commit: 95829e202951b2532d72d20a1f5b4450b11de2c1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=95829e202951b2532d72d20a1f5b4450b11de2c1

Author: Zack Rusin <zackr at vmware.com>
Date:   Fri Aug  2 22:08:25 2013 -0400

llvmpipe: fix frontface behavior again

Lets make sure the frontface is 1 for front and -1 for back.
Discussed with Roland and Jose.

Signed-off-by: Zack Rusin <zackr at vmware.com>

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index cecfbce..dab5096 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -182,9 +182,17 @@ emit_facing_coef(struct gallivm_state *gallivm,
    LLVMValueRef a0_0 = args->facing;
    LLVMValueRef a0_0f = LLVMBuildSIToFP(builder, a0_0, float_type, "");
    LLVMValueRef zero = lp_build_const_float(gallivm, 0.0);
-   LLVMValueRef face_val = LLVMBuildFSub(builder, a0_0f,
-                                         lp_build_const_float(gallivm, 0.5),
-                                         "");
+   /* Our face val is either 1 or 0 so we do
+    * face = (val * 2) - 1
+    * to make it 1 or -1
+    */
+   LLVMValueRef face_val =
+      LLVMBuildFAdd(builder,
+                    LLVMBuildFMul(builder, a0_0f,
+                                  lp_build_const_float(gallivm, 2.0),
+                                  ""),
+                    lp_build_const_float(gallivm, -1.0),
+                    "");
    LLVMValueRef a0 = vec4f(gallivm, face_val, zero, zero, zero, "facing");
    LLVMValueRef zerovec = vec4f_from_scalar(gallivm, zero, "zero");
 




More information about the mesa-commit mailing list