diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-01 01:41:01 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-01 01:41:01 +0100 |
| commit | e6e34e551a73e65301685071445aaec9aaf60fd2 (patch) | |
| tree | 40b374b0137abc71c121ef5f94d1a5ba645108cd /src/gpu/effects/particle_spray_effect.cc | |
| parent | 709067df5303ddf0715f56903ccfdb877cb4db7e (diff) | |
Refactor: Move common GPU fields to base Effect classes
Moved WGPUDevice, WGPUQueue, and GpuBuffer uniforms_ into the base Effect
and PostProcessEffect classes. Updated all derived effect classes to use
these inherited members and refactored their constructors. Also fixed
associated compilation errors in test files and adjusted a printf statement.
Diffstat (limited to 'src/gpu/effects/particle_spray_effect.cc')
| -rw-r--r-- | src/gpu/effects/particle_spray_effect.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/gpu/effects/particle_spray_effect.cc b/src/gpu/effects/particle_spray_effect.cc index a5e4292..b5c5f42 100644 --- a/src/gpu/effects/particle_spray_effect.cc +++ b/src/gpu/effects/particle_spray_effect.cc @@ -8,26 +8,26 @@ // --- ParticleSprayEffect --- ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format) - : queue_(queue) { + : Effect(device, queue) { uniforms_ = - gpu_create_buffer(device, sizeof(float) * 4, + gpu_create_buffer(device_, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); std::vector<Particle> init_p(NUM_PARTICLES); for (Particle& p : init_p) p.pos[3] = 0.0f; particles_buffer_ = gpu_create_buffer( - device, sizeof(Particle) * NUM_PARTICLES, + device_, sizeof(Particle) * NUM_PARTICLES, WGPUBufferUsage_Storage | WGPUBufferUsage_Vertex, init_p.data()); ResourceBinding cb[] = {{particles_buffer_, WGPUBufferBindingType_Storage}, {uniforms_, WGPUBufferBindingType_Uniform}}; compute_pass_ = - gpu_create_compute_pass(device, particle_spray_compute_wgsl, cb, 2); + gpu_create_compute_pass(device_, particle_spray_compute_wgsl, cb, 2); compute_pass_.workgroup_size_x = (NUM_PARTICLES + 63) / 64; ResourceBinding rb[] = { {particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage}, {uniforms_, WGPUBufferBindingType_Uniform}}; render_pass_ = - gpu_create_render_pass(device, format, particle_render_wgsl, rb, 2); + gpu_create_render_pass(device_, format, particle_render_wgsl, rb, 2); render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } |
