summaryrefslogtreecommitdiff
path: root/src/gpu/post_process_helper.h
blob: 9a710468925d7c47452544103b617f0719b02a62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// This file is part of the 64k demo project.
// It declares helper functions for post-processing effects.

#pragma once

#include "gpu/gpu.h"
#include "gpu/sequence.h"
#include "util/mini_math.h"

// Use UniformsSequenceParams (defined in sequence.h) for post-process effects

// 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
#define PP_BINDING_EFFECT_PARAMS 3 // Effect-specific parameters

// 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);

// Helper to create a simple post-processing pipeline (no effect params, 3
// bindings only)
WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device,
                                                       WGPUTextureFormat format,
                                                       const char* shader_code);

// Helper to update bind group for post-processing effects
void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline,
                          WGPUBindGroup* bind_group, WGPUTextureView input_view,
                          GpuBuffer uniforms, GpuBuffer effect_params);