summaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorGravatar Ameer J2023-08-09 18:45:52 -0400
committerGravatar Ameer J2023-08-09 18:45:52 -0400
commit5c25712af9530dfd27960036141989a6c2f0c3bc (patch)
tree51301d49759708b1d1d5181e917fbc1655393c0e /src/video_core/host_shaders
parentflatten encoding_values (diff)
downloadyuzu-5c25712af9530dfd27960036141989a6c2f0c3bc.tar.gz
yuzu-5c25712af9530dfd27960036141989a6c2f0c3bc.tar.xz
yuzu-5c25712af9530dfd27960036141989a6c2f0c3bc.zip
flatten color_values
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/astc_decoder.comp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp
index a5d9c97b4..5ff17cd0c 100644
--- a/src/video_core/host_shaders/astc_decoder.comp
+++ b/src/video_core/host_shaders/astc_decoder.comp
@@ -457,8 +457,7 @@ void DecodeIntegerSequence(uint max_range, uint num_values) {
457 } 457 }
458} 458}
459 459
460uvec4 color_values[8]; 460void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits, out uint color_values[32]) {
461void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
462 uint num_values = 0; 461 uint num_values = 0;
463 for (uint i = 0; i < num_partitions; i++) { 462 for (uint i = 0; i < num_partitions; i++) {
464 num_values += ((modes[i] >> 2) + 1) << 1; 463 num_values += ((modes[i] >> 2) + 1) << 1;
@@ -486,8 +485,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
486 A = ReplicateBitTo9((bitval & 1)); 485 A = ReplicateBitTo9((bitval & 1));
487 switch (encoding) { 486 switch (encoding) {
488 case JUST_BITS: 487 case JUST_BITS:
489 color_values[out_index / 4][out_index % 4] = FastReplicateTo8(bitval, bitlen); 488 color_values[++out_index] = FastReplicateTo8(bitval, bitlen);
490 ++out_index;
491 break; 489 break;
492 case TRIT: { 490 case TRIT: {
493 D = QuintTritValue(val); 491 D = QuintTritValue(val);
@@ -566,8 +564,7 @@ void DecodeColorValues(uvec4 modes, uint num_partitions, uint color_data_bits) {
566 uint T = (D * C) + B; 564 uint T = (D * C) + B;
567 T ^= A; 565 T ^= A;
568 T = (A & 0x80) | (T >> 2); 566 T = (A & 0x80) | (T >> 2);
569 color_values[out_index / 4][out_index % 4] = T; 567 color_values[++out_index] = T;
570 ++out_index;
571 } 568 }
572 } 569 }
573} 570}
@@ -592,19 +589,17 @@ ivec4 BlueContract(int a, int r, int g, int b) {
592 return ivec4(a, (r + b) >> 1, (g + b) >> 1, b); 589 return ivec4(a, (r + b) >> 1, (g + b) >> 1, b);
593} 590}
594 591
595void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode, 592void ComputeEndpoints(out uvec4 ep1, out uvec4 ep2, uint color_endpoint_mode, uint color_values[32],
596 inout uint colvals_index) { 593 inout uint colvals_index) {
597#define READ_UINT_VALUES(N) \ 594#define READ_UINT_VALUES(N) \
598 uvec4 V[2]; \ 595 uvec4 V[2]; \
599 for (uint i = 0; i < N; i++) { \ 596 for (uint i = 0; i < N; i++) { \
600 V[i / 4][i % 4] = color_values[colvals_index / 4][colvals_index % 4]; \ 597 V[i / 4][i % 4] = color_values[++colvals_index]; \
601 ++colvals_index; \
602 } 598 }
603#define READ_INT_VALUES(N) \ 599#define READ_INT_VALUES(N) \
604 ivec4 V[2]; \ 600 ivec4 V[2]; \
605 for (uint i = 0; i < N; i++) { \ 601 for (uint i = 0; i < N; i++) { \
606 V[i / 4][i % 4] = int(color_values[colvals_index / 4][colvals_index % 4]); \ 602 V[i / 4][i % 4] = int(color_values[++colvals_index]); \
607 ++colvals_index; \
608 } 603 }
609 604
610 switch (color_endpoint_mode) { 605 switch (color_endpoint_mode) {
@@ -1111,11 +1106,11 @@ void DecompressBlock(ivec3 coord) {
1111 { 1106 {
1112 // This decode phase should at most push 32 elements into the vector 1107 // This decode phase should at most push 32 elements into the vector
1113 result_vector_max_index = 32; 1108 result_vector_max_index = 32;
1114 1109 uint color_values[32];
1115 uint colvals_index = 0; 1110 uint colvals_index = 0;
1116 DecodeColorValues(color_endpoint_mode, num_partitions, color_data_bits); 1111 DecodeColorValues(color_endpoint_mode, num_partitions, color_data_bits, color_values);
1117 for (uint i = 0; i < num_partitions; i++) { 1112 for (uint i = 0; i < num_partitions; i++) {
1118 ComputeEndpoints(endpoints0[i], endpoints1[i], color_endpoint_mode[i], 1113 ComputeEndpoints(endpoints0[i], endpoints1[i], color_endpoint_mode[i], color_values,
1119 colvals_index); 1114 colvals_index);
1120 } 1115 }
1121 } 1116 }