From e6e34e551a73e65301685071445aaec9aaf60fd2 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 1 Feb 2026 01:41:01 +0100 Subject: Refactor: Move common GPU fields to base Effect classes Moved WGPUDevice, WGPUQueue, and GpuBuffer uniforms_ into the base Effect and PostProcessEffect classes. Updated all derived effect classes to use these inherited members and refactored their constructors. Also fixed associated compilation errors in test files and adjusted a printf statement. --- src/tests/test_sequence.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/tests') diff --git a/src/tests/test_sequence.cc b/src/tests/test_sequence.cc index 6b04302..d944371 100644 --- a/src/tests/test_sequence.cc +++ b/src/tests/test_sequence.cc @@ -26,8 +26,8 @@ class DummyEffect : public Effect { int end_calls = 0; bool is_pp = false; - DummyEffect(bool post_process = false) : is_pp(post_process) { - } + DummyEffect(WGPUDevice device, WGPUQueue queue, bool post_process = false) + : Effect(device, queue), is_pp(post_process) {} void init(MainSequence* demo) override { ++init_calls; @@ -68,8 +68,9 @@ class DummyPostProcessEffect : public PostProcessEffect { int render_calls = 0; int update_bind_group_calls = 0; - DummyPostProcessEffect(WGPUDevice device, WGPUTextureFormat format) { - (void)device; + DummyPostProcessEffect(WGPUDevice device, WGPUQueue queue, + WGPUTextureFormat format) + : PostProcessEffect(device, queue) { (void)format; } @@ -99,7 +100,7 @@ void test_effect_lifecycle() { MainSequence main_seq; main_seq.init_test(dummy_device, dummy_queue, dummy_format); - auto effect1 = std::make_shared(); + auto effect1 = std::make_shared(dummy_device, dummy_queue); auto seq1 = std::make_shared(); seq1->add_effect(effect1, 1.0f, 3.0f); main_seq.add_sequence(seq1, 0.0f, 0); @@ -145,7 +146,7 @@ void test_simulate_until() { MainSequence main_seq; main_seq.init_test(dummy_device, dummy_queue, dummy_format); - auto effect1 = std::make_shared(); + auto effect1 = std::make_shared(dummy_device, dummy_queue); auto seq1 = std::make_shared(); seq1->add_effect(effect1, 1.0f, 3.0f); main_seq.add_sequence(seq1, 0.0f, 0); @@ -164,7 +165,7 @@ void test_simulate_until() { assert(effect1->render_calls == 0); assert(effect1->end_calls == 1); // Should end #else - printf(" test_simulate_until (skipped in STRIP_ALL build)...\n"); + printf(" test_simulate_until (skipped in STRIP_ALL build)...\\n"); #endif /* !defined(STRIP_ALL) */ } @@ -184,4 +185,4 @@ int main() { printf("Sequence/Effect System tests PASSED\n"); return 0; -} +} \ No newline at end of file -- cgit v1.2.3