diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-17 08:16:03 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-17 08:16:03 +0100 |
| commit | 64f977f6fbedf75d5edbc3963e002b593c8428d8 (patch) | |
| tree | ef711b63d34b5c3f5ecc93d46a0a3ab0b6d26a6f /src | |
| parent | 8c9332c16b44270921eb1b6a2886717eb3435d5d (diff) | |
style: Apply clang-format
Diffstat (limited to 'src')
43 files changed, 304 insertions, 304 deletions
diff --git a/src/app/main.cc b/src/app/main.cc index eefec03..e020a2a 100644 --- a/src/app/main.cc +++ b/src/app/main.cc @@ -17,10 +17,10 @@ #include <csignal> #endif #endif -#include "generated/assets.h" // Include generated asset header +#include "generated/assets.h" // Include generated asset header +#include "generated/timeline.h" // For GetDemoDuration(), RenderTimeline() #include "gpu/demo_effects.h" #include "gpu/gpu.h" -#include "generated/timeline.h" // For GetDemoDuration(), RenderTimeline() #include "platform/platform.h" #include "util/math.h" #include <cmath> @@ -211,7 +211,8 @@ int main(int argc, char** argv) { } audio_start(); - g_last_audio_time = 0.0f; // Initialize to zero (will use smooth interpolation) + g_last_audio_time = + 0.0f; // Initialize to zero (will use smooth interpolation) #if !defined(STRIP_ALL) // Hot-reload setup @@ -414,8 +415,8 @@ int main(int argc, char** argv) { } // Draw graphics using v2 timeline - RenderTimeline(gpu_get_surface(), (float)current_physical_time, width, height, - absolute_beat_time, visual_peak); + RenderTimeline(gpu_get_surface(), (float)current_physical_time, width, + height, absolute_beat_time, visual_peak); last_frame_time = current_physical_time; } diff --git a/src/app/test_demo.cc b/src/app/test_demo.cc index 6031aef..afeb3bd 100644 --- a/src/app/test_demo.cc +++ b/src/app/test_demo.cc @@ -309,7 +309,7 @@ int main(int argc, char** argv) { // Draw graphics using v2 timeline const float graphics_frame_time = (float)current_physical_time; RenderTimeline(gpu_get_surface(), graphics_frame_time, width, height, - absolute_beat_time, visual_peak); + absolute_beat_time, visual_peak); } // Shutdown diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 9a6d689..89380cd 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -245,7 +245,8 @@ float audio_get_playback_time() { const double elapsed = current_time - last_callback_time; const float interpolated_samples = (float)(elapsed * RING_BUFFER_SAMPLE_RATE * RING_BUFFER_CHANNELS); - const float total_samples = (float)last_callback_samples + interpolated_samples; + const float total_samples = + (float)last_callback_samples + interpolated_samples; return total_samples / (RING_BUFFER_SAMPLE_RATE * RING_BUFFER_CHANNELS); } } diff --git a/src/audio/backend/miniaudio_backend.cc b/src/audio/backend/miniaudio_backend.cc index 8c5ce4a..312d36e 100644 --- a/src/audio/backend/miniaudio_backend.cc +++ b/src/audio/backend/miniaudio_backend.cc @@ -161,8 +161,8 @@ void MiniaudioBackend::audio_callback(ma_device* pDevice, void* pOutput, } #endif /* defined(DEBUG_LOG_RING_BUFFER) */ - // Peak calculation moved to audio_get_realtime_peak() for RMS-based measurement - // (uses ring buffer peek for accurate time-windowed RMS) + // Peak calculation moved to audio_get_realtime_peak() for RMS-based + // measurement (uses ring buffer peek for accurate time-windowed RMS) } #if defined(DEBUG_LOG_AUDIO) diff --git a/src/audio/backend/miniaudio_backend.h b/src/audio/backend/miniaudio_backend.h index 435496c..953a0c0 100644 --- a/src/audio/backend/miniaudio_backend.h +++ b/src/audio/backend/miniaudio_backend.h @@ -34,7 +34,7 @@ class MiniaudioBackend : public AudioBackend { static volatile float realtime_peak_; // Smooth playback time interpolation (updated in callback) - static volatile double last_callback_time_; // Absolute CLOCK_MONOTONIC time + static volatile double last_callback_time_; // Absolute CLOCK_MONOTONIC time static volatile int64_t last_callback_samples_; // Static callback required by miniaudio C API diff --git a/src/audio/tracker.cc b/src/audio/tracker.cc index e7da26a..9446c6f 100644 --- a/src/audio/tracker.cc +++ b/src/audio/tracker.cc @@ -149,7 +149,8 @@ void tracker_init() { for (uint32_t pid = 0; pid < g_tracker_patterns_count; ++pid) { const TrackerPattern& pattern = g_tracker_patterns[pid]; for (uint32_t i = 1; i < pattern.num_events; ++i) { - FATAL_CHECK(pattern.events[i].unit_time >= pattern.events[i - 1].unit_time, + FATAL_CHECK(pattern.events[i].unit_time >= + pattern.events[i - 1].unit_time, "Pattern %d has unsorted events: event[%d].time=%.3f < " "event[%d].time=%.3f\n", pid, i, pattern.events[i].unit_time, i - 1, 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, ©_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 = diff --git a/src/gpu/bind_group_builder.h b/src/gpu/bind_group_builder.h index 49b7ebe..7481f34 100644 --- a/src/gpu/bind_group_builder.h +++ b/src/gpu/bind_group_builder.h @@ -94,7 +94,8 @@ class BindGroupLayoutBuilder { } WGPUBindGroupLayout build(WGPUDevice device) { - // Headless mode: skip bind group layout creation (compiled out in STRIP_ALL) + // Headless mode: skip bind group layout creation (compiled out in + // STRIP_ALL) HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); WGPUBindGroupLayoutDescriptor desc{}; desc.entryCount = entries_.size(); diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index d98045e..85299ca 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -9,14 +9,15 @@ #include "3d/scene.h" // Base effect classes (v2) +#include "effects/shaders.h" #include "gpu/effect.h" #include "gpu/post_process_helper.h" #include "gpu/sequence.h" -#include "effects/shaders.h" #include "gpu/texture_manager.h" #include "gpu/uniform_helper.h" // Individual Effect Headers (v2) +#include "effects/flash_effect.h" #include "effects/gaussian_blur_effect.h" #include "effects/heptagon_effect.h" #include "effects/hybrid3_d_effect.h" @@ -25,7 +26,6 @@ #include "effects/peak_meter_effect.h" #include "effects/placeholder_effect.h" #include "effects/rotating_cube_effect.h" -#include "effects/flash_effect.h" // TODO: Port CNN effects to v2 // #include "../../cnn_v1/src/cnn_v1_effect.h" // #include "../../cnn_v2/src/cnn_v2_effect.h" diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index e4d3a90..b729321 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -4,7 +4,7 @@ #include "util/fatal_error.h" Effect::Effect(const GpuContext& ctx, const std::vector<std::string>& inputs, - const std::vector<std::string>& outputs) + const std::vector<std::string>& outputs) : ctx_(ctx), input_nodes_(inputs), output_nodes_(outputs) { FATAL_CHECK(!inputs.empty(), "Effect must have at least one input\n"); FATAL_CHECK(!outputs.empty(), "Effect must have at least one output\n"); diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 9955169..2226889 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -3,9 +3,9 @@ // Driven by audio peaks for synchronized visual effects. #include "gpu.h" +#include "effects/shaders.h" #include "generated/timeline.h" #include "gpu/shader_composer.h" -#include "effects/shaders.h" #include "platform/platform.h" #include <cassert> diff --git a/src/gpu/post_process_helper.cc b/src/gpu/post_process_helper.cc index 281fde6..9e7803c 100644 --- a/src/gpu/post_process_helper.cc +++ b/src/gpu/post_process_helper.cc @@ -41,9 +41,9 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, } // Helper to create a simple post-processing pipeline (no effect params) -WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device, - WGPUTextureFormat format, - const char* shader_code) { +WGPURenderPipeline +create_post_process_pipeline_simple(WGPUDevice device, WGPUTextureFormat format, + const char* shader_code) { // Headless mode: skip pipeline creation (compiled out in STRIP_ALL) HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); diff --git a/src/gpu/post_process_helper.h b/src/gpu/post_process_helper.h index 963f671..9a71046 100644 --- a/src/gpu/post_process_helper.h +++ b/src/gpu/post_process_helper.h @@ -21,7 +21,8 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format, const char* shader_code); -// Helper to create a simple post-processing pipeline (no effect params, 3 bindings only) +// Helper to create a simple post-processing pipeline (no effect params, 3 +// bindings only) WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device, WGPUTextureFormat format, const char* shader_code); diff --git a/src/gpu/sequence.cc b/src/gpu/sequence.cc index 0a0cb1e..5348992 100644 --- a/src/gpu/sequence.cc +++ b/src/gpu/sequence.cc @@ -42,9 +42,9 @@ NodeRegistry::~NodeRegistry() { } void NodeRegistry::declare_node(const std::string& name, NodeType type, - int width, int height) { - FATAL_CHECK(nodes_.find(name) == nodes_.end(), - "Node already declared: %s\n", name.c_str()); + int width, int height) { + FATAL_CHECK(nodes_.find(name) == nodes_.end(), "Node already declared: %s\n", + name.c_str()); if (width <= 0) width = default_width_; @@ -64,8 +64,8 @@ void NodeRegistry::declare_aliased_node(const std::string& name, const std::string& alias_of) { FATAL_CHECK(nodes_.find(alias_of) != nodes_.end(), "Alias target does not exist: %s\n", alias_of.c_str()); - FATAL_CHECK(aliases_.find(name) == aliases_.end(), "Alias already exists: %s\n", - name.c_str()); + FATAL_CHECK(aliases_.find(name) == aliases_.end(), + "Alias already exists: %s\n", name.c_str()); aliases_[name] = alias_of; } @@ -131,7 +131,7 @@ bool NodeRegistry::has_node(const std::string& name) const { } void NodeRegistry::set_external_view(const std::string& name, - WGPUTextureView view) { + WGPUTextureView view) { // Register external view (texture not owned by registry) Node node = {}; node.view = view; @@ -151,15 +151,25 @@ void NodeRegistry::create_texture(Node& node) { switch (node.type) { case NodeType::U8X4_NORM: format = WGPUTextureFormat_RGBA8Unorm; - usage = (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); + usage = + (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | + WGPUTextureUsage_TextureBinding | + WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); break; case NodeType::F32X4: format = WGPUTextureFormat_RGBA32Float; - usage = (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); + usage = + (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | + WGPUTextureUsage_TextureBinding | + WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); break; case NodeType::F16X8: - format = WGPUTextureFormat_RGBA16Float; // WebGPU doesn't have 8-channel, use RGBA16 - usage = (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); + format = WGPUTextureFormat_RGBA16Float; // WebGPU doesn't have 8-channel, + // use RGBA16 + usage = + (WGPUTextureUsage)(WGPUTextureUsage_RenderAttachment | + WGPUTextureUsage_TextureBinding | + WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst); break; case NodeType::DEPTH24: format = WGPUTextureFormat_Depth24Plus; @@ -167,7 +177,8 @@ void NodeRegistry::create_texture(Node& node) { break; case NodeType::COMPUTE_F32: format = WGPUTextureFormat_RGBA32Float; - usage = (WGPUTextureUsage)(WGPUTextureUsage_StorageBinding | WGPUTextureUsage_TextureBinding); + usage = (WGPUTextureUsage)(WGPUTextureUsage_StorageBinding | + WGPUTextureUsage_TextureBinding); break; } @@ -207,8 +218,9 @@ Sequence::Sequence(const GpuContext& ctx, int width, int height) } void Sequence::preprocess(float seq_time, float beat_time, float beat_phase, - float audio_intensity) { - params_.resolution = {static_cast<float>(width_), static_cast<float>(height_)}; + float audio_intensity) { + params_.resolution = {static_cast<float>(width_), + static_cast<float>(height_)}; params_.aspect_ratio = static_cast<float>(width_) / static_cast<float>(height_); params_.time = seq_time; diff --git a/src/gpu/sequence.h b/src/gpu/sequence.h index e96e183..0f448ce 100644 --- a/src/gpu/sequence.h +++ b/src/gpu/sequence.h @@ -35,9 +35,9 @@ struct Node { struct UniformsSequenceParams { vec2 resolution; float aspect_ratio; - float time; // Per-sequence relative time - float beat_time; // Musical beats - float beat_phase; // Fractional beat 0.0-1.0 + float time; // Per-sequence relative time + float beat_time; // Musical beats + float beat_phase; // Fractional beat 0.0-1.0 float audio_intensity; float _pad; }; diff --git a/src/tests/3d/test_3d_render.cc b/src/tests/3d/test_3d_render.cc index f802a40..bd301bd 100644 --- a/src/tests/3d/test_3d_render.cc +++ b/src/tests/3d/test_3d_render.cc @@ -7,8 +7,8 @@ #include "3d/renderer.h" #include "3d/renderer_helpers.h" #include "3d/scene.h" -#include "generated/assets.h" #include "effects/shaders.h" +#include "generated/assets.h" #include "gpu/texture_manager.h" #include "platform/platform.h" #include "procedural/generator.h" diff --git a/src/tests/assets/test_sequence.cc b/src/tests/assets/test_sequence.cc index 445e44b..8de9eca 100644 --- a/src/tests/assets/test_sequence.cc +++ b/src/tests/assets/test_sequence.cc @@ -179,7 +179,7 @@ int main() { return 0; } -#else // v2 port TODO +#else // v2 port TODO int main() { printf("test_sequence: SKIPPED (needs v2 port)\n"); return 0; diff --git a/src/tests/common/effect_test_helpers.cc b/src/tests/common/effect_test_helpers.cc index d776609..430b90f 100644 --- a/src/tests/common/effect_test_helpers.cc +++ b/src/tests/common/effect_test_helpers.cc @@ -66,4 +66,3 @@ uint64_t hash_pixels(const std::vector<uint8_t>& pixels) { } return hash; } - diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc index d012afb..7f9d3da 100644 --- a/src/tests/gpu/test_demo_effects.cc +++ b/src/tests/gpu/test_demo_effects.cc @@ -37,42 +37,33 @@ static void test_effects() { } std::vector<std::pair<const char*, std::shared_ptr<Effect>>> effects = { - {"Passthrough", - std::make_shared<Passthrough>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"GaussianBlur", - std::make_shared<GaussianBlur>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Placeholder", - std::make_shared<Placeholder>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Heptagon", - std::make_shared<Heptagon>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Particles", - std::make_shared<Particles>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"RotatingCube", - std::make_shared<RotatingCube>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Hybrid3D", - std::make_shared<Hybrid3D>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"Flash", - std::make_shared<Flash>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, - {"PeakMeter", - std::make_shared<PeakMeter>( - fixture.ctx(), std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"})}, + {"Passthrough", std::make_shared<Passthrough>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"GaussianBlur", std::make_shared<GaussianBlur>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"Placeholder", std::make_shared<Placeholder>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"Heptagon", std::make_shared<Heptagon>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"Particles", std::make_shared<Particles>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"RotatingCube", std::make_shared<RotatingCube>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"Hybrid3D", std::make_shared<Hybrid3D>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"Flash", std::make_shared<Flash>(fixture.ctx(), + std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, + {"PeakMeter", std::make_shared<PeakMeter>( + fixture.ctx(), std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"})}, }; int passed = 0; diff --git a/src/tests/gpu/test_effect_base.cc b/src/tests/gpu/test_effect_base.cc index ecf1dca..f46a4ef 100644 --- a/src/tests/gpu/test_effect_base.cc +++ b/src/tests/gpu/test_effect_base.cc @@ -102,11 +102,11 @@ static void test_effect_in_sequence() { // Create minimal sequence with one effect class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { - auto effect = std::make_shared<Passthrough>( - ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"}); + auto effect = + std::make_shared<Passthrough>(ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}); effect_dag_.push_back({effect, {"source"}, {"sink"}, 0}); init_effect_nodes(); @@ -134,11 +134,11 @@ static void test_sequence_render() { OffscreenRenderTarget target(fixture.instance(), fixture.device(), 256, 256); class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { - auto effect = std::make_shared<Passthrough>( - ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"sink"}); + auto effect = + std::make_shared<Passthrough>(ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"sink"}); effect_dag_.push_back({effect, {"source"}, {"sink"}, 0}); init_effect_nodes(); @@ -154,8 +154,8 @@ static void test_sequence_render() { seq->preprocess(0.0f, 0.0f, 0.0f, 0.0f); // Create encoder and attempt render - WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder( - fixture.device(), nullptr); + WGPUCommandEncoder encoder = + wgpuDeviceCreateCommandEncoder(fixture.device(), nullptr); seq->render_effects(encoder); @@ -177,7 +177,7 @@ static void test_sequence_time_params() { } class TestSequence : public Sequence { - public: + public: TestSequence(const GpuContext& ctx, int w, int h) : Sequence(ctx, w, h) { init_effect_nodes(); } diff --git a/src/tests/gpu/test_noise_functions.cc b/src/tests/gpu/test_noise_functions.cc index 4e1791f..d96a982 100644 --- a/src/tests/gpu/test_noise_functions.cc +++ b/src/tests/gpu/test_noise_functions.cc @@ -1,9 +1,9 @@ // This file is part of the 64k demo project. // It validates that the noise.wgsl functions are accessible and usable. +#include "effects/shaders.h" #include "generated/assets.h" #include "gpu/shader_composer.h" -#include "effects/shaders.h" #include <cassert> #include <cstdio> #include <cstring> diff --git a/src/tests/gpu/test_sequence.cc b/src/tests/gpu/test_sequence.cc index 337381a..fa6bd5e 100644 --- a/src/tests/gpu/test_sequence.cc +++ b/src/tests/gpu/test_sequence.cc @@ -1,8 +1,8 @@ // Test file for Sequence v2 system // Phase 1: Foundation tests (NodeRegistry, Sequence base class) -#include "gpu/sequence.h" #include "gpu/effect.h" +#include "gpu/sequence.h" #include "tests/common/webgpu_test_fixture.h" #include <cassert> #include <cstdio> @@ -11,7 +11,7 @@ class TestEffect : public Effect { public: TestEffect(const GpuContext& ctx, const std::vector<std::string>& inputs, - const std::vector<std::string>& outputs) + const std::vector<std::string>& outputs) : Effect(ctx, inputs, outputs), render_called_(false) { } @@ -132,16 +132,15 @@ void test_sequence_v2_dag_execution() { class TestSequence : public Sequence { public: TestSequence(const GpuContext& ctx) - : Sequence(ctx, 1280, 720), - effect1_(std::make_shared<TestEffect>(ctx, std::vector<std::string>{"source"}, - std::vector<std::string>{"temp"})), - effect2_(std::make_shared<TestEffect>(ctx, std::vector<std::string>{"temp"}, - std::vector<std::string>{"sink"})) { + : Sequence(ctx, 1280, 720), effect1_(std::make_shared<TestEffect>( + ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"temp"})), + effect2_(std::make_shared<TestEffect>( + ctx, std::vector<std::string>{"temp"}, + std::vector<std::string>{"sink"})) { // Build DAG (2 effects in sequence) - effect_dag_.push_back( - {effect1_, {"source"}, {"temp"}, 0}); - effect_dag_.push_back( - {effect2_, {"temp"}, {"sink"}, 1}); + effect_dag_.push_back({effect1_, {"source"}, {"temp"}, 0}); + effect_dag_.push_back({effect2_, {"temp"}, {"sink"}, 1}); } std::shared_ptr<TestEffect> effect1_; diff --git a/src/tests/gpu/test_sequence_e2e.cc b/src/tests/gpu/test_sequence_e2e.cc index 6ae82bd..ed8920a 100644 --- a/src/tests/gpu/test_sequence_e2e.cc +++ b/src/tests/gpu/test_sequence_e2e.cc @@ -1,12 +1,12 @@ // End-to-end test for Sequence v2 system // Tests compiler output instantiation and execution -#include "gpu/sequence.h" -#include "gpu/effect.h" #include "effects/gaussian_blur_effect.h" #include "effects/heptagon_effect.h" #include "effects/passthrough_effect.h" #include "effects/shaders.h" +#include "gpu/effect.h" +#include "gpu/sequence.h" #include "tests/common/webgpu_test_fixture.h" #include <cassert> #include <cstdio> @@ -21,22 +21,18 @@ class SimpleTestSequence : public Sequence { nodes_.declare_node("temp", NodeType::U8X4_NORM, width_, height_); // Effect DAG construction (2 effects: source->temp->sink) - effect_dag_.push_back({ - .effect = std::make_shared<Passthrough>(ctx, - std::vector<std::string>{"source"}, - std::vector<std::string>{"temp"}), - .input_nodes = {"source"}, - .output_nodes = {"temp"}, - .execution_order = 0 - }); - effect_dag_.push_back({ - .effect = std::make_shared<Passthrough>(ctx, - std::vector<std::string>{"temp"}, - std::vector<std::string>{"sink"}), - .input_nodes = {"temp"}, - .output_nodes = {"sink"}, - .execution_order = 1 - }); + effect_dag_.push_back({.effect = std::make_shared<Passthrough>( + ctx, std::vector<std::string>{"source"}, + std::vector<std::string>{"temp"}), + .input_nodes = {"source"}, + .output_nodes = {"temp"}, + .execution_order = 0}); + effect_dag_.push_back({.effect = std::make_shared<Passthrough>( + ctx, std::vector<std::string>{"temp"}, + std::vector<std::string>{"sink"}), + .input_nodes = {"temp"}, + .output_nodes = {"sink"}, + .execution_order = 1}); } }; diff --git a/src/tests/gpu/test_shader_compilation.cc b/src/tests/gpu/test_shader_compilation.cc index 3f2219d..2aff115 100644 --- a/src/tests/gpu/test_shader_compilation.cc +++ b/src/tests/gpu/test_shader_compilation.cc @@ -5,9 +5,9 @@ // - Missing binding declarations // - Type mismatches +#include "effects/shaders.h" #include "generated/assets.h" #include "gpu/shader_composer.h" -#include "effects/shaders.h" #include "platform/platform.h" #include <cassert> #include <cstdio> diff --git a/src/util/fatal_error.h b/src/util/fatal_error.h index 988ec1d..e1dda38 100644 --- a/src/util/fatal_error.h +++ b/src/util/fatal_error.h @@ -31,17 +31,17 @@ // ============================================================================== // Early return if device is nullptr (headless mode stub) -#define HEADLESS_RETURN_IF_NULL(device) \ - do { \ - if ((device) == nullptr) \ - return; \ +#define HEADLESS_RETURN_IF_NULL(device) \ + do { \ + if ((device) == nullptr) \ + return; \ } while (0) // Early return with value if device is nullptr (headless mode stub) -#define HEADLESS_RETURN_VAL_IF_NULL(device, val) \ - do { \ - if ((device) == nullptr) \ - return (val); \ +#define HEADLESS_RETURN_VAL_IF_NULL(device, val) \ + do { \ + if ((device) == nullptr) \ + return (val); \ } while (0) #endif /* defined(STRIP_ALL) || defined(FINAL_STRIP) */ |
