diff options
author | Eric Anholt <[email protected]> | 2014-08-05 14:24:29 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-11 14:47:54 -0700 |
commit | e63598aecb5d1cc2a20b8db1ef85790e301f4241 (patch) | |
tree | 68820ed5b8b2e61a97f5ce1eac2c495ca1ea922d /src/gallium/drivers/vc4/vc4_program.c | |
parent | d34fbdda120b2b0e0a33a4a18fa112e58f8a2f4a (diff) |
vc4: Add support for gl_FragCoord.
This isn't passing all tests (glsl-fs-fragcoord-zw-ortho, for example),
but it does get a bunch more tests passing.
v2: Rebase on helpers change.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 8109f635e3b..d871dcd88d3 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -570,6 +570,20 @@ emit_vertex_input(struct tgsi_to_qir *trans, int attr) } static void +emit_fragcoord_input(struct tgsi_to_qir *trans, int attr) +{ + struct qcompile *c = trans->c; + + trans->inputs[attr * 4 + 0] = qir_FRAG_X(c); + trans->inputs[attr * 4 + 1] = qir_FRAG_Y(c); + trans->inputs[attr * 4 + 2] = + qir_FMUL(c, + qir_FRAG_Z(c), + qir_uniform_f(trans, 1.0 / 0xffffff)); + trans->inputs[attr * 4 + 3] = qir_FRAG_RCP_W(c); +} + +static void emit_fragment_input(struct tgsi_to_qir *trans, int attr) { struct qcompile *c = trans->c; @@ -599,7 +613,12 @@ emit_tgsi_declaration(struct tgsi_to_qir *trans, i <= decl->Range.Last; i++) { if (c->stage == QSTAGE_FRAG) { - emit_fragment_input(trans, i); + if (decl->Semantic.Name == + TGSI_SEMANTIC_POSITION) { + emit_fragcoord_input(trans, i); + } else { + emit_fragment_input(trans, i); + } } else { emit_vertex_input(trans, i); } |