diff options
| author | skal <pascal.massimino@gmail.com> | 2026-01-31 20:44:23 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-01-31 20:44:23 +0100 |
| commit | c6b33c5e9b2325ca472dab8c4b64d1dab7b2885a (patch) | |
| tree | bdd7ad7a253562a5860fb9db20a9179931401672 /src/tests | |
| parent | 4a55151d1a30f03ce1aa67e4c952ff6759c480c9 (diff) | |
fix(gpu): resolve multiple WebGPU validation and runtime errors
- Fixed 'Invalid sample count 0' and 'Invalid anisotropic clamp: 0' by ensuring explicit pipeline and sampler states.
- Resolved WGSL parsing errors by replacing swizzle assignments in compute shaders.
- Fixed 'Texture destroyed' error in render_frame by reordering command submission and resource presentation/release.
- Added WGPU_DEPTH_SLICE_UNDEFINED for Windows compatibility and ensured consistent resolveTarget initialization.
- Cleaned up PassthroughEffect bind group layout mismatch and redundant string helper definitions.
- Verified all tests pass and applied consistent formatting.
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/test_sequence.cc | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/src/tests/test_sequence.cc b/src/tests/test_sequence.cc index 48ae436..db66b8a 100644 --- a/src/tests/test_sequence.cc +++ b/src/tests/test_sequence.cc @@ -1,8 +1,8 @@ // This file is part of the 64k demo project. // It tests the Sequence and Effect management system. -#include "gpu/effect.h" #include "gpu/demo_effects.h" +#include "gpu/effect.h" #include "gpu/gpu.h" #include <assert.h> #include <stdio.h> @@ -14,7 +14,8 @@ static WGPUQueue dummy_queue = (WGPUQueue)1; static WGPUTextureFormat dummy_format = (WGPUTextureFormat)1; static WGPUSurface dummy_surface = (WGPUSurface)1; static WGPUCommandEncoder dummy_encoder = (WGPUCommandEncoder)1; -static WGPURenderPassEncoder dummy_render_pass_encoder = (WGPURenderPassEncoder)1; +static WGPURenderPassEncoder dummy_render_pass_encoder = + (WGPURenderPassEncoder)1; // --- Dummy Effect for Tracking --- class DummyEffect : public Effect { @@ -25,14 +26,39 @@ public: int end_calls = 0; bool is_pp = false; - DummyEffect(bool post_process = false) : is_pp(post_process) {} + DummyEffect(bool post_process = false) : is_pp(post_process) { + } - void init(MainSequence *demo) override { init_calls++; (void)demo; } - void start() override { start_calls++; } - void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override { render_calls++; (void)pass; (void)time; (void)beat; (void)intensity; (void)aspect_ratio; } - void compute(WGPUCommandEncoder encoder, float time, float beat, float intensity, float aspect_ratio) override { (void)encoder; (void)time; (void)beat; (void)intensity; (void)aspect_ratio; } - void end() override { end_calls++; } - bool is_post_process() const override { return is_pp; } + void init(MainSequence *demo) override { + init_calls++; + (void)demo; + } + void start() override { + start_calls++; + } + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override { + render_calls++; + (void)pass; + (void)time; + (void)beat; + (void)intensity; + (void)aspect_ratio; + } + void compute(WGPUCommandEncoder encoder, float time, float beat, + float intensity, float aspect_ratio) override { + (void)encoder; + (void)time; + (void)beat; + (void)intensity; + (void)aspect_ratio; + } + void end() override { + end_calls++; + } + bool is_post_process() const override { + return is_pp; + } }; // --- Dummy PostProcessEffect for Tracking (unused in simplified tests) --- @@ -42,14 +68,30 @@ public: int render_calls = 0; int update_bind_group_calls = 0; - DummyPostProcessEffect(WGPUDevice device, WGPUTextureFormat format) { (void)device; (void)format; } + DummyPostProcessEffect(WGPUDevice device, WGPUTextureFormat format) { + (void)device; + (void)format; + } - void init(MainSequence *demo) override { init_calls++; (void)demo; } - void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override { render_calls++; (void)pass; (void)time; (void)beat; (void)intensity; (void)aspect_ratio; } - void update_bind_group(WGPUTextureView input_view) override { update_bind_group_calls++; (void)input_view; } + void init(MainSequence *demo) override { + init_calls++; + (void)demo; + } + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override { + render_calls++; + (void)pass; + (void)time; + (void)beat; + (void)intensity; + (void)aspect_ratio; + } + void update_bind_group(WGPUTextureView input_view) override { + update_bind_group_calls++; + (void)input_view; + } }; - // --- Test Cases --- void test_effect_lifecycle() { @@ -63,7 +105,9 @@ void test_effect_lifecycle() { main_seq.add_sequence(seq1, 0.0f, 0); // Before effect starts - main_seq.render_frame(0.5f, 0, 0, 1.0f, dummy_surface); // This will still call real render, but test counts only init + main_seq.render_frame(0.5f, 0, 0, 1.0f, + dummy_surface); // This will still call real render, but + // test counts only init assert(effect1->init_calls == 1); assert(effect1->start_calls == 0); assert(effect1->render_calls == 0); @@ -72,7 +116,8 @@ void test_effect_lifecycle() { // Effect starts main_seq.render_frame(1.0f, 0, 0, 1.0f, dummy_surface); assert(effect1->start_calls == 1); - // assert(effect1->render_calls == 1); // No longer checking render calls directly from here + // assert(effect1->render_calls == 1); // No longer checking render calls + // directly from here assert(effect1->end_calls == 0); // During effect @@ -109,7 +154,8 @@ void test_simulate_until() { assert(effect1->init_calls == 1); assert(effect1->start_calls == 1); - assert(effect1->render_calls == 0); // Render should not be called in simulate_until + assert(effect1->render_calls == + 0); // Render should not be called in simulate_until assert(effect1->end_calls == 0); main_seq.simulate_until(3.5f, 1.0f / 60.0f); @@ -126,18 +172,17 @@ int main() { printf("Running Sequence/Effect System tests...\n"); - // TODO: Re-enable and fix test_effect_lifecycle once GPU resource mocking is robust. + // TODO: Re-enable and fix test_effect_lifecycle once GPU resource mocking is + // robust. // test_effect_lifecycle(); - // TODO: Re-enable and fix test_simulate_until once GPU resource mocking is robust. + // TODO: Re-enable and fix test_simulate_until once GPU resource mocking is + // robust. // test_simulate_until(); printf("Sequence/Effect System tests PASSED\n"); return 0; - } - - |
