diff options
author | Eric Anholt <[email protected]> | 2014-08-05 14:23:40 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-11 14:47:54 -0700 |
commit | d34fbdda120b2b0e0a33a4a18fa112e58f8a2f4a (patch) | |
tree | e6e3d95465e5989ec72884ff926e874a8830a2dd /src/gallium/drivers/vc4/vc4_program.c | |
parent | a7faca5d2716c5f87f228c6f82eaf10373154852 (diff) |
vc4: Refactor shader input setup again.
This makes some space for handling special inputs like fragcoords.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 82526300879..8109f635e3b 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -570,6 +570,24 @@ emit_vertex_input(struct tgsi_to_qir *trans, int attr) } static void +emit_fragment_input(struct tgsi_to_qir *trans, int attr) +{ + struct qcompile *c = trans->c; + + for (int i = 0; i < 4; i++) { + struct qreg vary = { + QFILE_VARY, + attr * 4 + i + }; + + /* XXX: multiply by W */ + trans->inputs[attr * 4 + i] = + qir_VARY_ADD_C(c, qir_MOV(c, vary)); + c->num_inputs++; + } +} + +static void emit_tgsi_declaration(struct tgsi_to_qir *trans, struct tgsi_full_declaration *decl) { @@ -577,23 +595,12 @@ emit_tgsi_declaration(struct tgsi_to_qir *trans, switch (decl->Declaration.File) { case TGSI_FILE_INPUT: - if (c->stage == QSTAGE_FRAG) { - for (int i = decl->Range.First * 4; - i < (decl->Range.Last + 1) * 4; - i++) { - struct qreg vary = { - QFILE_VARY, - i - }; - trans->inputs[i] = - qir_VARY_ADD_C(c, qir_MOV(c, vary)); - - c->num_inputs++; - } - } else { - for (int i = decl->Range.First; - i <= decl->Range.Last; - i++) { + for (int i = decl->Range.First; + i <= decl->Range.Last; + i++) { + if (c->stage == QSTAGE_FRAG) { + emit_fragment_input(trans, i); + } else { emit_vertex_input(trans, i); } } |