diff options
author | Eric Anholt <[email protected]> | 2014-11-12 14:14:32 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2014-11-12 18:24:10 -0800 |
commit | b3d269f5ae1844b542d8e875d7177c5eff3a29f2 (patch) | |
tree | 7fac5b2ee86e45c023e941902c109e7500a7493a /src/gallium/drivers/vc4 | |
parent | acc1cca7ae35e9e7fb55b4c05fd80564253e1634 (diff) |
vc4: Avoid reusing a pointer from c->outputs[] after add_output().
add_output() can resize the qreg array, so we might use a stale pointer.
Diffstat (limited to 'src/gallium/drivers/vc4')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 1cc6e9615b4..ef0d5b89c93 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1822,12 +1822,11 @@ emit_stub_vpm_read(struct vc4_compile *c) static void emit_ucp_clipdistance(struct vc4_compile *c) { - struct qreg *clipvertex; - + unsigned cv; if (c->output_clipvertex_index != -1) - clipvertex = &c->outputs[c->output_clipvertex_index]; + cv = c->output_clipvertex_index; else if (c->output_position_index != -1) - clipvertex = &c->outputs[c->output_position_index]; + cv = c->output_position_index; else return; @@ -1846,12 +1845,14 @@ emit_ucp_clipdistance(struct vc4_compile *c) plane, TGSI_SWIZZLE_X); + struct qreg dist = qir_uniform_f(c, 0.0); for (int i = 0; i < 4; i++) { + struct qreg pos_chan = c->outputs[cv + i]; struct qreg ucp = add_uniform(c, QUNIFORM_USER_CLIP_PLANE, plane * 4 + i); - dist = qir_FADD(c, dist, qir_FMUL(c, clipvertex[i], ucp)); + dist = qir_FADD(c, dist, qir_FMUL(c, pos_chan, ucp)); } c->outputs[output_index] = dist; |