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_v2(const char* name, std::shared_ptr<EffectV2> 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_v2_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<EffectV2>>> effects = {
{"PassthroughEffectV2",
std::make_shared<PassthroughEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"GaussianBlurEffectV2",
std::make_shared<GaussianBlurEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"PlaceholderEffectV2",
std::make_shared<PlaceholderEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"HeptagonEffectV2",
std::make_shared<HeptagonEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"ParticlesEffectV2",
std::make_shared<ParticlesEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"RotatingCubeEffectV2",
std::make_shared<RotatingCubeEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
{"Hybrid3DEffectV2",
std::make_shared<Hybrid3DEffectV2>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"})},
};
int passed = 0;
for (const auto& [name, effect] : effects) {
passed += test_effect_v2(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_v2_effects();
fprintf(stdout, "=== All Tests Passed ===\n");
return 0;
}
|