9 #ifndef ADAPTIVE_SAMPLER_H
10 #define ADAPTIVE_SAMPLER_H
72 uint64_t frame_index);
82 size_t target_samples,
float initial_fps_guess);
94 double current_time, uint64_t frame_index);
103 double current_time);
126 uint64_t* start_frame,
127 uint64_t* end_frame);
137 uint64_t* out_indices,
size_t adaptive_sampler_get_sample_count(const AdaptiveSampler *sampler)
Returns the number of samples currently in the buffer.
Definition: adaptive_sampler.c:253
void adaptive_sampler_cleanup(AdaptiveSampler *sampler)
Frees all dynamic memory associated with the sampler.
Definition: adaptive_sampler.c:293
void adaptive_sampler_init(AdaptiveSampler *sampler, float window_duration, size_t target_samples, float initial_fps_guess)
Initializes the adaptive sampler.
Definition: adaptive_sampler.c:53
void adaptive_sampler_get_window_range(const AdaptiveSampler *sampler, uint64_t *start_frame, uint64_t *end_frame)
Retrieves the frame index range covered by the current window.
Definition: adaptive_sampler.c:258
void adaptive_sampler_reset(AdaptiveSampler *sampler, double current_time)
Resets the sampler state for a new window.
Definition: adaptive_sampler.c:91
size_t adaptive_sampler_get_sample_indices(const AdaptiveSampler *sampler, uint64_t *out_indices, size_t max_count)
Retrieves the list of frame indices for all collected samples.
Definition: adaptive_sampler.c:273
int adaptive_sampler_is_finished(const AdaptiveSampler *sampler, double current_time)
Checks if the current sampling window has concluded.
Definition: adaptive_sampler.c:231
void adaptive_sampler_add(AdaptiveSampler *sampler, float value, uint64_t frame_index)
Manually adds a sample to the sampler (e.g. from external source like GPU profiler).
Definition: adaptive_sampler.c:192
float adaptive_sampler_get_average(const AdaptiveSampler *sampler)
Calculates the arithmetic mean of all samples in the current window.
Definition: adaptive_sampler.c:241
int adaptive_sampler_should_sample(AdaptiveSampler *sampler, float delta_time, double current_time, uint64_t frame_index)
Determines if a sample should be taken this frame based on probability.
Definition: adaptive_sampler.c:101
Represents a single data point in the sampler.
Definition: adaptive_sampler.h:19
float value
Definition: adaptive_sampler.h:21
float timestamp
Definition: adaptive_sampler.h:20
uint64_t frame_index
Definition: adaptive_sampler.h:22
Collector for performance samples within a rolling or fixed window.
Definition: adaptive_sampler.h:38
double window_start_time
Definition: adaptive_sampler.h:50
size_t capacity
Definition: adaptive_sampler.h:59
uint64_t window_start_frame
Definition: adaptive_sampler.h:52
uint64_t window_end_frame
Definition: adaptive_sampler.h:53
Pcg32 rng
Definition: adaptive_sampler.h:40
size_t target_samples
Definition: adaptive_sampler.h:45
AdaptiveSampleItem * samples
Definition: adaptive_sampler.h:58
size_t count
Definition: adaptive_sampler.h:60
size_t samples_taken
Definition: adaptive_sampler.h:49
float window_duration
Definition: adaptive_sampler.h:44
float alpha
Definition: adaptive_sampler.h:55
float avg_dt
Definition: adaptive_sampler.h:54
State for a Permuted Congruential Generator (PCG) RNG.
Definition: adaptive_sampler.h:29
uint64_t inc
Definition: adaptive_sampler.h:31
uint64_t state
Definition: adaptive_sampler.h:30