From a958c6ca8dd48f642570037df127a4b23c984d82 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 17:05:15 +0100 Subject: feat: Multi-pass rendering architecture and effect stubs Implements a post-processing pipeline using offscreen framebuffers. Adds stubs for MovingEllipse, ParticleSpray, GaussianBlur, Solarize, Distort, and ChromaAberration effects. Updates MainSequence to orchestrate the scene pass and post-processing chain. --- src/gpu/gpu.cc | 60 ++++++---------------------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) (limited to 'src/gpu/gpu.cc') diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index e76aecc..db79b9d 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -22,66 +22,20 @@ // --- WebGPU Headers & Compatibility --- #if defined(DEMO_CROSS_COMPILE_WIN32) -// Windows (MinGW) using wgpu-native v0.19.4.1 -#include -#include - -// Type Shims -using WGPUStringView = const char *; -static const char *str_view(const char *str) { - return str; -} -static const char *label_view(const char *str) { - return str; -} - // Renamed Types/Enums #define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; -#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal \ - WGPUSurfaceGetCurrentTextureStatus_Success -#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal \ - WGPUSurfaceGetCurrentTextureStatus_Success - -// Callback Mode Shim (Not used in old API signatures, but needed for ifdef -// logic) +#define WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal WGPUSurfaceGetCurrentTextureStatus_Success +#define WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal WGPUSurfaceGetCurrentTextureStatus_Success #define WGPUCallbackMode_WaitAnyOnly 0 - -// Wait Shim -static void wgpuInstanceWaitAny(WGPUInstance instance, size_t, void *, - uint64_t) { +static void wgpuInstanceWaitAny(WGPUInstance instance, size_t, void *, uint64_t) { wgpuInstanceProcessEvents(instance); } - -// Uncaptured Error Callback Helper static void set_error_callback(WGPUDevice device, WGPUErrorCallback callback) { wgpuDeviceSetUncapturedErrorCallback(device, callback, nullptr); } - #else -// Native (macOS/Linux) using newer wgpu-native -#include -#include - -static WGPUStringView label_view(const char *str) { -#ifndef STRIP_ALL - if (!str) - return {nullptr, 0}; - return {str, strlen(str)}; -#else - (void)str; - return {nullptr, 0}; -#endif -} - -static WGPUStringView str_view(const char *str) { - if (!str) - return {nullptr, 0}; - return {str, strlen(str)}; -} - -static void set_error_callback(WGPUDevice device, - WGPUUncapturedErrorCallback callback) { +static void set_error_callback(WGPUDevice device, WGPUUncapturedErrorCallback callback) { // Handled in descriptor for new API. } #endif @@ -353,7 +307,7 @@ static void handle_request_device(WGPURequestDeviceStatus status, #endif #endif -void gpu_init(GLFWwindow *window) { +void gpu_init(GLFWwindow *window, int width, int height) { g_instance = wgpuCreateInstance(nullptr); g_surface = platform_create_wgpu_surface(g_instance); @@ -404,8 +358,6 @@ void gpu_init(GLFWwindow *window) { wgpuSurfaceGetCapabilities(g_surface, g_adapter, &caps); WGPUTextureFormat swap_chain_format = caps.formats[0]; - int width, height; - glfwGetFramebufferSize(window, &width, &height); g_config.device = g_device; g_config.format = swap_chain_format; g_config.usage = WGPUTextureUsage_RenderAttachment; @@ -415,7 +367,7 @@ void gpu_init(GLFWwindow *window) { g_config.alphaMode = WGPUCompositeAlphaMode_Opaque; wgpuSurfaceConfigure(g_surface, &g_config); - g_main_sequence.init(g_device, g_queue, g_config.format); + g_main_sequence.init(g_device, g_queue, g_config.format, width, height); LoadTimeline(g_main_sequence, g_device, g_queue, g_config.format); } -- cgit v1.2.3