$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
gpu_profiler.h File Reference
#include "adaptive_sampler.h"
#include "metric_stack.h"
#include "perf_timer.h"
#include <stdint.h>
#include "app_settings.h"
Include dependency graph for gpu_profiler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GPUStage
 Represents a single profiling stage (e.g., "Shadow Map", "G-Buffer"). More...
 
struct  GPUStageInfo
 Per-frame stage metadata stored alongside queries. More...
 
struct  GPUQueryBuffer
 Set of GL queries for one frame, with stage metadata. More...
 
struct  GPUProfiler
 Manages GPU timing using double-buffered queries to avoid stalls. More...
 
struct  GPUStageRAII
 RAII container for automatic GPU stage management and Tracy zones. More...
 

Macros

#define GPU_STAGE_PROFILER(profiler_ptr, name, color)
 Scoped GPU profiling stage. Automatically ends on scope exit. More...
 

Enumerations

enum  { MAX_GPU_STAGES = 32 , MAX_GPU_STAGE_NAME = 32 , GPU_QUERY_BUFFER_COUNT = 2 }
 

Functions

void gpu_profiler_init (GPUProfiler *profiler)
 Initializes the GPU profiler. More...
 
void gpu_profiler_cleanup (GPUProfiler *profiler)
 Cleans up GPU resources. More...
 
void gpu_profiler_begin_frame (GPUProfiler *profiler, uint64_t frame_index)
 Marks the beginning of a frame. Swaps buffers and processes previous results. More...
 
void gpu_profiler_set_enabled (GPUProfiler *profiler, bool enabled)
 Enables or disables the profiler. More...
 
void gpu_profiler_start_stage (GPUProfiler *profiler, const char *name, uint32_t color)
 Starts a new profiling stage. More...
 
void gpu_profiler_end_stage (GPUProfiler *profiler)
 Ends the current profiling stage. More...
 
void gpu_profiler_reset_samplers (GPUProfiler *profiler, double current_time)
 Resets all samplers for a new capture window. More...
 
static void gpu_stage_cleanup_raii (GPUStageRAII *stage_raii)
 Internal cleanup function for GPUStageRAII. More...
 

Variables

static const int GPU_PROFILER_TOTAL_FRAME_COLOR = 0xECEFF4
 
static const int GPU_PROFILER_ENV_COLOR = 0x88C0D0
 
static const int GPU_PROFILER_SCENE_COLOR = 0xD08770
 
static const int GPU_PROFILER_AUTO_EXPOSURE_COLOR = 0xEBCB8B
 
static const int GPU_PROFILER_BLOOM_COLOR = 0x5E81AC
 
static const int GPU_PROFILER_DOF_COLOR = 0xA3BE8C
 
static const int GPU_PROFILER_MOTION_BLUR_COLOR = 0xBF616A
 
static const int GPU_PROFILER_COMPOSITE_COLOR = 0x81A1C1
 
static const int GPU_PROFILER_POSTPROCESS_COLOR = 0xB48EAD
 
static const int GPU_PROFILER_UI_COLOR = 0x4C566A
 
static const int GPU_PROFILER_GI_SYNC_COLOR = 0x8FBCBB
 
static const int GPU_PROFILER_GI_DEBUG_COLOR = 0xB48EAD
 
static const float GPU_PROFILER_WINDOW_DURATION_S = 0.5F
 
static const float GPU_PROFILER_WINDOW_TRANSITION_S = 0.2F
 
static const float GPU_PROFILER_ROW_HEIGHT = 28.0F
 

Macro Definition Documentation

◆ GPU_STAGE_PROFILER

#define GPU_STAGE_PROFILER (   profiler_ptr,
  name,
  color 
)
Value:
GPUStageRAII _stage_raii##__LINE__ \
__attribute__((cleanup(gpu_stage_cleanup_raii))) \
__attribute__((unused)) = {profiler_ptr}; \
gpu_profiler_start_stage(profiler_ptr, name, color)
static void gpu_stage_cleanup_raii(GPUStageRAII *stage_raii)
Internal cleanup function for GPUStageRAII.
Definition: gpu_profiler.h:168
RAII container for automatic GPU stage management and Tracy zones.
Definition: gpu_profiler.h:159

Scoped GPU profiling stage. Automatically ends on scope exit.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_GPU_STAGES 
MAX_GPU_STAGE_NAME 
GPU_QUERY_BUFFER_COUNT 

