Ameer J 3 лет назад
Родитель
Сommit
75ac7845ce
1 измененных файлов с 43 добавлено и 48 удалено
  1. 43 48
      src/video_core/host_shaders/astc_decoder.comp

+ 43 - 48
src/video_core/host_shaders/astc_decoder.comp

@@ -40,9 +40,6 @@ struct TexelWeightParams {
     uvec2 size;
     uvec2 size;
     uint max_weight;
     uint max_weight;
     bool dual_plane;
     bool dual_plane;
-    bool error_state;
-    bool void_extent_ldr;
-    bool void_extent_hdr;
 };
 };
 
 
 layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 {
 layout(binding = BINDING_INPUT_BUFFER, std430) readonly restrict buffer InputBufferU32 {
@@ -983,28 +980,54 @@ int FindLayout(uint mode) {
     return 5;
     return 5;
 }
 }
 
 
-TexelWeightParams DecodeBlockInfo() {
-    TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false, false, false, false);
-    uint mode = StreamBits(11);
+
+void FillError(ivec3 coord) {
+    for (uint j = 0; j < block_dims.y; j++) {
+        for (uint i = 0; i < block_dims.x; i++) {
+            imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0));
+        }
+    }
+}
+
+void FillVoidExtentLDR(ivec3 coord) {
+    SkipBits(52);
+    const uint r_u = StreamBits(16);
+    const uint g_u = StreamBits(16);
+    const uint b_u = StreamBits(16);
+    const uint a_u = StreamBits(16);
+    const float a = float(a_u) / 65535.0f;
+    const float r = float(r_u) / 65535.0f;
+    const float g = float(g_u) / 65535.0f;
+    const float b = float(b_u) / 65535.0f;
+    for (uint j = 0; j < block_dims.y; j++) {
+        for (uint i = 0; i < block_dims.x; i++) {
+            imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a));
+        }
+    }
+}
+
+bool IsError(uint mode) {
     if ((mode & 0x1ff) == 0x1fc) {
     if ((mode & 0x1ff) == 0x1fc) {
         if ((mode & 0x200) != 0) {
         if ((mode & 0x200) != 0) {
-            params.void_extent_hdr = true;
-        } else {
-            params.void_extent_ldr = true;
+            // params.void_extent_hdr = true;
+            return true;
         }
         }
         if ((mode & 0x400) == 0 || StreamBits(1) == 0) {
         if ((mode & 0x400) == 0 || StreamBits(1) == 0) {
-            params.error_state = true;
+            return true;
         }
         }
-        return params;
+        return false;
     }
     }
     if ((mode & 0xf) == 0) {
     if ((mode & 0xf) == 0) {
-        params.error_state = true;
-        return params;
+        return true;
     }
     }
     if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) {
     if ((mode & 3) == 0 && (mode & 0x1c0) == 0x1c0) {
-        params.error_state = true;
-        return params;
+        return true;
     }
     }
+    return false;
+}
+
+TexelWeightParams DecodeBlockInfo(uint mode) {
+    TexelWeightParams params = TexelWeightParams(uvec2(0), 0, false);
     uint A, B;
     uint A, B;
     uint mode_layout = FindLayout(mode);
     uint mode_layout = FindLayout(mode);
     switch (mode_layout) {
     switch (mode_layout) {
@@ -1053,7 +1076,6 @@ TexelWeightParams DecodeBlockInfo() {
         params.size = uvec2(A + 6, B + 6);
         params.size = uvec2(A + 6, B + 6);
         break;
         break;
     default:
     default:
-        params.error_state = true;
         break;
         break;
     }
     }
     params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0);
     params.dual_plane = (mode_layout != 9) && ((mode & 0x400) != 0);
@@ -1072,42 +1094,15 @@ TexelWeightParams DecodeBlockInfo() {
     return params;
     return params;
 }
 }
 
 
-void FillError(ivec3 coord) {
-    for (uint j = 0; j < block_dims.y; j++) {
-        for (uint i = 0; i < block_dims.x; i++) {
-            imageStore(dest_image, coord + ivec3(i, j, 0), vec4(0.0, 0.0, 0.0, 0.0));
-        }
-    }
-}
-
-void FillVoidExtentLDR(ivec3 coord) {
-    SkipBits(52);
-    const uint r_u = StreamBits(16);
-    const uint g_u = StreamBits(16);
-    const uint b_u = StreamBits(16);
-    const uint a_u = StreamBits(16);
-    const float a = float(a_u) / 65535.0f;
-    const float r = float(r_u) / 65535.0f;
-    const float g = float(g_u) / 65535.0f;
-    const float b = float(b_u) / 65535.0f;
-    for (uint j = 0; j < block_dims.y; j++) {
-        for (uint i = 0; i < block_dims.x; i++) {
-            imageStore(dest_image, coord + ivec3(i, j, 0), vec4(r, g, b, a));
-        }
-    }
-}
-
 void DecompressBlock(ivec3 coord) {
 void DecompressBlock(ivec3 coord) {
-    const TexelWeightParams params = DecodeBlockInfo();
-    if (params.error_state) {
-        FillError(coord);
-        return;
-    }
-    if (params.void_extent_hdr) {
+    uint mode = StreamBits(11);
+    const TexelWeightParams params = DecodeBlockInfo(mode);
+    if (IsError(mode)) {
         FillError(coord);
         FillError(coord);
         return;
         return;
     }
     }
-    if (params.void_extent_ldr) {
+    if ((mode & 0x1ff) == 0x1fc) {
+        // params.void_extent_ldr = true;
         FillVoidExtentLDR(coord);
         FillVoidExtentLDR(coord);
         return;
         return;
     }
     }