summaryrefslogtreecommitdiff
path: root/src/effects/particles_effect.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-17 08:16:03 +0100
committerskal <pascal.massimino@gmail.com>2026-02-17 08:16:03 +0100
commit64f977f6fbedf75d5edbc3963e002b593c8428d8 (patch)
treeef711b63d34b5c3f5ecc93d46a0a3ab0b6d26a6f /src/effects/particles_effect.cc
parent8c9332c16b44270921eb1b6a2886717eb3435d5d (diff)
style: Apply clang-format
Diffstat (limited to 'src/effects/particles_effect.cc')
-rw-r--r--src/effects/particles_effect.cc38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/effects/particles_effect.cc b/src/effects/particles_effect.cc
index 7a8d94d..35e9919 100644
--- a/src/effects/particles_effect.cc
+++ b/src/effects/particles_effect.cc
@@ -1,15 +1,15 @@
// This file is part of the 64k demo project.
// It implements the Particles.
-#include "util/fatal_error.h"
#include "effects/particles_effect.h"
-#include "gpu/gpu.h"
#include "effects/shaders.h"
+#include "gpu/gpu.h"
+#include "util/fatal_error.h"
#include <vector>
Particles::Particles(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs)
+ const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs)
: Effect(ctx, inputs, outputs) {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
HEADLESS_RETURN_IF_NULL(ctx_.device);
@@ -57,23 +57,27 @@ Particles::Particles(const GpuContext& ctx,
ResourceBinding render_bindings[] = {
{particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage},
{uniforms_.get(), WGPUBufferBindingType_Uniform}};
- render_pass_ = gpu_create_render_pass(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- particle_render_wgsl, render_bindings, 2);
+ render_pass_ =
+ gpu_create_render_pass(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
+ particle_render_wgsl, render_bindings, 2);
render_pass_.vertex_count = 6;
render_pass_.instance_count = NUM_PARTICLES;
}
void Particles::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
// Update uniforms
uniforms_.update(ctx_.queue, params);
// Run compute pass (particle simulation)
- WGPUComputePassEncoder compute = wgpuCommandEncoderBeginComputePass(encoder, nullptr);
+ WGPUComputePassEncoder compute =
+ wgpuCommandEncoderBeginComputePass(encoder, nullptr);
wgpuComputePassEncoderSetPipeline(compute, compute_pass_.pipeline);
- wgpuComputePassEncoderSetBindGroup(compute, 0, compute_pass_.bind_group, 0, nullptr);
- wgpuComputePassEncoderDispatchWorkgroups(compute, compute_pass_.workgroup_size_x, 1, 1);
+ wgpuComputePassEncoderSetBindGroup(compute, 0, compute_pass_.bind_group, 0,
+ nullptr);
+ wgpuComputePassEncoderDispatchWorkgroups(
+ compute, compute_pass_.workgroup_size_x, 1, 1);
wgpuComputePassEncoderEnd(compute);
// Run render pass (draw particles to output)
@@ -87,12 +91,14 @@ void Particles::render(WGPUCommandEncoder encoder,
.clearValue = {0.0, 0.0, 0.0, 1.0}};
WGPURenderPassDescriptor render_desc = {
- .colorAttachmentCount = 1,
- .colorAttachments = &color_attachment};
+ .colorAttachmentCount = 1, .colorAttachments = &color_attachment};
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &render_desc);
wgpuRenderPassEncoderSetPipeline(pass, render_pass_.pipeline);
- wgpuRenderPassEncoderSetBindGroup(pass, 0, render_pass_.bind_group, 0, nullptr);
- wgpuRenderPassEncoderDraw(pass, render_pass_.vertex_count, render_pass_.instance_count, 0, 0);
+ wgpuRenderPassEncoderSetBindGroup(pass, 0, render_pass_.bind_group, 0,
+ nullptr);
+ wgpuRenderPassEncoderDraw(pass, render_pass_.vertex_count,
+ render_pass_.instance_count, 0, 0);
wgpuRenderPassEncoderEnd(pass);
}