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

Automated A/B GPU cost measurement for postprocess effects. More...

#include "effect_benchmark.h"
#include "log.h"
#include <math.h>
#include <string.h>
Include dependency graph for effect_benchmark.c:

Data Structures

struct  EffectEntry
 

Macros

#define BENCH_TAG   "suckless-ogl.bench"
 
#define MS_PER_SEC   1000.0F
 

Functions

static float find_composite_duration (const GPUProfiler *profiler)
 Find the "Final Composite" stage in the profiler and return its raw duration_ms, or -1.0 if not found. More...
 
static void reset_accumulator (EffectBenchmark *bench)
 
static void apply_effects (EffectBenchmark *bench, unsigned int effects)
 Atomically apply a new effect bitmask. More...
 
static void compute_stats (const EffectBenchmark *bench, float *out_mean, float *out_stddev)
 
void effect_benchmark_init (EffectBenchmark *bench, PostProcess *postprocess, GPUProfiler *profiler)
 Initializes the benchmark (call once at startup). More...
 
bool effect_benchmark_start (EffectBenchmark *bench)
 Starts a new benchmark sweep. More...
 
bool effect_benchmark_is_running (const EffectBenchmark *bench)
 Returns true if a benchmark is currently running. More...
 
bool effect_benchmark_update (EffectBenchmark *bench)
 Per-frame update. Call after gpu_profiler_begin_frame(). More...
 
void effect_benchmark_log_results (const EffectBenchmark *bench)
 Logs all results to the console via LOG_INFO. More...
 

Variables

static const unsigned int DEBUG_VIEW_BITS
 
static const EffectEntry BENCHMARKABLE_EFFECTS []
 
static const int BENCHMARKABLE_COUNT
 

Detailed Description

Automated A/B GPU cost measurement for postprocess effects.

State machine that cycles through effects, measuring "Final Composite" GPU time with each effect disabled vs baseline (all ON).

Macro Definition Documentation

◆ BENCH_TAG

#define BENCH_TAG   "suckless-ogl.bench"

◆ MS_PER_SEC

#define MS_PER_SEC   1000.0F

Function Documentation

◆ apply_effects()

static void apply_effects ( EffectBenchmark bench,
unsigned int  effects 
)
static

Atomically apply a new effect bitmask.

Sets active_effects, marks the UBO dirty, AND recompiles the uber-shader if running in optimized mode (release builds bake effect toggles as compile-time #defines — without recompilation the shader ignores the UBO activeEffects field).

Here is the call graph for this function:

◆ compute_stats()

static void compute_stats ( const EffectBenchmark bench,
float *  out_mean,
float *  out_stddev 
)
static

◆ effect_benchmark_init()

void effect_benchmark_init ( EffectBenchmark bench,
PostProcess postprocess,
GPUProfiler profiler 
)

Initializes the benchmark (call once at startup).

◆ effect_benchmark_is_running()

bool effect_benchmark_is_running ( const EffectBenchmark bench)

Returns true if a benchmark is currently running.

◆ effect_benchmark_log_results()

void effect_benchmark_log_results ( const EffectBenchmark bench)

Logs all results to the console via LOG_INFO.

◆ effect_benchmark_start()

bool effect_benchmark_start ( EffectBenchmark bench)

Starts a new benchmark sweep.

Returns
true if started, false if already running.
Here is the call graph for this function:

◆ effect_benchmark_update()

bool effect_benchmark_update ( EffectBenchmark bench)

Per-frame update. Call after gpu_profiler_begin_frame().

Reads the "Final Composite" timing from the profiler, advances the state machine, and toggles effects as needed.

Returns
true if the sweep just completed this frame, false otherwise.
Here is the call graph for this function:

◆ find_composite_duration()

static float find_composite_duration ( const GPUProfiler profiler)
static

Find the "Final Composite" stage in the profiler and return its raw duration_ms, or -1.0 if not found.

◆ reset_accumulator()

static void reset_accumulator ( EffectBenchmark bench)
static

Variable Documentation

◆ BENCHMARKABLE_COUNT

const int BENCHMARKABLE_COUNT
static
Initial value:
=
(int)(sizeof(BENCHMARKABLE_EFFECTS) / sizeof(BENCHMARKABLE_EFFECTS[0]))
static const EffectEntry BENCHMARKABLE_EFFECTS[]
Definition: effect_benchmark.c:42

◆ BENCHMARKABLE_EFFECTS

const EffectEntry BENCHMARKABLE_EFFECTS[]
static
Initial value:
= {
{"Motion Blur", POSTFX_MOTION_BLUR},
{"Chromatic Aberration", POSTFX_CHROM_ABBR},
{"FXAA", POSTFX_FXAA},
{"DOF", POSTFX_DOF},
{"Bloom", POSTFX_BLOOM},
{"Exposure", POSTFX_EXPOSURE},
{"Auto Exposure", POSTFX_AUTO_EXPOSURE},
{"Color Grading", POSTFX_COLOR_GRADING},
{"Vignette", POSTFX_VIGNETTE},
{"Banding", POSTFX_BANDING},
{"Grain", POSTFX_GRAIN},
}
@ POSTFX_BANDING
Definition: postprocess.h:99
@ POSTFX_AUTO_EXPOSURE
Definition: postprocess.h:90
@ POSTFX_MOTION_BLUR
Definition: postprocess.h:94
@ POSTFX_COLOR_GRADING
Definition: postprocess.h:86
@ POSTFX_GRAIN
Definition: postprocess.h:82
@ POSTFX_FXAA
Definition: postprocess.h:97
@ POSTFX_DOF
Definition: postprocess.h:88
@ POSTFX_BLOOM
Definition: postprocess.h:85
@ POSTFX_EXPOSURE
Definition: postprocess.h:83
@ POSTFX_VIGNETTE
Definition: postprocess.h:81
@ POSTFX_CHROM_ABBR
Definition: postprocess.h:84

◆ DEBUG_VIEW_BITS

const unsigned int DEBUG_VIEW_BITS
static
Initial value:
=
(unsigned int)POSTFX_MOTION_BLUR_DEBUG |
(unsigned int)POSTFX_VECTOR_FIELD_DEBUG | (unsigned int)POSTFX_DOF_DEBUG |
(unsigned int)POSTFX_EXPOSURE_DEBUG | (unsigned int)POSTFX_FXAA_DEBUG
@ POSTFX_DOF_DEBUG
Definition: postprocess.h:89
@ POSTFX_EXPOSURE_DEBUG
Definition: postprocess.h:92
@ POSTFX_MOTION_BLUR_DEBUG
Definition: postprocess.h:95
@ POSTFX_VECTOR_FIELD_DEBUG
Definition: postprocess.h:100
@ POSTFX_FXAA_DEBUG
Definition: postprocess.h:98

All toggleable effects executed in the "Final Composite" fullscreen pass (postprocess.frag). This includes multi-pass effects like Bloom, DoF, and Motion Blur whose setup runs in separate profiler stages but whose final compositing/sampling cost is paid here.

Order follows the pipeline stages in postprocess.frag main().