diff options
author | Eric Anholt <[email protected]> | 2015-06-15 15:05:36 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2015-06-16 15:15:14 -0700 |
commit | a0cd1a4060fdb55a57609b460629c7059bbe7047 (patch) | |
tree | ac939eae00ab2ac973fb74664e19f9530cea83f1 /src/gallium/drivers/vc4/vc4_program.c | |
parent | d4d27361499cac73da4716b571519ecb71cef551 (diff) |
vc4: Make sure that direct texture clamps have a minimum value of 0.
I was thinking of the MIN opcode in terms of unsigned math, but it's
signed, so if you used a negative array index, you could read before the
UBO. Fixes segfaults under simulation in piglit array indexing tests with
mprotect-based guard pages.
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_program.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 91540cfe2fa..bb45eb1288e 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -147,6 +147,9 @@ indirect_uniform_load(struct vc4_compile *c, indirect_offset = qir_ADD(c, indirect_offset, qir_uniform_ui(c, (range->dst_offset + offset))); + + /* Clamp to [0, array size). Note that MIN/MAX are signed. */ + indirect_offset = qir_MAX(c, indirect_offset, qir_uniform_ui(c, 0)); indirect_offset = qir_MIN(c, indirect_offset, qir_uniform_ui(c, (range->dst_offset + range->size - 4))); |