$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
postprocess_internal.h
Go to the documentation of this file.
1 #ifndef POSTPROCESS_INTERNAL_H
2 #define POSTPROCESS_INTERNAL_H
3 
12 #include "effects/fx_auto_exposure.h"
13 #include "effects/fx_bloom.h"
14 #include "effects/fx_dof.h"
15 #include "effects/fx_lut3d.h"
16 #include "effects/fx_lut_viz.h"
17 #include "effects/fx_motion_blur.h"
18 #include "gpu_profiler.h"
19 #include "postprocess.h"
20 #include "pp_exposure_readback.h"
21 #include "pp_gpu_resources.h"
22 #include "pp_params.h"
23 #include "pp_shader_state.h"
24 #include "pp_ubo.h"
25 #include "shader.h"
26 #include <cglm/types.h>
27 #include <stdbool.h>
28 
29 /* --- FX-specific DEFAULT VALUES (owned by PostProcess init) --- */
30 #define DEFAULT_BLOOM_INTENSITY 0.0F
31 #define DEFAULT_BLOOM_THRESHOLD 1.0F
32 #define DEFAULT_BLOOM_SOFT_THRESHOLD 0.5F
33 #define DEFAULT_BLOOM_RADIUS 1.0F
34 
35 /* DoF defaults */
36 #define DEFAULT_DOF_FOCAL_DISTANCE 20.0F
37 #define DEFAULT_DOF_FOCAL_RANGE 5.0F
38 #define DEFAULT_DOF_BOKEH_SCALE 10.0F
39 #define DEFAULT_DOF_ANAMORPHIC_RATIO \
40  1.0F
46 struct PostProcess {
47  /* GPU Resources */
50  /* Module Resources */
51  BloomFX bloom_fx;
52  DoFFX dof_fx;
53  AutoExposureFX auto_exposure_fx;
54  MotionBlurFX motion_blur_fx;
55  LUT3DFX lut3d_fx;
56  LUTVizFX lut_viz_fx;
58  /* Shader Management */
61  int width;
62  int height;
64  unsigned int active_effects;
66  /* Logic Parameters */
74  BloomParams bloom;
75  DoFParams dof;
76  AutoExposureParams auto_exposure;
77  MotionBlurParams motion_blur;
81  LUT3DParams lut3d;
82 
83  float time;
84  float delta_time;
85  bool ubo_dirty;
90  /* Exposure Readback */
92 };
93 
99  unsigned int active_effects;
107  BloomParams bloom;
108  DoFParams dof;
112  LUT3DParams lut3d;
113 };
114 
115 /* ---- Texture Units (shared across init, apply, shader TUs) ---- */
116 enum {
126 };
127 
128 /* ---- Internal helpers shared across TUs ---- */
129 
131 void pp_destroy_framebuffer(PostProcess* post_processing);
132 
134 void pp_destroy_screen_quad(PostProcess* post_processing);
135 
137 void pp_destroy_readback_buffers(PostProcess* post_processing);
138 
140 void pp_destroy_cached_shaders(PostProcess* post_processing);
141 
143 bool pp_is_shader_in_cache(PostProcess* post_processing, Shader* shader);
144 
146 int pp_create_framebuffer(PostProcess* post_processing);
147 
149 void pp_setup_sampler_uniforms(PostProcess* post_processing);
150 
152 void pp_update_current_shader(PostProcess* post_processing, Shader* new_shader,
153  bool is_optimized);
154 
155 #endif /* POSTPROCESS_INTERNAL_H */
Public API for the post-processing pipeline.
void pp_destroy_screen_quad(PostProcess *post_processing)
Definition: postprocess_cleanup.c:28
void pp_update_current_shader(PostProcess *post_processing, Shader *new_shader, bool is_optimized)
Definition: postprocess_shader.c:41
int pp_create_framebuffer(PostProcess *post_processing)
Definition: postprocess_init.c:12
void pp_destroy_cached_shaders(PostProcess *post_processing)
Definition: postprocess_cleanup.c:54
void pp_destroy_readback_buffers(PostProcess *post_processing)
Definition: postprocess_cleanup.c:34
bool pp_is_shader_in_cache(PostProcess *post_processing, Shader *shader)
Definition: postprocess_shader.c:6
void pp_setup_sampler_uniforms(PostProcess *post_processing)
Definition: postprocess_shader.c:19
@ POSTPROCESS_TEX_UNIT_STENCIL
Definition: postprocess_internal.h:124
@ POSTPROCESS_TEX_UNIT_DOF_BLUR
Definition: postprocess_internal.h:123
@ POSTPROCESS_TEX_UNIT_DEPTH
Definition: postprocess_internal.h:119
@ POSTPROCESS_TEX_UNIT_NEIGHBOR_MAX
Definition: postprocess_internal.h:122
@ POSTPROCESS_TEX_UNIT_VELOCITY
Definition: postprocess_internal.h:121
@ POSTPROCESS_TEX_UNIT_BLOOM
Definition: postprocess_internal.h:118
@ POSTPROCESS_TEX_UNIT_LUT3D
Definition: postprocess_internal.h:125
@ POSTPROCESS_TEX_UNIT_EXPOSURE
Definition: postprocess_internal.h:120
@ POSTPROCESS_TEX_UNIT_SCENE
Definition: postprocess_internal.h:117
void pp_destroy_framebuffer(PostProcess *post_processing)
Definition: postprocess_cleanup.c:11
Async GPU readback state for exposure and histogram.
GPU resource handles for the post-processing pipeline.
Parameter structs and defaults for uber-shader post-processing effects.
Shader management state for the optimized uber-shader pipeline.
GPU-side Uniform Buffer Object layout for the post-processing uber-shader.
High-level OpenGL shader management with metadata and uniform caching.
Controls for color banding/quantization.
Definition: pp_params.h:158
Focal-length distortion simulation.
Definition: pp_params.h:106
Unreal-style color grading parameters.
Definition: pp_params.h:61
Manual exposure tuning.
Definition: pp_params.h:98
Parameters for Fast Approximate Anti-Aliasing.
Definition: pp_params.h:135
Depth-based atmospheric fog parameters.
Definition: pp_params.h:170
Manages GPU timing using double-buffered queries to avoid stalls.
Definition: gpu_profiler.h:86
Fine-grained controls for film noise.
Definition: pp_params.h:84
Async GPU readback state for exposure and histogram.
Definition: pp_exposure_readback.h:18
GPU handles for the post-processing pipeline (FBOs, textures, UBO).
Definition: pp_gpu_resources.h:15
Shader management state for the optimized uber-shader pipeline.
Definition: pp_shader_state.h:28
Snapshot of every configurable parameter in the pipeline.
Definition: postprocess_internal.h:98
DoFParams dof
Definition: postprocess_internal.h:108
BloomParams bloom
Definition: postprocess_internal.h:107
TonemapParams tonemapper
Definition: postprocess_internal.h:106
WhiteBalanceParams white_balance
Definition: postprocess_internal.h:104
BandingParams banding
Definition: postprocess_internal.h:110
ExposureParams exposure
Definition: postprocess_internal.h:102
unsigned int active_effects
Definition: postprocess_internal.h:99
VignetteParams vignette
Definition: postprocess_internal.h:100
ColorGradingParams color_grading
Definition: postprocess_internal.h:105
ChromAbberationParams chrom_abbr
Definition: postprocess_internal.h:103
FXAAParams fxaa
Definition: postprocess_internal.h:109
FogParams fog
Definition: postprocess_internal.h:111
GrainParams grain
Definition: postprocess_internal.h:101
LUT3DParams lut3d
Definition: postprocess_internal.h:112
Main pipeline state for post-processing.
Definition: postprocess_internal.h:46
int height
Definition: postprocess_internal.h:62
FogParams fog
Definition: postprocess_internal.h:80
PPShaderState shaders
Definition: postprocess_internal.h:59
PPGPUResources gpu
Definition: postprocess_internal.h:48
int banding_preset_idx
Definition: postprocess_internal.h:88
unsigned int active_effects
Definition: postprocess_internal.h:64
AutoExposureFX auto_exposure_fx
Definition: postprocess_internal.h:53
ExposureParams exposure
Definition: postprocess_internal.h:69
DoFFX dof_fx
Definition: postprocess_internal.h:52
int width
Definition: postprocess_internal.h:61
bool ubo_dirty
Definition: postprocess_internal.h:85
AutoExposureParams auto_exposure
Definition: postprocess_internal.h:76
TonemapParams tonemapper
Definition: postprocess_internal.h:73
LUTVizFX lut_viz_fx
Definition: postprocess_internal.h:56
ChromAbberationParams chrom_abbr
Definition: postprocess_internal.h:70
LUT3DFX lut3d_fx
Definition: postprocess_internal.h:55
LUT3DParams lut3d
Definition: postprocess_internal.h:81
WhiteBalanceParams white_balance
Definition: postprocess_internal.h:71
DoFParams dof
Definition: postprocess_internal.h:75
FXAAParams fxaa
Definition: postprocess_internal.h:78
GrainParams grain
Definition: postprocess_internal.h:68
MotionBlurParams motion_blur
Definition: postprocess_internal.h:77
GPUProfiler * gpu_profiler
Definition: postprocess_internal.h:87
BloomFX bloom_fx
Definition: postprocess_internal.h:51
BloomParams bloom
Definition: postprocess_internal.h:74
VignetteParams vignette
Definition: postprocess_internal.h:67
PPExposureReadback readback
Definition: postprocess_internal.h:91
BandingParams banding
Definition: postprocess_internal.h:79
MotionBlurFX motion_blur_fx
Definition: postprocess_internal.h:54
float delta_time
Definition: postprocess_internal.h:84
float time
Definition: postprocess_internal.h:83
ColorGradingParams color_grading
Definition: postprocess_internal.h:72
Wrapper for an OpenGL program with uniform caching and automatic cleanup.
Definition: shader.h:71
ACES-like filmic tonemapping curve parameters.
Definition: pp_params.h:123
Controls for the screen-edge darkening effect.
Definition: pp_params.h:74
Temperature and tint correction.
Definition: pp_params.h:114