$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
effect_benchmark.h
Go to the documentation of this file.
1 
17 #ifndef EFFECT_BENCHMARK_H
18 #define EFFECT_BENCHMARK_H
19 
20 #include <stdbool.h>
21 
22 typedef struct PostProcess PostProcess;
23 typedef struct GPUProfiler GPUProfiler;
24 
26 #define BENCH_MEASURE_FRAMES 120
27 
29 #define BENCH_WARMUP_FRAMES 30
30 
32 #define BENCH_MAX_EFFECTS 16
33 
35 #define BENCH_TIMEOUT_MS 2000.0F
36 
41 typedef enum {
42  BENCH_IDLE = 0,
46  BENCH_DONE
48 
53 typedef struct EffectBenchResult {
54  const char* name;
55  unsigned int effect_bit;
56  float mean_ms;
57  float stddev_ms;
58  float cost_ms;
60 
65 typedef struct EffectBenchmark {
69 
70  /* Original state (restored at end) */
71  unsigned int saved_effects;
72 
73  /* Benchmark mask: all benchmarkable effects forced ON */
74  unsigned int benchmark_effects;
75 
76  /* Effect table */
77  struct {
78  const char* name;
79  unsigned int bit;
81 
83 
84  /* Current sweep position */
87  float timeout_timer;
89  /* Accumulation */
90  double sum_ms;
91  double sum_sq_ms;
93 
94  /* Results */
100 
104 void effect_benchmark_init(EffectBenchmark* bench, PostProcess* postprocess,
105  GPUProfiler* profiler);
106 
112 
122 
127 
132 
133 #endif /* EFFECT_BENCHMARK_H */
void effect_benchmark_log_results(const EffectBenchmark *bench)
Logs all results to the console via LOG_INFO.
Definition: effect_benchmark.c:312
bool effect_benchmark_is_running(const EffectBenchmark *bench)
Returns true if a benchmark is currently running.
Definition: effect_benchmark.c:183
#define BENCH_MAX_EFFECTS
Maximum number of effects that can be benchmarked.
Definition: effect_benchmark.h:32
bool effect_benchmark_start(EffectBenchmark *bench)
Starts a new benchmark sweep.
Definition: effect_benchmark.c:147
void effect_benchmark_init(EffectBenchmark *bench, PostProcess *postprocess, GPUProfiler *profiler)
Initializes the benchmark (call once at startup).
Definition: effect_benchmark.c:128
bool effect_benchmark_update(EffectBenchmark *bench)
Per-frame update. Call after gpu_profiler_begin_frame().
Definition: effect_benchmark.c:190
BenchPhase
State machine phases for the benchmark sweep.
Definition: effect_benchmark.h:41
@ BENCH_DONE
Definition: effect_benchmark.h:46
@ BENCH_BASELINE
Definition: effect_benchmark.h:43
@ BENCH_STABILIZE
Definition: effect_benchmark.h:44
@ BENCH_IDLE
Definition: effect_benchmark.h:42
@ BENCH_EFFECT_TEST
Definition: effect_benchmark.h:45
Timing result for a single effect.
Definition: effect_benchmark.h:53
float mean_ms
Definition: effect_benchmark.h:56
unsigned int effect_bit
Definition: effect_benchmark.h:55
const char * name
Definition: effect_benchmark.h:54
float stddev_ms
Definition: effect_benchmark.h:57
float cost_ms
Definition: effect_benchmark.h:58
State for the automated benchmark sweep.
Definition: effect_benchmark.h:65
double sum_sq_ms
Definition: effect_benchmark.h:91
EffectBenchResult results[16]
Definition: effect_benchmark.h:97
PostProcess * postprocess
Definition: effect_benchmark.h:67
unsigned int bit
Definition: effect_benchmark.h:79
unsigned int benchmark_effects
Definition: effect_benchmark.h:74
int result_count
Definition: effect_benchmark.h:98
int frame_counter
Definition: effect_benchmark.h:86
float baseline_stddev_ms
Definition: effect_benchmark.h:96
const char * name
Definition: effect_benchmark.h:78
struct EffectBenchmark::@10 effects[16]
double sum_ms
Definition: effect_benchmark.h:90
int current_effect_idx
Definition: effect_benchmark.h:85
unsigned int saved_effects
Definition: effect_benchmark.h:71
BenchPhase phase
Definition: effect_benchmark.h:66
float baseline_mean_ms
Definition: effect_benchmark.h:95
GPUProfiler * profiler
Definition: effect_benchmark.h:68
int sample_count
Definition: effect_benchmark.h:92
int effect_count
Definition: effect_benchmark.h:82
float timeout_timer
Definition: effect_benchmark.h:87
Manages GPU timing using double-buffered queries to avoid stalls.
Definition: gpu_profiler.h:86
Main pipeline state for post-processing.
Definition: postprocess_internal.h:46