diff options
| -rw-r--r-- | src/video_core/host_shaders/astc_decoder.comp | 13 |
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) { | |||
| 349 | if (bits <= 0) { | 349 | if (bits <= 0) { |
| 350 | return 0; | 350 | return 0; |
| 351 | } | 351 | } |
| 352 | int last_offset = offset + bits - 1; | 352 | if (bits > 32) { |
| 353 | int shifted_offset = offset >> 5; | 353 | return 0; |
| 354 | } | ||
| 355 | const int last_offset = offset + bits - 1; | ||
| 356 | const int shifted_offset = offset >> 5; | ||
| 354 | if ((last_offset >> 5) == shifted_offset) { | 357 | if ((last_offset >> 5) == shifted_offset) { |
| 355 | return bitfieldExtract(payload[shifted_offset], offset & 31, bits); | 358 | return bitfieldExtract(payload[shifted_offset], offset & 31, bits); |
| 356 | } | 359 | } |
| 357 | int first_bits = 32 - (offset & 31); | 360 | const int first_bits = 32 - (offset & 31); |
| 358 | int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits)); | 361 | const int result_first = int(bitfieldExtract(payload[shifted_offset], offset & 31, first_bits)); |
| 359 | int result_second = int(bitfieldExtract(payload[shifted_offset + 1], 0, bits - first_bits)); | 362 | const int result_second = int(bitfieldExtract(payload[shifted_offset + 1], 0, bits - first_bits)); |
| 360 | return result_first | (result_second << first_bits); | 363 | return result_first | (result_second << first_bits); |
| 361 | } | 364 | } |
| 362 | 365 | ||