summaryrefslogtreecommitdiff
path: root/src/effects
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
parent8c9332c16b44270921eb1b6a2886717eb3435d5d (diff)
style: Apply clang-format
Diffstat (limited to 'src/effects')
-rw-r--r--src/effects/flash_effect.cc38
-rw-r--r--src/effects/flash_effect.h8
-rw-r--r--src/effects/gaussian_blur_effect.cc19
-rw-r--r--src/effects/gaussian_blur_effect.h6
-rw-r--r--src/effects/heptagon_effect.cc44
-rw-r--r--src/effects/heptagon_effect.h3
-rw-r--r--src/effects/hybrid3_d_effect.cc36
-rw-r--r--src/effects/hybrid3_d_effect.h8
-rw-r--r--src/effects/particles_effect.cc38
-rw-r--r--src/effects/particles_effect.h9
-rw-r--r--src/effects/passthrough_effect.cc32
-rw-r--r--src/effects/passthrough_effect.h2
-rw-r--r--src/effects/peak_meter_effect.cc22
-rw-r--r--src/effects/peak_meter_effect.h8
-rw-r--r--src/effects/placeholder_effect.cc32
-rw-r--r--src/effects/placeholder_effect.h5
-rw-r--r--src/effects/rotating_cube_effect.cc35
-rw-r--r--src/effects/rotating_cube_effect.h8
-rw-r--r--src/effects/shaders.cc3
19 files changed, 177 insertions, 179 deletions
diff --git a/src/effects/flash_effect.cc b/src/effects/flash_effect.cc
index 9f0a6fa..ac46562 100644
--- a/src/effects/flash_effect.cc
+++ b/src/effects/flash_effect.cc
@@ -2,21 +2,19 @@
// Pulses white based on beat timing
#include "effects/flash_effect.h"
-#include "gpu/post_process_helper.h"
#include "effects/shaders.h"
+#include "gpu/post_process_helper.h"
#include "util/fatal_error.h"
-Flash::Flash(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs)
+Flash::Flash(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs)
: Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr), dummy_texture_(nullptr), dummy_texture_view_(nullptr) {
HEADLESS_RETURN_IF_NULL(ctx_.device);
uniforms_buffer_.init(ctx_.device);
- pipeline_ = create_post_process_pipeline(ctx_.device,
- WGPUTextureFormat_RGBA8Unorm,
- flash_shader_wgsl);
+ pipeline_ = create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, flash_shader_wgsl);
// Create dummy sampler (scene effects don't use texture input)
WGPUSamplerDescriptor sampler_desc = {};
@@ -40,16 +38,20 @@ Flash::Flash(const GpuContext& ctx,
}
Flash::~Flash() {
- if (bind_group_) wgpuBindGroupRelease(bind_group_);
- if (pipeline_) wgpuRenderPipelineRelease(pipeline_);
- if (sampler_) wgpuSamplerRelease(sampler_);
- if (dummy_texture_view_) wgpuTextureViewRelease(dummy_texture_view_);
- if (dummy_texture_) wgpuTextureRelease(dummy_texture_);
+ if (bind_group_)
+ wgpuBindGroupRelease(bind_group_);
+ if (pipeline_)
+ wgpuRenderPipelineRelease(pipeline_);
+ if (sampler_)
+ wgpuSamplerRelease(sampler_);
+ if (dummy_texture_view_)
+ wgpuTextureViewRelease(dummy_texture_view_);
+ if (dummy_texture_)
+ wgpuTextureRelease(dummy_texture_);
}
void Flash::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params, NodeRegistry& nodes) {
// Get output view (scene effects typically write to output, ignore input)
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -57,8 +59,9 @@ void Flash::render(WGPUCommandEncoder encoder,
uniforms_buffer_.update(ctx_.queue, params);
// Update bind group (use dummy texture for scene effect)
- pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, dummy_texture_view_,
- uniforms_buffer_.get(), {nullptr, 0});
+ pp_update_bind_group(ctx_.device, pipeline_, &bind_group_,
+ dummy_texture_view_, uniforms_buffer_.get(),
+ {nullptr, 0});
// Render pass
WGPURenderPassColorAttachment color_attachment = {};
@@ -72,7 +75,8 @@ void Flash::render(WGPUCommandEncoder encoder,
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
diff --git a/src/effects/flash_effect.h b/src/effects/flash_effect.h
index 9e7a326..08b7709 100644
--- a/src/effects/flash_effect.h
+++ b/src/effects/flash_effect.h
@@ -7,13 +7,11 @@
class Flash : public Effect {
public:
- Flash(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ Flash(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
~Flash() override;
- void render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
diff --git a/src/effects/gaussian_blur_effect.cc b/src/effects/gaussian_blur_effect.cc
index d163e51..b2713ae 100644
--- a/src/effects/gaussian_blur_effect.cc
+++ b/src/effects/gaussian_blur_effect.cc
@@ -1,21 +1,21 @@
// Gaussian blur effect implementation
#include "effects/gaussian_blur_effect.h"
-#include "util/fatal_error.h"
-#include "gpu/post_process_helper.h"
#include "effects/shaders.h"
+#include "gpu/post_process_helper.h"
+#include "util/fatal_error.h"
GaussianBlur::GaussianBlur(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), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr) {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
HEADLESS_RETURN_IF_NULL(ctx_.device);
// Create pipeline
- pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- gaussian_blur_shader_wgsl);
+ pipeline_ = create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, gaussian_blur_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
@@ -32,8 +32,8 @@ GaussianBlur::GaussianBlur(const GpuContext& ctx,
}
void GaussianBlur::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
// Get input/output views
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -77,7 +77,8 @@ void GaussianBlur::render(WGPUCommandEncoder encoder,
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
diff --git a/src/effects/gaussian_blur_effect.h b/src/effects/gaussian_blur_effect.h
index 0fd3d4e..4cb55a3 100644
--- a/src/effects/gaussian_blur_effect.h
+++ b/src/effects/gaussian_blur_effect.h
@@ -16,9 +16,8 @@ static_assert(sizeof(GaussianBlurParams) == 16,
class GaussianBlur : public Effect {
public:
- GaussianBlur(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ GaussianBlur(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
@@ -31,4 +30,3 @@ class GaussianBlur : public Effect {
UniformBuffer<GaussianBlurParams> params_buffer_;
UniformBuffer<UniformsSequenceParams> uniforms_buffer_;
};
-
diff --git a/src/effects/heptagon_effect.cc b/src/effects/heptagon_effect.cc
index 20761dc..fd83229 100644
--- a/src/effects/heptagon_effect.cc
+++ b/src/effects/heptagon_effect.cc
@@ -1,15 +1,16 @@
// Heptagon effect implementation
#include "effects/heptagon_effect.h"
-#include "util/fatal_error.h"
+#include "effects/shaders.h"
#include "gpu/gpu.h"
#include "gpu/post_process_helper.h"
-#include "effects/shaders.h"
+#include "util/fatal_error.h"
Heptagon::Heptagon(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs)
- : Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr), sampler_(nullptr) {
+ const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs)
+ : Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr),
+ sampler_(nullptr) {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
HEADLESS_RETURN_IF_NULL(ctx_.device);
@@ -17,8 +18,8 @@ Heptagon::Heptagon(const GpuContext& ctx,
uniforms_buffer_.init(ctx_.device);
// Create pipeline (standard post-process, no depth)
- pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- heptagon_shader_wgsl);
+ pipeline_ = create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, heptagon_shader_wgsl);
// Create dummy sampler (scene effects don't use texture input)
WGPUSamplerDescriptor sampler_desc = {};
@@ -42,16 +43,21 @@ Heptagon::Heptagon(const GpuContext& ctx,
}
Heptagon::~Heptagon() {
- if (bind_group_) wgpuBindGroupRelease(bind_group_);
- if (pipeline_) wgpuRenderPipelineRelease(pipeline_);
- if (sampler_) wgpuSamplerRelease(sampler_);
- if (dummy_texture_view_) wgpuTextureViewRelease(dummy_texture_view_);
- if (dummy_texture_) wgpuTextureRelease(dummy_texture_);
+ if (bind_group_)
+ wgpuBindGroupRelease(bind_group_);
+ if (pipeline_)
+ wgpuRenderPipelineRelease(pipeline_);
+ if (sampler_)
+ wgpuSamplerRelease(sampler_);
+ if (dummy_texture_view_)
+ wgpuTextureViewRelease(dummy_texture_view_);
+ if (dummy_texture_)
+ wgpuTextureRelease(dummy_texture_);
}
void Heptagon::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
// Get output view (scene effects typically write to output, ignore input)
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -59,8 +65,9 @@ void Heptagon::render(WGPUCommandEncoder encoder,
uniforms_buffer_.update(ctx_.queue, params);
// Create bind group (use dummy texture for scene effect)
- pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, dummy_texture_view_,
- uniforms_buffer_.get(), {nullptr, 0});
+ pp_update_bind_group(ctx_.device, pipeline_, &bind_group_,
+ dummy_texture_view_, uniforms_buffer_.get(),
+ {nullptr, 0});
// Render pass
WGPURenderPassColorAttachment color_attachment = {};
@@ -74,10 +81,11 @@ void Heptagon::render(WGPUCommandEncoder encoder,
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
- wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle
+ wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle
wgpuRenderPassEncoderEnd(pass);
wgpuRenderPassEncoderRelease(pass);
}
diff --git a/src/effects/heptagon_effect.h b/src/effects/heptagon_effect.h
index fbc0b8c..f4e4f9e 100644
--- a/src/effects/heptagon_effect.h
+++ b/src/effects/heptagon_effect.h
@@ -8,7 +8,7 @@
class Heptagon : public Effect {
public:
Heptagon(const GpuContext& ctx, const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ const std::vector<std::string>& outputs);
~Heptagon();
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
@@ -22,4 +22,3 @@ class Heptagon : public Effect {
WGPUTextureView dummy_texture_view_;
UniformBuffer<UniformsSequenceParams> uniforms_buffer_;
};
-
diff --git a/src/effects/hybrid3_d_effect.cc b/src/effects/hybrid3_d_effect.cc
index c13c1e9..027e2a7 100644
--- a/src/effects/hybrid3_d_effect.cc
+++ b/src/effects/hybrid3_d_effect.cc
@@ -8,8 +8,8 @@
#include <cmath>
Hybrid3D::Hybrid3D(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), depth_node_(outputs[0] + "_depth"),
dummy_texture_(nullptr), dummy_texture_view_(nullptr) {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
@@ -33,24 +33,12 @@ Hybrid3D::Hybrid3D(const GpuContext& ctx,
uint32_t white_pixel = 0xFFFFFFFF;
#if defined(DEMO_CROSS_COMPILE_WIN32)
WGPUImageCopyTexture dst = {
- .texture = dummy_texture_,
- .mipLevel = 0,
- .origin = {0, 0, 0}
- };
- WGPUTextureDataLayout data_layout = {
- .bytesPerRow = 4,
- .rowsPerImage = 1
- };
+ .texture = dummy_texture_, .mipLevel = 0, .origin = {0, 0, 0}};
+ WGPUTextureDataLayout data_layout = {.bytesPerRow = 4, .rowsPerImage = 1};
#else
WGPUTexelCopyTextureInfo dst = {
- .texture = dummy_texture_,
- .mipLevel = 0,
- .origin = {0, 0, 0}
- };
- WGPUTexelCopyBufferLayout data_layout = {
- .bytesPerRow = 4,
- .rowsPerImage = 1
- };
+ .texture = dummy_texture_, .mipLevel = 0, .origin = {0, 0, 0}};
+ WGPUTexelCopyBufferLayout data_layout = {.bytesPerRow = 4, .rowsPerImage = 1};
#endif
WGPUExtent3D size = {1, 1, 1};
wgpuQueueWriteTexture(ctx_.queue, &dst, &white_pixel, 4, &data_layout, &size);
@@ -68,8 +56,9 @@ Hybrid3D::Hybrid3D(const GpuContext& ctx,
scene_.add_object(center);
for (int i = 0; i < 8; ++i) {
- ObjectType type = (i % 3 == 1) ? ObjectType::TORUS :
- (i % 3 == 2) ? ObjectType::BOX : ObjectType::SPHERE;
+ ObjectType type = (i % 3 == 1) ? ObjectType::TORUS
+ : (i % 3 == 2) ? ObjectType::BOX
+ : ObjectType::SPHERE;
Object3D obj(type);
float angle = (i / 8.0f) * 6.28318f;
@@ -101,8 +90,8 @@ void Hybrid3D::declare_nodes(NodeRegistry& registry) {
}
void Hybrid3D::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
// Update camera (orbiting)
float angle = params.time * 0.3f;
vec3 cam_pos = vec3(std::cos(angle) * 10.0f, 5.0f, std::sin(angle) * 10.0f);
@@ -135,7 +124,8 @@ void Hybrid3D::render(WGPUCommandEncoder encoder,
pass_desc.colorAttachments = &color_attachment;
pass_desc.depthStencilAttachment = &depth_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
renderer_.draw(pass, scene_, camera_, params.time);
wgpuRenderPassEncoderEnd(pass);
wgpuRenderPassEncoderRelease(pass);
diff --git a/src/effects/hybrid3_d_effect.h b/src/effects/hybrid3_d_effect.h
index 7950374..10bee58 100644
--- a/src/effects/hybrid3_d_effect.h
+++ b/src/effects/hybrid3_d_effect.h
@@ -11,14 +11,12 @@
class Hybrid3D : public Effect {
public:
- Hybrid3D(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ Hybrid3D(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
~Hybrid3D() override;
void declare_nodes(NodeRegistry& registry) override;
- void render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
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);
}
diff --git a/src/effects/particles_effect.h b/src/effects/particles_effect.h
index 174a6c7..5799690 100644
--- a/src/effects/particles_effect.h
+++ b/src/effects/particles_effect.h
@@ -20,11 +20,9 @@ struct Particle {
class Particles : public Effect {
public:
- Particles(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
- void render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
+ Particles(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
@@ -33,4 +31,3 @@ class Particles : public Effect {
GpuBuffer particles_buffer_;
UniformBuffer<UniformsSequenceParams> uniforms_;
};
-
diff --git a/src/effects/passthrough_effect.cc b/src/effects/passthrough_effect.cc
index 94da241..be53846 100644
--- a/src/effects/passthrough_effect.cc
+++ b/src/effects/passthrough_effect.cc
@@ -1,13 +1,13 @@
// Passthrough effect implementation
#include "effects/passthrough_effect.h"
-#include "util/fatal_error.h"
-#include "gpu/post_process_helper.h"
#include "effects/shaders.h"
+#include "gpu/post_process_helper.h"
+#include "util/fatal_error.h"
Passthrough::Passthrough(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), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr) {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
@@ -16,8 +16,8 @@ Passthrough::Passthrough(const GpuContext& ctx,
// Init uniform buffer
uniforms_buffer_.init(ctx_.device);
// Create pipeline (simple version without effect params)
- pipeline_ = create_post_process_pipeline_simple(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- passthrough_shader_wgsl);
+ pipeline_ = create_post_process_pipeline_simple(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, passthrough_shader_wgsl);
// Create sampler
WGPUSamplerDescriptor sampler_desc = {};
@@ -32,8 +32,8 @@ Passthrough::Passthrough(const GpuContext& ctx,
}
void Passthrough::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
// Get input/output views
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -63,21 +63,21 @@ void Passthrough::render(WGPUCommandEncoder encoder,
// Render pass
WGPURenderPassColorAttachment color_attachment = {
- .view = output_view,
- .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
- .loadOp = WGPULoadOp_Clear,
- .storeOp = WGPUStoreOp_Store,
- .clearValue = {0.0, 0.0, 0.0, 1.0}
- };
+ .view = output_view,
+ .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
+ .loadOp = WGPULoadOp_Clear,
+ .storeOp = WGPUStoreOp_Store,
+ .clearValue = {0.0, 0.0, 0.0, 1.0}};
WGPURenderPassDescriptor pass_desc = {};
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
- wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle
+ wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle
wgpuRenderPassEncoderEnd(pass);
wgpuRenderPassEncoderRelease(pass);
}
diff --git a/src/effects/passthrough_effect.h b/src/effects/passthrough_effect.h
index 88c623b..00bf423 100644
--- a/src/effects/passthrough_effect.h
+++ b/src/effects/passthrough_effect.h
@@ -8,7 +8,7 @@
class Passthrough : public Effect {
public:
Passthrough(const GpuContext& ctx, const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ const std::vector<std::string>& outputs);
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
diff --git a/src/effects/peak_meter_effect.cc b/src/effects/peak_meter_effect.cc
index 124c59b..a2cf6fc 100644
--- a/src/effects/peak_meter_effect.cc
+++ b/src/effects/peak_meter_effect.cc
@@ -6,8 +6,8 @@
#include "util/fatal_error.h"
PeakMeter::PeakMeter(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), pipeline_(nullptr), bind_group_(nullptr) {
HEADLESS_RETURN_IF_NULL(ctx_.device);
@@ -58,19 +58,20 @@ 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());
+ 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_);
+ if (bind_group_)
+ wgpuBindGroupRelease(bind_group_);
+ if (pipeline_)
+ wgpuRenderPipelineRelease(pipeline_);
}
void PeakMeter::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -89,7 +90,8 @@ void PeakMeter::render(WGPUCommandEncoder encoder,
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
diff --git a/src/effects/peak_meter_effect.h b/src/effects/peak_meter_effect.h
index ea1cce5..b563289 100644
--- a/src/effects/peak_meter_effect.h
+++ b/src/effects/peak_meter_effect.h
@@ -7,13 +7,11 @@
class PeakMeter : public Effect {
public:
- PeakMeter(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ PeakMeter(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
~PeakMeter() override;
- void render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
diff --git a/src/effects/placeholder_effect.cc b/src/effects/placeholder_effect.cc
index 73ee5a8..1428779 100644
--- a/src/effects/placeholder_effect.cc
+++ b/src/effects/placeholder_effect.cc
@@ -1,15 +1,15 @@
// Placeholder effect implementation - logs TODO warning once
#include "effects/placeholder_effect.h"
-#include "util/fatal_error.h"
-#include "gpu/post_process_helper.h"
#include "effects/shaders.h"
+#include "gpu/post_process_helper.h"
+#include "util/fatal_error.h"
#include <cstdio>
Placeholder::Placeholder(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs,
- const char* placeholder_name)
+ const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs,
+ const char* placeholder_name)
: Effect(ctx, inputs, outputs), pipeline_(nullptr), bind_group_(nullptr),
sampler_(nullptr), name_(placeholder_name) {
// Log once on construction
@@ -19,8 +19,8 @@ Placeholder::Placeholder(const GpuContext& ctx,
HEADLESS_RETURN_IF_NULL(ctx_.device);
uniforms_buffer_.init(ctx_.device);
- pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm,
- passthrough_shader_wgsl);
+ pipeline_ = create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, passthrough_shader_wgsl);
WGPUSamplerDescriptor sampler_desc = {};
sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge;
@@ -34,8 +34,8 @@ Placeholder::Placeholder(const GpuContext& ctx,
}
void Placeholder::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
WGPUTextureView input_view = nodes.get_view(input_nodes_[0]);
WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
@@ -45,18 +45,18 @@ void Placeholder::render(WGPUCommandEncoder encoder,
uniforms_buffer_.get(), {nullptr, 0});
WGPURenderPassColorAttachment color_attachment = {
- .view = output_view,
- .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
- .loadOp = WGPULoadOp_Clear,
- .storeOp = WGPUStoreOp_Store,
- .clearValue = {0.0, 0.0, 0.0, 1.0}
- };
+ .view = output_view,
+ .depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
+ .loadOp = WGPULoadOp_Clear,
+ .storeOp = WGPUStoreOp_Store,
+ .clearValue = {0.0, 0.0, 0.0, 1.0}};
WGPURenderPassDescriptor pass_desc = {};
pass_desc.colorAttachmentCount = 1;
pass_desc.colorAttachments = &color_attachment;
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
diff --git a/src/effects/placeholder_effect.h b/src/effects/placeholder_effect.h
index eaa1f6e..7d8d734 100644
--- a/src/effects/placeholder_effect.h
+++ b/src/effects/placeholder_effect.h
@@ -9,8 +9,8 @@
class Placeholder : public Effect {
public:
Placeholder(const GpuContext& ctx, const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs,
- const char* placeholder_name = "UnknownEffect");
+ const std::vector<std::string>& outputs,
+ const char* placeholder_name = "UnknownEffect");
void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
@@ -22,4 +22,3 @@ class Placeholder : public Effect {
UniformBuffer<UniformsSequenceParams> uniforms_buffer_;
const char* name_;
};
-
diff --git a/src/effects/rotating_cube_effect.cc b/src/effects/rotating_cube_effect.cc
index c892dfe..42a0ba7 100644
--- a/src/effects/rotating_cube_effect.cc
+++ b/src/effects/rotating_cube_effect.cc
@@ -1,15 +1,15 @@
// This file is part of the 64k demo project.
// It implements RotatingCube.
-#include "util/fatal_error.h"
#include "effects/rotating_cube_effect.h"
+#include "effects/shaders.h"
#include "gpu/bind_group_builder.h"
#include "gpu/gpu.h"
-#include "effects/shaders.h"
+#include "util/fatal_error.h"
RotatingCube::RotatingCube(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), depth_node_(outputs[0] + "_depth") {
// Headless mode: skip GPU resource creation (compiled out in STRIP_ALL)
HEADLESS_RETURN_IF_NULL(ctx_.device);
@@ -113,8 +113,8 @@ void RotatingCube::declare_nodes(NodeRegistry& registry) {
}
void RotatingCube::render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
- NodeRegistry& nodes) {
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
rotation_ += 0.016f * 1.5f;
// Camera setup
@@ -138,7 +138,8 @@ void RotatingCube::render(WGPUCommandEncoder encoder,
const Uniforms uniforms = {
.view_proj = view_proj,
.inv_view_proj = view_proj.inverse(),
- .camera_pos_time = vec4(camera_pos.x, camera_pos.y, camera_pos.z, params.time),
+ .camera_pos_time =
+ vec4(camera_pos.x, camera_pos.y, camera_pos.z, params.time),
.params = vec4(1.0f, 0.0f, 0.0f, 0.0f),
.resolution = params.resolution,
.aspect_ratio = params.aspect_ratio,
@@ -163,8 +164,9 @@ void RotatingCube::render(WGPUCommandEncoder encoder,
if (input_tex && output_tex) {
WGPUTexelCopyTextureInfo src = {
.texture = input_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All};
- WGPUTexelCopyTextureInfo dst = {
- .texture = output_tex, .mipLevel = 0, .aspect = WGPUTextureAspect_All};
+ WGPUTexelCopyTextureInfo dst = {.texture = output_tex,
+ .mipLevel = 0,
+ .aspect = WGPUTextureAspect_All};
WGPUExtent3D copy_size = {(uint32_t)params.resolution.x,
(uint32_t)params.resolution.y, 1};
wgpuCommandEncoderCopyTextureToTexture(encoder, &src, &dst, &copy_size);
@@ -179,7 +181,7 @@ void RotatingCube::render(WGPUCommandEncoder encoder,
WGPURenderPassColorAttachment color_attachment = {
.view = color_view,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
-// .loadOp = WGPULoadOp_Clear,
+ // .loadOp = WGPULoadOp_Clear,
.loadOp = WGPULoadOp_Load,
.storeOp = WGPUStoreOp_Store,
.clearValue = {0.0, 0.0, 0.0, 0.0}};
@@ -190,15 +192,16 @@ void RotatingCube::render(WGPUCommandEncoder encoder,
.depthStoreOp = WGPUStoreOp_Discard,
.depthClearValue = 1.0f};
- WGPURenderPassDescriptor pass_desc = {
- .colorAttachmentCount = 1,
- .colorAttachments = &color_attachment,
- .depthStencilAttachment = &depth_attachment};
+ WGPURenderPassDescriptor pass_desc = {.colorAttachmentCount = 1,
+ .colorAttachments = &color_attachment,
+ .depthStencilAttachment =
+ &depth_attachment};
- WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
wgpuRenderPassEncoderSetPipeline(pass, pipeline_);
wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr);
- wgpuRenderPassEncoderDraw(pass, 36, 1, 0, 0); // 36 vertices for cube
+ 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 bdcf180..0c713d2 100644
--- a/src/effects/rotating_cube_effect.h
+++ b/src/effects/rotating_cube_effect.h
@@ -10,14 +10,12 @@
class RotatingCube : public Effect {
public:
- RotatingCube(const GpuContext& ctx,
- const std::vector<std::string>& inputs,
- const std::vector<std::string>& outputs);
+ RotatingCube(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs);
~RotatingCube() override;
void declare_nodes(NodeRegistry& registry) override;
- void render(WGPUCommandEncoder encoder,
- const UniformsSequenceParams& params,
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
NodeRegistry& nodes) override;
private:
diff --git a/src/effects/shaders.cc b/src/effects/shaders.cc
index a9a82de..d181632 100644
--- a/src/effects/shaders.cc
+++ b/src/effects/shaders.cc
@@ -91,8 +91,7 @@ const char* particle_render_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_PARTICLE_RENDER);
const char* rotating_cube_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_ROTATING_CUBE_V2);
-const char* flash_shader_wgsl =
- SafeGetAsset(AssetId::ASSET_SHADER_FLASH);
+const char* flash_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_FLASH);
// Compute shaders
const char* gen_noise_compute_wgsl =