summaryrefslogtreecommitdiff
path: root/src/effects
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-05-20 23:12:08 +0200
committerskal <pascal.massimino@gmail.com>2026-05-20 23:21:59 +0200
commitca8acd5e7c0556bee7cb21f5ff280c5fd1f47801 (patch)
tree3811886d12f075ba196f2a7ba2d05c0d5b43574b /src/effects
parenta91f89c8ea15665853176c05597760d0fcf6e0df (diff)
fix: audio & effects cleanup — dead code removal, simplifications
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/peak_meter_effect.cc19
-rw-r--r--src/effects/peak_meter_effect.h6
-rw-r--r--src/effects/rotating_cube_effect.cc15
-rw-r--r--src/effects/rotating_cube_effect.h6
4 files changed, 16 insertions, 30 deletions
diff --git a/src/effects/peak_meter_effect.cc b/src/effects/peak_meter_effect.cc
index c2ef42e..8956e32 100644
--- a/src/effects/peak_meter_effect.cc
+++ b/src/effects/peak_meter_effect.cc
@@ -9,8 +9,7 @@ PeakMeter::PeakMeter(const GpuContext& ctx,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs, float start_time,
float end_time)
- : Effect(ctx, inputs, outputs, start_time, end_time), pipeline_(nullptr),
- bind_group_(nullptr) {
+ : Effect(ctx, inputs, outputs, start_time, end_time) {
HEADLESS_RETURN_IF_NULL(ctx_.device);
const char* shader_main = R"(
@@ -58,15 +57,8 @@ PeakMeter::PeakMeter(const GpuContext& ctx,
std::string shader_code =
ShaderComposer::Get().Compose({"common_uniforms"}, shader_main);
- pipeline_ = create_post_process_pipeline(
- ctx_.device, WGPUTextureFormat_RGBA8Unorm, shader_code.c_str());
-}
-
-PeakMeter::~PeakMeter() {
- if (bind_group_)
- wgpuBindGroupRelease(bind_group_);
- if (pipeline_)
- wgpuRenderPipelineRelease(pipeline_);
+ pipeline_.set(create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, shader_code.c_str()));
}
void PeakMeter::render(WGPUCommandEncoder encoder,
@@ -75,9 +67,10 @@ void PeakMeter::render(WGPUCommandEncoder encoder,
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
- pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view,
+ pp_update_bind_group(ctx_.device, pipeline_.get(),
+ bind_group_.get_address(), input_view,
uniforms_buffer_.get(), {nullptr, 0});
- run_fullscreen_pass(encoder, pipeline_, bind_group_, output_view,
+ run_fullscreen_pass(encoder, pipeline_.get(), bind_group_.get(), output_view,
WGPULoadOp_Load);
}
diff --git a/src/effects/peak_meter_effect.h b/src/effects/peak_meter_effect.h
index 1f19ed6..b822efd 100644
--- a/src/effects/peak_meter_effect.h
+++ b/src/effects/peak_meter_effect.h
@@ -4,18 +4,18 @@
#pragma once
#include "gpu/effect.h"
#include "gpu/uniform_helper.h"
+#include "gpu/wgpu_resource.h"
class PeakMeter : public Effect {
public:
PeakMeter(const GpuContext& ctx, const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs, float start_time,
float end_time);
- ~PeakMeter() override;
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
- WGPURenderPipeline pipeline_;
- WGPUBindGroup bind_group_;
+ RenderPipeline pipeline_;
+ BindGroup bind_group_;
};
diff --git a/src/effects/rotating_cube_effect.cc b/src/effects/rotating_cube_effect.cc
index 82f90c5..000d177 100644
--- a/src/effects/rotating_cube_effect.cc
+++ b/src/effects/rotating_cube_effect.cc
@@ -84,7 +84,7 @@ RotatingCube::RotatingCube(const GpuContext& ctx,
pipeline_desc.multisample.mask = 0xFFFFFFFF;
pipeline_desc.fragment = &fragment;
- pipeline_ = wgpuDeviceCreateRenderPipeline(ctx_.device, &pipeline_desc);
+ pipeline_.set(wgpuDeviceCreateRenderPipeline(ctx_.device, &pipeline_desc));
wgpuShaderModuleRelease(shader_module);
wgpuPipelineLayoutRelease(pipeline_layout);
@@ -103,17 +103,10 @@ RotatingCube::RotatingCube(const GpuContext& ctx,
.entryCount = 2,
.entries = entries,
};
- bind_group_ = wgpuDeviceCreateBindGroup(ctx_.device, &bg_desc);
+ bind_group_.set(wgpuDeviceCreateBindGroup(ctx_.device, &bg_desc));
wgpuBindGroupLayoutRelease(bgl);
}
-RotatingCube::~RotatingCube() {
- if (bind_group_)
- wgpuBindGroupRelease(bind_group_);
- if (pipeline_)
- wgpuRenderPipelineRelease(pipeline_);
-}
-
void RotatingCube::declare_nodes(NodeRegistry& registry) {
// Declare depth buffer node
registry.declare_node(depth_node_, NodeType::DEPTH24, -1, -1);
@@ -201,8 +194,8 @@ void RotatingCube::render(WGPUCommandEncoder encoder,
WGPURenderPassEncoder pass =
wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
- wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
- wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
+ wgpuRenderPassEncoderSetPipeline(pass, pipeline_.get());
+ wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_.get(), 0, nullptr);
wgpuRenderPassEncoderDraw(pass, 36, 1, 0, 0); // 36 vertices for cube
wgpuRenderPassEncoderEnd(pass);
wgpuRenderPassEncoderRelease(pass);
diff --git a/src/effects/rotating_cube_effect.h b/src/effects/rotating_cube_effect.h
index fb321fa..0aa1469 100644
--- a/src/effects/rotating_cube_effect.h
+++ b/src/effects/rotating_cube_effect.h
@@ -6,6 +6,7 @@
#include "gpu/effect.h"
#include "gpu/gpu.h"
#include "gpu/uniform_helper.h"
+#include "gpu/wgpu_resource.h"
#include "util/mini_math.h"
class RotatingCube : public Effect {
@@ -13,7 +14,6 @@ class RotatingCube : public Effect {
RotatingCube(const GpuContext& ctx, const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs, float start_time,
float end_time);
- ~RotatingCube() override;
void declare_nodes(NodeRegistry& registry) override;
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
@@ -44,8 +44,8 @@ class RotatingCube : public Effect {
};
static_assert(sizeof(ObjectData) == 160, "ObjectData size mismatch");
- WGPURenderPipeline pipeline_ = nullptr;
- WGPUBindGroup bind_group_ = nullptr;
+ RenderPipeline pipeline_;
+ BindGroup bind_group_;
GpuBuffer uniform_buffer_;
GpuBuffer object_buffer_;
float rotation_ = 0.0f;