diff options
| -rw-r--r-- | src/video_core/host_shaders/astc_decoder.comp | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index f34c5f5d9..3a10578cb 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp | |||
| @@ -155,9 +155,6 @@ uint SwizzleOffset(uvec2 pos) { | |||
| 155 | // Replicates low num_bits such that [(to_bit - 1):(to_bit - 1 - from_bit)] | 155 | // Replicates low num_bits such that [(to_bit - 1):(to_bit - 1 - from_bit)] |
| 156 | // is the same as [(num_bits - 1):0] and repeats all the way down. | 156 | // is the same as [(num_bits - 1):0] and repeats all the way down. |
| 157 | uint Replicate(uint val, uint num_bits, uint to_bit) { | 157 | uint Replicate(uint val, uint num_bits, uint to_bit) { |
| 158 | if (num_bits == 0 || to_bit == 0) { | ||
| 159 | return 0; | ||
| 160 | } | ||
| 161 | const uint v = val & uint((1 << num_bits) - 1); | 158 | const uint v = val & uint((1 << num_bits) - 1); |
| 162 | uint res = v; | 159 | uint res = v; |
| 163 | uint reslen = num_bits; | 160 | uint reslen = num_bits; |
| @@ -187,42 +184,57 @@ uint ReplicateBitTo9(uint value) { | |||
| 187 | return REPLICATE_1_BIT_TO_9_TABLE[value]; | 184 | return REPLICATE_1_BIT_TO_9_TABLE[value]; |
| 188 | } | 185 | } |
| 189 | 186 | ||
| 190 | uint FastReplicateTo8(uint value, uint num_bits) { | 187 | uint FastReplicate(uint value, uint num_bits, uint to_bit) { |
| 191 | switch (num_bits) { | 188 | if (num_bits == 0) { |
| 192 | case 1: | 189 | return 0; |
| 193 | return REPLICATE_1_BIT_TO_8_TABLE[value]; | 190 | } |
| 194 | case 2: | 191 | if (num_bits == to_bit) { |
| 195 | return REPLICATE_2_BIT_TO_8_TABLE[value]; | ||
| 196 | case 3: | ||
| 197 | return REPLICATE_3_BIT_TO_8_TABLE[value]; | ||
| 198 | case 4: | ||
| 199 | return REPLICATE_4_BIT_TO_8_TABLE[value]; | ||
| 200 | case 5: | ||
| 201 | return REPLICATE_5_BIT_TO_8_TABLE[value]; | ||
| 202 | case 6: | ||
| 203 | return REPLICATE_6_BIT_TO_8_TABLE[value]; | ||
| 204 | case 7: | ||
| 205 | return REPLICATE_7_BIT_TO_8_TABLE[value]; | ||
| 206 | case 8: | ||
| 207 | return value; | 192 | return value; |
| 208 | } | 193 | } |
| 209 | return Replicate(value, num_bits, 8); | 194 | if (to_bit == 6) { |
| 195 | switch (num_bits) { | ||
| 196 | case 1: | ||
| 197 | return REPLICATE_1_BIT_TO_6_TABLE[value]; | ||
| 198 | case 2: | ||
| 199 | return REPLICATE_2_BIT_TO_6_TABLE[value]; | ||
| 200 | case 3: | ||
| 201 | return REPLICATE_3_BIT_TO_6_TABLE[value]; | ||
| 202 | case 4: | ||
| 203 | return REPLICATE_4_BIT_TO_6_TABLE[value]; | ||
| 204 | case 5: | ||
| 205 | return REPLICATE_5_BIT_TO_6_TABLE[value]; | ||
| 206 | default: | ||
| 207 | break; | ||
| 208 | } | ||
| 209 | } else { /* if (to_bit == 8) */ | ||
| 210 | switch (num_bits) { | ||
| 211 | case 1: | ||
| 212 | return REPLICATE_1_BIT_TO_8_TABLE[value]; | ||
| 213 | case 2: | ||
| 214 | return REPLICATE_2_BIT_TO_8_TABLE[value]; | ||
| 215 | case 3: | ||
| 216 | return REPLICATE_3_BIT_TO_8_TABLE[value]; | ||
| 217 | case 4: | ||
| 218 | return REPLICATE_4_BIT_TO_8_TABLE[value]; | ||
| 219 | case 5: | ||
| 220 | return REPLICATE_5_BIT_TO_8_TABLE[value]; | ||
| 221 | case 6: | ||
| 222 | return REPLICATE_6_BIT_TO_8_TABLE[value]; | ||
| 223 | case 7: | ||
| 224 | return REPLICATE_7_BIT_TO_8_TABLE[value]; | ||
| 225 | default: | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | } | ||
| 229 | return Replicate(value, num_bits, to_bit); | ||
| 230 | } | ||
| 231 | |||
| 232 | uint FastReplicateTo8(uint value, uint num_bits) { | ||
| 233 | return FastReplicate(value, num_bits, 8); | ||
| 210 | } | 234 | } |
| 211 | 235 | ||
| 212 | uint FastReplicateTo6(uint value, uint num_bits) { | 236 | uint FastReplicateTo6(uint value, uint num_bits) { |
| 213 | switch (num_bits) { | 237 | return FastReplicate(value, num_bits, 6); |
| 214 | case 1: | ||
| 215 | return REPLICATE_1_BIT_TO_6_TABLE[value]; | ||
| 216 | case 2: | ||
| 217 | return REPLICATE_2_BIT_TO_6_TABLE[value]; | ||
| 218 | case 3: | ||
| 219 | return REPLICATE_3_BIT_TO_6_TABLE[value]; | ||
| 220 | case 4: | ||
| 221 | return REPLICATE_4_BIT_TO_6_TABLE[value]; | ||
| 222 | case 5: | ||
| 223 | return REPLICATE_5_BIT_TO_6_TABLE[value]; | ||
| 224 | } | ||
| 225 | return Replicate(value, num_bits, 6); | ||
| 226 | } | 238 | } |
| 227 | 239 | ||
| 228 | uint Div3Floor(uint v) { | 240 | uint Div3Floor(uint v) { |