Mesa (nvc0): nvc0: fix FACE state and and handle FACE sysval/varying offset

Christoph Bumiller chrisbmr at kemper.freedesktop.org
Fri Dec 10 11:21:06 PST 2010


Module: Mesa
Branch: nvc0
Commit: dea9d604005e9aaed2bd6807f1913ac668479443
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dea9d604005e9aaed2bd6807f1913ac668479443

Author: Christoph Bumiller <e0425955 at student.tuwien.ac.at>
Date:   Fri Dec 10 20:16:10 2010 +0100

nvc0: fix FACE state and and handle FACE sysval/varying offset

---

 src/gallium/drivers/nvc0/nvc0_program.c    |    6 +++++
 src/gallium/drivers/nvc0/nvc0_state.c      |   34 ++++++++++++---------------
 src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c |    2 +
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/nvc0/nvc0_program.c b/src/gallium/drivers/nvc0/nvc0_program.c
index aeb9213..7aa6ef0 100644
--- a/src/gallium/drivers/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nvc0/nvc0_program.c
@@ -23,6 +23,8 @@
 #include "pipe/p_shader_tokens.h"
 #include "pipe/p_defines.h"
 
+#define NOUVEAU_DEBUG
+
 #include "tgsi/tgsi_parse.h"
 #include "tgsi/tgsi_util.h"
 #include "tgsi/tgsi_dump.h"
@@ -147,6 +149,8 @@ nvc0_system_value_location(unsigned sn, unsigned si)
       */
    case TGSI_SEMANTIC_INSTANCEID:
       return 0x2f8;
+   case TGSI_SEMANTIC_FACE:
+      return 0x3fc;
    default:
       assert(0);
       return 0x000;
@@ -178,6 +182,8 @@ nvc0_varying_location(unsigned sn, unsigned si)
       return 0x360;
    case TGSI_SEMANTIC_PRIMID:
       return 0x40;
+   case TGSI_SEMANTIC_FACE:
+      return 0x3fc;
       /*
    case TGSI_SEMANTIC_CLIP_DISTANCE:
       return 0x2c0 + (si * 4);
diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c
index afba7ce..c7a8c4b 100644
--- a/src/gallium/drivers/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nvc0/nvc0_state.c
@@ -210,25 +210,21 @@ nvc0_rasterizer_state_create(struct pipe_context *pipe,
     SB_DATA    (so, nvgl_polygon_mode(cso->fill_back));
     SB_OUT_3D  (so, POLYGON_SMOOTH_ENABLE, cso->poly_smooth);
 
-    if (cso->cull_face != PIPE_FACE_NONE) {
-        SB_BEGIN_3D(so, CULL_FACE_ENABLE, 3);
-        SB_DATA    (so, 1);
-        SB_DATA    (so, cso->front_ccw ? NVC0_3D_FRONT_FACE_CCW :
-                                         NVC0_3D_FRONT_FACE_CW);
-        switch (cso->cull_face) {
-        case PIPE_FACE_FRONT_AND_BACK:
-            SB_DATA(so, NVC0_3D_CULL_FACE_FRONT_AND_BACK);
-            break;
-        case PIPE_FACE_FRONT:
-            SB_DATA(so, NVC0_3D_CULL_FACE_FRONT);
-            break;
-        case PIPE_FACE_BACK:
-        default:
-            SB_DATA(so, NVC0_3D_CULL_FACE_BACK);
-            break;
-        }
-    } else {
-       SB_OUT_3D(so, CULL_FACE_ENABLE, 0);
+    SB_BEGIN_3D(so, CULL_FACE_ENABLE, 3);
+    SB_DATA    (so, cso->cull_face != PIPE_FACE_NONE);
+    SB_DATA    (so, cso->front_ccw ? NVC0_3D_FRONT_FACE_CCW :
+                                     NVC0_3D_FRONT_FACE_CW);
+    switch (cso->cull_face) {
+    case PIPE_FACE_FRONT_AND_BACK:
+       SB_DATA(so, NVC0_3D_CULL_FACE_FRONT_AND_BACK);
+       break;
+    case PIPE_FACE_FRONT:
+       SB_DATA(so, NVC0_3D_CULL_FACE_FRONT);
+       break;
+    case PIPE_FACE_BACK:
+    default:
+       SB_DATA(so, NVC0_3D_CULL_FACE_BACK);
+       break;
     }
 
     SB_OUT_3D  (so, POLYGON_STIPPLE_ENABLE, cso->poly_stipple_enable);
diff --git a/src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c b/src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c
index 26f9e73..8a20983 100644
--- a/src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c
+++ b/src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c
@@ -963,8 +963,10 @@ bld_interp(struct bld_context *bld, unsigned mode, struct nv_value *val)
    if (val->reg.address == 0x3fc) {
       /* gl_FrontFacing: 0/~0 to -1.0/+1.0 */
       val = bld_insn_1(bld, NV_OP_LINTERP, val);
+      val->insn->flat = 1;
       val = bld_insn_2(bld, NV_OP_SHL, val, bld_imm_u32(bld, 31));
       val = bld_insn_2(bld, NV_OP_XOR, val, bld_imm_f32(bld, -1.0f));
+      return val;
    } else
    if (mode == NVC0_INTERP_PERSPECTIVE) {
       val = bld_insn_2(bld, NV_OP_PINTERP, val, bld->frag_coord[3]);



More information about the mesa-commit mailing list