summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/3d/test_3d_physics.cc2
-rw-r--r--src/tests/3d/test_3d_render.cc2
-rw-r--r--src/tests/3d/test_mesh.cc2
-rw-r--r--src/tests/assets/test_sequence.cc2
-rw-r--r--src/tests/common/effect_test_helpers.cc7
-rw-r--r--src/tests/common/offscreen_render_target.cc4
-rw-r--r--src/tests/gpu/test_demo_effects.cc63
-rw-r--r--src/tests/gpu/test_effect_base.cc32
-rw-r--r--src/tests/gpu/test_noise_functions.cc2
-rw-r--r--src/tests/gpu/test_sequence.cc25
-rw-r--r--src/tests/gpu/test_sequence_e2e.cc34
-rw-r--r--src/tests/gpu/test_shader_compilation.cc2
12 files changed, 83 insertions, 94 deletions
diff --git a/src/tests/3d/test_3d_physics.cc b/src/tests/3d/test_3d_physics.cc
index 26b9bfa..7858f2f 100644
--- a/src/tests/3d/test_3d_physics.cc
+++ b/src/tests/3d/test_3d_physics.cc
@@ -9,7 +9,7 @@
#include "3d/renderer.h"
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/3d/test_3d_render.cc b/src/tests/3d/test_3d_render.cc
index 9398649..bd301bd 100644
--- a/src/tests/3d/test_3d_render.cc
+++ b/src/tests/3d/test_3d_render.cc
@@ -7,8 +7,8 @@
#include "3d/renderer.h"
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
+#include "effects/shaders.h"
#include "generated/assets.h"
-#include "gpu/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/3d/test_mesh.cc b/src/tests/3d/test_mesh.cc
index 2a13125..746cfb1 100644
--- a/src/tests/3d/test_mesh.cc
+++ b/src/tests/3d/test_mesh.cc
@@ -7,7 +7,7 @@
#include "3d/renderer.h"
#include "3d/renderer_helpers.h"
#include "3d/scene.h"
-#include "gpu/shaders.h"
+#include "effects/shaders.h"
#include "gpu/texture_manager.h"
#include "platform/platform.h"
#include "procedural/generator.h"
diff --git a/src/tests/assets/test_sequence.cc b/src/tests/assets/test_sequence.cc
index 445e44b..8de9eca 100644
--- a/src/tests/assets/test_sequence.cc
+++ b/src/tests/assets/test_sequence.cc
@@ -179,7 +179,7 @@ int main() {
return 0;
}
-#else // v2 port TODO
+#else // v2 port TODO
int main() {
printf("test_sequence: SKIPPED (needs v2 port)\n");
return 0;
diff --git a/src/tests/common/effect_test_helpers.cc b/src/tests/common/effect_test_helpers.cc
index d776609..2a40f60 100644
--- a/src/tests/common/effect_test_helpers.cc
+++ b/src/tests/common/effect_test_helpers.cc
@@ -45,9 +45,9 @@ bool all_pixels_match_color(const std::vector<uint8_t>& pixels, int width,
const uint8_t g = pixels[offset + 1];
const uint8_t r = pixels[offset + 2];
- const int diff_r = static_cast<int>(r) - static_cast<int>(target_r);
- const int diff_g = static_cast<int>(g) - static_cast<int>(target_g);
- const int diff_b = static_cast<int>(b) - static_cast<int>(target_b);
+ const int diff_r = (int)(r) - (int)(target_r);
+ const int diff_g = (int)(g) - (int)(target_g);
+ const int diff_b = (int)(b) - (int)(target_b);
if (diff_r * diff_r + diff_g * diff_g + diff_b * diff_b >
tolerance * tolerance) {
@@ -66,4 +66,3 @@ uint64_t hash_pixels(const std::vector<uint8_t>& pixels) {
}
return hash;
}
-
diff --git a/src/tests/common/offscreen_render_target.cc b/src/tests/common/offscreen_render_target.cc
index 33f0ae0..2b0a43b 100644
--- a/src/tests/common/offscreen_render_target.cc
+++ b/src/tests/common/offscreen_render_target.cc
@@ -20,7 +20,7 @@ OffscreenRenderTarget::OffscreenRenderTarget(WGPUInstance instance,
.usage = WGPUTextureUsage_RenderAttachment | WGPUTextureUsage_CopySrc |
WGPUTextureUsage_TextureBinding,
.dimension = WGPUTextureDimension_2D,
- .size = {static_cast<uint32_t>(width), static_cast<uint32_t>(height), 1},
+ .size = {(uint32_t)(width), (uint32_t)(height), 1},
.format = format,
.mipLevelCount = 1,
.sampleCount = 1,
@@ -44,7 +44,7 @@ OffscreenRenderTarget::~OffscreenRenderTarget() {
void OffscreenRenderTarget::map_callback(WGPUMapAsyncStatus status,
void* userdata) {
- MapState* state = static_cast<MapState*>(userdata);
+ MapState* state = (MapState*)(userdata);
state->status = status;
state->done = true;
}
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>