shengine pre-release
shengine by mrsinho
Loading...
Searching...
No Matches
shEngine.h
Go to the documentation of this file.
1/**
2 * @file shEngine.h
3 * @brief Declares the @ref ShEngine structure and associated functions for managing the engine.
4 *
5 * It contains and manages the main information about the engine state,
6 * window properties, timing, profiling, and various other configurations.
7 */
8
9#ifndef SH_ENGINE_H
10#define SH_ENGINE_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif//__cplusplus
15
17#include "shengine/shWindow.h"
18#include "shengine/shTime.h"
20#include "shengine/shInput.h"
21#include "shengine/shScene.h"
22#include "shengine/shEngineUI.h"
26
27#include <shthreads/shthreads.h>
28#include <smd/smd.h>
29
30
31
32/**
33 * @brief Number of swapchain images in the engine.
34 */
35#define SH_ENGINE_SWAPCHAIN_IMAGE_COUNT 2
36
37/**
38 * @brief Maximum number of swapchain images in the engine.
39 */
40#define SH_ENGINE_MAX_SWAPCHAIN_IMAGE_COUNT 6
41
42/**
43 * @brief Number of renderpass attachments in the engine.
44 */
45#define SH_ENGINE_RENDERPASS_ATTACHMENT_COUNT 3
46
47/**
48 * @brief Number of color attachments in a subpass in the engine.
49 */
50#define SH_ENGINE_SUBPASS_COLOR_ATTACHMENT_COUNT 1
51
52/**
53 * @brief Boolean value representing true.
54 */
55#ifndef SH_TRUE
56#ifndef __cplusplus
57#define SH_TRUE 1
58#else
59#define SH_TRUE true
60#endif//__cplusplus
61#endif//SH_TRUE
62
63/**
64 * @brief Boolean value representing false.
65 */
66#ifndef SH_FALSE
67#ifndef __cplusplus
68#define SH_FALSE 0
69#else
70#define SH_FALSE false
71#endif//__cplusplus
72#endif//SH_FALSE
73
74/**
75 * @struct ShEngine
76 * @brief Represents the ShEngine structure, which is the main instance of the engine.
77 */
78typedef struct ShEngine {
79 ShEngineVkCore core; /**< Vulkan core instance. */
80 ShWindow window; /**< Window properties. */
81 ShTime time; /**< Timing information. */
82 ShProfilingTimer profiling_timer; /**< Profiling timer. */
83 SmdFileHandle ini_smd; /**< SMD file handle for initialization. */
84 SmdFileHandle application_smd; /**< SMD file handle for application-specific data. */
85 SmdFileHandle host_memory_smd; /**< SMD file handle for host memory. */
86 SmdFileHandle vulkan_memory_smd; /**< SMD file handle for Vulkan memory. */
87 SmdFileHandle serial_smd; /**< SMD file handle for serialization. */
88 SmdFileHandle scene_smd; /**< SMD file handle for scene-related data. */
89 ShIniProperties ini_properties; /**< Initialization properties. */
90 ShApplicationProperties application_properties; /**< Application properties. */
91 ShHostMemoryProperties host_memory_properties; /**< Host memory properties. */
92 ShVulkanMemoryProperties vulkan_memory_properties; /**< Vulkan memory properties. */
93 ShSerialProperties serial_properties; /**< Serialization properties. */
94 ShSceneProperties scene_properties; /**< Scene properties. */
95 uint8_t load_shared; /**< Flag indicating whether to load shared resources. */
96 ShApplicationHost application_host; /**< Application host information. */
97 ShThreadPool thread_pool; /**< Thread pool for parallel processing. */
98 ShVkPipelinePool pipeline_pool; /**< Vulkan pipeline pool. */
99 ShGui gui; /**< Main gui structure. */
100 void* p_ext; /**< Additional extension pointer. */
102
103/**
104 * @brief Allocates memory for a new ShEngine instance.
105 *
106 * @return A pointer to the allocated ShEngine structure.
107 */
108#define shAllocateEngine() (ShEngine*)calloc(1, sizeof(ShEngine));
109
110/**
111 * @brief Frees the memory of a ShEngine instance.
112 *
113 * @param p_engine Valid pointer to a @ref ShEngine structure.
114 */
115#define shFreeEngine(p_engine) free(p_engine); (p_engine) = NULL
116
117/**
118 * @brief Generates an error message for the `shengine` module.
119 *
120 * @param condition The condition to check.
121 * @param msg The error message.
122 * @param failure_expression The expression to execute in case of failure.
123 */
124#define shEngineError(condition, msg, failure_expression) \
125 if ((int)(condition)) { printf("shengine error: %s.\n", msg); failure_expression; }
126
127/**
128 * @brief Generates an error message for the ShApplication.
129 *
130 * @param condition The condition to check.
131 * @param msg The error message.
132 * @param failure_expression The expression to execute in case of failure.
133 */
134#define shApplicationError(condition, msg, failure_expression) \
135 if ((int)(condition)) { printf("shapplication error: %s. \n", msg); failure_expression; }
136
137/**
138 * @brief Represents the engine being ready.
139 */
140#define SH_ENGINE_READY 1
141
142/**
143 * @brief Represents the engine not being ready.
144 */
145#define SH_ENGINE_NOT_READY 0
146
147
148
149/**
150 * @brief Sets up Vulkan for the `shengine` module.
151 *
152 * @param p_engine Valid pointer to a @ref ShEngine structure.
153 *
154 * @return Integer status code indicating the success or failure of the operation.
155 */
156extern uint8_t shEngineSetupVulkan(
157 ShEngine* p_engine
158);
159
160/**
161 * @brief Allocates a profiling handle for the `shengine` module.
162 *
163 * @param p_engine Valid pointer to a @ref ShEngine structure.
164 *
165 * @return Integer status code indicating the success or failure of the operation.
166 */
168 ShEngine* p_engine
169);
170
171/**
172 * @brief Sets the state of the `shengine` module.
173 *
174 * @param p_engine Valid pointer to a @ref ShEngine structure.
175 *
176 * @return Integer status code indicating the success or failure of the operation.
177 */
178extern uint8_t shSetEngineState(
179 ShEngine* p_engine
180);
181
182/**
183 * @brief Resets the state of the `shengine` module.
184 *
185 * @param p_engine Valid pointer to a @ref ShEngine structure.
186 *
187 * @return Integer status code indicating the success or failure of the operation.
188 */
189extern uint8_t shResetEngineState(
190 ShEngine* p_engine
191);
192
193/**
194 * @brief Safely sets the state of the `shengine` module.
195 *
196 * @param p_engine Valid pointer to a @ref ShEngine structure.
197 *
198 * @return Integer status code indicating the success or failure of the operation.
199 */
200extern uint8_t shEngineSafeState(
201 ShEngine* p_engine
202);
203
204/**
205 * @brief Resizes the frame in the `shengine` module.
206 *
207 * @param p_engine Valid pointer to a @ref ShEngine structure.
208 *
209 * @return Integer status code indicating the success or failure of the operation.
210 */
211extern uint8_t shEngineFrameResize(
212 ShEngine* p_engine
213);
214
215/**
216 * @brief Updates the profiling in the `shengine` module.
217 *
218 * @param p_engine Valid pointer to a @ref ShEngine structure.
219 *
220 * @return Integer status code indicating the success or failure of the operation.
221 */
222extern uint8_t shEngineProfilingUpdate(
223 ShEngine* p_engine
224);
225
226/**
227 * @brief Updates Vulkan in the `shengine` module.
228 *
229 * @param p_engine Valid pointer to a @ref ShEngine structure.
230 *
231 * @return Integer status code indicating the success or failure of the operation.
232 */
233extern uint8_t shEngineVulkanUpdate(
234 ShEngine* p_engine
235);
236
237/**
238 * @brief Updates the state of the `shengine` module.
239 *
240 * @param p_engine Valid pointer to a @ref ShEngine structure.
241 *
242 * @return Integer status code indicating the success or failure of the operation.
243 */
244extern uint8_t shEngineUpdateState(
245 ShEngine* p_engine
246);
247
248/**
249 * @brief Manages the state of the `shengine` module.
250 *
251 * @param p_engine Valid pointer to a @ref ShEngine structure.
252 * @param ready State of the engine.
253 *
254 * @return Integer status code indicating the success or failure of the operation.
255 */
256extern uint8_t shEngineManageState(
257 ShEngine* p_engine,
258 uint8_t ready
259);
260
261/**
262 * @brief Releases Vulkan resources in the `shengine` module.
263 *
264 * @param p_engine Valid pointer to a @ref ShEngine structure.
265 *
266 * @return Integer status code indicating the success or failure of the operation.
267 */
268extern uint8_t shEngineVulkanRelease(
269 ShEngine* p_engine
270);
271
272/**
273 * @brief Releases resources in the `shengine` module.
274 *
275 * @param p_engine Valid pointer to a @ref ShEngine structure.
276 */
277extern uint8_t shEngineRelease(
278 ShEngine* p_engine
279);
280
281/**
282 * @brief Shuts down the `shengine` module.
283 *
284 * @param p_engine Valid pointer to a @ref ShEngine structure.
285 */
286extern void shEngineShutdown(
287 ShEngine* p_engine
288);
289
290
291
292#ifdef __cplusplus
293}
294#endif//__cplusplus
295
296#endif//SH_ENGINE_H
Platform-specific shared library loading functions.
uint8_t shSetEngineState(ShEngine *p_engine)
Sets the state of the shengine module.
Definition shEngine.c:414
uint8_t shResetEngineState(ShEngine *p_engine)
Resets the state of the shengine module.
Definition shEngine.c:573
uint8_t shAllocateProfilingHandle(ShEngine *p_engine)
Allocates a profiling handle for the shengine module.
uint8_t shEngineSetupVulkan(ShEngine *p_engine)
Sets up Vulkan for the shengine module.
Definition shEngine.c:23
uint8_t shEngineVulkanUpdate(ShEngine *p_engine)
Updates Vulkan in the shengine module.
Definition shEngine.c:775
uint8_t shEngineProfilingUpdate(ShEngine *p_engine)
Updates the profiling in the shengine module.
Definition shEngine.c:740
uint8_t shEngineFrameResize(ShEngine *p_engine)
Resizes the frame in the shengine module.
Definition shEngine.c:583
uint8_t shEngineManageState(ShEngine *p_engine, uint8_t ready)
Manages the state of the shengine module.
Definition shEngine.c:935
uint8_t shEngineRelease(ShEngine *p_engine)
Releases resources in the shengine module.
Definition shEngine.c:998
uint8_t shEngineSafeState(ShEngine *p_engine)
Safely sets the state of the shengine module.
Definition shEngine.c:380
uint8_t shEngineUpdateState(ShEngine *p_engine)
Updates the state of the shengine module.
Definition shEngine.c:890
void shEngineShutdown(ShEngine *p_engine)
Shuts down the shengine module.
Definition shEngine.c:1072
uint8_t shEngineVulkanRelease(ShEngine *p_engine)
Releases Vulkan resources in the shengine module.
Definition shEngine.c:955
Declares functions related to setting up the graphical user interface (GUI) for the shengine module.
Handling environment descriptor functionalities in the shengine framework.
Profiling functionality for the shengine module.
Handling scenes in the shengine framework.
Handling time-related functionalities in the shengine framework.
Handling window-related functionalities in the shengine framework.
Represents the host for a shared application.
Definition shApplicationHost.h:121
Structure representing properties related to the application.
Definition shEnvironment.h:65
Represents the ShEngine structure, which is the main instance of the engine.
Definition shEngine.h:78
SmdFileHandle serial_smd
Definition shEngine.h:87
ShIniProperties ini_properties
Definition shEngine.h:89
ShProfilingTimer profiling_timer
Definition shEngine.h:82
SmdFileHandle vulkan_memory_smd
Definition shEngine.h:86
SmdFileHandle scene_smd
Definition shEngine.h:88
ShVulkanMemoryProperties vulkan_memory_properties
Definition shEngine.h:92
ShEngineVkCore core
Definition shEngine.h:79
void * p_ext
Definition shEngine.h:100
ShApplicationProperties application_properties
Definition shEngine.h:90
SmdFileHandle application_smd
Definition shEngine.h:84
ShThreadPool thread_pool
Definition shEngine.h:97
ShApplicationHost application_host
Definition shEngine.h:96
ShWindow window
Definition shEngine.h:80
ShSceneProperties scene_properties
Definition shEngine.h:94
SmdFileHandle host_memory_smd
Definition shEngine.h:85
SmdFileHandle ini_smd
Definition shEngine.h:83
uint8_t load_shared
Definition shEngine.h:95
ShVkPipelinePool pipeline_pool
Definition shEngine.h:98
ShTime time
Definition shEngine.h:81
ShGui gui
Definition shEngine.h:99
ShHostMemoryProperties host_memory_properties
Definition shEngine.h:91
ShSerialProperties serial_properties
Definition shEngine.h:93
Definition shEngineVkCore.h:21
Structure representing properties related to host memory.
Definition shEnvironment.h:89
Structure representing properties related to the initialization (INI) file.
Definition shEnvironment.h:47
Structure to hold profiling timer information in ShEngine.
Definition shProfiling.h:61
Structure representing properties related to the scene.
Definition shEnvironment.h:164
Structure representing properties related to serial communication.
Definition shEnvironment.h:140
Structure representing time in the shengine framework.
Definition shTime.h:63
Structure representing properties related to Vulkan memory.
Definition shEnvironment.h:110
Structure representing a window in the shengine framework.
Definition shWindow.h:54