From 25e693cc46324b4ec588530de542bba8af6f47c6 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 21:11:11 +0100 Subject: style: add vertical compression rules to clang-format - Enabled AllowShortFunctionsOnASingleLine: All - Enabled AllowShortBlocksOnASingleLine: Always - Enabled AllowShortIfStatementsOnASingleLine: Always - Enabled AllowShortLoopsOnASingleLine: true - Set MaxEmptyLinesToKeep: 1 - Applied formatting to all source files. --- src/gpu/demo_effects.cc | 6 ++---- src/gpu/effect.cc | 23 +++++++---------------- src/gpu/effect.h | 21 ++++++--------------- src/gpu/gpu.cc | 10 +++------- src/gpu/gpu.h | 17 ++++------------- 5 files changed, 22 insertions(+), 55 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/demo_effects.cc b/src/gpu/demo_effects.cc index 27712d3..77fb152 100644 --- a/src/gpu/demo_effects.cc +++ b/src/gpu/demo_effects.cc @@ -320,8 +320,7 @@ static void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline, WGPUBindGroup *bind_group, WGPUTextureView input_view, GpuBuffer uniforms) { - if (*bind_group) - wgpuBindGroupRelease(*bind_group); + if (*bind_group) wgpuBindGroupRelease(*bind_group); WGPUBindGroupLayout bgl = wgpuRenderPipelineGetBindGroupLayout(pipeline, 0); WGPUSamplerDescriptor sd = {}; sd.magFilter = WGPUFilterMode_Linear; @@ -386,8 +385,7 @@ ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue, gpu_create_buffer(device, sizeof(float) * 4, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst); std::vector init_p(NUM_PARTICLES); - for (auto &p : init_p) - p.pos[3] = 0.0f; + for (auto &p : init_p) p.pos[3] = 0.0f; particles_buffer_ = gpu_create_buffer( device, sizeof(Particle) * NUM_PARTICLES, WGPUBufferUsage_Storage | WGPUBufferUsage_Vertex, init_p.data()); diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index f9ebf0c..054c0ef 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -35,8 +35,7 @@ void Sequence::add_effect(std::shared_ptr effect, float start_time, } void Sequence::sort_items() { - if (is_sorted_) - return; + if (is_sorted_) return; std::sort(items_.begin(), items_.end(), [](const SequenceItem &a, const SequenceItem &b) { return a.priority < b.priority; @@ -130,9 +129,7 @@ void MainSequence::init(WGPUDevice d, WGPUQueue q, WGPUTextureFormat f, create_framebuffers(width, height); passthrough_effect_ = std::make_unique(device, format); - for (auto &entry : sequences_) { - entry.seq->init(this); - } + for (auto &entry : sequences_) { entry.seq->init(this); } } void MainSequence::add_sequence(std::shared_ptr seq, float start_time, @@ -259,17 +256,11 @@ void MainSequence::render_frame(float global_time, float beat, float peak, } void MainSequence::shutdown() { - if (framebuffer_view_a_) - wgpuTextureViewRelease(framebuffer_view_a_); - if (framebuffer_a_) - wgpuTextureRelease(framebuffer_a_); - if (framebuffer_view_b_) - wgpuTextureViewRelease(framebuffer_view_b_); - if (framebuffer_b_) - wgpuTextureRelease(framebuffer_b_); - for (auto &entry : sequences_) { - entry.seq->reset(); - } + if (framebuffer_view_a_) wgpuTextureViewRelease(framebuffer_view_a_); + if (framebuffer_a_) wgpuTextureRelease(framebuffer_a_); + if (framebuffer_view_b_) wgpuTextureViewRelease(framebuffer_view_b_); + if (framebuffer_b_) wgpuTextureRelease(framebuffer_b_); + for (auto &entry : sequences_) { entry.seq->reset(); } } #ifndef STRIP_ALL diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 1d339e2..0b791a3 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -15,11 +15,8 @@ class PostProcessEffect; class Effect { public: virtual ~Effect() = default; - virtual void init(MainSequence *demo) { - (void)demo; - } - virtual void start() { - } + virtual void init(MainSequence *demo) { (void)demo; } + virtual void start() {} virtual void compute(WGPUCommandEncoder encoder, float time, float beat, float intensity, float aspect_ratio) { (void)encoder; @@ -30,21 +27,15 @@ public: } virtual void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) = 0; - virtual void end() { - } + virtual void end() {} bool is_initialized = false; - virtual bool is_post_process() const { - return false; - } + virtual bool is_post_process() const { return false; } }; class PostProcessEffect : public Effect { public: - bool is_post_process() const override { - return true; - } - void compute(WGPUCommandEncoder, float, float, float, float) override { - } + bool is_post_process() const override { return true; } + void compute(WGPUCommandEncoder, float, float, float, float) override {} void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; virtual void update_bind_group(WGPUTextureView input_view) = 0; diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index b9545bf..ebf709e 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -327,8 +327,7 @@ void gpu_init(GLFWwindow *window, int width, int height) { adapter_cb.userdata1 = &g_adapter; wgpuInstanceRequestAdapter(g_instance, &adapter_opts, adapter_cb); #endif - while (!g_adapter) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + while (!g_adapter) wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); WGPUDeviceDescriptor device_desc = {}; #ifndef STRIP_ALL @@ -347,8 +346,7 @@ void gpu_init(GLFWwindow *window, int width, int height) { device_cb.userdata1 = &g_device; wgpuAdapterRequestDevice(g_adapter, &device_desc, device_cb); #endif - while (!g_device) - wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); + while (!g_device) wgpuInstanceWaitAny(g_instance, 0, nullptr, 0); #if defined(DEMO_CROSS_COMPILE_WIN32) && !defined(STRIP_ALL) set_error_callback(g_device, handle_device_error); @@ -384,6 +382,4 @@ void gpu_simulate_until(float time) { } #endif -void gpu_shutdown() { - g_main_sequence.shutdown(); -} \ No newline at end of file +void gpu_shutdown() { g_main_sequence.shutdown(); } \ No newline at end of file diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h index c2c0670..eb3dd8a 100644 --- a/src/gpu/gpu.h +++ b/src/gpu/gpu.h @@ -16,13 +16,9 @@ #include -static inline const char *str_view(const char *str) { - return str; -} +static inline const char *str_view(const char *str) { return str; } -static inline const char *label_view(const char *str) { - return str; -} +static inline const char *label_view(const char *str) { return str; } #define WGPUSType_ShaderSourceWGSL WGPUSType_ShaderModuleWGSLDescriptor @@ -40,8 +36,6 @@ using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; #else - - // Native (macOS/Linux) using newer wgpu-native #include @@ -49,9 +43,7 @@ using WGPUShaderSourceWGSL = WGPUShaderModuleWGSLDescriptor; #include static inline WGPUStringView str_view(const char *str) { - - if (!str) - return {nullptr, 0}; + if (!str) return {nullptr, 0}; return {str, strlen(str)}; } @@ -60,8 +52,7 @@ static inline WGPUStringView label_view(const char *str) { #ifndef STRIP_ALL - if (!str) - return {nullptr, 0}; + if (!str) return {nullptr, 0}; return {str, strlen(str)}; -- cgit v1.2.3