nvc0: fix FACE state and and handle FACE sysval/varying offset
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 10 Dec 2010 19:16:10 +0000 (20:16 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 10 Dec 2010 19:20:37 +0000 (20:20 +0100)
src/gallium/drivers/nvc0/nvc0_program.c
src/gallium/drivers/nvc0/nvc0_state.c
src/gallium/drivers/nvc0/nvc0_tgsi_to_nc.c

index aeb92130371b6ae2265390cf47b7ad964558c93c..7aa6ef02bcd38d1acf3749839faa77abdec80d98 100644 (file)
@@ -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);
index afba7ce6a0df1e3011e01e5a33223bf56defbc2e..c7a8c4b747ffaaaed448b66551030b8b3d8274ae 100644 (file)
@@ -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);
index 26f9e735fb26149a1a4e88a9b41b63bf40747f26..8a20983a7e2f16464fc8ae7a6547470300d9ecd2 100644 (file)
@@ -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]);