$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
ibl_coordinator.h
Go to the documentation of this file.
1 
10 #ifndef IBL_COORDINATOR_H
11 #define IBL_COORDINATOR_H
12 
13 #include "gl_common.h"
14 #include "pbr.h"
15 #include "perf_timer.h"
16 
21 typedef enum {
31 
36 typedef struct {
37  /* --- State Machine --- */
39  GLsync lum_sync;
41  int total_mips;
42  int width;
43  int height;
44  float threshold;
48  /* --- Resources (Owned/Managed during process) --- */
49  GLuint pending_hdr_tex;
51  GLuint pending_irr_tex;
53  /* --- Dependencies (Injected) --- */
54  GLuint shader_spmap;
55  GLuint shader_irmap;
58  GLuint lum_ssbo[2];
67  /* --- Performance Metrics --- */
70  double stage_gpu_min;
71  double stage_gpu_max;
72  double stage_gpu_sum;
75 
84 void ibl_coordinator_init(IBLCoordinator* coord, GLuint shader_spmap,
85  GLuint shader_irmap, GLuint shader_lum_pass1,
86  GLuint shader_lum_pass2);
87 
93 
101 void ibl_coordinator_start(IBLCoordinator* coord, GLuint hdr_tex, int width,
102  int height);
103 
110 IBLState ibl_coordinator_update(IBLCoordinator* coord, uint64_t frame_count);
111 
121 int ibl_coordinator_get_results(IBLCoordinator* coord, GLuint* out_hdr_tex,
122  GLuint* out_spec_tex, GLuint* out_irr_tex,
123  float* out_threshold);
124 
130 
131 #endif /* IBL_COORDINATOR_H */
Common OpenGL definitions, RAII helpers, and utilities.
void ibl_coordinator_reset(IBLCoordinator *coord)
Resets the coordinator to IDLE state.
Definition: ibl_coordinator.c:155
IBLState
States for the IBL generation state machine.
Definition: ibl_coordinator.h:21
@ IBL_STATE_SPECULAR_INIT
Definition: ibl_coordinator.h:25
@ IBL_STATE_SPECULAR_MIPS
Definition: ibl_coordinator.h:26
@ IBL_STATE_IDLE
Definition: ibl_coordinator.h:22
@ IBL_STATE_DONE
Definition: ibl_coordinator.h:29
@ IBL_STATE_IRRADIANCE
Definition: ibl_coordinator.h:28
@ IBL_STATE_LUMINANCE
Definition: ibl_coordinator.h:23
@ IBL_STATE_LUMINANCE_WAIT
Definition: ibl_coordinator.h:24
void ibl_coordinator_start(IBLCoordinator *coord, GLuint hdr_tex, int width, int height)
Starts the IBL generation process for a new HDR texture.
Definition: ibl_coordinator.c:176
void ibl_coordinator_cleanup(IBLCoordinator *coord)
Cleanups any pending resources held by the coordinator.
Definition: ibl_coordinator.c:145
int ibl_coordinator_get_results(IBLCoordinator *coord, GLuint *out_hdr_tex, GLuint *out_spec_tex, GLuint *out_irr_tex, float *out_threshold)
Retrieves the results of the IBL generation.
Definition: ibl_coordinator.c:413
IBLState ibl_coordinator_update(IBLCoordinator *coord, uint64_t frame_count)
Advances the state machine by one step (slice or pass).
Definition: ibl_coordinator.c:371
void ibl_coordinator_init(IBLCoordinator *coord, GLuint shader_spmap, GLuint shader_irmap, GLuint shader_lum_pass1, GLuint shader_lum_pass2)
Initializes the IBL coordinator with necessary shader resources.
Definition: ibl_coordinator.c:128
Physically-Based Rendering (PBR) and Image-Based Lighting (IBL) utilities.
High-precision performance measurement (CPU and GPU).
Manages the progressive IBL generation process.
Definition: ibl_coordinator.h:36
int current_slice
Definition: ibl_coordinator.h:45
GLuint pending_spec_tex
Definition: ibl_coordinator.h:50
float threshold
Definition: ibl_coordinator.h:44
GLuint shader_spmap
Definition: ibl_coordinator.h:54
PBRIrrUniforms irr_uniforms
Definition: ibl_coordinator.h:63
PBRLumUniforms lum_uniforms
Definition: ibl_coordinator.h:65
int width
Definition: ibl_coordinator.h:42
double stage_gpu_max
Definition: ibl_coordinator.h:71
int total_slices
Definition: ibl_coordinator.h:46
int total_mips
Definition: ibl_coordinator.h:41
int current_mip
Definition: ibl_coordinator.h:40
double stage_gpu_sum
Definition: ibl_coordinator.h:72
GLsync lum_sync
Definition: ibl_coordinator.h:39
PerfTimer global_timer
Definition: ibl_coordinator.h:68
int stage_slice_count
Definition: ibl_coordinator.h:73
GLuint shader_irmap
Definition: ibl_coordinator.h:55
GLuint pending_irr_tex
Definition: ibl_coordinator.h:51
PBRSpecUniforms spec_uniforms
Definition: ibl_coordinator.h:61
GLuint shader_lum_pass2
Definition: ibl_coordinator.h:57
double stage_gpu_min
Definition: ibl_coordinator.h:70
PerfTimer stage_timer
Definition: ibl_coordinator.h:69
int height
Definition: ibl_coordinator.h:43
GLuint shader_lum_pass1
Definition: ibl_coordinator.h:56
IBLState state
Definition: ibl_coordinator.h:38
GLuint pending_hdr_tex
Definition: ibl_coordinator.h:49
Cached uniform locations for radiance convolution shader.
Definition: pbr.h:30
Cached uniform locations for luminance reduction shader.
Definition: pbr.h:39
Cached uniform locations for specular prefiltering shader.
Definition: pbr.h:18
CPU high-precision timer.
Definition: perf_timer.h:23