diff options
Diffstat (limited to 'src/gpu/effects')
| -rw-r--r-- | src/gpu/effects/post_process_helper.cc | 15 | ||||
| -rw-r--r-- | src/gpu/effects/post_process_helper.h | 6 |
2 files changed, 14 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 = { diff --git a/src/gpu/effects/post_process_helper.h b/src/gpu/effects/post_process_helper.h index 1986ff3..45757cf 100644 --- a/src/gpu/effects/post_process_helper.h +++ b/src/gpu/effects/post_process_helper.h @@ -5,7 +5,13 @@ #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 + // Helper to create a standard post-processing pipeline +// Uniforms are accessible to both vertex and fragment shaders WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format, const char* shader_code); |
