mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Refactor] (MG_Util/ShaderTranspiler): replace Photon shared vec3 regex hack with SPIR-V pass
Replace the application-specific PackPhotonSharedVec3Memory GLSL regex patch with a general DecomposeWorkgroupVec3Pass SPIR-V optimization pass. The new pass decomposes vec3/ivec3/uvec3/bvec3 Workgroup (shared) memory variables into scalar arrays (e.g. shared vec3 arr[N][M] -> shared float arr[N][M][3]), rewriting whole-vector loads/stores into per-component scalar loads/stores. Component-level accesses (e.g. arr[i].x) are unchanged since a trailing component index into a float[3] yields the same scalar pointer as it did for a vec3. Unlike the regex hack, the pass is application-agnostic: it does not match on variable names, array dimensions, or shader pack identity, and runs at the SPIR-V level before SPIRV-Cross decompilation. Registered in SanitizeAndOptimizeBinary after AggressiveDCE so dead workgroup accesses are already eliminated. Asserts on unsupported OpAtomic*/OpCopyMemory targeting vec3 workgroup pointers. Adds ProgramUtilTest.DecomposeWorkgroupVec3InSpirvPass covering array declaration, +=, whole load/store, component access, and row-copy loop.
This commit is contained in:
@@ -186,6 +186,7 @@ set(SOURCE_FILES
|
||||
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/FlattenInterfaceStructPass.cpp
|
||||
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/EliminateFloatEqualsZeroPass.cpp
|
||||
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/RenameSamplerFunctionParameterPass.cpp
|
||||
MobileGL/MG_Util/ShaderTranspiler/SpirvPasses/DecomposeWorkgroupVec3Pass.cpp
|
||||
|
||||
MobileGL/MG_Util/BackendLoaders/OpenGL/Loader.cpp
|
||||
MobileGL/MG_Util/BackendLoaders/Vulkan/Loader.cpp
|
||||
|
||||
Reference in New Issue
Block a user