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/gpu.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/gpu.cc')
| -rw-r--r-- | src/gpu/gpu.cc | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 8342c94..1f71711 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -5,15 +5,13 @@ #include "gpu.h" #include "demo_effects.h" #include "effect.h" -#include "platform.h" #include "gpu/effects/shaders.h" +#include "platform.h" -#include <GLFW/glfw3.h> -#include <math.h> - -#include <algorithm> #include <cassert> +#include <cmath> #include <cstdint> +#include <cstdio> #include <cstring> #include <vector> @@ -21,29 +19,6 @@ #include <iostream> #endif /* !defined(STRIP_ALL) */ -// --- WebGPU Headers & Compatibility --- -#if defined(DEMO_CROSS_COMPILE_WIN32) -// Renamed Types/Enums -#define WGPUOptionalBool_False false -#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal \ - WGPUSurfaceGetCurrentTextureStatus_Success -#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal \ - WGPUSurfaceGetCurrentTextureStatus_Success -#define WGPUCallbackMode_WaitAnyOnly 0 -static void wgpuInstanceWaitAny(WGPUInstance instance, size_t, void*, - uint64_t) { - wgpuInstanceProcessEvents(instance); -} -static void set_error_callback(WGPUDevice device, WGPUErrorCallback callback) { - wgpuDeviceSetUncapturedErrorCallback(device, callback, nullptr); -} -#else -static void set_error_callback(WGPUDevice device, - WGPUUncapturedErrorCallback callback) { - // Handled in descriptor for new API. -} -#endif /* defined(DEMO_CROSS_COMPILE_WIN32) */ - static WGPUInstance g_instance = nullptr; static WGPUAdapter g_adapter = nullptr; static WGPUDevice g_device = nullptr; @@ -331,7 +306,7 @@ void gpu_init(PlatformState* platform_state) { wgpuInstanceRequestAdapter(g_instance, &adapter_opts, adapter_cb); #endif /* defined(DEMO_CROSS_COMPILE_WIN32) */ while (!g_adapter) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + platform_wgpu_wait_any(g_instance); WGPUDeviceDescriptor device_desc = {}; #if !defined(STRIP_ALL) @@ -351,10 +326,10 @@ void gpu_init(PlatformState* platform_state) { wgpuAdapterRequestDevice(g_adapter, &device_desc, device_cb); #endif /* defined(DEMO_CROSS_COMPILE_WIN32) */ while (!g_device) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + platform_wgpu_wait_any(g_instance); #if defined(DEMO_CROSS_COMPILE_WIN32) && !defined(STRIP_ALL) - set_error_callback(g_device, handle_device_error); + platform_wgpu_set_error_callback(g_device, handle_device_error); #endif /* defined(DEMO_CROSS_COMPILE_WIN32) && !defined(STRIP_ALL) */ g_queue = wgpuDeviceGetQueue(g_device); |
