summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-10 21:14:21 +0100
committerskal <pascal.massimino@gmail.com>2026-02-10 21:14:21 +0100
commit861182bd33cae0b538f2e4beeb5b56e66c8f0ff7 (patch)
tree0d6faa7abfc00d2f53b3ed665fa3981528ffc883 /src
parent7a05f4d33b611ba1e9b6c68e0d0bd67d6ea011ee (diff)
fix: PostProcessHelperTest signature and fixture sharing
Update pp_update_bind_group extern declaration to match implementation (add effect_params parameter). Refactor tests to share single fixture across all subtests, preventing SamplerCache device mismatch crashes. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/gpu/test_post_process_helper.cc48
1 files changed, 15 insertions, 33 deletions
diff --git a/src/tests/gpu/test_post_process_helper.cc b/src/tests/gpu/test_post_process_helper.cc
index 868bf26..13fd856 100644
--- a/src/tests/gpu/test_post_process_helper.cc
+++ b/src/tests/gpu/test_post_process_helper.cc
@@ -16,7 +16,7 @@ extern WGPURenderPipeline create_post_process_pipeline(WGPUDevice device,
extern void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline,
WGPUBindGroup* bind_group,
WGPUTextureView input_view,
- GpuBuffer uniforms);
+ GpuBuffer uniforms, GpuBuffer effect_params);
// Helper: Create a texture suitable for post-processing (both render target and
// texture binding)
@@ -71,15 +71,9 @@ fn fs_main(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
)";
// Test 1: Pipeline creation
-static void test_pipeline_creation() {
+static void test_pipeline_creation(WebGPUTestFixture& fixture) {
fprintf(stdout, "Testing post-process pipeline creation...\n");
- WebGPUTestFixture fixture;
- if (!fixture.init()) {
- fprintf(stdout, " ⚠ WebGPU unavailable - skipping test\n");
- return;
- }
-
WGPURenderPipeline pipeline = create_post_process_pipeline(
fixture.device(), fixture.format(), test_shader);
@@ -92,15 +86,9 @@ static void test_pipeline_creation() {
}
// Test 2: Bind group creation
-static void test_bind_group_creation() {
+static void test_bind_group_creation(WebGPUTestFixture& fixture) {
fprintf(stdout, "Testing post-process bind group creation...\n");
- WebGPUTestFixture fixture;
- if (!fixture.init()) {
- fprintf(stdout, " ⚠ WebGPU unavailable - skipping test\n");
- return;
- }
-
// Create pipeline
WGPURenderPipeline pipeline = create_post_process_pipeline(
fixture.device(), fixture.format(), test_shader);
@@ -147,15 +135,9 @@ static void test_bind_group_creation() {
}
// Test 3: Bind group update (replacement)
-static void test_bind_group_update() {
+static void test_bind_group_update(WebGPUTestFixture& fixture) {
fprintf(stdout, "Testing post-process bind group update...\n");
- WebGPUTestFixture fixture;
- if (!fixture.init()) {
- fprintf(stdout, " ⚠ WebGPU unavailable - skipping test\n");
- return;
- }
-
WGPURenderPipeline pipeline = create_post_process_pipeline(
fixture.device(), fixture.format(), test_shader);
@@ -206,15 +188,9 @@ static void test_bind_group_update() {
}
// Test 4: Full post-process setup (pipeline + bind group)
-static void test_full_setup() {
+static void test_full_setup(WebGPUTestFixture& fixture) {
fprintf(stdout, "Testing full post-process setup...\n");
- WebGPUTestFixture fixture;
- if (!fixture.init()) {
- fprintf(stdout, " ⚠ WebGPU unavailable - skipping test\n");
- return;
- }
-
// Create pipeline
WGPURenderPipeline pipeline = create_post_process_pipeline(
fixture.device(), fixture.format(), test_shader);
@@ -296,10 +272,16 @@ static void test_full_setup() {
int main() {
fprintf(stdout, "=== Post-Process Helper Tests ===\n");
- test_pipeline_creation();
- test_bind_group_creation();
- test_bind_group_update();
- test_full_setup();
+ WebGPUTestFixture fixture;
+ if (!fixture.init()) {
+ fprintf(stdout, " ⚠ WebGPU unavailable - skipping all tests\n");
+ return 0;
+ }
+
+ test_pipeline_creation(fixture);
+ test_bind_group_creation(fixture);
+ test_bind_group_update(fixture);
+ test_full_setup(fixture);
fprintf(stdout, "=== All Post-Process Helper Tests Passed ===\n");
return 0;