Function Documentation

◆ gpu_profiler_begin_frame()

void gpu_profiler_begin_frame ( GPUProfiler profiler,
uint64_t  frame_index 
)

Marks the beginning of a frame. Swaps buffers and processes previous results.

Parameters
profilerPointer to the profiler.
frame_indexThe current frame index.
Here is the call graph for this function:

◆ gpu_profiler_cleanup()

void gpu_profiler_cleanup ( GPUProfiler profiler)

Cleans up GPU resources.

Parameters
profilerPointer to the profiler.
Here is the call graph for this function:

◆ gpu_profiler_end_stage()

void gpu_profiler_end_stage ( GPUProfiler profiler)

Ends the current profiling stage.

Parameters
profilerPointer to the profiler.
Here is the call graph for this function:

◆ gpu_profiler_init()

void gpu_profiler_init ( GPUProfiler profiler)

Initializes the GPU profiler.

Parameters
profilerPointer to the profiler.
Here is the call graph for this function:

◆ gpu_profiler_reset_samplers()

void gpu_profiler_reset_samplers ( GPUProfiler profiler,
double  current_time 
)

Resets all samplers for a new capture window.

Here is the call graph for this function:

◆ gpu_profiler_set_enabled()

void gpu_profiler_set_enabled ( GPUProfiler profiler,
bool  enabled 
)

Enables or disables the profiler.

Parameters
profilerPointer to the profiler.
enabledWhether to enable profiling.

◆ gpu_profiler_start_stage()

void gpu_profiler_start_stage ( GPUProfiler profiler,
const char *  name,
uint32_t  color 
)

Starts a new profiling stage.

Parameters
profilerPointer to the profiler.
nameName of the stage (must be persistent or copied).
colorHex color for visualization (e.g., 0xFF0000).
Here is the call graph for this function:

◆ gpu_stage_cleanup_raii()

static void gpu_stage_cleanup_raii ( GPUStageRAII stage_raii)
inlinestatic

Internal cleanup function for GPUStageRAII.

Here is the call graph for this function:

Variable Documentation

◆ GPU_PROFILER_AUTO_EXPOSURE_COLOR

const int GPU_PROFILER_AUTO_EXPOSURE_COLOR = 0xEBCB8B
static

◆ GPU_PROFILER_BLOOM_COLOR

const int GPU_PROFILER_BLOOM_COLOR = 0x5E81AC
static

◆ GPU_PROFILER_COMPOSITE_COLOR

const int GPU_PROFILER_COMPOSITE_COLOR = 0x81A1C1
static

◆ GPU_PROFILER_DOF_COLOR

const int GPU_PROFILER_DOF_COLOR = 0xA3BE8C
static

◆ GPU_PROFILER_ENV_COLOR

const int GPU_PROFILER_ENV_COLOR = 0x88C0D0
static

◆ GPU_PROFILER_GI_DEBUG_COLOR

const int GPU_PROFILER_GI_DEBUG_COLOR = 0xB48EAD
static

◆ GPU_PROFILER_GI_SYNC_COLOR

const int GPU_PROFILER_GI_SYNC_COLOR = 0x8FBCBB
static

◆ GPU_PROFILER_MOTION_BLUR_COLOR

const int GPU_PROFILER_MOTION_BLUR_COLOR = 0xBF616A
static

◆ GPU_PROFILER_POSTPROCESS_COLOR

const int GPU_PROFILER_POSTPROCESS_COLOR = 0xB48EAD
static

◆ GPU_PROFILER_ROW_HEIGHT

const float GPU_PROFILER_ROW_HEIGHT = 28.0F
static

◆ GPU_PROFILER_SCENE_COLOR

const int GPU_PROFILER_SCENE_COLOR = 0xD08770
static

◆ GPU_PROFILER_TOTAL_FRAME_COLOR

const int GPU_PROFILER_TOTAL_FRAME_COLOR = 0xECEFF4
static

◆ GPU_PROFILER_UI_COLOR

const int GPU_PROFILER_UI_COLOR = 0x4C566A
static

◆ GPU_PROFILER_WINDOW_DURATION_S

const float GPU_PROFILER_WINDOW_DURATION_S = 0.5F
static

◆ GPU_PROFILER_WINDOW_TRANSITION_S

const float GPU_PROFILER_WINDOW_TRANSITION_S = 0.2F
static