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/gpu/effect.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/gpu/effect.h') diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 0cc9de5..006ee6f 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -9,7 +9,7 @@ class PostProcessEffect; class Effect { public: - Effect(WGPUDevice device, WGPUQueue queue) : device_(device), queue_(queue) { + Effect(const GpuContext& ctx) : device_(ctx.device), queue_(ctx.queue), format_(ctx.format) { } virtual ~Effect() = default; virtual void init(MainSequence* demo) { @@ -42,6 +42,7 @@ class Effect { protected: WGPUDevice device_; WGPUQueue queue_; + WGPUTextureFormat format_; GpuBuffer uniforms_; int width_ = 1280; int height_ = 720; @@ -49,8 +50,8 @@ class Effect { class PostProcessEffect : public Effect { public: - PostProcessEffect(WGPUDevice device, WGPUQueue queue) - : Effect(device, queue) { + PostProcessEffect(const GpuContext& ctx) + : Effect(ctx) { } bool is_post_process() const override { return true; @@ -103,13 +104,10 @@ class MainSequence { public: MainSequence(); ~MainSequence(); - WGPUDevice device; - WGPUQueue queue; - WGPUTextureFormat format; + GpuContext gpu_ctx; - void init(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format, - int width, int height); - void init_test(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + void init(const GpuContext& ctx, int width, int height); + void init_test(const GpuContext& ctx); void add_sequence(std::shared_ptr seq, float start_time, int priority = 0); void render_frame(float global_time, float beat, float peak, -- cgit v1.2.3