$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 "gpu_profiler.h"
21 #include "postprocess.h"
22 #include <stdbool.h>
23 
25 #define BENCH_MEASURE_FRAMES 120
26 
28 #define BENCH_WARMUP_FRAMES 30
29 
31 #define BENCH_MAX_EFFECTS 16
32 
34 #define BENCH_TIMEOUT_MS 2000.0F
35 
40 typedef enum {
41  BENCH_IDLE = 0,
45  BENCH_DONE
47 
52 typedef struct {
53  const char* name;
54  unsigned int effect_bit;
55  float mean_ms;
56  float stddev_ms;
57  float cost_ms;
59 
64 typedef struct {
68 
69  /* Original state (restored at end) */
70  unsigned int saved_effects;
71 
72  /* Benchmark mask: all benchmarkable effects forced ON */
73  unsigned int benchmark_effects;
74 
75  /* Effect table */
76  struct {
77  const char* name;
78  unsigned int bit;
79  } effects[BENCH_MAX_EFFECTS];
81 
82  /* Current sweep position */
85  float timeout_timer;
87  /* Accumulation */
88  double sum_ms;
89  double sum_sq_ms;
91 
92  /* Results */
98 
102 void effect_benchmark_init(EffectBenchmark* bench, PostProcess* postprocess,
103  GPUProfiler* profiler);
104 
110 
120 
125 
130 
131 #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:310
bool effect_benchmark_is_running(const EffectBenchmark *bench)
Returns true if a benchmark is currently running.
Definition: effect_benchmark.c:181
#define BENCH_MAX_EFFECTS
Maximum number of effects that can be benchmarked.
Definition: effect_benchmark.h:31
bool effect_benchmark_start(EffectBenchmark *bench)
Starts a new benchmark sweep.
Definition: effect_benchmark.c:145
void effect_benchmark_init(EffectBenchmark *bench, PostProcess *postprocess, GPUProfiler *profiler)
Initializes the benchmark (call once at startup).
Definition: effect_benchmark.c:126
bool effect_benchmark_update(EffectBenchmark *bench)
Per-frame update. Call after gpu_profiler_begin_frame().
Definition: effect_benchmark.c:188
BenchPhase
State machine phases for the benchmark sweep.
Definition: effect_benchmark.h:40
@ BENCH_DONE
Definition: effect_benchmark.h:45
@ BENCH_BASELINE
Definition: effect_benchmark.h:42
@ BENCH_STABILIZE
Definition: effect_benchmark.h:43
@ BENCH_IDLE
Definition: effect_benchmark.h:41
@ BENCH_EFFECT_TEST
Definition: effect_benchmark.h:44
High-level post-processing pipeline and effects.
Timing result for a single effect.
Definition: effect_benchmark.h:52
float mean_ms
Definition: effect_benchmark.h:55
unsigned int effect_bit
Definition: effect_benchmark.h:54
const char * name
Definition: effect_benchmark.h:53
float stddev_ms
Definition: effect_benchmark.h:56
float cost_ms
Definition: effect_benchmark.h:57
State for the automated benchmark sweep.
Definition: effect_benchmark.h:64
double sum_sq_ms
Definition: effect_benchmark.h:89
PostProcess * postprocess
Definition: effect_benchmark.h:66
unsigned int bit
Definition: effect_benchmark.h:78
unsigned int benchmark_effects
Definition: effect_benchmark.h:73
int result_count
Definition: effect_benchmark.h:96
int frame_counter
Definition: effect_benchmark.h:84
float baseline_stddev_ms
Definition: effect_benchmark.h:94
const char * name
Definition: effect_benchmark.h:77
double sum_ms
Definition: effect_benchmark.h:88
int current_effect_idx
Definition: effect_benchmark.h:83
unsigned int saved_effects
Definition: effect_benchmark.h:70
BenchPhase phase
Definition: effect_benchmark.h:65
float baseline_mean_ms
Definition: effect_benchmark.h:93
GPUProfiler * profiler
Definition: effect_benchmark.h:67
int sample_count
Definition: effect_benchmark.h:90
int effect_count
Definition: effect_benchmark.h:80
float timeout_timer
Definition: effect_benchmark.h:85
Manages GPU timing using double-buffered queries to avoid stalls.
Definition: gpu_profiler.h:86
Main pipeline state for post-processing.
Definition: postprocess.h:353