summaryrefslogtreecommitdiff
path: root/src/gpu/demo_effects.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-01 00:58:20 +0100
committerskal <pascal.massimino@gmail.com>2026-02-01 01:13:53 +0100
commit18eb8a07ba39a8aad1c75521cee027b9c9c72e40 (patch)
tree87e498dbaffdd591eb94fddca315f6ba28756a32 /src/gpu/demo_effects.cc
parent03cd94817097e59a0809b222e0e1e74dd9a8ede7 (diff)
clang-format
Diffstat (limited to 'src/gpu/demo_effects.cc')
-rw-r--r--src/gpu/demo_effects.cc30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/gpu/demo_effects.cc b/src/gpu/demo_effects.cc
index 77fb152..dbf5be8 100644
--- a/src/gpu/demo_effects.cc
+++ b/src/gpu/demo_effects.cc
@@ -11,7 +11,7 @@
// Helper to create a standard post-processing pipeline
static WGPURenderPipeline
create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format,
- const char *shader_code) {
+ const char* shader_code) {
WGPUShaderModuleDescriptor shader_desc = {};
WGPUShaderSourceWGSL wgsl_src = {};
wgsl_src.chain.sType = WGPUSType_ShaderSourceWGSL;
@@ -66,7 +66,7 @@ create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format,
// --- SHADERS ---
-const char *main_shader_wgsl = R"(
+const char* main_shader_wgsl = R"(
struct Uniforms { audio_peak: f32, aspect_ratio: f32, time: f32, };
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
@vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> {
@@ -84,7 +84,7 @@ struct Uniforms { audio_peak: f32, aspect_ratio: f32, time: f32, };
return vec4<f32>(r+boost,g+boost,b+boost, 1.0);
})";
-const char *particle_compute_wgsl = R"(
+const char* particle_compute_wgsl = R"(
struct Particle { pos: vec4<f32>, vel: vec4<f32>, rot: vec4<f32>, color: vec4<f32>, };
struct Uniforms { audio_peak: f32, aspect_ratio: f32, time: f32, beat: f32, };
@group(0) @binding(0) var<storage, read_write> particles: array<Particle>;
@@ -105,7 +105,7 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
particles[i] = p;
})";
-const char *particle_render_wgsl = R"(
+const char* particle_render_wgsl = R"(
struct Particle { pos: vec4<f32>, vel: vec4<f32>, rot: vec4<f32>, color: vec4<f32>, };
struct Uniforms { audio_peak: f32, aspect_ratio: f32, time: f32, beat: f32, };
@group(0) @binding(0) var<storage, read> particles: array<Particle>;
@@ -124,7 +124,7 @@ struct VSOut { @builtin(position) pos: vec4<f32>, @location(0) color: vec4<f32>,
@fragment fn fs_main(@location(0) color: vec4<f32>) -> @location(0) vec4<f32> { return color; }
)";
-const char *passthrough_shader_wgsl = R"(
+const char* passthrough_shader_wgsl = R"(
@group(0) @binding(0) var smplr: sampler;
@group(0) @binding(1) var txt: texture_2d<f32>;
@vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> {
@@ -135,7 +135,7 @@ const char *passthrough_shader_wgsl = R"(
return textureSample(txt, smplr, p.xy / vec2<f32>(1280.0, 720.0));
})";
-const char *ellipse_shader_wgsl = R"(
+const char* ellipse_shader_wgsl = R"(
struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
@group(0) @binding(0) var<uniform> uniforms: Uniforms;
@vertex fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> {
@@ -158,7 +158,7 @@ fn sdEllipse(p: vec2<f32>, ab: vec2<f32>) -> f32 {
return mix(vec4<f32>(0.2, 0.8, 0.4, 1.0), vec4<f32>(0.0), smoothstep(0.0, 0.01, d));
})";
-const char *particle_spray_compute_wgsl = R"(
+const char* particle_spray_compute_wgsl = R"(
struct Particle { pos: vec4<f32>, vel: vec4<f32>, rot: vec4<f32>, color: vec4<f32>, };
struct Uniforms { intensity: f32, aspect_ratio: f32, time: f32, beat: f32, };
@group(0) @binding(0) var<storage, read_write> particles: array<Particle>;
@@ -180,7 +180,7 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
particles[i] = p;
})";
-const char *gaussian_blur_shader_wgsl = R"(
+const char* gaussian_blur_shader_wgsl = R"(
@group(0) @binding(0) var smplr: sampler; @group(0) @binding(1) var txt: texture_2d<f32>;
struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
@group(0) @binding(2) var<uniform> uniforms: Uniforms;
@@ -199,7 +199,7 @@ struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
return res / 25.0;
})";
-const char *solarize_shader_wgsl = R"(
+const char* solarize_shader_wgsl = R"(
@group(0) @binding(0) var smplr: sampler; @group(0) @binding(1) var txt: texture_2d<f32>;
struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
@group(0) @binding(2) var<uniform> uniforms: Uniforms;
@@ -216,7 +216,7 @@ struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
return col;
})";
-const char *distort_shader_wgsl = R"(
+const char* distort_shader_wgsl = R"(
@group(0) @binding(0) var smplr: sampler; @group(0) @binding(1) var txt: texture_2d<f32>;
struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
@group(0) @binding(2) var<uniform> uniforms: Uniforms;
@@ -230,7 +230,7 @@ struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
return textureSample(txt, smplr, uv + vec2<f32>(dist, 0.0));
})";
-const char *chroma_aberration_shader_wgsl = R"(
+const char* chroma_aberration_shader_wgsl = R"(
@group(0) @binding(0) var smplr: sampler; @group(0) @binding(1) var txt: texture_2d<f32>;
struct Uniforms { time: f32, beat: f32, intensity: f32, aspect_ratio: f32, };
@group(0) @binding(2) var<uniform> uniforms: Uniforms;
@@ -317,10 +317,11 @@ void ParticlesEffect::render(WGPURenderPassEncoder pass, float t, float b,
// --- PostProcess Implementation Helper ---
static void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline,
- WGPUBindGroup *bind_group,
+ 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;
@@ -385,7 +386,8 @@ ParticleSprayEffect::ParticleSprayEffect(WGPUDevice device, WGPUQueue queue,
gpu_create_buffer(device, sizeof(float) * 4,
WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
std::vector<Particle> init_p(NUM_PARTICLES);
- for (auto &p : init_p) p.pos[3] = 0.0f;
+ for (Particle& 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());