Mesa (master): vc4: Add support for the FACE semantic.

Eric Anholt anholt at kemper.freedesktop.org
Thu Oct 2 00:05:32 UTC 2014


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Sep 30 16:08:23 2014 -0700

vc4: Add support for the FACE semantic.

Fixes glsl-fs-frontfacing.

---

 src/gallium/drivers/vc4/vc4_program.c     |   15 +++++++++++++++
 src/gallium/drivers/vc4/vc4_qir.c         |    1 +
 src/gallium/drivers/vc4/vc4_qir.h         |    2 ++
 src/gallium/drivers/vc4/vc4_qpu_defines.h |    2 +-
 src/gallium/drivers/vc4/vc4_qpu_emit.c    |    5 +++++
 5 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 804a1dc..09a39a1 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -954,6 +954,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))) {
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c
index 0975460..432fb1b 100644
--- a/src/gallium/drivers/vc4/vc4_qir.c
+++ b/src/gallium/drivers/vc4/vc4_qir.c
@@ -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 },
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index 2807b49..ddd1f06 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -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)
diff --git a/src/gallium/drivers/vc4/vc4_qpu_defines.h b/src/gallium/drivers/vc4/vc4_qpu_defines.h
index cee2ae8..27b4efe 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_defines.h
+++ b/src/gallium/drivers/vc4/vc4_qpu_defines.h
@@ -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,
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index bbfefeb..397e6f2 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -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




More information about the mesa-commit mailing list