summaryrefslogtreecommitdiff
path: root/src/gpu/effects/post_process_helper.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-07 18:50:40 +0100
committerskal <pascal.massimino@gmail.com>2026-02-07 18:50:40 +0100
commit3b1d28500629b8488863aeaba3203ad5c3118d5f (patch)
treea55fe3c61682077d1717bde8dc8a719054a272d9 /src/gpu/effects/post_process_helper.cc
parent01d3d4ecd33b74ffa8935a0a58079d59a3074700 (diff)
feat(gpu): Systematize post-process bindings and enable vertex shader uniforms
- Add PP_BINDING_* macros for standard post-process bind group layout - PP_BINDING_SAMPLER (0): Input texture sampler - PP_BINDING_TEXTURE (1): Input texture from previous pass - PP_BINDING_UNIFORMS (2): Custom uniforms buffer - Change uniforms visibility from Fragment-only to Vertex|Fragment - Enables dynamic geometry in vertex shaders (e.g., peak meter bar) - Replace all hardcoded binding numbers with macros in post_process_helper.cc - Update test_demo.cc to use systematic bindings - Benefits: All post-process effects can now access uniforms in vertex shaders Result: More flexible post-process effects, better code maintainability
Diffstat (limited to 'src/gpu/effects/post_process_helper.cc')
-rw-r--r--src/gpu/effects/post_process_helper.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/gpu/effects/post_process_helper.cc b/src/gpu/effects/post_process_helper.cc
index db89d77..0a2ac22 100644
--- a/src/gpu/effects/post_process_helper.cc
+++ b/src/gpu/effects/post_process_helper.cc
@@ -1,6 +1,7 @@
// This file is part of the 64k demo project.
// It implements helper functions for post-processing effects.
+#include "post_process_helper.h"
#include "../demo_effects.h"
#include "gpu/gpu.h"
#include <cstring>
@@ -18,15 +19,15 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device,
wgpuDeviceCreateShaderModule(device, &shader_desc);
WGPUBindGroupLayoutEntry bgl_entries[3] = {};
- bgl_entries[0].binding = 0;
+ bgl_entries[0].binding = PP_BINDING_SAMPLER;
bgl_entries[0].visibility = WGPUShaderStage_Fragment;
bgl_entries[0].sampler.type = WGPUSamplerBindingType_Filtering;
- bgl_entries[1].binding = 1;
+ bgl_entries[1].binding = PP_BINDING_TEXTURE;
bgl_entries[1].visibility = WGPUShaderStage_Fragment;
bgl_entries[1].texture.sampleType = WGPUTextureSampleType_Float;
bgl_entries[1].texture.viewDimension = WGPUTextureViewDimension_2D;
- bgl_entries[2].binding = 2;
- bgl_entries[2].visibility = WGPUShaderStage_Fragment;
+ bgl_entries[2].binding = PP_BINDING_UNIFORMS;
+ bgl_entries[2].visibility = WGPUShaderStage_Vertex | WGPUShaderStage_Fragment;
bgl_entries[2].buffer.type = WGPUBufferBindingType_Uniform;
WGPUBindGroupLayoutDescriptor bgl_desc = {};
@@ -74,11 +75,11 @@ void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline,
sd.maxAnisotropy = 1;
WGPUSampler sampler = wgpuDeviceCreateSampler(device, &sd);
WGPUBindGroupEntry bge[3] = {};
- bge[0].binding = 0;
+ bge[0].binding = PP_BINDING_SAMPLER;
bge[0].sampler = sampler;
- bge[1].binding = 1;
+ bge[1].binding = PP_BINDING_TEXTURE;
bge[1].textureView = input_view;
- bge[2].binding = 2;
+ bge[2].binding = PP_BINDING_UNIFORMS;
bge[2].buffer = uniforms.buffer;
bge[2].size = uniforms.size;
WGPUBindGroupDescriptor bgd = {