From e38be0dbf5816338ff97e2ee2f9adfff2902dc2b Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 15:13:09 +0100 Subject: refactor(wgsl): modularize common shader functions Extracted common WGSL functions into separate files in `common/shaders/` to improve reusability and maintainability. - Created `common/shaders/render/fullscreen_vs.wgsl` for a reusable fullscreen vertex shader. - Created `common/shaders/math/color.wgsl` for color conversion and tone mapping functions. - Created `common/shaders/math/utils.wgsl` for general math utilities. - Created `common/shaders/render/raymarching.wgsl` for SDF raymarching logic. - Updated multiple shaders to use these new common snippets via `#include`. - Fixed the shader asset validation test to correctly handle shaders that include the common vertex shader. This refactoring makes the shader code more modular and easier to manage. --- src/tests/gpu/test_shader_assets.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/tests/gpu/test_shader_assets.cc') diff --git a/src/tests/gpu/test_shader_assets.cc b/src/tests/gpu/test_shader_assets.cc index f1562ea..5619a61 100644 --- a/src/tests/gpu/test_shader_assets.cc +++ b/src/tests/gpu/test_shader_assets.cc @@ -71,12 +71,15 @@ int main() { validate_shader(AssetId::ASSET_SHADER_GAUSSIAN_BLUR, "GAUSSIAN_BLUR", {"@vertex", "vs_main", "@fragment", "fs_main"}); all_passed &= validate_shader(AssetId::ASSET_SHADER_SOLARIZE, "SOLARIZE", - {"@vertex", "vs_main", "@fragment", "fs_main"}); + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); all_passed &= validate_shader(AssetId::ASSET_SHADER_DISTORT, "DISTORT", - {"@vertex", "vs_main", "@fragment", "fs_main"}); + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); all_passed &= validate_shader(AssetId::ASSET_SHADER_CHROMA_ABERRATION, "CHROMA_ABERRATION", - {"@vertex", "vs_main", "@fragment", "fs_main"}); + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); + all_passed &= validate_shader(AssetId::ASSET_SHADER_VIGNETTE, + "VIGNETTE", + {"#include \"render/fullscreen_vs\"", "@fragment", "fs_main"}); all_passed &= validate_shader(AssetId::ASSET_SHADER_VISUAL_DEBUG, "VISUAL_DEBUG", {"@vertex", "vs_main", "@fragment", "fs_main"}); -- cgit v1.2.3