summaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorGravatar Ameer J2023-08-01 23:41:46 -0400
committerGravatar Ameer J2023-08-06 14:54:57 -0400
commitfd2051b401bf0469bf199ce972289abad8087620 (patch)
treecf2dbb2b27cc75eaa63f955c9eba992ff1e31596 /src/video_core/host_shaders
parenterror/void extent funcs (diff)
downloadyuzu-fd2051b401bf0469bf199ce972289abad8087620.tar.gz
yuzu-fd2051b401bf0469bf199ce972289abad8087620.tar.xz
yuzu-fd2051b401bf0469bf199ce972289abad8087620.zip
remove TexelWeightParams
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/astc_decoder.comp77
1 files changed, 31 insertions, 46 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp
index 63b3d9f44..f497c4d17 100644
--- a/src/video_core/host_shaders/astc_decoder.comp
+++ b/src/video_core/host_shaders/astc_decoder.comp
@@ -36,12 +36,6 @@ struct EncodingData {
36 uint data; 36 uint data;
37}; 37};
38 38
39struct TexelWeightParams {
40 uvec2 size;
41 uint max_weight;
42 bool dual_plane;
43};
44
45layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 { 39layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 {
46 uvec4 astc_data[]; 40 uvec4 astc_data[];
47}; 41};
@@ -1026,59 +1020,50 @@ bool IsError(uint mode) {
1026 return false; 1020 return false;
1027} 1021}
1028 1022
1029TexelWeightParams DecodeBlockInfo(uint mode) { 1023uvec2 DecodeBlockSize(uint mode) {
1030 TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false);
1031 uint A, B; 1024 uint A, B;
1032 uint mode_layout = FindLayout(mode); 1025 switch (FindLayout(mode)) {
1033 switch (mode_layout) {
1034 case 0: 1026 case 0:
1035 A = (mode >> 5) & 0x3; 1027 A = (mode >> 5) & 0x3;
1036 B = (mode >> 7) & 0x3; 1028 B = (mode >> 7) & 0x3;
1037 params.size = uvec2(B + 4, A + 2); 1029 return uvec2(B + 4, A + 2);
1038 break;
1039 case 1: 1030 case 1:
1040 A = (mode >> 5) & 0x3; 1031 A = (mode >> 5) & 0x3;
1041 B = (mode >> 7) & 0x3; 1032 B = (mode >> 7) & 0x3;
1042 params.size = uvec2(B + 8, A + 2); 1033 return uvec2(B + 8, A + 2);
1043 break;
1044 case 2: 1034 case 2:
1045 A = (mode >> 5) & 0x3; 1035 A = (mode >> 5) & 0x3;
1046 B = (mode >> 7) & 0x3; 1036 B = (mode >> 7) & 0x3;
1047 params.size = uvec2(A + 2, B + 8); 1037 return uvec2(A + 2, B + 8);
1048 break;
1049 case 3: 1038 case 3:
1050 A = (mode >> 5) & 0x3; 1039 A = (mode >> 5) & 0x3;
1051 B = (mode >> 7) & 0x1; 1040 B = (mode >> 7) & 0x1;
1052 params.size = uvec2(A + 2, B + 6); 1041 return uvec2(A + 2, B + 6);
1053 break;
1054 case 4: 1042 case 4:
1055 A = (mode >> 5) & 0x3; 1043 A = (mode >> 5) & 0x3;
1056 B = (mode >> 7) & 0x1; 1044 B = (mode >> 7) & 0x1;
1057 params.size = uvec2(B + 2, A + 2); 1045 return uvec2(B + 2, A + 2);
1058 break;
1059 case 5: 1046 case 5:
1060 A = (mode >> 5) & 0x3; 1047 A = (mode >> 5) & 0x3;
1061 params.size = uvec2(12, A + 2); 1048 return uvec2(12, A + 2);
1062 break;
1063 case 6: 1049 case 6:
1064 A = (mode >> 5) & 0x3; 1050 A = (mode >> 5) & 0x3;
1065 params.size = uvec2(A + 2, 12); 1051 return uvec2(A + 2, 12);
1066 break;
1067 case 7: 1052 case 7:
1068 params.size = uvec2(6, 10); 1053 return uvec2(6, 10);
1069 break;
1070 case 8: 1054 case 8:
1071 params.size = uvec2(10, 6); 1055 return uvec2(10, 6);
1072 break;
1073 case 9: 1056 case 9:
1074 A = (mode >> 5) & 0x3; 1057 A = (mode >> 5) & 0x3;
1075 B = (mode >> 9) & 0x3; 1058 B = (mode >> 9) & 0x3;
1076 params.size = uvec2(A + 6, B + 6); 1059 return uvec2(A + 6, B + 6);
1077 break;
1078 default: 1060 default:
1079 break; 1061 return uvec2(0);
1080 } 1062 }
1081 params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0); 1063}
1064
1065uint DecodeMaxWeight(uint mode) {
1066 const uint mode_layout = FindLayout(mode);
1082 uint weight_index = (mode & 0x10) != 0 ? 1 : 0; 1067 uint weight_index = (mode & 0x10) != 0 ? 1 : 0;
1083 if (mode_layout < 5) { 1068 if (mode_layout < 5) {
1084 weight_index |= (mode & 0x3) << 1; 1069 weight_index |= (mode & 0x3) << 1;
@@ -1089,14 +1074,11 @@ TexelWeightParams DecodeBlockInfo(uint mode) {
1089 if ((mode_layout != 9) && ((mode & 0x200) != 0)) { 1074 if ((mode_layout != 9) && ((mode & 0x200) != 0)) {
1090 weight_index += 6; 1075 weight_index += 6;
1091 } 1076 }
1092 params.max_weight = weight_index + 1; 1077 return weight_index + 1;
1093
1094 return params;
1095} 1078}
1096 1079
1097void DecompressBlock(ivec3 coord) { 1080void DecompressBlock(ivec3 coord) {
1098 uint mode = StreamBits(11); 1081 uint mode = StreamBits(11);
1099 const TexelWeightParams params = DecodeBlockInfo(mode);
1100 if (IsError(mode)) { 1082 if (IsError(mode)) {
1101 FillError(coord); 1083 FillError(coord);
1102 return; 1084 return;
@@ -1106,12 +1088,15 @@ void DecompressBlock(ivec3 coord) {
1106 FillVoidExtentLDR(coord); 1088 FillVoidExtentLDR(coord);
1107 return; 1089 return;
1108 } 1090 }
1109 if ((params.size.x > block_dims.x) || (params.size.y > block_dims.y)) { 1091 const uvec2 size_params = DecodeBlockSize(mode);
1092 if ((size_params.x > block_dims.x) || (size_params.y > block_dims.y)) {
1110 FillError(coord); 1093 FillError(coord);
1111 return; 1094 return;
1112 } 1095 }
1113 const uint num_partitions = StreamBits(2) + 1; 1096 const uint num_partitions = StreamBits(2) + 1;
1114 if (num_partitions > 4 || (num_partitions == 4 && params.dual_plane)) { 1097 const uint mode_layout = FindLayout(mode);
1098 const bool dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0);
1099 if (num_partitions > 4 || (num_partitions == 4 && dual_plane)) {
1115 FillError(coord); 1100 FillError(coord);
1116 return; 1101 return;
1117 } 1102 }
@@ -1127,7 +1112,8 @@ void DecompressBlock(ivec3 coord) {
1127 base_cem = StreamBits(6); 1112 base_cem = StreamBits(6);
1128 } 1113 }
1129 const uint base_mode = base_cem & 3; 1114 const uint base_mode = base_cem & 3;
1130 const uint weight_bits = GetPackedBitSize(params.size, params.dual_plane, params.max_weight); 1115 const uint max_weight = DecodeMaxWeight(mode);
1116 const uint weight_bits = GetPackedBitSize(size_params, dual_plane, max_weight);
1131 uint remaining_bits = 128 - weight_bits - total_bitsread; 1117 uint remaining_bits = 128 - weight_bits - total_bitsread;
1132 uint extra_cem_bits = 0; 1118 uint extra_cem_bits = 0;
1133 if (base_mode > 0) { 1119 if (base_mode > 0) {
@@ -1146,7 +1132,7 @@ void DecompressBlock(ivec3 coord) {
1146 } 1132 }
1147 } 1133 }
1148 remaining_bits -= extra_cem_bits; 1134 remaining_bits -= extra_cem_bits;
1149 const uint plane_selector_bits = params.dual_plane ? 2 : 0; 1135 const uint plane_selector_bits = dual_plane ? 2 : 0;
1150 remaining_bits -= plane_selector_bits; 1136 remaining_bits -= plane_selector_bits;
1151 if (remaining_bits > 128) { 1137 if (remaining_bits > 128) {
1152 // Bad data, more remaining bits than 4 bytes 1138 // Bad data, more remaining bits than 4 bytes
@@ -1198,7 +1184,6 @@ void DecompressBlock(ivec3 coord) {
1198 // This decode phase should at most push 32 elements into the vector 1184 // This decode phase should at most push 32 elements into the vector
1199 result_vector_max_index = 32; 1185 result_vector_max_index = 32;
1200 1186
1201 // uvec4 color_values[8];
1202 uint colvals_index = 0; 1187 uint colvals_index = 0;
1203 DecodeColorValues(color_endpoint_mode, num_partitions, color_data_bits); 1188 DecodeColorValues(color_endpoint_mode, num_partitions, color_data_bits);
1204 for (uint i = 0; i < num_partitions; i++) { 1189 for (uint i = 0; i < num_partitions; i++) {
@@ -1226,13 +1211,13 @@ void DecompressBlock(ivec3 coord) {
1226 result_limit_reached = false; 1211 result_limit_reached = false;
1227 1212
1228 // The limit for the Unquantize phase, avoids decoding more data than needed. 1213 // The limit for the Unquantize phase, avoids decoding more data than needed.
1229 result_vector_max_index = params.size.x * params.size.y; 1214 result_vector_max_index = size_params.x * size_params.y;
1230 if (params.dual_plane) { 1215 if (dual_plane) {
1231 result_vector_max_index *= 2; 1216 result_vector_max_index *= 2;
1232 } 1217 }
1233 DecodeIntegerSequence(params.max_weight, GetNumWeightValues(params.size, params.dual_plane)); 1218 DecodeIntegerSequence(max_weight, GetNumWeightValues(size_params, dual_plane));
1234 1219
1235 UnquantizeTexelWeights(params.size, params.dual_plane); 1220 UnquantizeTexelWeights(size_params, dual_plane);
1236 for (uint j = 0; j < block_dims.y; j++) { 1221 for (uint j = 0; j < block_dims.y; j++) {
1237 for (uint i = 0; i < block_dims.x; i++) { 1222 for (uint i = 0; i < block_dims.x; i++) {
1238 uint local_partition = 0; 1223 uint local_partition = 0;
@@ -1247,7 +1232,7 @@ void DecompressBlock(ivec3 coord) {
1247 const uint vector_index = weight_offset % 4; 1232 const uint vector_index = weight_offset % 4;
1248 const uint primary_weight = unquantized_texel_weights[array_index][vector_index]; 1233 const uint primary_weight = unquantized_texel_weights[array_index][vector_index];
1249 uvec4 weight_vec = uvec4(primary_weight); 1234 uvec4 weight_vec = uvec4(primary_weight);
1250 if (params.dual_plane) { 1235 if (dual_plane) {
1251 const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS; 1236 const uint secondary_weight_offset = (j * block_dims.x + i) + ARRAY_NUM_ELEMENTS;
1252 const uint secondary_array_index = secondary_weight_offset / 4; 1237 const uint secondary_array_index = secondary_weight_offset / 4;
1253 const uint secondary_vector_index = secondary_weight_offset % 4; 1238 const uint secondary_vector_index = secondary_weight_offset % 4;