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

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

#include "gpu_profiler.h"
#include "postprocess.h"
#include <stdbool.h>
Include dependency graph for effect_benchmark.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  EffectBenchResult
 Timing result for a single effect. More...
 
struct  EffectBenchmark
 State for the automated benchmark sweep. More...
 

Macros

#define BENCH_MEASURE_FRAMES   120
 Number of frames to measure per phase (warmup excluded). More...
 
#define BENCH_WARMUP_FRAMES   30
 Frames to skip at the start of each phase (cache warmup). More...
 
#define BENCH_MAX_EFFECTS   16
 Maximum number of effects that can be benchmarked. More...
 
#define BENCH_TIMEOUT_MS   2000.0F
 Timeout in milliseconds to abort benchmark if no profiler data. More...
 

Enumerations

enum  BenchPhase {
  BENCH_IDLE = 0 , BENCH_BASELINE , BENCH_STABILIZE , BENCH_EFFECT_TEST ,
  BENCH_DONE
}
 State machine phases for the benchmark sweep. More...
 

Functions

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_update (EffectBenchmark *bench)
 Per-frame update. Call after gpu_profiler_begin_frame(). More...
 
bool effect_benchmark_is_running (const EffectBenchmark *bench)
 Returns true if a benchmark is currently running. More...
 
void effect_benchmark_log_results (const EffectBenchmark *bench)
 Logs all results to the console via LOG_INFO. More...
 

Detailed Description

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

Cycles through each toggleable postprocess effect, disabling it one at a time while measuring the "Final Composite" GPU timer. The difference between the baseline (all effects ON) and each disabled-effect run gives the per-effect GPU cost.

Usage:

  1. Call effect_benchmark_start() to begin a sweep (e.g. on key press).
  2. Call effect_benchmark_update() every frame after gpu_profiler_begin_frame.
  3. Results are logged to console and displayed via notification.

Macro Definition Documentation

◆ BENCH_MAX_EFFECTS

#define BENCH_MAX_EFFECTS   16

Maximum number of effects that can be benchmarked.

◆ BENCH_MEASURE_FRAMES

#define BENCH_MEASURE_FRAMES   120

Number of frames to measure per phase (warmup excluded).

◆ BENCH_TIMEOUT_MS

#define BENCH_TIMEOUT_MS   2000.0F

Timeout in milliseconds to abort benchmark if no profiler data.

◆ BENCH_WARMUP_FRAMES

#define BENCH_WARMUP_FRAMES   30

Frames to skip at the start of each phase (cache warmup).

Enumeration Type Documentation

◆ BenchPhase

enum BenchPhase

State machine phases for the benchmark sweep.

Enumerator
BENCH_IDLE 

No benchmark running.

BENCH_BASELINE 

Measuring with all effects at original state.

BENCH_STABILIZE 

Restoring baseline between tests (warmup only).

BENCH_EFFECT_TEST 

Measuring with one effect disabled.

BENCH_DONE 

All phases complete, results ready.

Function Documentation

◆ 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: