From bd939acdf750181ef0e1a612b445da4c15077c85 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 7 Feb 2026 17:04:56 +0100 Subject: 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. --- src/test_demo.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/test_demo.cc') diff --git a/src/test_demo.cc b/src/test_demo.cc index 9ae0e3a..69b18cc 100644 --- a/src/test_demo.cc +++ b/src/test_demo.cc @@ -15,14 +15,14 @@ // External declarations from generated files extern float GetDemoDuration(); -extern void LoadTimeline(MainSequence& main_seq, WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); +extern void LoadTimeline(MainSequence& main_seq, const GpuContext& ctx); // Inline peak meter effect for debugging audio-visual sync #include "gpu/effects/post_process_helper.h" class PeakMeterEffect : public PostProcessEffect { public: - PeakMeterEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format) - : PostProcessEffect(device, queue) { + PeakMeterEffect(const GpuContext& ctx) + : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4, @@ -82,9 +82,9 @@ class PeakMeterEffect : public PostProcessEffect { } )"; - pipeline_ = create_post_process_pipeline(device, format, shader_code); + pipeline_ = create_post_process_pipeline(device_, format_, shader_code); uniforms_ = gpu_create_buffer( - device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + device_, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void update_bind_group(WGPUTextureView input_view) { @@ -196,7 +196,8 @@ int main(int argc, char** argv) { // Add peak meter visualization effect (renders as final post-process) #if !defined(STRIP_ALL) - auto* peak_meter = new PeakMeterEffect(g_device, g_queue, g_format); + const GpuContext* gpu_ctx = gpu_get_context(); + auto* peak_meter = new PeakMeterEffect(*gpu_ctx); gpu_add_custom_effect(peak_meter, 0.0f, 99999.0f, 999); // High priority = renders last #endif -- cgit v1.2.3