diff options
| author | 2023-08-01 23:33:47 -0400 | |
|---|---|---|
| committer | 2023-08-06 14:54:57 -0400 | |
| commit | 75ac7845ce2f9fe46602eeac03207040659e6bc9 (patch) | |
| tree | fc1b34e89d12782a7047f85ec3a3f150f7b6f042 /src | |
| parent | more packing (diff) | |
| download | yuzu-75ac7845ce2f9fe46602eeac03207040659e6bc9.tar.gz yuzu-75ac7845ce2f9fe46602eeac03207040659e6bc9.tar.xz yuzu-75ac7845ce2f9fe46602eeac03207040659e6bc9.zip | |
error/void extent funcs
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/host_shaders/astc_decoder.comp | 91 |
1 files changed, 43 insertions, 48 deletions
diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index 0e611ede5..63b3d9f44 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp | |||
| @@ -40,9 +40,6 @@ struct TexelWeightParams { | |||
| 40 | uvec2 size; | 40 | uvec2 size; |
| 41 | uint max_weight; | 41 | uint max_weight; |
| 42 | bool dual_plane; | 42 | bool dual_plane; |
| 43 | bool error_state; | ||
| 44 | bool void_extent_ldr; | ||
| 45 | bool void_extent_hdr; | ||
| 46 | }; | 43 | }; |
| 47 | 44 | ||
| 48 | layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 { | 45 | layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 { |
| @@ -983,28 +980,54 @@ int FindLayout(uint mode) { | |||
| 983 | return 5; | 980 | return 5; |
| 984 | } | 981 | } |
| 985 | 982 | ||
| 986 | TexelWeightParams DecodeBlockInfo() { | 983 | |
| 987 | TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false, false, false, false); | 984 | void FillError(ivec3 coord) { |
| 988 | uint mode = StreamBits(11); | 985 | for (uint j = 0; j < block_dims.y; j++) { |
| 986 | for (uint i = 0; i < block_dims.x; i++) { | ||
| 987 | imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0)); | ||
| 988 | } | ||
| 989 | } | ||
| 990 | } | ||
| 991 | |||
| 992 | void FillVoidExtentLDR(ivec3 coord) { | ||
| 993 | SkipBits(52); | ||
| 994 | const uint r_u = StreamBits(16); | ||
| 995 | const uint g_u = StreamBits(16); | ||
| 996 | const uint b_u = StreamBits(16); | ||
| 997 | const uint a_u = StreamBits(16); | ||
| 998 | const float a = float(a_u) / 65535.0f; | ||
| 999 | const float r = float(r_u) / 65535.0f; | ||
| 1000 | const float g = float(g_u) / 65535.0f; | ||
| 1001 | const float b = float(b_u) / 65535.0f; | ||
| 1002 | for (uint j = 0; j < block_dims.y; j++) { | ||
| 1003 | for (uint i = 0; i < block_dims.x; i++) { | ||
| 1004 | imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a)); | ||
| 1005 | } | ||
| 1006 | } | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | bool IsError(uint mode) { | ||
| 989 | if ((mode & 0x1ff) == 0x1fc) { | 1010 | if ((mode & 0x1ff) == 0x1fc) { |
| 990 | if ((mode & 0x200) != 0) { | 1011 | if ((mode & 0x200) != 0) { |
| 991 | params.void_extent_hdr = true; | 1012 | // params.void_extent_hdr = true; |
| 992 | } else { | 1013 | return true; |
| 993 | params.void_extent_ldr = true; | ||
| 994 | } | 1014 | } |
| 995 | if ((mode & 0x400) == 0 || StreamBits(1) == 0) { | 1015 | if ((mode & 0x400) == 0 || StreamBits(1) == 0) { |
| 996 | params.error_state = true; | 1016 | return true; |
| 997 | } | 1017 | } |
| 998 | return params; | 1018 | return false; |
| 999 | } | 1019 | } |
| 1000 | if ((mode & 0xf) == 0) { | 1020 | if ((mode & 0xf) == 0) { |
| 1001 | params.error_state = true; | 1021 | return true; |
| 1002 | return params; | ||
| 1003 | } | 1022 | } |
| 1004 | if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) { | 1023 | if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) { |
| 1005 | params.error_state = true; | 1024 | return true; |
| 1006 | return params; | ||
| 1007 | } | 1025 | } |
| 1026 | return false; | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | TexelWeightParams DecodeBlockInfo(uint mode) { | ||
| 1030 | TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false); | ||
| 1008 | uint A, B; | 1031 | uint A, B; |
| 1009 | uint mode_layout = FindLayout(mode); | 1032 | uint mode_layout = FindLayout(mode); |
| 1010 | switch (mode_layout) { | 1033 | switch (mode_layout) { |
| @@ -1053,7 +1076,6 @@ TexelWeightParams DecodeBlockInfo() { | |||
| 1053 | params.size = uvec2(A + 6, B + 6); | 1076 | params.size = uvec2(A + 6, B + 6); |
| 1054 | break; | 1077 | break; |
| 1055 | default: | 1078 | default: |
| 1056 | params.error_state = true; | ||
| 1057 | break; | 1079 | break; |
| 1058 | } | 1080 | } |
| 1059 | params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0); | 1081 | params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0); |
| @@ -1072,42 +1094,15 @@ TexelWeightParams DecodeBlockInfo() { | |||
| 1072 | return params; | 1094 | return params; |
| 1073 | } | 1095 | } |
| 1074 | 1096 | ||
| 1075 | void FillError(ivec3 coord) { | ||
| 1076 | for (uint j = 0; j < block_dims.y; j++) { | ||
| 1077 | for (uint i = 0; i < block_dims.x; i++) { | ||
| 1078 | imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0)); | ||
| 1079 | } | ||
| 1080 | } | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | void FillVoidExtentLDR(ivec3 coord) { | ||
| 1084 | SkipBits(52); | ||
| 1085 | const uint r_u = StreamBits(16); | ||
| 1086 | const uint g_u = StreamBits(16); | ||
| 1087 | const uint b_u = StreamBits(16); | ||
| 1088 | const uint a_u = StreamBits(16); | ||
| 1089 | const float a = float(a_u) / 65535.0f; | ||
| 1090 | const float r = float(r_u) / 65535.0f; | ||
| 1091 | const float g = float(g_u) / 65535.0f; | ||
| 1092 | const float b = float(b_u) / 65535.0f; | ||
| 1093 | for (uint j = 0; j < block_dims.y; j++) { | ||
| 1094 | for (uint i = 0; i < block_dims.x; i++) { | ||
| 1095 | imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a)); | ||
| 1096 | } | ||
| 1097 | } | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | void DecompressBlock(ivec3 coord) { | 1097 | void DecompressBlock(ivec3 coord) { |
| 1101 | const TexelWeightParams params = DecodeBlockInfo(); | 1098 | uint mode = StreamBits(11); |
| 1102 | if (params.error_state) { | 1099 | const TexelWeightParams params = DecodeBlockInfo(mode); |
| 1103 | FillError(coord); | 1100 | if (IsError(mode)) { |
| 1104 | return; | ||
| 1105 | } | ||
| 1106 | if (params.void_extent_hdr) { | ||
| 1107 | FillError(coord); | 1101 | FillError(coord); |
| 1108 | return; | 1102 | return; |
| 1109 | } | 1103 | } |
| 1110 | if (params.void_extent_ldr) { | 1104 | if ((mode & 0x1ff) == 0x1fc) { |
| 1105 | // params.void_extent_ldr = true; | ||
| 1111 | FillVoidExtentLDR(coord); | 1106 | FillVoidExtentLDR(coord); |
| 1112 | return; | 1107 | return; |
| 1113 | } | 1108 | } |