diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-03 18:44:41 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-03 18:44:41 +0100 |
| commit | bf46e44e1cb6027a072819a2a3aa3be32651f6e1 (patch) | |
| tree | 21267e7ef52fd91e7b99271ed87e275e91b3de3c /src/gpu/effects/shaders.cc | |
| parent | 815c428dea14a6a1ea5c421c400985d0c14d473d (diff) | |
refactor: Task #20 - Platform & Code Hygiene
- Consolidated all WebGPU shims and platform-specific logic into src/platform.h.
- Refactored platform_init to return PlatformState by value and platform_poll to automatically refresh time and aspect_ratio.
- Removed STL dependencies (std::map, std::vector, std::string) from AssetManager and Procedural subsystems.
- Fixed Windows cross-compilation by adjusting include paths and linker flags in CMakeLists.txt and updating build_win.sh.
- Removed redundant direct inclusions of GLFW/glfw3.h and WebGPU headers across the project.
- Applied clang-format and updated documentation.
handoff(Gemini): Completed Task #20 and 20.1. Platform abstraction is now unified, and core paths are STL-free. Windows build is stable.
Diffstat (limited to 'src/gpu/effects/shaders.cc')
| -rw-r--r-- | src/gpu/effects/shaders.cc | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/src/gpu/effects/shaders.cc b/src/gpu/effects/shaders.cc index cd516cd..b2d184d 100644 --- a/src/gpu/effects/shaders.cc +++ b/src/gpu/effects/shaders.cc @@ -3,8 +3,6 @@ #include "../demo_effects.h" - - #if defined(USE_TEST_ASSETS) #include "test_assets.h" @@ -15,36 +13,23 @@ #endif - - #include "gpu/effects/shader_composer.h" #include "util/asset_manager.h" - - void InitShaderComposer() { - auto& sc = ShaderComposer::Get(); - - auto register_if_exists = [&](const char* name, AssetId id) { + size_t size; - size_t size; - - const char* data = (const char*)GetAsset(id, &size); - - if (data) { - - sc.RegisterSnippet(name, std::string(data, size)); - - } + const char* data = (const char*)GetAsset(id, &size); + if (data) { + sc.RegisterSnippet(name, std::string(data, size)); + } }; - - register_if_exists("common_uniforms", AssetId::ASSET_SHADER_COMMON_UNIFORMS); register_if_exists("sdf_primitives", AssetId::ASSET_SHADER_SDF_PRIMITIVES); @@ -52,23 +37,16 @@ void InitShaderComposer() { register_if_exists("lighting", AssetId::ASSET_SHADER_LIGHTING); register_if_exists("ray_box", AssetId::ASSET_SHADER_RAY_BOX); - } - - // Helper to get asset string or empty string static const char* SafeGetAsset(AssetId id) { + const uint8_t* data = GetAsset(id); - const uint8_t* data = GetAsset(id); - - return data ? (const char*)data : ""; - + return data ? (const char*)data : ""; } - - const char* main_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_MAIN); const char* particle_compute_wgsl = |
