summaryrefslogtreecommitdiff
path: root/src/effects/peak_meter_effect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/peak_meter_effect.cc')
-rw-r--r--src/effects/peak_meter_effect.cc19
1 files changed, 6 insertions, 13 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);
}