vc4: Add support for the FACE semantic.
authorEric Anholt <eric@anholt.net>
Tue, 30 Sep 2014 23:08:23 +0000 (16:08 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 2 Oct 2014 00:03:35 +0000 (17:03 -0700)
Fixes glsl-fs-frontfacing.

src/gallium/drivers/vc4/vc4_program.c
src/gallium/drivers/vc4/vc4_qir.c
src/gallium/drivers/vc4/vc4_qir.h
src/gallium/drivers/vc4/vc4_qpu_defines.h
src/gallium/drivers/vc4/vc4_qpu_emit.c

index 804a1dc20976f6f8373048da40e8a8ca9c9827d7..09a39a121013be94d8b47d40ccfca9648412f034 100644 (file)
@@ -953,6 +953,19 @@ emit_fragment_input(struct vc4_compile *c, int attr,
         }
 }
 
+static void
+emit_face_input(struct vc4_compile *c, int attr)
+{
+        c->inputs[attr * 4 + 0] = qir_FSUB(c,
+                                           qir_uniform_f(c, 1.0),
+                                           qir_FMUL(c,
+                                                    qir_ITOF(c, qir_FRAG_REV_FLAG(c)),
+                                                    qir_uniform_f(c, 2.0)));
+        c->inputs[attr * 4 + 1] = qir_uniform_f(c, 0.0);
+        c->inputs[attr * 4 + 2] = qir_uniform_f(c, 0.0);
+        c->inputs[attr * 4 + 3] = qir_uniform_f(c, 1.0);
+}
+
 static void
 emit_tgsi_declaration(struct vc4_compile *c,
                       struct tgsi_full_declaration *decl)
@@ -974,6 +987,8 @@ emit_tgsi_declaration(struct vc4_compile *c,
                                 if (decl->Semantic.Name ==
                                     TGSI_SEMANTIC_POSITION) {
                                         emit_fragcoord_input(c, i);
+                                } else if (decl->Semantic.Name == TGSI_SEMANTIC_FACE) {
+                                        emit_face_input(c, i);
                                 } else if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
                                            (c->fs_key->point_sprite_mask &
                                             (1 << decl->Semantic.Index))) {
index 0975460ffec94d0e92f70099cf5c8e1233442cfe..432fb1bf55569e280d1dd4f06f7b624db1102ad4 100644 (file)
@@ -87,6 +87,7 @@ static const struct qir_op_info qir_op_info[] = {
         [QOP_FRAG_Y] = { "frag_y", 1, 0 },
         [QOP_FRAG_Z] = { "frag_z", 1, 0 },
         [QOP_FRAG_W] = { "frag_w", 1, 0 },
+        [QOP_FRAG_REV_FLAG] = { "frag_rev_flag", 1, 0 },
 
         [QOP_TEX_S] = { "tex_s", 0, 2 },
         [QOP_TEX_T] = { "tex_t", 0, 2 },
index 2807b497ffe85b3b13cac88b87cd2276a55342d6..ddd1f063a3855900673fc2152c2a6d11b77e02d1 100644 (file)
@@ -107,6 +107,7 @@ enum qop {
         QOP_FRAG_Y,
         QOP_FRAG_Z,
         QOP_FRAG_W,
+        QOP_FRAG_REV_FLAG,
 
         QOP_UNPACK_8A,
         QOP_UNPACK_8B,
@@ -377,6 +378,7 @@ QIR_ALU0(FRAG_X)
 QIR_ALU0(FRAG_Y)
 QIR_ALU0(FRAG_Z)
 QIR_ALU0(FRAG_W)
+QIR_ALU0(FRAG_REV_FLAG)
 QIR_ALU0(TEX_RESULT)
 QIR_ALU0(TLB_COLOR_READ)
 QIR_NODST_1(TLB_Z_WRITE)
index cee2ae8a928f2038cd9216016266499548ad199b..27b4efef415426053ddb65fbdf736167dd9ad84a 100644 (file)
@@ -73,7 +73,7 @@ enum qpu_raddr {
         QPU_R_ELEM_QPU = 38,
         QPU_R_NOP,
         QPU_R_XY_PIXEL_COORD = 41,
-        QPU_R_MS_REV_FLAGS = 41,
+        QPU_R_MS_REV_FLAGS = 42,
         QPU_R_VPM = 48,
         QPU_R_VPM_LD_BUSY,
         QPU_R_VPM_LD_WAIT,
index bbfefebbbe4f8086181a5b892997a292b8c7e5b7..397e6f26dd2f89713bac2d44f3c61821575bcc85 100644 (file)
@@ -426,6 +426,11 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c)
                                             qpu_rb(QPU_R_XY_PIXEL_COORD)));
                         break;
 
+                case QOP_FRAG_REV_FLAG:
+                        queue(c, qpu_a_ITOF(dst,
+                                            qpu_rb(QPU_R_MS_REV_FLAGS)));
+                        break;
+
                 case QOP_FRAG_Z:
                 case QOP_FRAG_W:
                         /* QOP_FRAG_Z/W don't emit instructions, just allocate