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