diff options
Diffstat (limited to 'src/video_core/host_shaders')
| -rw-r--r-- | src/video_core/host_shaders/astc_decoder.comp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index fd38dcfe5..5346cba0c 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp | |||
| @@ -21,6 +21,8 @@ | |||
| 21 | 21 | ||
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #define bfe bitfieldExtract | ||
| 25 | |||
| 24 | layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; | 26 | layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; |
| 25 | 27 | ||
| 26 | BEGIN_PUSH_CONSTANTS | 28 | BEGIN_PUSH_CONSTANTS |
| @@ -132,7 +134,7 @@ void ResultEmplaceBack(EncodingData val) { | |||
| 132 | return; | 134 | return; |
| 133 | } | 135 | } |
| 134 | const uint array_index = result_index / 4; | 136 | const uint array_index = result_index / 4; |
| 135 | const uint vector_index = result_index % 4; | 137 | const uint vector_index = bfe(result_index, 0, 2); |
| 136 | result_vector[array_index][vector_index] = val.data; | 138 | result_vector[array_index][vector_index] = val.data; |
| 137 | ++result_index; | 139 | ++result_index; |
| 138 | } | 140 | } |
| @@ -384,7 +386,7 @@ uint StreamColorBits(uint num_bits) { | |||
| 384 | 386 | ||
| 385 | EncodingData GetEncodingFromVector(uint index) { | 387 | EncodingData GetEncodingFromVector(uint index) { |
| 386 | const uint array_index = index / 4; | 388 | const uint array_index = index / 4; |
| 387 | const uint vector_index = index % 4; | 389 | const uint vector_index = bfe(index, 0, 2); |
| 388 | 390 | ||
| 389 | const uint data = result_vector[array_index][vector_index]; | 391 | const uint data = result_vector[array_index][vector_index]; |
| 390 | return EncodingData(data); | 392 | return EncodingData(data); |
| @@ -393,7 +395,7 @@ EncodingData GetEncodingFromVector(uint index) { | |||
| 393 | // Returns the number of bits required to encode n_vals values. | 395 | // Returns the number of bits required to encode n_vals values. |
| 394 | uint GetBitLength(uint n_vals, uint encoding_index) { | 396 | uint GetBitLength(uint n_vals, uint encoding_index) { |
| 395 | const EncodingData encoding_value = | 397 | const EncodingData encoding_value = |
| 396 | EncodingData(encoding_values[encoding_index / 4][encoding_index % 4]); | 398 | EncodingData(encoding_values[encoding_index / 4][bfe(encoding_index, 0, 2)]); |
| 397 | const uint encoding = Encoding(encoding_value); | 399 | const uint encoding = Encoding(encoding_value); |
| 398 | uint total_bits = NumBits(encoding_value) * n_vals; | 400 | uint total_bits = NumBits(encoding_value) * n_vals; |
| 399 | if (encoding == TRIT) { | 401 | if (encoding == TRIT) { |
| @@ -513,7 +515,7 @@ void DecodeTritBlock(uint num_bits) { | |||
| 513 | } | 515 | } |
| 514 | 516 | ||
| 515 | void DecodeIntegerSequence(uint max_range, uint num_values) { | 517 | void DecodeIntegerSequence(uint max_range, uint num_values) { |
| 516 | EncodingData val = EncodingData(encoding_values[max_range / 4][max_range % 4]); | 518 | EncodingData val = EncodingData(encoding_values[max_range / 4][bfe(max_range, 0, 2)]); |
| 517 | const uint encoding = Encoding(val); | 519 | const uint encoding = Encoding(val); |
| 518 | const uint num_bits = NumBits(val); | 520 | const uint num_bits = NumBits(val); |
| 519 | uint vals_decoded = 0; | 521 | uint vals_decoded = 0; |
| @@ -565,7 +567,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) { | |||
| 565 | A = ReplicateBitTo9((bitval & 1)); | 567 | A = ReplicateBitTo9((bitval & 1)); |
| 566 | switch (encoding) { | 568 | switch (encoding) { |
| 567 | case JUST_BITS: | 569 | case JUST_BITS: |
| 568 | color_values[out_index / 4][out_index % 4] = FastReplicateTo8(bitval, bitlen); | 570 | color_values[out_index / 4][bfe(out_index, 0, 2)] = FastReplicateTo8(bitval, bitlen); |
| 569 | ++out_index; | 571 | ++out_index; |
| 570 | break; | 572 | break; |
| 571 | case TRIT: { | 573 | case TRIT: { |
| @@ -645,7 +647,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) { | |||
| 645 | uint T = (D * C) + B; | 647 | uint T = (D * C) + B; |
| 646 | T ^= A; | 648 | T ^= A; |
| 647 | T = (A & 0x80) | (T >> 2); | 649 | T = (A & 0x80) | (T >> 2); |
| 648 | color_values[out_index / 4][out_index % 4] = T; | 650 | color_values[out_index / 4][bfe(out_index, 0, 2)] = T; |
| 649 | ++out_index; | 651 | ++out_index; |
| 650 | } | 652 | } |
| 651 | } | 653 | } |
| @@ -676,14 +678,14 @@ void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode, | |||
| 676 | #define READ_UINT_VALUES(N) \ | 678 | #define READ_UINT_VALUES(N) \ |
| 677 | uint v[N]; \ | 679 | uint v[N]; \ |
| 678 | for (uint i = 0; i < N; i++) { \ | 680 | for (uint i = 0; i < N; i++) { \ |
| 679 | v[i] = color_values[colvals_index / 4][colvals_index % 4]; \ | 681 | v[i] = color_values[colvals_index / 4][bfe(colvals_index, 0, 2)]; \ |
| 680 | ++colvals_index; \ | 682 | ++colvals_index; \ |
| 681 | } | 683 | } |
| 682 | 684 | ||
| 683 | #define READ_INT_VALUES(N) \ | 685 | #define READ_INT_VALUES(N) \ |
| 684 | int v[N]; \ | 686 | int v[N]; \ |
| 685 | for (uint i = 0; i < N; i++) { \ | 687 | for (uint i = 0; i < N; i++) { \ |
| 686 | v[i] = int(color_values[colvals_index / 4][colvals_index % 4]); \ | 688 | v[i] = int(color_values[colvals_index / 4][bfe(colvals_index, 0, 2)]); \ |
| 687 | ++colvals_index; \ | 689 | ++colvals_index; \ |
| 688 | } | 690 | } |
| 689 | 691 | ||
| @@ -894,7 +896,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) { | |||
| 894 | const uint loop_count = min(result_index, area * num_planes); | 896 | const uint loop_count = min(result_index, area * num_planes); |
| 895 | for (uint itr = 0; itr < loop_count; ++itr) { | 897 | for (uint itr = 0; itr < loop_count; ++itr) { |
| 896 | const uint array_index = itr / 4; | 898 | const uint array_index = itr / 4; |
| 897 | const uint vector_index = itr % 4; | 899 | const uint vector_index = bfe(itr, 0, 2); |
| 898 | result_vector[array_index][vector_index] = | 900 | result_vector[array_index][vector_index] = |
| 899 | UnquantizeTexelWeight(GetEncodingFromVector(itr)); | 901 | UnquantizeTexelWeight(GetEncodingFromVector(itr)); |
| 900 | } | 902 | } |
| @@ -921,7 +923,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) { | |||
| 921 | #define VectorIndicesFromBase(offset_base) \ | 923 | #define VectorIndicesFromBase(offset_base) \ |
| 922 | const uint offset = is_dual_plane ? 2 * offset_base + plane : offset_base; \ | 924 | const uint offset = is_dual_plane ? 2 * offset_base + plane : offset_base; \ |
| 923 | const uint array_index = offset / 4; \ | 925 | const uint array_index = offset / 4; \ |
| 924 | const uint vector_index = offset % 4; | 926 | const uint vector_index = bfe(offset, 0, 2); |
| 925 | 927 | ||
| 926 | if (v0 < area) { | 928 | if (v0 < area) { |
| 927 | const uint offset_base = v0; | 929 | const uint offset_base = v0; |
| @@ -945,7 +947,7 @@ void UnquantizeTexelWeights(uvec2 size, bool is_dual_plane) { | |||
| 945 | } | 947 | } |
| 946 | const uint offset = (t * block_dims.x + s) + ARRAY_NUM_ELEMENTS * plane; | 948 | const uint offset = (t * block_dims.x + s) + ARRAY_NUM_ELEMENTS * plane; |
| 947 | const uint array_index = offset / 4; | 949 | const uint array_index = offset / 4; |
| 948 | const uint vector_index = offset % 4; | 950 | const uint vector_index = bfe(offset, 0, 2); |
| 949 | unquantized_texel_weights[array_index][vector_index] = (uint(dot(p, w)) + 8) >> 4; | 951 | unquantized_texel_weights[array_index][vector_index] = (uint(dot(p, w)) + 8) >> 4; |
| 950 | } | 952 | } |
| 951 | } | 953 | } |
| @@ -1249,13 +1251,13 @@ void DecompressBlock(ivec3 coord) { | |||
| 1249 | const uvec4 C1 = ReplicateByteTo16(endpoints1[local_partition]); | 1251 | const uvec4 C1 = ReplicateByteTo16(endpoints1[local_partition]); |
| 1250 | const uint weight_offset = (j * block_dims.x + i); | 1252 | const uint weight_offset = (j * block_dims.x + i); |
| 1251 | const uint array_index = weight_offset / 4; | 1253 | const uint array_index = weight_offset / 4; |
| 1252 | const uint vector_index = weight_offset % 4; | 1254 | const uint vector_index = bfe(weight_offset, 0, 2); |
| 1253 | const uint primary_weight = unquantized_texel_weights[array_index][vector_index]; | 1255 | const uint primary_weight = unquantized_texel_weights[array_index][vector_index]; |
| 1254 | uvec4 weight_vec = uvec4(primary_weight); | 1256 | uvec4 weight_vec = uvec4(primary_weight); |
| 1255 | if (params.dual_plane) { | 1257 | if (params.dual_plane) { |
| 1256 | const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS; | 1258 | const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS; |
| 1257 | const uint secondary_array_index = secondary_weight_offset / 4; | 1259 | const uint secondary_array_index = secondary_weight_offset / 4; |
| 1258 | const uint secondary_vector_index = secondary_weight_offset % 4; | 1260 | const uint secondary_vector_index = bfe(secondary_weight_offset, 0, 2); |
| 1259 | const uint secondary_weight = | 1261 | const uint secondary_weight = |
| 1260 | unquantized_texel_weights[secondary_array_index][secondary_vector_index]; | 1262 | unquantized_texel_weights[secondary_array_index][secondary_vector_index]; |
| 1261 | for (uint c = 0; c < 4; c++) { | 1263 | for (uint c = 0; c < 4; c++) { |