diff options
| -rw-r--r-- | src/tests/common/webgpu_test_fixture.h | 6 | ||||
| -rw-r--r-- | src/tests/gpu/test_effect_base.cc | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/tests/common/webgpu_test_fixture.h b/src/tests/common/webgpu_test_fixture.h index e10a2ed..fa23587 100644 --- a/src/tests/common/webgpu_test_fixture.h +++ b/src/tests/common/webgpu_test_fixture.h @@ -34,8 +34,9 @@ class WebGPUTestFixture { WGPUTextureFormat format() const { return WGPUTextureFormat_BGRA8Unorm; } - GpuContext ctx() const { - return {device_, queue_, format()}; + const GpuContext& ctx() const { + ctx_ = {device_, queue_, format()}; + return ctx_; } // Check if fixture is ready @@ -48,6 +49,7 @@ class WebGPUTestFixture { WGPUAdapter adapter_ = nullptr; WGPUDevice device_ = nullptr; WGPUQueue queue_ = nullptr; + mutable GpuContext ctx_ = {}; // Callback state for async device request struct RequestState { diff --git a/src/tests/gpu/test_effect_base.cc b/src/tests/gpu/test_effect_base.cc index 68aabe3..64e5fa4 100644 --- a/src/tests/gpu/test_effect_base.cc +++ b/src/tests/gpu/test_effect_base.cc @@ -164,9 +164,11 @@ static void test_sequence_render() { WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, nullptr); wgpuQueueSubmit(fixture.queue(), 1, &commands); wgpuCommandBufferRelease(commands); + wgpuCommandEncoderRelease(encoder); - // Wait for the GPU to complete rendering to avoid race conditions on exit. - wgpuDevicePoll(fixture.device(), true, nullptr); + // Read back pixels to ensure the GPU finishes rendering before teardown. + // This avoids intermittent crashes on shutdown. + target.read_pixels(); fprintf(stdout, " ✓ Sequence rendered without error\n"); } |
