diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 07:40:29 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 07:40:29 +0100 |
| commit | c9195f997f3e797f03ab90464e4158717198a167 (patch) | |
| tree | 331304f42870246efdc64cc97ad42de59444ef3a /src/gpu | |
| parent | b8e6929cafa41681f0b27ac104c9cf1d4e510837 (diff) | |
style: Apply clang-format to all source files
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/effect.cc | 6 | ||||
| -rw-r--r-- | src/gpu/effect.h | 3 | ||||
| -rw-r--r-- | src/gpu/effects/distort_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/fade_effect.cc | 12 | ||||
| -rw-r--r-- | src/gpu/effects/flash_cube_effect.cc | 3 | ||||
| -rw-r--r-- | src/gpu/effects/flash_effect.cc | 12 | ||||
| -rw-r--r-- | src/gpu/effects/gaussian_blur_effect.cc | 4 | ||||
| -rw-r--r-- | src/gpu/effects/heptagon_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/hybrid_3d_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/moving_ellipse_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/particle_spray_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/particles_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/passthrough_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/post_process_helper.h | 6 | ||||
| -rw-r--r-- | src/gpu/effects/shader_composer.cc | 2 | ||||
| -rw-r--r-- | src/gpu/effects/solarize_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/theme_modulation_effect.cc | 9 | ||||
| -rw-r--r-- | src/gpu/gpu.cc | 9 | ||||
| -rw-r--r-- | src/gpu/gpu.h | 5 |
19 files changed, 65 insertions, 62 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index ea5230d..a1b45f1 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -164,8 +164,7 @@ void MainSequence::init(const GpuContext& ctx, int width, int height) { height_ = height; create_framebuffers(width, height); - passthrough_effect_ = - std::make_unique<PassthroughEffect>(gpu_ctx); + passthrough_effect_ = std::make_unique<PassthroughEffect>(gpu_ctx); passthrough_effect_->resize(width, height); for (ActiveSequence& entry : sequences_) { @@ -220,7 +219,8 @@ void MainSequence::resize(int width, int height) { void MainSequence::render_frame(float global_time, float beat, float peak, float aspect_ratio, WGPUSurface surface) { - WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(gpu_ctx.device, nullptr); + WGPUCommandEncoder encoder = + wgpuDeviceCreateCommandEncoder(gpu_ctx.device, nullptr); std::vector<SequenceItem*> scene_effects; std::vector<SequenceItem*> post_effects; diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 725c020..19b8118 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -48,8 +48,7 @@ class Effect { class PostProcessEffect : public Effect { public: - PostProcessEffect(const GpuContext& ctx) - : Effect(ctx) { + PostProcessEffect(const GpuContext& ctx) : Effect(ctx) { } bool is_post_process() const override { return true; diff --git a/src/gpu/effects/distort_effect.cc b/src/gpu/effects/distort_effect.cc index 3bd4540..b7e27a7 100644 --- a/src/gpu/effects/distort_effect.cc +++ b/src/gpu/effects/distort_effect.cc @@ -5,13 +5,12 @@ #include "gpu/gpu.h" // --- DistortEffect --- -DistortEffect::DistortEffect(const GpuContext& ctx) - : PostProcessEffect(ctx) { +DistortEffect::DistortEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - pipeline_ = - create_post_process_pipeline(ctx_.device, ctx_.format, distort_shader_wgsl); + pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, + distort_shader_wgsl); } void DistortEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc index 8aad6b3..359d341 100644 --- a/src/gpu/effects/fade_effect.cc +++ b/src/gpu/effects/fade_effect.cc @@ -5,8 +5,7 @@ #include "gpu/effects/post_process_helper.h" #include <cmath> -FadeEffect::FadeEffect(const GpuContext& ctx) - : PostProcessEffect(ctx) { +FadeEffect::FadeEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -45,13 +44,15 @@ FadeEffect::FadeEffect(const GpuContext& ctx) } )"; - pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); + pipeline_ = + create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); uniforms_ = gpu_create_buffer( ctx_.device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FadeEffect::update_bind_group(WGPUTextureView input_view) { - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_); + pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, + uniforms_); } void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat, @@ -73,7 +74,8 @@ void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat, } float uniforms[4] = {fade_amount, 0.0f, 0.0f, 0.0f}; - wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, sizeof(uniforms)); + wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, + sizeof(uniforms)); wgpuRenderPassEncoderSetPipeline(pass, pipeline_); wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr); diff --git a/src/gpu/effects/flash_cube_effect.cc b/src/gpu/effects/flash_cube_effect.cc index 8c97d5d..f01bbd1 100644 --- a/src/gpu/effects/flash_cube_effect.cc +++ b/src/gpu/effects/flash_cube_effect.cc @@ -8,8 +8,7 @@ #include <cmath> #include <iostream> -FlashCubeEffect::FlashCubeEffect(const GpuContext& ctx) - : Effect(ctx) { +FlashCubeEffect::FlashCubeEffect(const GpuContext& ctx) : Effect(ctx) { } void FlashCubeEffect::resize(int width, int height) { diff --git a/src/gpu/effects/flash_effect.cc b/src/gpu/effects/flash_effect.cc index 5aebe2d..d0226e5 100644 --- a/src/gpu/effects/flash_effect.cc +++ b/src/gpu/effects/flash_effect.cc @@ -5,8 +5,7 @@ #include "gpu/effects/post_process_helper.h" #include <cmath> -FlashEffect::FlashEffect(const GpuContext& ctx) - : PostProcessEffect(ctx) { +FlashEffect::FlashEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { const char* shader_code = R"( struct VertexOutput { @builtin(position) position: vec4<f32>, @@ -49,13 +48,15 @@ FlashEffect::FlashEffect(const GpuContext& ctx) } )"; - pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); + pipeline_ = + create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); uniforms_ = gpu_create_buffer( ctx_.device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FlashEffect::update_bind_group(WGPUTextureView input_view) { - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_); + pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, + uniforms_); } void FlashEffect::render(WGPURenderPassEncoder pass, float time, float beat, @@ -73,7 +74,8 @@ void FlashEffect::render(WGPURenderPassEncoder pass, float time, float beat, flash_intensity_ *= 0.98f; float uniforms[4] = {flash_intensity_, intensity, 0.0f, 0.0f}; - wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, sizeof(uniforms)); + wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, + sizeof(uniforms)); wgpuRenderPassEncoderSetPipeline(pass, pipeline_); wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_, 0, nullptr); diff --git a/src/gpu/effects/gaussian_blur_effect.cc b/src/gpu/effects/gaussian_blur_effect.cc index f3a3544..f1736bf 100644 --- a/src/gpu/effects/gaussian_blur_effect.cc +++ b/src/gpu/effects/gaussian_blur_effect.cc @@ -10,8 +10,8 @@ GaussianBlurEffect::GaussianBlurEffect(const GpuContext& ctx) uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - pipeline_ = - create_post_process_pipeline(ctx_.device, ctx_.format, gaussian_blur_shader_wgsl); + pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, + gaussian_blur_shader_wgsl); } void GaussianBlurEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/heptagon_effect.cc b/src/gpu/effects/heptagon_effect.cc index 40ff860..7321cd7 100644 --- a/src/gpu/effects/heptagon_effect.cc +++ b/src/gpu/effects/heptagon_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- HeptagonEffect --- -HeptagonEffect::HeptagonEffect(const GpuContext& ctx) - : Effect(ctx) { +HeptagonEffect::HeptagonEffect(const GpuContext& ctx) : Effect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); ResourceBinding bindings[] = {{uniforms_, WGPUBufferBindingType_Uniform}}; - pass_ = - gpu_create_render_pass(ctx_.device, ctx_.format, main_shader_wgsl, bindings, 1); + pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, main_shader_wgsl, + bindings, 1); pass_.vertex_count = 21; } void HeptagonEffect::render(WGPURenderPassEncoder pass, float t, float b, diff --git a/src/gpu/effects/hybrid_3d_effect.cc b/src/gpu/effects/hybrid_3d_effect.cc index 0f31b92..17fef25 100644 --- a/src/gpu/effects/hybrid_3d_effect.cc +++ b/src/gpu/effects/hybrid_3d_effect.cc @@ -8,8 +8,7 @@ #include <cmath> #include <iostream> -Hybrid3DEffect::Hybrid3DEffect(const GpuContext& ctx) - : Effect(ctx) { +Hybrid3DEffect::Hybrid3DEffect(const GpuContext& ctx) : Effect(ctx) { } void Hybrid3DEffect::resize(int width, int height) { @@ -21,8 +20,8 @@ void Hybrid3DEffect::resize(int width, int height) { void Hybrid3DEffect::init(MainSequence* demo) { (void)demo; WGPUTextureFormat format = - demo->gpu_ctx.format; // Get current format from MainSequence (might be different - // than constructor if resized) + demo->gpu_ctx.format; // Get current format from MainSequence (might be + // different than constructor if resized) renderer_.init(ctx_.device, ctx_.queue, ctx_.format); renderer_.resize(width_, height_); diff --git a/src/gpu/effects/moving_ellipse_effect.cc b/src/gpu/effects/moving_ellipse_effect.cc index 94596df..096ebc2 100644 --- a/src/gpu/effects/moving_ellipse_effect.cc +++ b/src/gpu/effects/moving_ellipse_effect.cc @@ -5,14 +5,13 @@ #include "gpu/gpu.h" // --- MovingEllipseEffect --- -MovingEllipseEffect::MovingEllipseEffect(const GpuContext& ctx) - : Effect(ctx) { +MovingEllipseEffect::MovingEllipseEffect(const GpuContext& ctx) : Effect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); ResourceBinding bindings[] = {{uniforms_, WGPUBufferBindingType_Uniform}}; - pass_ = - gpu_create_render_pass(ctx_.device, ctx_.format, ellipse_shader_wgsl, bindings, 1); + pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, ellipse_shader_wgsl, + bindings, 1); pass_.vertex_count = 3; } void MovingEllipseEffect::render(WGPURenderPassEncoder pass, float t, float b, diff --git a/src/gpu/effects/particle_spray_effect.cc b/src/gpu/effects/particle_spray_effect.cc index 8c20065..707d38d 100644 --- a/src/gpu/effects/particle_spray_effect.cc +++ b/src/gpu/effects/particle_spray_effect.cc @@ -6,8 +6,7 @@ #include <vector> // --- ParticleSprayEffect --- -ParticleSprayEffect::ParticleSprayEffect(const GpuContext& ctx) - : Effect(ctx) { +ParticleSprayEffect::ParticleSprayEffect(const GpuContext& ctx) : Effect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); @@ -25,8 +24,8 @@ ParticleSprayEffect::ParticleSprayEffect(const GpuContext& ctx) ResourceBinding rb[] = { {particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage}, {uniforms_, WGPUBufferBindingType_Uniform}}; - render_pass_ = - gpu_create_render_pass(ctx_.device, ctx_.format, particle_render_wgsl, rb, 2); + render_pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, + particle_render_wgsl, rb, 2); render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } diff --git a/src/gpu/effects/particles_effect.cc b/src/gpu/effects/particles_effect.cc index d9f8f2a..f25009b 100644 --- a/src/gpu/effects/particles_effect.cc +++ b/src/gpu/effects/particles_effect.cc @@ -6,8 +6,7 @@ #include <vector> // --- ParticlesEffect --- -ParticlesEffect::ParticlesEffect(const GpuContext& ctx) - : Effect(ctx) { +ParticlesEffect::ParticlesEffect(const GpuContext& ctx) : Effect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); @@ -23,8 +22,8 @@ ParticlesEffect::ParticlesEffect(const GpuContext& ctx) ResourceBinding rb[] = { {particles_buffer_, WGPUBufferBindingType_ReadOnlyStorage}, {uniforms_, WGPUBufferBindingType_Uniform}}; - render_pass_ = - gpu_create_render_pass(ctx_.device, ctx_.format, particle_render_wgsl, rb, 2); + render_pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, + particle_render_wgsl, rb, 2); render_pass_.vertex_count = 6; render_pass_.instance_count = NUM_PARTICLES; } diff --git a/src/gpu/effects/passthrough_effect.cc b/src/gpu/effects/passthrough_effect.cc index 1aebb28..d567caf 100644 --- a/src/gpu/effects/passthrough_effect.cc +++ b/src/gpu/effects/passthrough_effect.cc @@ -10,13 +10,14 @@ PassthroughEffect::PassthroughEffect(const GpuContext& ctx) uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - pipeline_ = - create_post_process_pipeline(ctx_.device, ctx_.format, passthrough_shader_wgsl); + pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, + passthrough_shader_wgsl); } void PassthroughEffect::update_bind_group(WGPUTextureView input_view) { struct { float t, b, i, a, w, h; } u = {0, 0, 0, 0, (float)width_, (float)height_}; wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, &u, sizeof(u)); - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_); + pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, + uniforms_); } diff --git a/src/gpu/effects/post_process_helper.h b/src/gpu/effects/post_process_helper.h index 45757cf..8a9331b 100644 --- a/src/gpu/effects/post_process_helper.h +++ b/src/gpu/effects/post_process_helper.h @@ -6,9 +6,9 @@ #include "gpu/gpu.h" // Standard post-process bind group layout (group 0): -#define PP_BINDING_SAMPLER 0 // Sampler for input texture -#define PP_BINDING_TEXTURE 1 // Input texture (previous render pass) -#define PP_BINDING_UNIFORMS 2 // Custom uniforms buffer +#define PP_BINDING_SAMPLER 0 // Sampler for input texture +#define PP_BINDING_TEXTURE 1 // Input texture (previous render pass) +#define PP_BINDING_UNIFORMS 2 // Custom uniforms buffer // Helper to create a standard post-processing pipeline // Uniforms are accessible to both vertex and fragment shaders diff --git a/src/gpu/effects/shader_composer.cc b/src/gpu/effects/shader_composer.cc index 055b996..b746f8b 100644 --- a/src/gpu/effects/shader_composer.cc +++ b/src/gpu/effects/shader_composer.cc @@ -28,7 +28,7 @@ void ShaderComposer::ResolveRecursive(const std::string& source, size_t end = line.find('"', start + 1); if (start != std::string::npos && end != std::string::npos) { std::string name = line.substr(start + 1, end - start - 1); - + // Apply substitution if available auto sub_it = substitutions.find(name); if (sub_it != substitutions.end()) { diff --git a/src/gpu/effects/solarize_effect.cc b/src/gpu/effects/solarize_effect.cc index 4e9cbda..31b6c2e 100644 --- a/src/gpu/effects/solarize_effect.cc +++ b/src/gpu/effects/solarize_effect.cc @@ -5,13 +5,12 @@ #include "gpu/gpu.h" // --- SolarizeEffect --- -SolarizeEffect::SolarizeEffect(const GpuContext& ctx) - : PostProcessEffect(ctx) { +SolarizeEffect::SolarizeEffect(const GpuContext& ctx) : PostProcessEffect(ctx) { uniforms_ = gpu_create_buffer(ctx_.device, sizeof(float) * 6, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); - pipeline_ = - create_post_process_pipeline(ctx_.device, ctx_.format, solarize_shader_wgsl); + pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, + solarize_shader_wgsl); } void SolarizeEffect::render(WGPURenderPassEncoder pass, float t, float b, float i, float a) { diff --git a/src/gpu/effects/theme_modulation_effect.cc b/src/gpu/effects/theme_modulation_effect.cc index 4b5105d..6ec5bb9 100644 --- a/src/gpu/effects/theme_modulation_effect.cc +++ b/src/gpu/effects/theme_modulation_effect.cc @@ -47,7 +47,8 @@ ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) } )"; - pipeline_ = create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); + pipeline_ = + create_post_process_pipeline(ctx_.device, ctx_.format, shader_code); // Create uniform buffer (4 floats: brightness + padding) uniforms_ = gpu_create_buffer( @@ -55,7 +56,8 @@ ThemeModulationEffect::ThemeModulationEffect(const GpuContext& ctx) } void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) { - pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, uniforms_); + pp_update_bind_group(ctx_.device, pipeline_, &bind_group_, input_view, + uniforms_); } void ThemeModulationEffect::render(WGPURenderPassEncoder pass, float time, @@ -80,7 +82,8 @@ void ThemeModulationEffect::render(WGPURenderPassEncoder pass, float time, // Update uniform buffer float uniforms[4] = {theme_brightness, 0.0f, 0.0f, 0.0f}; - wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, sizeof(uniforms)); + wgpuQueueWriteBuffer(ctx_.queue, uniforms_.buffer, 0, uniforms, + sizeof(uniforms)); // Render wgpuRenderPassEncoderSetPipeline(pass, pipeline_); diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index fe71d3e..9776eac 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -371,7 +371,8 @@ void gpu_init(PlatformState* platform_state) { InitShaderComposer(); - g_main_sequence.init(g_gpu_context, platform_state->width, platform_state->height); + g_main_sequence.init(g_gpu_context, platform_state->width, + platform_state->height); LoadTimeline(g_main_sequence, g_gpu_context); } @@ -394,9 +395,11 @@ void gpu_simulate_until(float time) { g_main_sequence.simulate_until(time, 1.0f / 60.0f); } -void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, int priority) { +void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, + int priority) { auto seq = std::make_shared<Sequence>(); - seq->add_effect(std::shared_ptr<Effect>(effect), start_time, end_time, priority); + seq->add_effect(std::shared_ptr<Effect>(effect), start_time, end_time, + priority); seq->init(&g_main_sequence); g_main_sequence.add_sequence(seq, 0.0f, priority); } diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index c4d1993..36ee662 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -7,7 +7,7 @@ #include "platform/platform.h" struct PlatformState; // Forward declaration -class Effect; // Forward declaration +class Effect; // Forward declaration // GPU context bundling device, queue, and surface format struct GpuContext { @@ -44,7 +44,8 @@ void gpu_draw(float audio_peak, float aspect_ratio, float time, float beat); void gpu_resize(int width, int height); #if !defined(STRIP_ALL) void gpu_simulate_until(float time); -void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, int priority); +void gpu_add_custom_effect(Effect* effect, float start_time, float end_time, + int priority); // Get GPU context for custom effects (debug builds only) const GpuContext* gpu_get_context(); |
