summaryrefslogtreecommitdiff
path: root/src/gpu/effect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effect.cc')
-rw-r--r--src/gpu/effect.cc42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc
index 0ab476b..c3bd99a 100644
--- a/src/gpu/effect.cc
+++ b/src/gpu/effect.cc
@@ -188,11 +188,12 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
WGPUTextureView final_view = wgpuTextureCreateView(st.texture, nullptr);
passthrough_effect_->update_bind_group(framebuffer_view_a_);
- WGPURenderPassColorAttachment final_attachment = {
- .view = final_view, .loadOp = WGPULoadOp_Load, .storeOp = WGPUStoreOp_Store};
- WGPURenderPassDescriptor final_desc = {.colorAttachmentCount = 1,
- .colorAttachments =
- &final_attachment};
+ WGPURenderPassColorAttachment final_attachment = {.view = final_view,
+ .loadOp = WGPULoadOp_Load,
+ .storeOp =
+ WGPUStoreOp_Store};
+ WGPURenderPassDescriptor final_desc = {
+ .colorAttachmentCount = 1, .colorAttachments = &final_attachment};
WGPURenderPassEncoder final_pass =
wgpuCommandEncoderBeginRenderPass(encoder, &final_desc);
passthrough_effect_->render(final_pass, 0, 0, 0, aspect_ratio);
@@ -210,16 +211,19 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
wgpuSurfaceGetCurrentTexture(surface, &st);
WGPUTextureView current_output =
- is_last ? wgpuTextureCreateView(st.texture, nullptr)
- : (current_input == framebuffer_view_a_ ? framebuffer_view_b_
- : framebuffer_view_a_);
+ is_last
+ ? wgpuTextureCreateView(st.texture, nullptr)
+ : (current_input == framebuffer_view_a_ ? framebuffer_view_b_
+ : framebuffer_view_a_);
PostProcessEffect *pp =
static_cast<PostProcessEffect *>(post_effects[i]->effect.get());
pp->update_bind_group(current_input);
- WGPURenderPassColorAttachment pp_attachment = {
- .view = current_output, .loadOp = WGPULoadOp_Load, .storeOp = WGPUStoreOp_Store};
+ WGPURenderPassColorAttachment pp_attachment = {.view = current_output,
+ .loadOp = WGPULoadOp_Load,
+ .storeOp =
+ WGPUStoreOp_Store};
WGPURenderPassDescriptor pp_desc = {.colorAttachmentCount = 1,
.colorAttachments = &pp_attachment};
WGPURenderPassEncoder pp_pass =
@@ -242,10 +246,14 @@ void MainSequence::render_frame(float global_time, float beat, float peak,
}
void MainSequence::shutdown() {
- if (framebuffer_view_a_) wgpuTextureViewRelease(framebuffer_view_a_);
- if (framebuffer_a_) wgpuTextureRelease(framebuffer_a_);
- if (framebuffer_view_b_) wgpuTextureViewRelease(framebuffer_view_b_);
- if (framebuffer_b_) wgpuTextureRelease(framebuffer_b_);
+ if (framebuffer_view_a_)
+ wgpuTextureViewRelease(framebuffer_view_a_);
+ if (framebuffer_a_)
+ wgpuTextureRelease(framebuffer_a_);
+ if (framebuffer_view_b_)
+ wgpuTextureViewRelease(framebuffer_view_b_);
+ if (framebuffer_b_)
+ wgpuTextureRelease(framebuffer_b_);
for (auto &entry : sequences_) {
entry.seq->reset();
}
@@ -256,7 +264,8 @@ void MainSequence::simulate_until(float target_time, float step_rate) {
const float bpm = 128.0f;
const float aspect_ratio = 16.0f / 9.0f;
for (float t = 0.0f; t < target_time; t += step_rate) {
- WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
+ WGPUCommandEncoder encoder =
+ wgpuDeviceCreateCommandEncoder(device, nullptr);
float beat = fmodf(t * bpm / 60.0f, 1.0f);
std::vector<SequenceItem *> scene_effects, post_effects;
for (auto &entry : sequences_) {
@@ -266,7 +275,8 @@ void MainSequence::simulate_until(float target_time, float step_rate) {
}
}
for (const auto &item : scene_effects) {
- item->effect->compute(encoder, t - item->start_time, beat, 0.0f, aspect_ratio);
+ item->effect->compute(encoder, t - item->start_time, beat, 0.0f,
+ aspect_ratio);
}
WGPUCommandBuffer commands = wgpuCommandEncoderFinish(encoder, nullptr);
wgpuQueueSubmit(queue, 1, &commands);