summaryrefslogtreecommitdiffstats
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorAmeer J <52414509+ameerj@users.noreply.github.com>2023-07-30 19:05:45 +0200
committerAmeer J <52414509+ameerj@users.noreply.github.com>2023-08-06 20:54:57 +0200
commitd17a51bc59462b136635515e40019c8ae4e05b5e (patch)
tree5f7b06f0ecb36ca03fcb1caea08e3f4a945bb96e /src/video_core/host_shaders
parentreuse vectors memory (diff)
downloadyuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar.gz
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar.bz2
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar.lz
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar.xz
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.tar.zst
yuzu-d17a51bc59462b136635515e40019c8ae4e05b5e.zip
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/astc_decoder.comp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp
index 4277b0756..f65e1d1b9 100644
--- a/src/video_core/host_shaders/astc_decoder.comp
+++ b/src/video_core/host_shaders/astc_decoder.comp
@@ -349,14 +349,17 @@ uint ExtractBits(uvec4 payload, int offset, int bits) {
if (bits <= 0) {
return 0;
}
- int last_offset = offset + bits - 1;
- int shifted_offset = offset >> 5;
+ if (bits > 32) {
+ return 0;
+ }
+ const int last_offset = offset + bits - 1;
+ const int shifted_offset = offset >> 5;
if ((last_offset >> 5) == shifted_offset) {
return bitfieldExtract(payload[shifted_offset], offset & 31, bits);
}
- int first_bits = 32 - (offset & 31);
- int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits));
- int result_second = int(bitfieldExtract(payload[shifted_offset + 1], 0, bits - first_bits));
+ const int first_bits = 32 - (offset & 31);
+ const int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits));
+ const int result_second = int(bitfieldExtract(payload[shifted_offset + 1], 0, bits - first_bits));
return result_first | (result_second << first_bits);
}