Mesa (master): llvmpipe: make the front-face behavior match the gallium spec

Zack Rusin zack at kemper.freedesktop.org
Fri Aug 2 19:52:09 UTC 2013


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

Author: Zack Rusin <zackr at vmware.com>
Date:   Fri Aug  2 15:50:16 2013 -0400

llvmpipe: make the front-face behavior match the gallium spec

The spec says that front-face is true if the value is >0 and false
if it's <0. To make sure that we follow the spec, lets just
subtract 0.5 from our value (llvmpipe did 1 for frontface and 0
otherwise), which will get us a positive num for frontface and
negative for backface.

Signed-off-by: Zack Rusin <zackr at vmware.com>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/gallium/drivers/llvmpipe/lp_state_setup.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_state_setup.c b/src/gallium/drivers/llvmpipe/lp_state_setup.c
index bb5cfc4..cecfbce 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_setup.c
@@ -182,7 +182,10 @@ 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 a0 = vec4f(gallivm, a0_0f, zero, zero, zero, "facing");
+   LLVMValueRef face_val = LLVMBuildFSub(builder, a0_0f,
+                                         lp_build_const_float(gallivm, 0.5),
+                                         "");
+   LLVMValueRef a0 = vec4f(gallivm, face_val, zero, zero, zero, "facing");
    LLVMValueRef zerovec = vec4f_from_scalar(gallivm, zero, "zero");
 
    store_coef(gallivm, args, slot, a0, zerovec, zerovec);




More information about the mesa-commit mailing list