$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
ibl_coordinator.h File Reference

Coordinator for progressive Image-Based Lighting (IBL) generation. More...

#include "gl_common.h"
#include "pbr.h"
#include "perf_timer.h"
Include dependency graph for ibl_coordinator.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IBLCoordinator
 Manages the progressive IBL generation process. More...
 

Enumerations

enum  IBLState {
  IBL_STATE_IDLE = 0 , IBL_STATE_LUMINANCE , IBL_STATE_LUMINANCE_WAIT , IBL_STATE_SPECULAR_INIT ,
  IBL_STATE_SPECULAR_MIPS , IBL_STATE_IRRADIANCE , IBL_STATE_DONE
}
 States for the IBL generation state machine. More...
 

Functions

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. More...
 
void ibl_coordinator_cleanup (IBLCoordinator *coord)
 Cleanups any pending resources held by the coordinator. More...
 
void ibl_coordinator_start (IBLCoordinator *coord, GLuint hdr_tex, int width, int height)
 Starts the IBL generation process for a new HDR texture. More...
 
IBLState ibl_coordinator_update (IBLCoordinator *coord, uint64_t frame_count)
 Advances the state machine by one step (slice or pass). More...
 
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. More...
 
void ibl_coordinator_reset (IBLCoordinator *coord)
 Resets the coordinator to IDLE state. More...
 

Detailed Description

Coordinator for progressive Image-Based Lighting (IBL) generation.

This module manages the state machine that generates Irradiance and Prefiltered Specular maps from an HDR environment map over multiple frames to avoid stalling the main thread.

Enumeration Type Documentation

◆ IBLState

enum IBLState

States for the IBL generation state machine.

Enumerator
IBL_STATE_IDLE 

Application is waiting for a request.

IBL_STATE_LUMINANCE 

GPU-side analysis of HDR mean luminance.

IBL_STATE_LUMINANCE_WAIT 

Waiting for luminance GPU result.

IBL_STATE_SPECULAR_INIT 

Preparation of specular map textures.

IBL_STATE_SPECULAR_MIPS 

Sliced pre-filtering of specular levels.

IBL_STATE_IRRADIANCE 

Sliced convolution of irradiance map.

IBL_STATE_DONE 

Resource cleanup and texture activation.

Function Documentation

◆ ibl_coordinator_cleanup()

void ibl_coordinator_cleanup ( IBLCoordinator coord)

Cleanups any pending resources held by the coordinator.

Parameters
coordPointer to the coordinator instance.
Here is the call graph for this function:

◆ ibl_coordinator_get_results()

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.

Parameters
coordPointer to the coordinator instance.
out_hdr_texPointer to receive the HDR texture handle.
out_spec_texPointer to receive the specular texture handle.
out_irr_texPointer to receive the irradiance texture handle.
out_thresholdPointer to receive the computed luminance threshold.
Returns
1 if results were retrieved (state was DONE), 0 otherwise.

◆ ibl_coordinator_init()

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.

Parameters
coordPointer to the coordinator instance.
shader_spmapHandle to the specular pre-filter shader.
shader_irmapHandle to the irradiance convolution shader.
shader_lum_pass1Handle to luminance pass 1 shader.
shader_lum_pass2Handle to luminance pass 2 shader.
Here is the call graph for this function:

◆ ibl_coordinator_reset()

void ibl_coordinator_reset ( IBLCoordinator coord)

Resets the coordinator to IDLE state.

Parameters
coordPointer to the coordinator instance.

◆ ibl_coordinator_start()

void ibl_coordinator_start ( IBLCoordinator coord,
GLuint  hdr_tex,
int  width,
int  height 
)

Starts the IBL generation process for a new HDR texture.

Parameters
coordPointer to the coordinator instance.
hdr_texHandle to the source HDR texture (must be valid).
widthWidth of the HDR texture.
heightHeight of the HDR texture.
Here is the call graph for this function:

◆ ibl_coordinator_update()

IBLState ibl_coordinator_update ( IBLCoordinator coord,
uint64_t  frame_count 
)

Advances the state machine by one step (slice or pass).

Parameters
coordPointer to the coordinator instance.
frame_countCurrent frame number (for logging purposes).
Returns
IBLState The new state after the update.
Here is the call graph for this function: