diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/host_shaders/astc_decoder.comp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index 2ddac2e1d..5be716309 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp | |||
| @@ -339,6 +339,9 @@ uint Select2DPartition(uint seed, uint x, uint y, uint partition_count, bool sma | |||
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | uint ReadBit() { | 341 | uint ReadBit() { |
| 342 | if (current_index >= local_buff.length()) { | ||
| 343 | return 0; | ||
| 344 | } | ||
| 342 | uint bit = bitfieldExtract(local_buff[current_index], bitsread, 1); | 345 | uint bit = bitfieldExtract(local_buff[current_index], bitsread, 1); |
| 343 | bitsread++; | 346 | bitsread++; |
| 344 | total_bitsread++; | 347 | total_bitsread++; |
| @@ -1170,12 +1173,17 @@ void DecompressBlock(ivec3 coord, uint block_index) { | |||
| 1170 | plane_selector_bits = 2; | 1173 | plane_selector_bits = 2; |
| 1171 | } | 1174 | } |
| 1172 | remaining_bits -= plane_selector_bits; | 1175 | remaining_bits -= plane_selector_bits; |
| 1176 | if (remaining_bits > 128) { | ||
| 1177 | // Bad data, more remaining bits than 4 bytes | ||
| 1178 | // return early | ||
| 1179 | return; | ||
| 1180 | } | ||
| 1173 | // Read color data... | 1181 | // Read color data... |
| 1174 | uint color_data_bits = remaining_bits; | 1182 | uint color_data_bits = remaining_bits; |
| 1175 | while (remaining_bits > 0) { | 1183 | while (remaining_bits > 0) { |
| 1176 | uint nb = min(remaining_bits, 8); | 1184 | int nb = int(min(remaining_bits, 8U)); |
| 1177 | uint b = StreamBits(nb); | 1185 | uint b = StreamBits(nb); |
| 1178 | color_endpoint_data[ced_pointer] = uint(bitfieldExtract(b, 0, 8)); | 1186 | color_endpoint_data[ced_pointer] = uint(bitfieldExtract(b, 0, nb)); |
| 1179 | ced_pointer++; | 1187 | ced_pointer++; |
| 1180 | remaining_bits -= nb; | 1188 | remaining_bits -= nb; |
| 1181 | } | 1189 | } |