From 0a8c413708040eb6d2e85d54faebd1fc341cf7fe Mon Sep 17 00:00:00 2001 From: lizzie Date: Fri, 30 Jan 2026 05:03:40 +0000 Subject: [PATCH] bullshit3 --- src/video_core/host_shaders/CMakeLists.txt | 2 +- src/video_core/host_shaders/astc_decoder.comp | 52 +++++++++---------- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 40fa4968a8..606a2a8202 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt @@ -90,7 +90,7 @@ if ("${GLSLANGVALIDATOR}" STREQUAL "GLSLANGVALIDATOR-NOTFOUND") message(FATAL_ERROR "Required program `glslangValidator` not found.") endif() -set(GLSL_FLAGS "") +set(GLSL_FLAGS "-Os") set(SPIR_V_VERSION "spirv1.3") set(QUIET_FLAG "--quiet") diff --git a/src/video_core/host_shaders/astc_decoder.comp b/src/video_core/host_shaders/astc_decoder.comp index 8f3de1da73..08f79d59a1 100644 --- a/src/video_core/host_shaders/astc_decoder.comp +++ b/src/video_core/host_shaders/astc_decoder.comp @@ -784,34 +784,30 @@ bool IsError(uint mode) { } int FindLayout(uint mode) { - if ((mode & 3) != 0) { - if ((mode & 8) != 0) { - if ((mode & 4) != 0) { - if ((mode & 0x100) != 0) { - return 4; - } - return 3; - } - return 2; - } - if ((mode & 4) != 0) { - return 1; - } - return 0; - } - if ((mode & 0x100) != 0) { - if ((mode & 0x80) != 0) { - if ((mode & 0x20) != 0) { - return 8; - } - return 7; - } - return 9; - } - if ((mode & 0x80) != 0) { - return 6; - } - return 5; + // Possible (Relevant), x = dont care, (in hex) + // Before shift: 02x, 08x, 10x, 00x, 0Ax, 12x, 18x, 1Ax + // After shift: 01, 04, 08, 00, 05, 09, 0c, 0d + // Reassemble and remove middle 0x040 (stupid fucking table) + // 0000 -> 0 0020 -> 1 0040 -> 0 0060 -> 1 + // 0080 -> 2 00a0 -> 3 00c0 -> 2 00e0 -> 3 + // 0100 -> 4 0120 -> 5 0140 -> 4 0160 -> 5 + // 0180 -> 6 01a0 -> 7 01c0 -> 6 01e0 -> 7 + // Key ranges: 01a0 -> 7, 0180 -> 6, 0100 -> 4, 0080 -> 2 + // 8>>2 = 2, 4>>2 = 1 :: () = 0, (4) = 1, (8) = 2, (8,4) = 3 + const uint mask = 0 - uint((mode & 3) != 0); + const uint sh3_mode = (mode >> 2) & 3; + const uint sh0_mode = ((mode >> 6) & 6) | ((mode >> 5) & 1); + const uint fl_const_table = 0 + | ((1) << (2 * 3)) //0080 -> 2, 1 + 5 = 6 + | ((1) << (3 * 3)) + | ((4) << (4 * 3)) //0100 -> 4, 4 + 5 = 9 + | ((4) << (5 * 3)) + | ((2) << (6 * 3)) //0180 -> 6, 2 + 5 = 7 + | ((3) << (7 * 3)) //01a0 -> 7, 3 + 5 = 8 + ; + const uint if_mode3_t = sh3_mode + uint((mode & 0x10c) == 0x10c); + const uint if_mode3_f = 5 + ((fl_const_table >> (sh0_mode * 3)) & 7); + return int((if_mode3_t & mask) | (if_mode3_f & ~mask)); } uvec2 DecodeBlockSize(uint mode_layout, uint mode) {