aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-09-30 16:08:23 -0700
committerEric Anholt <[email protected]>2014-10-01 17:03:35 -0700
commitd7a0502a5440359d1cecd42e58bdb85c2d857824 (patch)
treec51845d91a4bae9a8d21e956e4deed4e203fa972
parent1bf2d17a60d112c7ca8da7ab0b539991df96a93d (diff)
vc4: Add support for the FACE semantic.
Fixes glsl-fs-frontfacing.
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c15
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.c1
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.h2
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_defines.h2
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_emit.c5
5 files changed, 24 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 804a1dc2097..09a39a12101 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 0975460ffec..432fb1bf555 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 2807b497ffe..ddd1f063a38 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 cee2ae8a928..27b4efef415 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 bbfefebbbe4..397e6f26dd2 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