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
88
|
// 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 = {
{"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"})},
};
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;
}
|