diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-17 12:51:29 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-17 12:51:29 +0100 |
| commit | 2e2e01048da5c466102bb57d64148aff72f4a558 (patch) | |
| tree | e88b5750395873ac9911fc4b7961f8558cc213fc /src/gpu/effect.h | |
| parent | b3eded8d56219fa19029a1b9bb7e7e7584f093d9 (diff) | |
refactor(gpu): Add RAII wrapper for WGPU resources to eliminate manual cleanup
Introduces WGPUResource template with automatic release on destruction.
Reduces boilerplate in effect destructors and prevents resource leaks.
- set() for one-time initialization
- replace() for per-frame recreation
- Field ordering documented for dependency management
Converted 3 effects (Heptagon, Flash, Passthrough) and Effect base class.
All tests pass (34/34).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effect.h')
| -rw-r--r-- | src/gpu/effect.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 82aa6e1..d47a8b7 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -7,6 +7,7 @@ #include "gpu/gpu.h" #include "gpu/sequence.h" #include "gpu/uniform_helper.h" +#include "gpu/wgpu_resource.h" #include <string> #include <vector> @@ -54,9 +55,9 @@ class Effect { // Common resources for most effects UniformBuffer<UniformsSequenceParams> uniforms_buffer_; - WGPUSampler sampler_ = nullptr; - WGPUTexture dummy_texture_ = nullptr; - WGPUTextureView dummy_texture_view_ = nullptr; + Sampler sampler_; + Texture dummy_texture_; + TextureView dummy_texture_view_; // Helper: Initialize uniforms buffer (call in subclass constructor) void init_uniforms_buffer(); |
