diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-07 17:04:56 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-07 17:04:56 +0100 |
| commit | bd939acdf750181ef0e1a612b445da4c15077c85 (patch) | |
| tree | 028401c762b0436d9a5de1aa656ab35ba6445674 /src/gpu/gpu.cc | |
| parent | f2963ac821a3af1c54002ba13944552166956d04 (diff) | |
refactor: Bundle GPU context into GpuContext struct
- Created GpuContext struct {device, queue, format}
- Updated Effect/PostProcessEffect to take const GpuContext&
- Updated all 19 effect implementations
- Updated MainSequence.init() and LoadTimeline() signatures
- Updated generated timeline files
- Updated all test files
- Added gpu_get_context() accessor and fixture.ctx() helper
Fixes test_mesh.cc compilation error from g_device/g_queue/g_format conflicts.
All targets build successfully.
Diffstat (limited to 'src/gpu/gpu.cc')
| -rw-r--r-- | src/gpu/gpu.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 63a30ff..fe71d3e 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -21,12 +21,13 @@ static WGPUInstance g_instance = nullptr; static WGPUAdapter g_adapter = nullptr; -WGPUDevice g_device = nullptr; // Non-static for external access (debug builds) -WGPUQueue g_queue = nullptr; // Non-static for external access (debug builds) +static WGPUDevice g_device = nullptr; +static WGPUQueue g_queue = nullptr; static WGPUSurface g_surface = nullptr; static WGPUSurfaceConfiguration g_config = {}; -WGPUTextureFormat g_format = WGPUTextureFormat_BGRA8Unorm; // Exposed for custom effects +static WGPUTextureFormat g_format = WGPUTextureFormat_BGRA8Unorm; +static GpuContext g_gpu_context = {}; static MainSequence g_main_sequence; // --- Helper Functions --- @@ -355,7 +356,12 @@ void gpu_init(PlatformState* platform_state) { g_config.device = g_device; g_config.format = swap_chain_format; - g_format = swap_chain_format; // Update global format for external access + g_format = swap_chain_format; + + // Update GPU context for accessor + g_gpu_context.device = g_device; + g_gpu_context.queue = g_queue; + g_gpu_context.format = g_format; g_config.usage = WGPUTextureUsage_RenderAttachment; g_config.width = platform_state->width; g_config.height = platform_state->height; @@ -365,10 +371,9 @@ void gpu_init(PlatformState* platform_state) { InitShaderComposer(); - g_main_sequence.init(g_device, g_queue, g_config.format, - platform_state->width, platform_state->height); + g_main_sequence.init(g_gpu_context, platform_state->width, platform_state->height); - LoadTimeline(g_main_sequence, g_device, g_queue, g_config.format); + LoadTimeline(g_main_sequence, g_gpu_context); } void gpu_draw(float audio_peak, float aspect_ratio, float time, float beat) { @@ -395,6 +400,10 @@ void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, int seq->init(&g_main_sequence); g_main_sequence.add_sequence(seq, 0.0f, priority); } + +const GpuContext* gpu_get_context() { + return &g_gpu_context; +} #endif /* !defined(STRIP_ALL) */ void gpu_shutdown() { |
