diff options
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/demo_effects.h | 3 | ||||
| -rw-r--r-- | src/gpu/effect.cc | 11 | ||||
| -rw-r--r-- | src/gpu/effect.h | 5 | ||||
| -rw-r--r-- | src/gpu/effects/fade_effect.cc | 7 | ||||
| -rw-r--r-- | src/gpu/effects/flash_effect.cc | 9 | ||||
| -rw-r--r-- | src/gpu/effects/shaders.cc | 6 | ||||
| -rw-r--r-- | src/gpu/effects/theme_modulation_effect.cc | 17 | ||||
| -rw-r--r-- | src/gpu/effects/theme_modulation_effect.h | 5 |
8 files changed, 36 insertions, 27 deletions
diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index 3e312ec..4b96ba7 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -178,4 +178,5 @@ class FlashEffect : public PostProcessEffect { // Auto-generated functions void LoadTimeline(MainSequence& main_seq, WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); -float GetDemoDuration(); // Returns demo end time in seconds, or -1 if not specified
\ No newline at end of file +float GetDemoDuration(); // Returns demo end time in seconds, or -1 if not + // specified
\ No newline at end of file diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index 96e7489..8ae5835 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -6,8 +6,8 @@ #include "gpu/gpu.h" #include <algorithm> #include <cstdio> -#include <vector> #include <typeinfo> +#include <vector> // --- PostProcessEffect --- void PostProcessEffect::render(WGPURenderPassEncoder pass, float, float, float, @@ -56,15 +56,14 @@ void Sequence::update_active_list(float seq_time) { const bool sequence_ended = (end_time_ >= 0.0f && seq_time >= end_time_); for (SequenceItem& item : items_) { - bool should_be_active = - !sequence_ended && - (seq_time >= item.start_time && seq_time < item.end_time); + bool should_be_active = !sequence_ended && (seq_time >= item.start_time && + seq_time < item.end_time); if (should_be_active && !item.active) { #if !defined(STRIP_ALL) const char* effect_name = typeid(*item.effect).name(); - printf(" [EFFECT START] %s (priority=%d, time=%.2f-%.2f)\n", - effect_name, item.priority, item.start_time, item.end_time); + printf(" [EFFECT START] %s (priority=%d, time=%.2f-%.2f)\n", effect_name, + item.priority, item.start_time, item.end_time); #endif item.effect->start(); item.active = true; diff --git a/src/gpu/effect.h b/src/gpu/effect.h index d23e6d6..0cc9de5 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -95,7 +95,7 @@ class Sequence { private: std::vector<SequenceItem> items_; bool is_sorted_ = false; - float end_time_ = -1.0f; // Optional: -1.0 means "no explicit end" + float end_time_ = -1.0f; // Optional: -1.0 means "no explicit end" void sort_items(); }; @@ -126,7 +126,8 @@ class MainSequence { std::shared_ptr<Sequence> seq; float start_time; int priority; - bool activated = false; // Track if sequence has been activated for debug output + bool activated = + false; // Track if sequence has been activated for debug output }; std::vector<ActiveSequence> sequences_; diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc index 3b942c0..4d7633c 100644 --- a/src/gpu/effects/fade_effect.cc +++ b/src/gpu/effects/fade_effect.cc @@ -47,15 +47,16 @@ FadeEffect::FadeEffect(WGPUDevice device, WGPUQueue queue, )"; pipeline_ = create_post_process_pipeline(device, format, shader_code); - uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + uniforms_ = gpu_create_buffer( + device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FadeEffect::update_bind_group(WGPUTextureView input_view) { pp_update_bind_group(device_, pipeline_, &bind_group_, input_view, uniforms_); } -void FadeEffect::render(WGPURenderPassEncoder pass, float time, - float beat, float intensity, float aspect_ratio) { +void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) { (void)beat; (void)intensity; (void)aspect_ratio; diff --git a/src/gpu/effects/flash_effect.cc b/src/gpu/effects/flash_effect.cc index de7be62..176c60c 100644 --- a/src/gpu/effects/flash_effect.cc +++ b/src/gpu/effects/flash_effect.cc @@ -49,22 +49,23 @@ FlashEffect::FlashEffect(WGPUDevice device, WGPUQueue queue, )"; pipeline_ = create_post_process_pipeline(device, format, shader_code); - uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + uniforms_ = gpu_create_buffer( + device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void FlashEffect::update_bind_group(WGPUTextureView input_view) { pp_update_bind_group(device_, pipeline_, &bind_group_, input_view, uniforms_); } -void FlashEffect::render(WGPURenderPassEncoder pass, float time, - float beat, float intensity, float aspect_ratio) { +void FlashEffect::render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) { (void)time; (void)beat; (void)aspect_ratio; // Trigger flash on strong beat hits if (intensity > 0.7f && flash_intensity_ < 0.2f) { - flash_intensity_ = 0.8f; // Trigger flash + flash_intensity_ = 0.8f; // Trigger flash } // Exponential decay diff --git a/src/gpu/effects/shaders.cc b/src/gpu/effects/shaders.cc index 7255cf5..7b543e1 100644 --- a/src/gpu/effects/shaders.cc +++ b/src/gpu/effects/shaders.cc @@ -34,8 +34,10 @@ void InitShaderComposer() { register_if_exists("math/sdf_shapes", AssetId::ASSET_SHADER_MATH_SDF_SHAPES); register_if_exists("math/sdf_utils", AssetId::ASSET_SHADER_MATH_SDF_UTILS); register_if_exists("render/shadows", AssetId::ASSET_SHADER_RENDER_SHADOWS); - register_if_exists("render/scene_query", AssetId::ASSET_SHADER_RENDER_SCENE_QUERY); - register_if_exists("render/lighting_utils", AssetId::ASSET_SHADER_RENDER_LIGHTING_UTILS); + register_if_exists("render/scene_query", + AssetId::ASSET_SHADER_RENDER_SCENE_QUERY); + register_if_exists("render/lighting_utils", + AssetId::ASSET_SHADER_RENDER_LIGHTING_UTILS); register_if_exists("sdf_primitives", AssetId::ASSET_SHADER_SDF_PRIMITIVES); diff --git a/src/gpu/effects/theme_modulation_effect.cc b/src/gpu/effects/theme_modulation_effect.cc index 4ddb1f4..d2705d5 100644 --- a/src/gpu/effects/theme_modulation_effect.cc +++ b/src/gpu/effects/theme_modulation_effect.cc @@ -51,7 +51,8 @@ ThemeModulationEffect::ThemeModulationEffect(WGPUDevice device, WGPUQueue queue, pipeline_ = create_post_process_pipeline(device, format, shader_code); // Create uniform buffer (4 floats: brightness + padding) - uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); + uniforms_ = gpu_create_buffer( + device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); } void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) { @@ -59,22 +60,24 @@ void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) { } void ThemeModulationEffect::render(WGPURenderPassEncoder pass, float time, - float beat, float intensity, - float aspect_ratio) { + float beat, float intensity, + float aspect_ratio) { (void)beat; (void)intensity; (void)aspect_ratio; // Alternate between bright and dark every 4 seconds (2 pattern changes) // Music patterns change every 2 seconds at 120 BPM - float cycle_time = fmodf(time, 8.0f); // 8 second cycle (4 patterns) - bool is_dark_section = (cycle_time >= 4.0f); // Dark for second half + float cycle_time = fmodf(time, 8.0f); // 8 second cycle (4 patterns) + bool is_dark_section = (cycle_time >= 4.0f); // Dark for second half // Smooth transition between themes using a sine wave - float transition = (std::sin(time * 3.14159f / 4.0f) + 1.0f) * 0.5f; // 0.0 to 1.0 + float transition = + (std::sin(time * 3.14159f / 4.0f) + 1.0f) * 0.5f; // 0.0 to 1.0 float bright_value = 1.0f; float dark_value = 0.35f; - float theme_brightness = bright_value + (dark_value - bright_value) * transition; + float theme_brightness = + bright_value + (dark_value - bright_value) * transition; // Update uniform buffer float uniforms[4] = {theme_brightness, 0.0f, 0.0f, 0.0f}; diff --git a/src/gpu/effects/theme_modulation_effect.h b/src/gpu/effects/theme_modulation_effect.h index 6f76695..ac584e2 100644 --- a/src/gpu/effects/theme_modulation_effect.h +++ b/src/gpu/effects/theme_modulation_effect.h @@ -1,6 +1,7 @@ // This file is part of the 64k demo project. -// It implements a theme modulation effect that alternates between bright and dark. -// Pattern changes every 2 seconds, so we alternate every 4 seconds (2 patterns). +// It implements a theme modulation effect that alternates between bright and +// dark. Pattern changes every 2 seconds, so we alternate every 4 seconds (2 +// patterns). #pragma once #include "gpu/effect.h" |
