diff options
author | Sebastián Aedo <saedo@codeweavers.com> | 2021-11-11 18:57:57 +0300 |
---|---|---|
committer | Sebastián Aedo <saedo@codeweavers.com> | 2021-12-07 22:00:06 +0300 |
commit | 905b8244e7756d8657c3a3ef97693af00f9e38bb (patch) | |
tree | 077adf80d8786c870d9a644ba04c18037277e21e /reference/shaders | |
parent | e9cc6403341baf0edd430a4027b074d0a06b782f (diff) |
Clamp vector element access to vector size.
In cases where we know the size of the vector and the index at compile
time, we can check if it's accessing in bounds and rely in undefined
behavior otherwise.
Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
Diffstat (limited to 'reference/shaders')
-rw-r--r-- | reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag | 15 | ||||
-rw-r--r-- | reference/shaders/asm/frag/out-of-bounds-access.asm.frag | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag b/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag new file mode 100644 index 00000000..eddb3829 --- /dev/null +++ b/reference/shaders/asm/frag/out-of-bounds-access-opspecconstant.asm.frag @@ -0,0 +1,15 @@ +#version 320 es +precision mediump float; +precision highp int; + +const uint _15 = 3u; + +void main() +{ + vec3 v = vec3(0.0); + if (false) + { + v[0] = 99.0; + } +} + diff --git a/reference/shaders/asm/frag/out-of-bounds-access.asm.frag b/reference/shaders/asm/frag/out-of-bounds-access.asm.frag new file mode 100644 index 00000000..080283d4 --- /dev/null +++ b/reference/shaders/asm/frag/out-of-bounds-access.asm.frag @@ -0,0 +1,14 @@ +#version 320 es +precision mediump float; +precision highp int; + +void main() +{ + vec3 v = vec3(0.0); + if (false) + { + v.x = 99.0; + v.x = 88.0; + } +} + |