1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
// This file is part of the 64k demo project.
// It tests all v2 demo effect classes for basic construction.
// Validates that every v2 effect can be instantiated without crashes.
//
// MAINTENANCE REQUIREMENT: When adding a new v2 effect to demo_effects.h:
// 1. Add it to the test list below
// 2. Run test to verify: ./build/test_demo_effects
#include "../common/webgpu_test_fixture.h"
#include "gpu/demo_effects.h"
#include <cassert>
#include <cstdio>
#include <memory>
#include <vector>
// Helper: Test v2 effect construction
static int test_effect(const char* name, std::shared_ptr<Effect> effect) {
fprintf(stdout, " Testing %s...\n", name);
if (!effect) {
fprintf(stderr, " ✗ Construction failed\n");
return 0;
}
fprintf(stdout, " ✓ %s OK\n", name);
return 1;
}
// Test all available v2 effects
static void test_effects() {
fprintf(stdout, "Testing V2 effects...\n");
WebGPUTestFixture fixture;
if (!fixture.init()) {
fprintf(stdout, " ⚠ WebGPU unavailable - skipping test\n");
return;
}
std::vector<std::pair<const char*, std::shared_ptr<Effect>>> effects = {
{"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;
for (const auto& [name, effect] : effects) {
passed += test_effect(name, effect);
}
fprintf(stdout, " ✓ %d/%zu V2 effects tested\n", passed, effects.size());
}
int main() {
fprintf(stdout, "=== Demo Effects Tests ===\n");
extern void InitShaderComposer();
InitShaderComposer();
test_effects();
fprintf(stdout, "=== All Tests Passed ===\n");
return 0;
}
|