shengine pre-release
shengine by mrsinho
Loading...
Searching...
No Matches
shProfiling.h
Go to the documentation of this file.
1/**
2 * @file shProfiling.h
3 * @brief Profiling functionality for the `shengine` module.
4 *
5 * The shProfiling.h file contains structures and functions related to profiling and timing
6 * within the `shengine` framework.
7 */
8
9#ifndef SH_PROFILING_H
10#define SH_PROFILING_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif//__cplusplus
15
17#include <smd/smd.h>
18
19
20
21/**
22 * @brief Maximum number of extension timers supported.
23 */
24#define SH_PROFILING_TIMER_MAX_EXT_COUNT 1024
25
26
27
28/**
29 * @enum ShProfilingTimerType
30 * @brief Types of profiling timers used by the `shengine` library.
31 *
32 * The `ShProfilingTimerType` enumeration defines various types of profiling timers used by the `shengine` library.
33 * Each type corresponds to a specific aspect of the engine's execution.
34 */
36 SH_PROFILING_TIMER_MAIN_THREAD = 0, /**< Main thread timer. */
37 SH_PROFILING_TIMER_APPLICATION_UPDATE = 1, /**< Application update timer. */
38 SH_PROFILING_TIMER_APPLICATION_MAIN_CMD_BUFFER = 2, /**< Application main command buffer timer. */
39 SH_PROFILING_TIMER_APPLICATION_MAIN_RENDERPASS , /**< Application main render pass timer. */
40 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_0 , /**< Main command buffer wait timer 0. */
41 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_1 , /**< Main command buffer wait timer 1. */
42 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_2 , /**< Main command buffer wait timer 2. */
43 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_3 , /**< Main command buffer wait timer 3. */
44 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_4 , /**< Main command buffer wait timer 4. */
45 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_5 , /**< Main command buffer wait timer 5. */
46 SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_6 , /**< Main command buffer wait timer 6. */
47 SH_PROFILING_TIMER_EXT , /**< extension timer type. */
48 SH_PROFILING_TIMER_MAX_ENUM , /**< Maximum value for enumeration. */
50
51
52
53/**
54 * @struct ShProfilingTimer
55 * @brief Structure to hold profiling timer information in ShEngine.
56 *
57 * The ShProfilingTimer structure is used to store timing information for different aspects of ShEngine execution.
58 * It includes timing data for the main thread, application update, command buffer execution, rendering pass,
59 * and extension timers, among other things.
60 */
61typedef struct ShProfilingTimer {
62 double main_profiling_tool_last_time; /**< Last time profiling tool was queried. */
63
64 double main_thread_start_s; /**< Start time of the main thread. */
65 double main_thread_end_s; /**< End time of the main thread. */
66 double main_thread_dtime_ms; /**< Duration of the main thread in milliseconds. */
67
68 double main_graphics_queue_start_s; /**< Start time of the main graphics queue. */
69 double main_graphics_queue_end_s; /**< End time of the main graphics queue. */
70 double main_graphics_queue_dtime_ms; /**< Duration of the main graphics queue in milliseconds. */
71
72 double application_update_start_s; /**< Start time of the application update. */
73 double application_update_end_s; /**< End time of the application update. */
74 double application_update_dtime_ms; /**< Duration of the application update in milliseconds. */
75
76 double application_main_cmd_buffer_start_s; /**< Start time of the application main command buffer. */
77 double application_main_cmd_buffer_end_s; /**< End time of the application main command buffer. */
78 double application_main_cmd_buffer_dtime_ms; /**< Duration of the application main command buffer in milliseconds. */
79
80 double application_main_renderpass_start_s; /**< Start time of the application main render pass. */
81 double application_main_renderpass_end_s; /**< End time of the application main render pass. */
82 double application_main_renderpass_dtime_ms; /**< Duration of the application main render pass in milliseconds. */
83
84 double main_cmd_buffer_wait_start_s[SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]; /**< Start times of main command buffer waits. */
85 double main_cmd_buffer_wait_end_s [SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]; /**< End times of main command buffer waits. */
86 double main_cmd_buffer_wait_dtime_s[SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]; /**< Durations of main command buffer waits in seconds. */
87
88 uint32_t ext_count; /**< Count of extension timers. */
89 double ext_start_s [SH_PROFILING_TIMER_MAX_EXT_COUNT]; /**< Start times of extension timers. */
90 double ext_end_s [SH_PROFILING_TIMER_MAX_EXT_COUNT]; /**< End times of extension timers. */
91 double ext_dtime_ms[SH_PROFILING_TIMER_MAX_EXT_COUNT]; /**< Durations of extension timers in milliseconds. */
92 SmdVarName ext_names [SH_PROFILING_TIMER_MAX_EXT_COUNT]; /**< Names of extension timers. */
93
94 SmdExportHandle export; /**< Export handle for serialization. */
96
97
98
99/**
100 * @brief Starts the specified profiling timer.
101 *
102 * @param p_timer Pointer to a valid @ref ShProfilingTimer structure.
103 * @param type Type of the profiling timer to start.
104 *
105 * @return 1 on success, 0 on failure.
106 */
107extern uint8_t shProfilingTimerStart(
108 ShProfilingTimer* p_timer,
110);
111
112/**
113 * @brief Ends the specified profiling timer.
114 *
115 * @param p_timer Pointer to a valid @ref ShProfilingTimer structure.
116 * @param type Type of the profiling timer to end.
117 *
118 * @return 1 on success, 0 on failure.
119 */
120extern uint8_t shProfilingTimerEnd(
121 ShProfilingTimer* p_timer,
123);
124
125/**
126 * @brief Sets the count of extension timers in the ShProfilingTimer structure.
127 *
128 * @param p_timer Pointer to a valid @ref ShProfilingTimer structure.
129 * @param ext_count Count of extension timers.
130 *
131 * @return 1 on success, 0 on failure.
132 */
133extern uint8_t shProfilingTimerSetExtCount(
134 ShProfilingTimer* p_timer,
135 uint32_t ext_count
136);
137
138/**
139 * @brief Starts an extension profiling timer with the specified name and index.
140 *
141 * @param p_timer Pointer to a valid @ref ShProfilingTimer structure.
142 * @param name Name of the extension timer.
143 * @param timer_idx Index of the extension timer.
144 *
145 * @return 1 on success, 0 on failure.
146 */
147extern uint8_t shProfilingTimerStartExt(
148 ShProfilingTimer* p_timer,
149 SmdVarName name,
150 uint32_t timer_idx
151);
152
153/**
154 * @brief Ends an extension profiling timer with the specified index.
155 *
156 * @param p_timer Pointer to a valid @ref ShProfilingTimer structure.
157 * @param timer_idx Index of the extension timer.
158 *
159 * @return 1 on success, 0 on failure.
160 */
161extern uint8_t shProfilingTimerEndExt(
162 ShProfilingTimer* p_timer,
163 uint32_t timer_idx
164);
165
166
167
168#ifdef __cplusplus
169}
170#endif//__cplusplus
171#endif//SH_PROFILING_H
#define SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT
Definition shEditor.c:20
#define SH_PROFILING_TIMER_MAX_EXT_COUNT
Maximum number of extension timers supported.
Definition shProfiling.h:24
uint8_t shProfilingTimerSetExtCount(ShProfilingTimer *p_timer, uint32_t ext_count)
Sets the count of extension timers in the ShProfilingTimer structure.
Definition shProfiling.c:94
uint8_t shProfilingTimerStartExt(ShProfilingTimer *p_timer, SmdVarName name, uint32_t timer_idx)
Starts an extension profiling timer with the specified name and index.
Definition shProfiling.c:111
uint8_t shProfilingTimerEndExt(ShProfilingTimer *p_timer, uint32_t timer_idx)
Ends an extension profiling timer with the specified index.
Definition shProfiling.c:130
ShProfilingTimerType
Types of profiling timers used by the shengine library.
Definition shProfiling.h:35
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_1
Definition shProfiling.h:41
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_0
Definition shProfiling.h:40
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_5
Definition shProfiling.h:45
@ SH_PROFILING_TIMER_MAX_ENUM
Definition shProfiling.h:48
@ SH_PROFILING_TIMER_APPLICATION_MAIN_CMD_BUFFER
Definition shProfiling.h:38
@ SH_PROFILING_TIMER_APPLICATION_MAIN_RENDERPASS
Definition shProfiling.h:39
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_3
Definition shProfiling.h:43
@ SH_PROFILING_TIMER_EXT
Definition shProfiling.h:47
@ SH_PROFILING_TIMER_APPLICATION_UPDATE
Definition shProfiling.h:37
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_6
Definition shProfiling.h:46
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_2
Definition shProfiling.h:42
@ SH_PROFILING_TIMER_MAIN_CMD_BUFFER_WAIT_4
Definition shProfiling.h:44
@ SH_PROFILING_TIMER_MAIN_THREAD
Definition shProfiling.h:36
uint8_t shProfilingTimerStart(ShProfilingTimer *p_timer, ShProfilingTimerType type)
Starts the specified profiling timer.
Definition shProfiling.c:20
uint8_t shProfilingTimerEnd(ShProfilingTimer *p_timer, ShProfilingTimerType type)
Ends the specified profiling timer.
Definition shProfiling.c:54
Structure to hold profiling timer information in ShEngine.
Definition shProfiling.h:61
double application_update_end_s
Definition shProfiling.h:73
double main_cmd_buffer_wait_end_s[SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]
Definition shProfiling.h:85
double application_main_cmd_buffer_dtime_ms
Definition shProfiling.h:78
uint32_t ext_count
Definition shProfiling.h:88
double ext_end_s[SH_PROFILING_TIMER_MAX_EXT_COUNT]
Definition shProfiling.h:90
double main_cmd_buffer_wait_dtime_s[SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]
Definition shProfiling.h:86
double application_main_cmd_buffer_end_s
Definition shProfiling.h:77
double application_main_cmd_buffer_start_s
Definition shProfiling.h:76
double main_thread_start_s
Definition shProfiling.h:64
double application_update_start_s
Definition shProfiling.h:72
double main_graphics_queue_end_s
Definition shProfiling.h:69
double ext_start_s[SH_PROFILING_TIMER_MAX_EXT_COUNT]
Definition shProfiling.h:89
SmdExportHandle export
Definition shProfiling.h:94
SmdVarName ext_names[SH_PROFILING_TIMER_MAX_EXT_COUNT]
Definition shProfiling.h:92
double main_thread_end_s
Definition shProfiling.h:65
double application_main_renderpass_dtime_ms
Definition shProfiling.h:82
double main_graphics_queue_start_s
Definition shProfiling.h:68
double ext_dtime_ms[SH_PROFILING_TIMER_MAX_EXT_COUNT]
Definition shProfiling.h:91
double main_graphics_queue_dtime_ms
Definition shProfiling.h:70
double application_main_renderpass_start_s
Definition shProfiling.h:80
double main_profiling_tool_last_time
Definition shProfiling.h:62
double application_main_renderpass_end_s
Definition shProfiling.h:81
double main_cmd_buffer_wait_start_s[SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT]
Definition shProfiling.h:84
double main_thread_dtime_ms
Definition shProfiling.h:66
double application_update_dtime_ms
Definition shProfiling.h:74