diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-09 11:39:54 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-09 11:39:54 +0100 |
| commit | d48aac685ecd47a80e0752011a1d78bc86094947 (patch) | |
| tree | 8b36b3c4a212e05aeae91c560346a73f0e7987b6 /src/gpu/effects/moving_ellipse_effect.cc | |
| parent | fd19130b3360d17b44247ec26533b20e051b7f8c (diff) | |
Refactor Effect class to centralize common uniforms management
Moved to Effect base class. Updated all subclasses to use the base member, removing redundant declarations and initializations. Cleaned up by removing redundant class definitions and including specific headers. Fixed a typo in DistortEffect constructor.
Diffstat (limited to 'src/gpu/effects/moving_ellipse_effect.cc')
| -rw-r--r-- | src/gpu/effects/moving_ellipse_effect.cc | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gpu/effects/moving_ellipse_effect.cc b/src/gpu/effects/moving_ellipse_effect.cc index 945f807..9866f20 100644 --- a/src/gpu/effects/moving_ellipse_effect.cc +++ b/src/gpu/effects/moving_ellipse_effect.cc @@ -7,10 +7,8 @@ // --- MovingEllipseEffect --- MovingEllipseEffect::MovingEllipseEffect(const GpuContext& ctx) : Effect(ctx) { - uniforms_ = - gpu_create_buffer(ctx_.device, sizeof(CommonPostProcessUniforms), - WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - ResourceBinding bindings[] = {{uniforms_, WGPUBufferBindingType_Uniform}}; + // uniforms_ is initialized by Effect base class + ResourceBinding bindings[] = {{uniforms_.get(), WGPUBufferBindingType_Uniform}}; pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, ellipse_shader_wgsl, bindings, 1); pass_.vertex_count = 3; @@ -19,12 +17,13 @@ void MovingEllipseEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { const CommonPostProcessUniforms u = { .resolution = {(float)width_, (float)height_}, + ._pad = {0.0f, 0.0f}, .aspect_ratio = a, .time = t, .beat = b, .audio_intensity = i, }; - wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, &u, sizeof(u)); + uniforms_.update(ctx_.queue, u); wgpuRenderPassEncoderSetPipeline(pass, pass_.pipeline); wgpuRenderPassEncoderSetBindGroup(pass, 0, pass_.bind_group, 0, nullptr); wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); |
