diff options
Diffstat (limited to 'src/tests/gpu')
| -rw-r--r-- | src/tests/gpu/test_demo_effects.cc | 63 | ||||
| -rw-r--r-- | src/tests/gpu/test_effect_base.cc | 32 | ||||
| -rw-r--r-- | src/tests/gpu/test_noise_functions.cc | 2 | ||||
| -rw-r--r-- | src/tests/gpu/test_sequence.cc | 25 | ||||
| -rw-r--r-- | src/tests/gpu/test_sequence_e2e.cc | 34 | ||||
| -rw-r--r-- | src/tests/gpu/test_shader_compilation.cc | 2 |
6 files changed, 74 insertions, 84 deletions
diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc index cebf4a6..f193c76 100644 --- a/src/tests/gpu/test_demo_effects.cc +++ b/src/tests/gpu/test_demo_effects.cc @@ -37,42 +37,33 @@ static void test_effects() { } std::vector<std::pair<const char*, std::shared_ptr<Effect>>> effects = { - {"PassthroughEffect", - std::make_shared<PassthroughEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"GaussianBlurEffect", - std::make_shared<GaussianBlurEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"PlaceholderEffect", - std::make_shared<PlaceholderEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"HeptagonEffect", - std::make_shared<HeptagonEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"ParticlesEffect", - std::make_shared<ParticlesEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"RotatingCubeEffect", - std::make_shared<RotatingCubeEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Hybrid3DEffect", - std::make_shared<Hybrid3DEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"FlashEffect", - std::make_shared<FlashEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"PeakMeterEffect", - std::make_shared<PeakMeterEffect>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, + {"Passthrough", std::make_shared<Passthrough>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"GaussianBlur", std::make_shared<GaussianBlur>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Placeholder", std::make_shared<Placeholder>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Heptagon", std::make_shared<Heptagon>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Particles", std::make_shared<Particles>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"RotatingCube", std::make_shared<RotatingCube>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Hybrid3D", std::make_shared<Hybrid3D>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"Flash", std::make_shared<Flash>(fixture.ctx(), + std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, + {"PeakMeter", std::make_shared<PeakMeter>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f)}, }; int passed = 0; diff --git a/src/tests/gpu/test_effect_base.cc b/src/tests/gpu/test_effect_base.cc index 8b0e6b2..29d3348 100644 --- a/src/tests/gpu/test_effect_base.cc +++ b/src/tests/gpu/test_effect_base.cc @@ -80,14 +80,14 @@ static void test_effect_construction() { return; } - // Create PassthroughEffect (simple effect) - auto effect = std::make_shared<PassthroughEffect>( + // Create Passthrough (simple effect) + auto effect = std::make_shared<Passthrough>( fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"}); + std::vector<std::string>{"sink"}, 0.0f, 1000.0f); assert(effect != nullptr && "Effect should be constructed"); - fprintf(stdout, " ✓ PassthroughEffect constructed\n"); + fprintf(stdout, " ✓ Passthrough constructed\n"); } // Test 4: Effect added to sequence DAG @@ -102,11 +102,12 @@ static void test_effect_in_sequence() { // Create minimal sequence with one effect class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { - auto effect = std::make_shared<PassthroughEffect>( - ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"}); + auto effect = + std::make_shared<Passthrough>(ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, + 1000.0f); effect_dag_.push_back({effect, {"source"}, {"sink"}, 0}); init_effect_nodes(); @@ -134,11 +135,12 @@ static void test_sequence_render() { OffscreenRenderTarget target(fixture.instance(), fixture.device(), 256, 256); class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { - auto effect = std::make_shared<PassthroughEffect>( - ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"}); + auto effect = + std::make_shared<Passthrough>(ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}, 0.0f, + 1000.0f); effect_dag_.push_back({effect, {"source"}, {"sink"}, 0}); init_effect_nodes(); @@ -154,8 +156,8 @@ static void test_sequence_render() { seq->preprocess(0.0f, 0.0f, 0.0f, 0.0f); // Create encoder and attempt render - WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder( - fixture.device(), nullptr); + WGPUCommandEncoder encoder = + wgpuDeviceCreateCommandEncoder(fixture.device(), nullptr); seq->render_effects(encoder); @@ -177,7 +179,7 @@ static void test_sequence_time_params() { } class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { init_effect_nodes(); } diff --git a/src/tests/gpu/test_noise_functions.cc b/src/tests/gpu/test_noise_functions.cc index eddd88e..d96a982 100644 --- a/src/tests/gpu/test_noise_functions.cc +++ b/src/tests/gpu/test_noise_functions.cc @@ -1,9 +1,9 @@ // This file is part of the 64k demo project. // It validates that the noise.wgsl functions are accessible and usable. +#include "effects/shaders.h" #include "generated/assets.h" #include "gpu/shader_composer.h" -#include "gpu/shaders.h" #include <cassert> #include <cstdio> #include <cstring> diff --git a/src/tests/gpu/test_sequence.cc b/src/tests/gpu/test_sequence.cc index 337381a..8e27efb 100644 --- a/src/tests/gpu/test_sequence.cc +++ b/src/tests/gpu/test_sequence.cc @@ -1,8 +1,8 @@ // Test file for Sequence v2 system // Phase 1: Foundation tests (NodeRegistry, Sequence base class) -#include "gpu/sequence.h" #include "gpu/effect.h" +#include "gpu/sequence.h" #include "tests/common/webgpu_test_fixture.h" #include <cassert> #include <cstdio> @@ -11,8 +11,10 @@ class TestEffect : public Effect { public: TestEffect(const GpuContext& ctx, const std::vector<std::string>& inputs, - const std::vector<std::string>& outputs) - : Effect(ctx, inputs, outputs), render_called_(false) { + const std::vector<std::string>& outputs, float start_time = 0.0f, + float end_time = 1000.0f) + : Effect(ctx, inputs, outputs, start_time, end_time), + render_called_(false) { } void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params, @@ -132,16 +134,15 @@ void test_sequence_v2_dag_execution() { class TestSequence : public Sequence { public: TestSequence(const GpuContext& ctx) - : Sequence(ctx, 1280, 720), - effect1_(std::make_shared<TestEffect>(ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"temp"})), - effect2_(std::make_shared<TestEffect>(ctx, std::vector<std::string>{"temp"}, - std::vector<std::string>{"sink"})) { + : Sequence(ctx, 1280, 720), effect1_(std::make_shared<TestEffect>( + ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"temp"})), + effect2_(std::make_shared<TestEffect>( + ctx, std::vector<std::string>{"temp"}, + std::vector<std::string>{"sink"})) { // Build DAG (2 effects in sequence) - effect_dag_.push_back( - {effect1_, {"source"}, {"temp"}, 0}); - effect_dag_.push_back( - {effect2_, {"temp"}, {"sink"}, 1}); + effect_dag_.push_back({effect1_, {"source"}, {"temp"}, 0}); + effect_dag_.push_back({effect2_, {"temp"}, {"sink"}, 1}); } std::shared_ptr<TestEffect> effect1_; diff --git a/src/tests/gpu/test_sequence_e2e.cc b/src/tests/gpu/test_sequence_e2e.cc index 91a8da2..5d59e0d 100644 --- a/src/tests/gpu/test_sequence_e2e.cc +++ b/src/tests/gpu/test_sequence_e2e.cc @@ -1,12 +1,12 @@ // End-to-end test for Sequence v2 system // Tests compiler output instantiation and execution -#include "gpu/sequence.h" -#include "gpu/effect.h" #include "effects/gaussian_blur_effect.h" #include "effects/heptagon_effect.h" #include "effects/passthrough_effect.h" -#include "gpu/shaders.h" +#include "effects/shaders.h" +#include "gpu/effect.h" +#include "gpu/sequence.h" #include "tests/common/webgpu_test_fixture.h" #include <cassert> #include <cstdio> @@ -21,22 +21,18 @@ class SimpleTestSequence : public Sequence { nodes_.declare_node("temp", NodeType::U8X4_NORM, width_, height_); // Effect DAG construction (2 effects: source->temp->sink) - effect_dag_.push_back({ - .effect = std::make_shared<PassthroughEffect>(ctx, - std::vector<std::string>{"source"}, - std::vector<std::string>{"temp"}), - .input_nodes = {"source"}, - .output_nodes = {"temp"}, - .execution_order = 0 - }); - effect_dag_.push_back({ - .effect = std::make_shared<PassthroughEffect>(ctx, - std::vector<std::string>{"temp"}, - std::vector<std::string>{"sink"}), - .input_nodes = {"temp"}, - .output_nodes = {"sink"}, - .execution_order = 1 - }); + effect_dag_.push_back({.effect = std::make_shared<Passthrough>( + ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"temp"}, 0.0f, 1000.0f), + .input_nodes = {"source"}, + .output_nodes = {"temp"}, + .execution_order = 0}); + effect_dag_.push_back({.effect = std::make_shared<Passthrough>( + ctx, std::vector<std::string>{"temp"}, + std::vector<std::string>{"sink"}, 0.0f, 1000.0f), + .input_nodes = {"temp"}, + .output_nodes = {"sink"}, + .execution_order = 1}); } }; diff --git a/src/tests/gpu/test_shader_compilation.cc b/src/tests/gpu/test_shader_compilation.cc index 3a7c2cf..2aff115 100644 --- a/src/tests/gpu/test_shader_compilation.cc +++ b/src/tests/gpu/test_shader_compilation.cc @@ -5,9 +5,9 @@ // - Missing binding declarations // - Type mismatches +#include "effects/shaders.h" #include "generated/assets.h" #include "gpu/shader_composer.h" -#include "gpu/shaders.h" #include "platform/platform.h" #include <cassert> #include <cstdio> |
