diff options
author | Eric Anholt <[email protected]> | 2014-08-01 15:45:41 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-08-08 18:59:47 -0700 |
commit | 1d03692f7888929c44446633809fe7bbc9da5d73 (patch) | |
tree | 43dac88f42a41c3d6a18011ae14871658a56613a /src/gallium | |
parent | 88bc5baa00c632c2411304b2c7e5cc49f882c30e (diff) |
vc4: Fix using and emitting the 1/W from the vertex/coord shaders.
v2: Rebase on helpers change.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 5d640f45321..0c821c8960d 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -579,7 +579,7 @@ emit_frag_end(struct tgsi_to_qir *trans) } static void -emit_scaled_viewport_write(struct tgsi_to_qir *trans) +emit_scaled_viewport_write(struct tgsi_to_qir *trans, struct qreg rcp_w) { struct qcompile *c = trans->c; struct qreg xyi[2]; @@ -588,28 +588,30 @@ emit_scaled_viewport_write(struct tgsi_to_qir *trans) struct qreg scale = add_uniform(trans, QUNIFORM_VIEWPORT_X_SCALE + i, 0); - xyi[i] = qir_FTOI(c, qir_FMUL(c, trans->outputs[i], scale)); + xyi[i] = qir_FTOI(c, qir_FMUL(c, + qir_FMUL(c, + trans->outputs[i], + scale), + rcp_w)); } qir_VPM_WRITE(c, qir_PACK_SCALED(c, xyi[0], xyi[1])); } static void -emit_zs_write(struct tgsi_to_qir *trans) +emit_zs_write(struct tgsi_to_qir *trans, struct qreg rcp_w) { struct qcompile *c = trans->c; - /* XXX: rescale */ - qir_VPM_WRITE(c, trans->outputs[2]); + qir_VPM_WRITE(c, qir_FMUL(c, trans->outputs[2], rcp_w)); } static void -emit_1_wc_write(struct tgsi_to_qir *trans) +emit_rcp_wc_write(struct tgsi_to_qir *trans, struct qreg rcp_w) { struct qcompile *c = trans->c; - /* XXX: RCP */ - qir_VPM_WRITE(c, trans->outputs[3]); + qir_VPM_WRITE(c, rcp_w); } static void @@ -617,9 +619,11 @@ emit_vert_end(struct tgsi_to_qir *trans) { struct qcompile *c = trans->c; - emit_scaled_viewport_write(trans); - emit_zs_write(trans); - emit_1_wc_write(trans); + struct qreg rcp_w = qir_RCP(c, trans->outputs[3]); + + emit_scaled_viewport_write(trans, rcp_w); + emit_zs_write(trans, rcp_w); + emit_rcp_wc_write(trans, rcp_w); for (int i = 4; i < trans->num_outputs; i++) { qir_VPM_WRITE(c, trans->outputs[i]); @@ -631,12 +635,14 @@ emit_coord_end(struct tgsi_to_qir *trans) { struct qcompile *c = trans->c; + struct qreg rcp_w = qir_RCP(c, trans->outputs[3]); + for (int i = 0; i < 4; i++) qir_VPM_WRITE(c, trans->outputs[i]); - emit_scaled_viewport_write(trans); - emit_zs_write(trans); - emit_1_wc_write(trans); + emit_scaled_viewport_write(trans, rcp_w); + emit_zs_write(trans, rcp_w); + emit_rcp_wc_write(trans, rcp_w); } static struct tgsi_to_qir * |