shvulkan pre-release
by mrsinho.
Loading...
Searching...
No Matches
shVulkan.h
Go to the documentation of this file.
1#ifndef SH_VULKAN_H
2#define SH_VULKAN_H
3
4
5
6/**
7 * @file my_vulkan_wrapper.h
8 * @brief This file contains Vulkan wrapper functions for handling device creation and resource management.
9 */
10
11
12
13#ifdef __cplusplus
14extern "C" {
15#endif//__cplusplus
16
17
18
19#include <vulkan/vulkan.h>
20#include <stdint.h>
21#include <stdlib.h>
22
23
24
25#ifndef SH_TRUE
26#ifndef __cplusplus
27#define SH_TRUE 1
28#else
29#define SH_TRUE true
30#endif//__cplusplus
31#endif//SH_TRUE
32
33#ifndef SH_FALSE
34#ifndef __cplusplus
35#define SH_FALSE 0
36#else
37#define SH_FALSE false
38#endif//__cplusplus
39#endif//SH_FALSE
40
41
42
43#ifndef VK_MAKE_API_VERSION
44#define VK_MAKE_API_VERSION(variant, major, minor, patch)\
45 ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
46#endif//VK_MAKE_API_VERSION
47
48
49
50/**
51 * @brief Error-checking macro for Vulkan conditions.
52 *
53 * This macro checks a given condition. If the condition evaluates to true, it prints an error message
54 * and executes a failure expression (like returning from a function or exiting).
55 *
56 * @param condition The condition to check (non-zero for an error).
57 * @param error_msg A message to be printed if the condition is true.
58 * @param failure_expression The expression to execute when the condition is true (e.g., return or exit).
59 *
60 * @note This macro does not return any value but executes the failure_expression if the condition is met.
61 */
62#define shVkError(condition, error_msg, failure_expression)\
63 if ((int)(condition)) {\
64 printf("shvulkan error: %s\n", (const char*)(error_msg));\
65 failure_expression;\
66 }
67
68/**
69 * @brief Error-checking macro for Vulkan VkResult.
70 *
71 * This macro checks the result of a Vulkan API call. If the result is not VK_SUCCESS,
72 * it prints an error message along with the translated Vulkan error code and executes
73 * a failure expression (like returning from a function or exiting).
74 *
75 * @param result The VkResult from a Vulkan function (VK_SUCCESS or an error code).
76 * @param error_msg A message to be printed if the result is not VK_SUCCESS.
77 * @param failure_expression The expression to execute when the result is an error (e.g., return or exit).
78 *
79 * @note This macro calls `shTranslateVkResult()` to convert the VkResult enum into a string representation.
80 */
81#define shVkResultError(result, error_msg, failure_expression)\
82 if ((VkResult)(result) != VK_SUCCESS) {\
83 printf("shvulkan error: %s, %s\n", error_msg, shTranslateVkResult((VkResult)(result)));\
84 failure_expression;\
85 }
86
87/**
88 * @brief Translates a VkResult enum into a literal string.
89 *
90 * This function converts a Vulkan `VkResult` code into a literal string that describes
91 * the result, which is helpful for error messages and debugging.
92 *
93 * @param vk_result The Vulkan result code (VkResult).
94 *
95 * @return A string representing the Vulkan result literal.
96 *
97 * @note This function is often used in error reporting to provide more descriptive
98 * information about Vulkan errors, such as converting `VK_ERROR_OUT_OF_HOST_MEMORY`
99 * to its string form.
100 */
101extern const char* shTranslateVkResult(
102 VkResult vk_result
103);
104
105
106#define SH_MAX_STACK_VALIDATION_LAYER_COUNT 32
107
108#define SH_MAX_STACK_QUEUE_FAMILY_COUNT 32
109#define SH_MAX_STACK_PHYSICAL_DEVICE_COUNT 8
110#define SH_MAX_STACK_QUEUE_COUNT 64
111#define SH_MAX_STACK_DEVICE_SURFACE_FORMAT_COUNT 256
112#define SH_MAX_STACK_SURFACE_PRESENT_MODE_COUNT 16
113
114
115
116/**
117 * @brief Searches for a specific Vulkan validation layer.
118 *
119 * This function searches through the available Vulkan validation layers
120 * to find a match with the provided validation layer name.
121 *
122 * @param validation_layer_name The name of the validation layer to find.
123 *
124 * @return 1 if the validation layer is found, 0 otherwise.
125 *
126 * @note This function is typically used to check if a specific validation layer
127 * (e.g., "VK_LAYER_KHRONOS_validation") is available for use.
128 */
130 const char* validation_layer_name
131);
132
133/**
134 * @brief Creates a Vulkan instance.
135 *
136 * This function initializes a Vulkan instance with the specified application name, engine name,
137 * validation layers, and extensions.
138 *
139 * @param application_name The name of the application.
140 * @param engine_name The name of the engine.
141 * @param enable_validation_layers Flag to enable (1) or disable (0) validation layers.
142 * @param extension_count Number of Vulkan extensions to enable.
143 * @param pp_extension_names Valid array of extension names to enable, if required.
144 * @param api_version The Vulkan API version to use.
145 * @param p_instance Valid destination pointer to the newly created VkInstance.
146 *
147 * @return 1 if the instance is created successfully, 0 otherwise.
148 */
149extern uint8_t shCreateInstance(
150 const char* application_name,
151 const char* engine_name,
152 const uint8_t enable_validation_layers,
153 const uint32_t extension_count,
154 const char** pp_extension_names,
155 uint32_t api_version,
156 VkInstance* p_instance
157);
158
159/**
160 * @brief Retrieves the queue family indices for a physical device.
161 *
162 * This function retrieves and categorizes the queue families available for a specified physical device
163 * and surface, such as graphics, compute, transfer, and presentation (surface support).
164 *
165 * @param physical_device The current physical device to query for queue families.
166 * @param surface The Vulkan surface (for surface support queries).
167 * @param p_queue_family_count Valid destination pointer to the total number of queue families available.
168 * @param p_graphics_queue_family_count Valid destination pointer to Number of graphics-capable queue families.
169 * @param p_surface_queue_family_count Valid destination pointer to Number of surface-capable queue families.
170 * @param p_compute_queue_family_count Valid destination pointer to Number of compute-capable queue families.
171 * @param p_transfer_queue_family_count Valid destination pointer to Number of transfer-capable queue families.
172 * @param p_graphics_queue_family_indices Valid destination pointer to the indices of the graphics-capable queue families.
173 * @param p_surface_queue_family_indices Valid destination pointer to the indices of the surface-capable queue families.
174 * @param p_compute_queue_family_indices Valid destination pointer to the indices of the compute-capable queue families.
175 * @param p_transfer_queue_family_indices Valid destination pointer to the indices of the transfer-capable queue families.
176 * @param p_queue_families_properties Valid destination pointer to a `VkQueueFamilyProperties` structure.
177 *
178 * @return 1 if successful, 0 otherwise.
179 */
181 VkPhysicalDevice physical_device,
182 VkSurfaceKHR surface,
183 uint32_t* p_queue_family_count,
184 uint32_t* p_graphics_queue_family_count,
185 uint32_t* p_surface_queue_family_count,
186 uint32_t* p_compute_queue_family_count,
187 uint32_t* p_transfer_queue_family_count,
188 uint32_t* p_graphics_queue_family_indices,
189 uint32_t* p_surface_queue_family_indices,
190 uint32_t* p_compute_queue_family_indices,
191 uint32_t* p_transfer_queue_family_indices,
192 VkQueueFamilyProperties* p_queue_families_properties
193);
194
195/**
196 * @brief Checks if a queue family supports presenting to a surface.
197 *
198 * This function checks whether a queue family of a physical device supports presentation to a surface.
199 *
200 * @param physical_device Valid physical device to query.
201 * @param queue_family_index Index of the queue family to check.
202 * @param surface Valid surface to check for support.
203 * @param p_support Valid destination pointer to Flag indicating support (1 if supported, 0 otherwise).
204 *
205 * @return 1 if successful, 0 otherwise.
206 */
208 VkPhysicalDevice physical_device,
209 uint32_t queue_family_index,
210 VkSurfaceKHR surface,
211 uint8_t* p_support
212);
213
214/**
215 * @brief Selects a physical device that meets specified requirements.
216 *
217 * This function selects a Vulkan physical device based on specified requirements such as queue support,
218 * surface capabilities, and required device features. Then it retrieves vital information about the GPU.
219 *
220 * @param instance Valid Vulkan instance.
221 * @param surface Valid surface if presentation support is required, otherwise it can be set as `VK_NULL_HANDLE`.
222 * @param requirements Queue family requirements (VkQueueFlags).
223 * @param p_physical_device Valid destination pointer to the selected Vulkan physical device.
224 * @param p_physical_device_properties Valid destination pointer to the properties of the selected physical device.
225 * @param p_physical_device_features Valid destination pointer to the features of the selected physical device.
226 * @param p_physical_device_memory_properties Valid destination pointer to the memory properties of the selected physical device.
227 *
228 * @return 1 if a suitable device is found, 0 otherwise.
229 */
231 VkInstance instance,
232 VkSurfaceKHR surface,
233 VkQueueFlags requirements,
234 VkPhysicalDevice* p_physical_device,
235 VkPhysicalDeviceProperties* p_physical_device_properties,
236 VkPhysicalDeviceFeatures* p_physical_device_features,
237 VkPhysicalDeviceMemoryProperties* p_physical_device_memory_properties
238);
239
240/**
241 * @brief Queries if a queue family supports presenting to a surface.
242 *
243 * This function queries whether a specific queue family of a physical device supports presenting
244 * to a Vulkan surface.
245 *
246 * @param physical_device Valid physical device.
247 * @param queue_family_index Index of the queue family to check.
248 * @param surface Valid surface to check for support.
249 * @param p_supported Valid destination pointer to Flag indicating support (1 if supported, 0 otherwise).
250 *
251 * @return 1 if successful, 0 otherwise.
252 */
254 VkPhysicalDevice physical_device,
255 uint32_t queue_family_index,
256 VkSurfaceKHR surface,
257 uint8_t* p_supported
258);
259
260/**
261 * @brief Retrieves the surface capabilities of a physical device.
262 *
263 * This function queries the surface capabilities (such as min/max image count and extent) for a
264 * physical device and surface combination.
265 *
266 * @param physical_device Valid physical device.
267 * @param surface Valid Vulkan surface to query capabilities for.
268 * @param p_surface_capabilities Valid destination pointer to a structure where the surface capabilities will be stored.
269 * @param clamp_current_extent_width_value Fixed current extent width value when vkGetPhysicalDeviceSurfaceCapabilitiesKHR writes UINT32_MAX (this might happen when using Wayland)
270 * @param clamp_current_extent_height_value Fixed current extent height value when vkGetPhysicalDeviceSurfaceCapabilitiesKHR writes UINT32_MAX (this might happen when using Wayland)
271 *
272 * @return 1 if successful, 0 otherwise.
273 */
275 VkPhysicalDevice physical_device,
276 VkSurfaceKHR surface,
277 VkSurfaceCapabilitiesKHR* p_surface_capabilities,
278 uint32_t clamp_current_extent_width_value,
279 uint32_t clamp_current_extent_height_value
280);
281
282/**
283 * @brief Queries information for device queue creation.
284 *
285 * This function sets up the necessary information for creating device queues, including the
286 * queue family index, queue count, priorities, and queue protection settings.
287 *
288 * @param queue_family_index Index of the queue family.
289 * @param queue_count Number of queues to create in the specified family.
290 * @param p_queue_priorities Valid pointer to an array of queue priorities.
291 * @param protected Flag indicating whether the queue should be protected (1 for protected, 0 for unprotected).
292 * @param p_device_queue_info Valid destination pointer to a VkDeviceQueueCreateInfo structure where the queue info will be stored.
293 *
294 * @return 1 if successful, 0 otherwise.
295 */
297 uint32_t queue_family_index,
298 uint32_t queue_count,
299 float* p_queue_priorities,
300 uint8_t protected,
301 VkDeviceQueueCreateInfo* p_device_queue_info
302);
303
304/**
305 * @brief Sets up a Vulkan logical device.
306 *
307 * This function creates a Vulkan logical device with specified extensions, queue creation info, and
308 * other configurations.
309 *
310 * @param physical_device Valid Vulkan physical device.
311 * @param p_device Valid destination pointer to the newly created VkDevice.
312 * @param extension_count Number of Vulkan extensions to enable.
313 * @param pp_extension_names Valid pointer to extension names to enable.
314 * @param device_queue_count Number of device queues to create.
315 * @param p_device_queue_infos Valid pointer to an array of VkDeviceQueueCreateInfo structures.
316 *
317 * @return 1 if the logical device is created successfully, 0 otherwise.
318 */
319extern uint8_t shSetLogicalDevice(
320 VkPhysicalDevice physical_device,
321 VkDevice* p_device,
322 uint32_t extension_count,
323 char** pp_extension_names,
324 uint32_t device_queue_count,
325 VkDeviceQueueCreateInfo* p_device_queue_infos
326);
327
328/**
329 * @brief Retrieves the Vulkan queues from a device.
330 *
331 * This function retrieves the Vulkan queues from a logical device based on specified queue family indices.
332 *
333 * @param device Valid Vulkan device.
334 * @param queue_count Number of queues to retrieve.
335 * @param p_queue_family_indices Valid pointer to an array of queue family indices.
336 * @param p_queues Valid destination pointer to an array of VkQueue handles.
337 *
338 * @return 1 if successful, 0 otherwise.
339 */
340extern uint8_t shGetDeviceQueues(
341 VkDevice device,
342 uint32_t queue_count,
343 uint32_t* p_queue_family_indices,
344 VkQueue* p_queues
345);
346
347//TODO
349 VkPhysicalDevice physical_device,
350 VkFormat format,
351 uint8_t* p_color_attachment_supported
352);
353
354#define SH_MAX_STACK_DEVICE_COLOR_FORMATS_QUERIES 44
355#define SH_FORMAT_UINT 0
356#define SH_FORMAT_SINT 1
357#define SH_FORMAT_SFLOAT 2
358#define SH_FORMAT_UNDEFINED 3
359
368
370 VkPhysicalDevice physical_device,
371 uint32_t min_channel_count,
372 uint32_t max_channel_count,
373 uint32_t min_channel_size,
374 uint32_t max_channel_size,
375 ShImageChannelTypeFlags channel_types,
376 uint32_t* p_supported_format_count,
377 VkFormat* p_supported_formats,
378 uint32_t* p_channels_count,
379 uint32_t* p_single_channels_sizes,
380 uint32_t* p_channels_types
381);
382
383/**
384 * @brief Creates a Vulkan swapchain.
385 *
386 * This function sets up a Vulkan swapchain with the specified surface, image format, and other parameters.
387 *
388 * @param device Valid Vulkan device.
389 * @param physical_device Valid Vulkan physical device.
390 * @param surface_capabilities Surface capabilities struct.
391 * @param surface Valid Vulkan surface.
392 * @param image_format Format of the images in the swapchain.
393 * @param p_image_format Valid destination pointer to the format of the swapchain images.
394 * @param swapchain_image_count Number of images in the swapchain.
395 * @param image_sharing_mode Sharing mode for the swapchain images.
396 * @param vsync Flag to enable (1) or disable (0) V-Sync.
397 * @param p_swapchain_image_count Valid destination pointer to the number of swapchain images.
398 * @param p_swapchain Valid destination pointer to the newly created VkSwapchainKHR.
399 *
400 * @note @ref p_swapchain_image_count might be different from @ref swapchain_image_count when @ref swapchain_image_count is not supported! Please take this in consideration for your API implementations.
401 *
402 * @return 1 if the swapchain is created successfully, 0 otherwise.
403 */
404extern uint8_t shCreateSwapchain(
405 VkDevice device,
406 VkPhysicalDevice physical_device,
407 VkSurfaceCapabilitiesKHR surface_capabilities,
408 VkSurfaceKHR surface,
409 VkFormat image_format,
410 VkFormat* p_image_format,
411 uint32_t swapchain_image_count,
412 VkSharingMode image_sharing_mode,
413 uint8_t vsync,
414 uint32_t* p_swapchain_image_count,
415 VkSwapchainKHR* p_swapchain
416);
417
418/**
419 * @brief Combines sample counts based on physical device properties.
420 *
421 * This function determines the maximum number of samples that can be used for color and depth
422 * attachments, considering the physical device properties.
423 *
424 * @param physical_device_properties Properties of the physical device.
425 * @param sample_count Sample count to combine.
426 * @param combine_color_sample Flag indicating whether to combine color samples.
427 * @param combine_depth_sample Flag indicating whether to combine depth samples.
428 * @param p_sample_count Destination pointer to the resulting maximum supported sample count for the current hardware.
429 *
430 * @return 1 if successful, 0 otherwise.
431 */
432extern uint8_t shCombineMaxSamples(
433 VkPhysicalDeviceProperties physical_device_properties,
434 uint32_t sample_count,
435 uint8_t combine_color_sample,
436 uint8_t combine_depth_sample,
437 uint32_t* p_sample_count
438);
439
440/**
441 * @brief Retrieves the images in a swapchain.
442 *
443 * This function retrieves the Vulkan images present in a swapchain.
444 *
445 * @param device Valid Vulkan device.
446 * @param swapchain Valid Vulkan swapchain.
447 * @param p_swapchain_image_count Valid destination pointer to the number of swapchain images.
448 * @param p_swapchain_images Valid destination pointer to an array of VkImage handles.
449 *
450 * @return 1 if successful, 0 otherwise.
451 */
452extern uint8_t shGetSwapchainImages(
453 VkDevice device,
454 VkSwapchainKHR swapchain,
455 uint32_t* p_swapchain_image_count,
456 VkImage* p_swapchain_images
457);
458
459/**
460 * @brief Creates a Vulkan image view.
461 *
462 * This function creates a Vulkan image view for a specified image, view type, format, and aspect.
463 *
464 * @param device Valid Vulkan device.
465 * @param image Valid Vulkan image.
466 * @param view_type Type of the image view.
467 * @param image_aspect Aspect flags of the image (e.g., color, depth).
468 * @param mip_levels Number of mipmap levels.
469 * @param format Format of the image.
470 * @param p_image_view Valid destination pointer to the newly created VkImageView.
471 *
472 * @return 1 if successful, 0 otherwise.
473 */
474extern uint8_t shCreateImageView(
475 VkDevice device,
476 VkImage image,
477 VkImageViewType view_type,
478 VkImageAspectFlagBits image_aspect,
479 uint32_t mip_levels,
480 VkFormat format,
481 VkImageView* p_image_view
482);
483
484/**
485 * @brief Creates image views for swapchain images.
486 *
487 * This function creates Vulkan image views for all images in a swapchain.
488 *
489 * @param device Valid Vulkan device.
490 * @param format Format of the image views.
491 * @param swapchain_image_count Number of swapchain images.
492 * @param p_swapchain_images Pointer to an array of VkImage handles.
493 * @param p_swapchain_image_views Valid destination pointer to an array of VkImageView handles.
494 *
495 * @return 1 if successful, 0 otherwise.
496 */
498 VkDevice device,
499 VkFormat format,
500 uint32_t swapchain_image_count,
501 VkImage* p_swapchain_images,
502 VkImageView* p_swapchain_image_views
503);
504
505/**
506 * @brief Creates a Vulkan command pool.
507 *
508 * This function creates a command pool for a specified queue family.
509 *
510 * @param device Valid Vulkan device.
511 * @param queue_family_index Queue family index for the command pool.
512 * @param p_cmd_pool Valid destination pointer to the newly created VkCommandPool.
513 *
514 * @return 1 if successful, 0 otherwise.
515 */
516extern uint8_t shCreateCommandPool(
517 VkDevice device,
518 uint32_t queue_family_index,
519 VkCommandPool* p_cmd_pool
520);
521
522/**
523 * @brief Allocates command buffers from a command pool.
524 *
525 * This function allocates a specified number of command buffers from a command pool.
526 *
527 * @param device Valid Vulkan device.
528 * @param cmd_pool Valid pointer to the command pool from which to allocate.
529 * @param cmd_buffer_count Number of command buffers to allocate.
530 * @param p_cmd_buffer Valid destination pointer to an array of newly created VkCommandBuffer handles.
531 *
532 * @return 1 if successful, 0 otherwise.
533 */
535 VkDevice device,
536 VkCommandPool cmd_pool,
537 uint32_t cmd_buffer_count,
538 VkCommandBuffer* p_cmd_buffer
539);
540
541/**
542 * @brief Creates a Vulkan render pass attachment description.
543 *
544 * This function creates an attachment description to use in a render pass.
545 *
546 * @param format Format of the attachment.
547 * @param sample_count Sample count for the attachment.
548 * @param load_treatment Load operation for the attachment.
549 * @param store_treatment Store operation for the attachment.
550 * @param stencil_load_treatment Load operation for stencil attachment.
551 * @param stencil_store_treatment Store operation for stencil attachment.
552 * @param initial_layout Initial layout of the attachment.
553 * @param final_layout Final layout of the attachment.
554 * @param p_attachment_description Valid destination pointer to the newly created VkAttachmentDescription.
555 *
556 * @return 1 if successful, 0 otherwise.
557 */
559 VkFormat format,
560 uint32_t sample_count,
561 VkAttachmentLoadOp load_treatment,
562 VkAttachmentStoreOp store_treatment,
563 VkAttachmentLoadOp stencil_load_treatment,
564 VkAttachmentStoreOp stencil_store_treatment,
565 VkImageLayout initial_layout,
566 VkImageLayout final_layout,
567 VkAttachmentDescription* p_attachment_description
568);
569
570/**
571 * @brief Creates a Vulkan render pass attachment reference.
572 *
573 * This function creates an attachment reference for use in a subpass of a render pass.
574 *
575 * @param attachment_idx Index of the attachment in the render pass.
576 * @param layout Layout of the attachment within the subpass.
577 * @param p_attachment_reference Valid destination pointer to the newly created VkAttachmentReference.
578 *
579 * @return 1 if successful, 0 otherwise.
580 */
582 uint32_t attachment_idx,
583 VkImageLayout layout,
584 VkAttachmentReference* p_attachment_reference
585);
586
587/**
588 * @brief Creates a Vulkan subpass description.
589 *
590 * This function creates a subpass description including input, color, depth/stencil, and resolve attachments.
591 *
592 * @param bind_point Pipeline bind point for the subpass.
593 * @param input_attachment_count Number of input attachments.
594 * @param p_input_attachments_reference Valid pointer to an array of input attachment references.
595 * @param color_attachment_count Number of color attachments.
596 * @param p_color_attachments_reference Valid pointer to an array of color attachment references.
597 * @param p_depth_stencil_attachment_reference Valid pointer to the depth/stencil attachment reference.
598 * @param p_resolve_attachment_reference Valid pointer to the resolve attachment reference.
599 * @param preserve_attachment_count Number of attachments to preserve.
600 * @param p_preserve_attachments Valid pointer to an array of indices of attachments to preserve.
601 * @param p_subpass Valid destination pointer to the newly created VkSubpassDescription.
602 *
603 * @return 1 if successful, 0 otherwise.
604 */
605extern uint8_t shCreateSubpass(
606 VkPipelineBindPoint bind_point,
607 uint32_t input_attachment_count,
608 VkAttachmentReference* p_input_attachments_reference,
609 uint32_t color_attachment_count,
610 VkAttachmentReference* p_color_attachments_reference,
611 VkAttachmentReference* p_depth_stencil_attachment_reference,
612 VkAttachmentReference* p_resolve_attachment_reference,
613 uint32_t preserve_attachment_count,
614 uint32_t* p_preserve_attachments,
615 VkSubpassDescription* p_subpass
616);
617
618/**
619 * @brief Creates a Vulkan render pass.
620 *
621 * This function creates a render pass with specified attachments and subpasses.
622 *
623 * @param device Valid pointer to Vulkan device.
624 * @param attachment_count Number of attachments in the render pass.
625 * @param p_attachments_descriptions Valid pointer to an array of VkAttachmentDescription structures.
626 * @param subpass_count Number of subpasses in the render pass.
627 * @param p_subpasses Valid pointer to an array of VkSubpassDescription structures.
628 * @param p_renderpass Valid destination pointer to the newly created VkRenderPass.
629 *
630 * @return 1 if successful, 0 otherwise.
631 */
632extern uint8_t shCreateRenderpass(
633 VkDevice device,
634 uint32_t attachment_count,
635 VkAttachmentDescription* p_attachments_descriptions,
636 uint32_t subpass_count,
637 VkSubpassDescription* p_subpasses,
638 VkRenderPass* p_renderpass
639);
640
641/**
642 * @brief Creates a Vulkan framebuffer.
643 *
644 * This function creates a framebuffer with specified image views and dimensions for use with a render pass.
645 *
646 * @param device Valid Vulkan device.
647 * @param renderpass Valid Vulkan render pass.
648 * @param image_view_count Number of image views in the framebuffer.
649 * @param p_image_views Valid pointer to an array of VkImageView handles.
650 * @param x Width of the framebuffer.
651 * @param y Height of the framebuffer.
652 * @param z Depth of the framebuffer.
653 * @param p_framebuffer Valid destination pointer to the newly created VkFramebuffer.
654 *
655 * @return 1 if successful, 0 otherwise.
656 */
657extern uint8_t shCreateFramebuffer(
658 VkDevice device,
659 VkRenderPass renderpass,
660 uint32_t image_view_count,
661 VkImageView* p_image_views,
662 uint32_t x,
663 uint32_t y,
664 uint32_t z,
665 VkFramebuffer* p_framebuffer
666);
667
668/**
669 * @brief Waits for a Vulkan device to become idle.
670 *
671 * This function waits until the Vulkan device has finished all its operations.
672 *
673 * @param device Valid Vulkan device.
674 *
675 * @return 1 if successful, 0 otherwise.
676 */
677extern uint8_t shWaitDeviceIdle(
678 VkDevice device
679);
680
681/**
682 * @brief Destroys a Vulkan swapchain.
683 *
684 * This function destroys the specified Vulkan swapchain.
685 *
686 * @param device Valid Vulkan device.
687 * @param swapchain Valid VkSwapchainKHR to destroy.
688 *
689 * @return 1 if successful, 0 otherwise.
690 */
691extern uint8_t shDestroySwapchain(
692 VkDevice device,
693 VkSwapchainKHR swapchain
694);
695
696/**
697 * @brief Destroys Vulkan framebuffers.
698 *
699 * This function destroys an array of Vulkan framebuffers.
700 *
701 * @param device Valid Vulkan device.
702 * @param framebuffer_count Number of framebuffers to destroy.
703 * @param p_framebuffers Valid pointer to an array of VkFramebuffer handles.
704 *
705 * @return 1 if successful, 0 otherwise.
706 */
708 VkDevice device,
709 uint32_t framebuffer_count,
710 VkFramebuffer* p_framebuffers
711);
712
713/**
714 * @brief Destroys Vulkan image views.
715 *
716 * This function destroys an array of Vulkan image views.
717 *
718 * @param device Valid Vulkan device.
719 * @param image_view_count Number of image views to destroy.
720 * @param p_image_views Valid pointer to an array of VkImageView handles.
721 *
722 * @return 1 if successful, 0 otherwise.
723 */
724extern uint8_t shDestroyImageViews(
725 VkDevice device,
726 uint32_t image_view_count,
727 VkImageView* p_image_views
728);
729
730/**
731 * @brief Destroys a Vulkan surface.
732 *
733 * This function destroys a Vulkan surface associated with an instance.
734 *
735 * @param instance Valid Vulkan instance.
736 * @param surface Valid VkSurfaceKHR to destroy.
737 *
738 * @return 1 if successful, 0 otherwise.
739 */
740extern uint8_t shDestroySurface(
741 VkInstance instance,
742 VkSurfaceKHR surface
743);
744
745/**
746 * @brief Destroys Vulkan command buffers.
747 *
748 * This function destroys an array of Vulkan command buffers from a command pool.
749 *
750 * @param device Valid Vulkan device.
751 * @param cmd_pool Valid Vulkan command pool.
752 * @param cmd_buffer_count Number of command buffers to destroy.
753 * @param p_cmd_buffers Valid pointer to an array of VkCommandBuffer handles.
754 *
755 * @return 1 if successful, 0 otherwise.
756 */
758 VkDevice device,
759 VkCommandPool cmd_pool,
760 uint32_t cmd_buffer_count,
761 VkCommandBuffer* p_cmd_buffers
762);
763
764/**
765 * @brief Destroys a Vulkan command pool.
766 *
767 * This function destroys a Vulkan command pool.
768 *
769 * @param device Valid Vulkan device.
770 * @param cmd_pool Valid Vulkan command pool to destroy.
771 *
772 * @return 1 if successful, 0 otherwise.
773 */
774extern uint8_t shDestroyCommandPool(
775 VkDevice device,
776 VkCommandPool cmd_pool
777);
778
779/**
780 * @brief Destroys a Vulkan render pass.
781 *
782 * This function destroys a Vulkan render pass.
783 *
784 * @param device Valid Vulkan device.
785 * @param render_pass Valid Vulkan render pass to destroy.
786 *
787 * @return 1 if successful, 0 otherwise.
788 */
789extern uint8_t shDestroyRenderpass(
790 VkDevice device,
791 VkRenderPass render_pass
792);
793
794/**
795 * @brief Destroys a Vulkan device.
796 *
797 * This function destroys a Vulkan device.
798 *
799 * @param device Valid Vulkan device to destroy.
800 *
801 * @return 1 if successful, 0 otherwise.
802 */
803extern uint8_t shDestroyDevice(
804 VkDevice device
805);
806
807/**
808 * @brief Destroys a Vulkan instance.
809 *
810 * This function destroys a Vulkan instance.
811 *
812 * @param instance Valid Vulkan instance to destroy.
813 *
814 * @return 1 if successful, 0 otherwise.
815 */
816extern uint8_t shDestroyInstance(
817 VkInstance instance
818);
819
820/**
821 * @brief Resets a Vulkan command buffer.
822 *
823 * This function resets a command buffer to the initial state.
824 *
825 * @param cmd_buffer Valid Vulkan command buffer to reset.
826 *
827 * @return 1 if successful, 0 otherwise.
828 */
829extern uint8_t shResetCommandBuffer(
830 VkCommandBuffer cmd_buffer
831);
832
833/**
834 * @brief Begins recording commands into a Vulkan command buffer.
835 *
836 * This function begins recording commands into the specified command buffer.
837 *
838 * @param cmd_buffer Valid Vulkan command buffer to begin recording.
839 *
840 * @return 1 if successful, 0 otherwise.
841 */
842extern uint8_t shBeginCommandBuffer(
843 VkCommandBuffer cmd_buffer
844);
845
846/**
847 * @brief Ends recording commands into a Vulkan command buffer.
848 *
849 * This function ends the recording of commands into the specified command buffer.
850 *
851 * @param cmd_buffer Valid Vulkan command buffer to end recording.
852 *
853 * @return 1 if successful, 0 otherwise.
854 */
855extern uint8_t shEndCommandBuffer(
856 VkCommandBuffer cmd_buffer
857);
858
859/**
860 * @brief Dispatches compute work from a Vulkan command buffer.
861 *
862 * This function dispatches a compute workload with specified group counts.
863 *
864 * @param cmd_buffer Valid Vulkan command buffer from which to dispatch.
865 * @param group_count_x Number of groups in the x dimension.
866 * @param group_count_y Number of groups in the y dimension.
867 * @param group_count_z Number of groups in the z dimension.
868 *
869 * @return 1 if successful, 0 otherwise.
870 */
871extern uint8_t shCmdDispatch(
872 VkCommandBuffer cmd_buffer,
873 uint32_t group_count_x,
874 uint32_t group_count_y,
875 uint32_t group_count_z
876);
877
878/**
879 * @brief Submits command buffers to a Vulkan queue.
880 *
881 * This function submits command buffers to a Vulkan queue and optionally waits for a fence and signals semaphores.
882 *
883 * @param cmd_buffer_count Number of command buffers to submit.
884 * @param p_cmd_buffers Valid pointer to an array of Vulkan command buffers.
885 * @param queue Valid Vulkan queue to which to submit.
886 * @param fence Valid Vulkan fence to signal upon completion.
887 * @param semaphores_to_wait_for_count Number of semaphores to wait for.
888 * @param p_semaphores_to_wait_for Valid pointer to an array of Vulkan semaphores to wait for.
889 * @param wait_stage Pipeline stage flags to wait for.
890 * @param signal_semaphore_count Number of semaphores to signal.
891 * @param p_signal_semaphores Valid pointer to an array of Vulkan semaphores to signal.
892 *
893 * @return 1 if successful, 0 otherwise.
894 */
895extern uint8_t shQueueSubmit(
896 uint32_t cmd_buffer_count,
897 VkCommandBuffer* p_cmd_buffers,
898 VkQueue queue,
899 VkFence fence,
900 uint32_t semaphores_to_wait_for_count,
901 VkSemaphore* p_semaphores_to_wait_for,
902 VkPipelineStageFlags wait_stage,
903 uint32_t signal_semaphore_count,
904 VkSemaphore* p_signal_semaphores
905);
906
907/**
908 * @brief Waits for a Vulkan queue to become idle.
909 *
910 * This function waits until the Vulkan queue has finished all its operations.
911 *
912 * @param queue Valid Vulkan queue to wait for.
913 *
914 * @return 1 if successful, 0 otherwise.
915 */
916extern uint8_t shWaitForQueue(
917 VkQueue queue
918);
919
920/**
921 * @brief Creates Vulkan fences.
922 *
923 * This function creates a specified number of Vulkan fences.
924 *
925 * @param device Valid Vulkan device.
926 * @param fence_count Number of fences to create.
927 * @param signaled Whether to initialize fences as signaled.
928 * @param p_fences Valid destination pointer to an array of newly created Vulkan fences.
929 *
930 * @return 1 if successful, 0 otherwise.
931 */
932extern uint8_t shCreateFences(
933 VkDevice device,
934 uint32_t fence_count,
935 uint8_t signaled,
936 VkFence* p_fences
937);
938
939/**
940 * @brief Creates Vulkan semaphores.
941 *
942 * This function creates a specified number of Vulkan semaphores.
943 *
944 * @param device Valid Vulkan device.
945 * @param semaphore_count Number of semaphores to create.
946 * @param p_semaphores Valid destination pointer to an array of newly created Vulkan semaphores.
947 *
948 * @return 1 if successful, 0 otherwise.
949 */
950extern uint8_t shCreateSemaphores(
951 VkDevice device,
952 uint32_t semaphore_count,
953 VkSemaphore* p_semaphores
954);
955
956/**
957 * @brief Destroys Vulkan fences.
958 *
959 * This function destroys a specified number of Vulkan fences.
960 *
961 * @param device Valid Vulkan device.
962 * @param fence_count Number of fences to destroy.
963 * @param p_fences Valid pointer to an array of Vulkan fences to destroy.
964 *
965 * @return 1 if successful, 0 otherwise.
966 */
967extern uint8_t shDestroyFences(
968 VkDevice device,
969 uint32_t fence_count,
970 VkFence* p_fences
971);
972
973/**
974 * @brief Destroys Vulkan semaphores.
975 *
976 * This function destroys a specified number of Vulkan semaphores.
977 *
978 * @param device Valid Vulkan device.
979 * @param semaphore_count Number of semaphores to destroy.
980 * @param p_semaphores Valid pointer to an array of Vulkan semaphores to destroy.
981 *
982 * @return 1 if successful, 0 otherwise.
983 */
984extern uint8_t shDestroySemaphores(
985 VkDevice device,
986 uint32_t semaphore_count,
987 VkSemaphore* p_semaphores
988);
989
990/**
991 * @brief Resets Vulkan fences.
992 *
993 * This function resets a specified number of Vulkan fences to their initial state.
994 *
995 * @param device Valid Vulkan device.
996 * @param fence_count Number of fences to reset.
997 * @param p_fences Valid pointer to an array of Vulkan fences to reset.
998 *
999 * @return 1 if successful, 0 otherwise.
1000 */
1001extern uint8_t shResetFences(
1002 VkDevice device,
1003 uint32_t fence_count,
1004 VkFence* p_fences
1005);
1006
1007/**
1008 * @brief Resets Vulkan semaphores.
1009 *
1010 * This function resets a specified number of Vulkan semaphores to their initial state.
1011 *
1012 * @param device Valid Vulkan device.
1013 * @param semaphore_count Number of semaphores to reset.
1014 * @param p_semaphores Valid pointer to an array of Vulkan semaphores to reset.
1015 *
1016 * @return 1 if successful, 0 otherwise.
1017 */
1018extern uint8_t shResetSemaphores(
1019 VkDevice device,
1020 uint32_t semaphore_count,
1021 VkSemaphore* p_semaphores
1022);
1023
1024/**
1025 * @brief Waits for Vulkan fences to become signaled.
1026 *
1027 * This function waits for a specified number of Vulkan fences to become signaled.
1028 *
1029 * @param device Valid Vulkan device.
1030 * @param fence_count Number of fences to wait for.
1031 * @param p_fences Valid pointer to an array of Vulkan fences to wait for.
1032 * @param wait_for_all Whether to wait for all fences to be signaled.
1033 * @param timeout_ns Timeout in nanoseconds to wait for the fences.
1034 *
1035 * @return 1 if successful, 0 otherwise.
1036 */
1037extern uint8_t shWaitForFences(
1038 VkDevice device,
1039 uint32_t fence_count,
1040 VkFence* p_fences,
1041 uint8_t wait_for_all,
1042 uint64_t timeout_ns
1043);
1044
1045/**
1046 * @brief Waits for Vulkan semaphores to become signaled.
1047 *
1048 * This function waits for a specified number of Vulkan semaphores to become signaled.
1049 *
1050 * @param device Valid Vulkan device.
1051 * @param semaphore_count Number of semaphores to wait for.
1052 * @param p_semaphores Valid pointer to an array of Vulkan semaphores to wait for.
1053 * @param wait_for_all Whether to wait for all semaphores to be signaled.
1054 * @param timeout_ns Timeout in nanoseconds to wait for the semaphores.
1055 * @param p_semaphores_values Valid destination pointer to an array of values for each semaphore.
1056 *
1057 * @return 1 if successful, 0 otherwise.
1058 */
1059extern uint8_t shWaitForSemaphores(
1060 VkDevice device,
1061 uint32_t semaphore_count,
1062 VkSemaphore* p_semaphores,
1063 uint8_t wait_for_all,
1064 uint64_t timeout_ns,
1065 uint64_t* p_semaphores_values
1066);
1067
1068/**
1069 * @brief Acquires an image from the Vulkan swapchain.
1070 *
1071 * This function acquires an image from the specified swapchain and optionally signals a semaphore or fence.
1072 *
1073 * @param device Valid Vulkan device.
1074 * @param swapchain Valid Vulkan swapchain from which to acquire an image.
1075 * @param timeout_ns Timeout in nanoseconds to wait for the image.
1076 * @param acquired_signal_semaphore Valid Vulkan semaphore to signal upon acquisition.
1077 * @param acquired_signal_fence Valid Vulkan fence to signal upon acquisition.
1078 * @param p_swapchain_image_index Valid destination pointer to the index of the acquired swapchain image.
1079 * @param p_swapchain_suboptimal Valid destination pointer to a flag indicating if the swapchain is suboptimal.
1080 *
1081 * @return 1 if successful, 0 otherwise.
1082 */
1084 VkDevice device,
1085 VkSwapchainKHR swapchain,
1086 uint64_t timeout_ns,
1087 VkSemaphore acquired_signal_semaphore,
1088 VkFence acquired_signal_fence,
1089 uint32_t* p_swapchain_image_index,
1090 uint8_t* p_swapchain_suboptimal
1091);
1092
1093/**
1094 * @brief Begins a Vulkan render pass.
1095 *
1096 * This function begins recording commands for a render pass in the specified command buffer.
1097 *
1098 * @param graphics_cmd_buffer Valid Vulkan command buffer to begin the render pass.
1099 * @param renderpass Valid Vulkan render pass to begin.
1100 * @param render_offset_x X offset for the render area.
1101 * @param render_offset_y Y offset for the render area.
1102 * @param render_size_x Width of the render area.
1103 * @param render_size_y Height of the render area.
1104 * @param clear_value_count Number of clear values.
1105 * @param p_clear_values Valid pointer to an array of Vulkan clear values.
1106 * @param framebuffer Valid Vulkan framebuffer to use for the render pass.
1107 *
1108 * @return 1 if successful, 0 otherwise.
1109 */
1110extern uint8_t shBeginRenderpass(
1111 VkCommandBuffer graphics_cmd_buffer,
1112 VkRenderPass renderpass,
1113 int32_t render_offset_x,
1114 int32_t render_offset_y,
1115 uint32_t render_size_x,
1116 uint32_t render_size_y,
1117 uint32_t clear_value_count,
1118 VkClearValue* p_clear_values,
1119 VkFramebuffer framebuffer
1120);
1121
1122/**
1123 * @brief Ends a Vulkan render pass.
1124 *
1125 * This function ends the recording of commands for a render pass in the specified command buffer.
1126 *
1127 * @param graphics_cmd_buffer Valid Vulkan command buffer to end the render pass.
1128 *
1129 * @return 1 if successful, 0 otherwise.
1130 */
1131extern uint8_t shEndRenderpass(
1132 VkCommandBuffer graphics_cmd_buffer
1133);
1134
1135/**
1136 * @brief Records a draw command into a Vulkan command buffer.
1137 *
1138 * This function records a draw command into the specified command buffer.
1139 *
1140 * @param graphics_cmd_buffer Valid Vulkan command buffer to record the draw command.
1141 * @param vertex_count Number of vertices to draw.
1142 * @param first_vertex Index of the first vertex to draw.
1143 * @param instance_count Number of instances to draw.
1144 * @param first_instance Index of the first instance to draw.
1145 *
1146 * @return 1 if successful, 0 otherwise.
1147 */
1148extern uint8_t shDraw(
1149 VkCommandBuffer graphics_cmd_buffer,
1150 uint32_t vertex_count,
1151 uint32_t first_vertex,
1152 uint32_t instance_count,
1153 uint32_t first_instance
1154);
1155
1156/**
1157 * @brief Records an indexed draw command into a Vulkan command buffer.
1158 *
1159 * This function records an indexed draw command into the specified command buffer.
1160 *
1161 * @param graphics_cmd_buffer Valid Vulkan command buffer to record the draw command.
1162 * @param index_count Number of indices to draw.
1163 * @param instance_count Number of instances to draw.
1164 * @param first_index Index of the first index to draw.
1165 * @param vertex_offset Offset added to each index to obtain the vertex index.
1166 * @param first_instance Index of the first instance to draw.
1167 *
1168 * @return 1 if successful, 0 otherwise.
1169 */
1170extern uint8_t shDrawIndexed(
1171 VkCommandBuffer graphics_cmd_buffer,
1172 uint32_t index_count,
1173 uint32_t instance_count,
1174 uint32_t first_index,
1175 int32_t vertex_offset,
1176 uint32_t first_instance
1177);
1178
1179/**
1180 * @brief Presents an image from a Vulkan swapchain to the screen.
1181 *
1182 * This function presents an image from the specified swapchain using the provided queue.
1183 *
1184 * @param present_queue Valid Vulkan queue to present the image.
1185 * @param semaphores_to_wait_for_count Number of semaphores to wait for before presenting.
1186 * @param p_semaphores_to_wait_for Valid pointer to an array of Vulkan semaphores to wait for.
1187 * @param swapchain Valid Vulkan swapchain containing the image to present.
1188 * @param swapchain_image_idx Index of the swapchain image to present.
1189 *
1190 * @return 1 if successful, 0 otherwise.
1191 */
1193 VkQueue present_queue,
1194 uint32_t semaphores_to_wait_for_count,
1195 VkSemaphore* p_semaphores_to_wait_for,
1196 VkSwapchainKHR swapchain,
1197 uint32_t swapchain_image_idx
1198);
1199
1200
1201
1202#define SH_VEC1_SIGNED_FLOAT VK_FORMAT_R32_SFLOAT
1203#define SH_VEC2_SIGNED_FLOAT VK_FORMAT_R32G32_SFLOAT
1204#define SH_VEC3_SIGNED_FLOAT VK_FORMAT_R32G32B32_SFLOAT
1205#define SH_VEC4_SIGNED_FLOAT VK_FORMAT_R32G32B32A32_SFLOAT
1206
1207#define SH_VEC1_SIGNED_DOUBLE VK_FORMAT_R64_SFLOAT
1208#define SH_VEC2_SIGNED_DOUBLE VK_FORMAT_R64G64_SFLOAT
1209#define SH_VEC3_SIGNED_DOUBLE VK_FORMAT_R64G64B64_SFLOAT
1210#define SH_VEC4_SIGNED_DOUBLE VK_FORMAT_R64G64B64A64_SFLOAT
1211
1212#define SH_VEC1_SIGNED_INT VK_FORMAT_R32_SINT
1213#define SH_VEC2_SIGNED_INT VK_FORMAT_R32G32_SINT
1214#define SH_VEC3_SIGNED_INT VK_FORMAT_R32G32B32_SINT
1215#define SH_VEC4_SIGNED_INT VK_FORMAT_R32G32B32A32_SINT
1216
1217#define SH_VEC1_UNSIGNED_INT VK_FORMAT_R32_UINT
1218#define SH_VEC2_UNSIGNED_INT VK_FORMAT_R32G32_UINT
1219#define SH_VEC3_UNSIGNED_INT VK_FORMAT_R32G32B32_UINT
1220#define SH_VEC4_UNSIGNED_INT VK_FORMAT_R32G32B32A32_UINT
1221
1222#define SH_VEC1_UNSIGNED_LONG VK_FORMAT_R64_UINT
1223#define SH_VEC2_UNSIGNED_LONG VK_FORMAT_R64G64_UINT
1224#define SH_VEC3_UNSIGNED_LONG VK_FORMAT_R64G64B64_UINT
1225#define SH_VEC4_UNSIGNED_LONG VK_FORMAT_R64G64B64A64_UINT
1226
1227
1228/**
1229 * @brief Creates a Vulkan buffer.
1230 *
1231 * This function creates a Vulkan buffer with the specified size and usage.
1232 *
1233 * @param device Valid Vulkan device.
1234 * @param size Size of the buffer in bytes.
1235 * @param usage Vulkan buffer usage flags indicating how the buffer will be used.
1236 * @param sharing_mode Vulkan sharing mode specifying how the buffer is shared between queues.
1237 * @param p_buffer Valid destination pointer to the newly created Vulkan buffer.
1238 *
1239 * @return 1 if successful, 0 otherwise.
1240 */
1241extern uint8_t shCreateBuffer(
1242 VkDevice device,
1243 uint32_t size,
1244 VkBufferUsageFlags usage,
1245 VkSharingMode sharing_mode,
1246 VkBuffer* p_buffer
1247);
1248
1249/**
1250 * @brief Retrieves the memory type index that supports the specified memory properties.
1251 *
1252 * This function finds the index of a memory type that matches the specified memory property flags.
1253 *
1254 * @param device Valid Vulkan device.
1255 * @param physical_device Valid Vulkan physical device.
1256 * @param property_flags Vulkan memory property flags to match.
1257 * @param p_memory_type_index Valid destination pointer to the index of the memory type.
1258 *
1259 * @return 1 if successful, 0 otherwise.
1260 */
1261extern uint8_t shGetMemoryType(
1262 VkDevice device,
1263 VkPhysicalDevice physical_device,
1264 VkMemoryPropertyFlags property_flags,
1265 uint32_t* p_memory_type_index
1266);
1267
1268/**
1269 * @brief Allocates memory for a Vulkan buffer.
1270 *
1271 * This function allocates memory for a specified Vulkan buffer with the desired memory properties.
1272 *
1273 * @param device Valid Vulkan device.
1274 * @param physical_device Valid Vulkan physical device.
1275 * @param buffer Valid Vulkan buffer for which memory is to be allocated.
1276 * @param property_flags Vulkan memory property flags for the allocated memory.
1277 * @param p_memory Valid destination pointer to the newly allocated Vulkan device memory.
1278 *
1279 * @return 1 if successful, 0 otherwise.
1280 */
1282 VkDevice device,
1283 VkPhysicalDevice physical_device,
1284 VkBuffer buffer,
1285 VkMemoryPropertyFlags property_flags,
1286 VkDeviceMemory* p_memory
1287);
1288
1289/**
1290 * @brief Copies data from one Vulkan buffer to another.
1291 *
1292 * This function copies data from a source buffer to a destination buffer.
1293 *
1294 * @param transfer_cmd_buffer Valid Vulkan command buffer for the copy operation.
1295 * @param src_buffer Valid Vulkan source buffer.
1296 * @param src_offset Offset in the source buffer to start copying from.
1297 * @param dst_offset Offset in the destination buffer to start copying to.
1298 * @param size Number of bytes to copy.
1299 * @param dst_buffer Valid Vulkan destination buffer.
1300 *
1301 * @return 1 if successful, 0 otherwise.
1302 */
1303extern uint8_t shCopyBuffer(
1304 VkCommandBuffer transfer_cmd_buffer,
1305 VkBuffer src_buffer,
1306 uint32_t src_offset,
1307 uint32_t dst_offset,
1308 uint64_t size,
1309 VkBuffer dst_buffer
1310);
1311
1312#define SH_MAX_STACK_BUFFER_REGION_COUNT 256
1313
1314/**
1315 * @brief Copies multiple regions of data from one Vulkan buffer to another.
1316 *
1317 * This function copies multiple regions of data from a source buffer to a destination buffer.
1318 *
1319 * @param transfer_cmd_buffer Valid Vulkan command buffer for the copy operation.
1320 * @param src_buffer Valid Vulkan source buffer.
1321 * @param region_count Number of regions to copy.
1322 * @param p_src_offsets Valid pointer to an array of offsets in the source buffer.
1323 * @param p_dst_offsets Valid pointer to an array of offsets in the destination buffer.
1324 * @param p_sizes Valid pointer to an array of sizes for each region to copy.
1325 * @param dst_buffer Valid Vulkan destination buffer.
1326 *
1327 * @return 1 if successful, 0 otherwise.
1328 */
1330 VkCommandBuffer transfer_cmd_buffer,
1331 VkBuffer src_buffer,
1332 uint32_t region_count,
1333 uint32_t* p_src_offsets,
1334 uint32_t* p_dst_offsets,
1335 uint32_t* p_sizes,
1336 VkBuffer dst_buffer
1337);
1338
1339//TODO DOCUMENTATION
1341 VkCommandBuffer transfer_cmd_buffer,
1342 uint32_t width,
1343 uint32_t height,
1344 VkImageAspectFlags src_image_aspect,
1345 VkImageAspectFlags dst_image_aspect,
1346 VkImage src_image,
1347 VkImage dst_image
1348);
1349
1350/**
1351 * @brief Binds a Vulkan buffer to a specified memory offset.
1352 *
1353 * This function binds a Vulkan buffer to a specific memory offset.
1354 *
1355 * @param device Valid Vulkan device.
1356 * @param buffer Valid Vulkan buffer to bind.
1357 * @param offset Offset in the memory where the buffer will be bound.
1358 * @param buffer_memory Valid Vulkan device memory to bind to the buffer.
1359 *
1360 * @return 1 if successful, 0 otherwise.
1361 */
1362extern uint8_t shBindBufferMemory(
1363 VkDevice device,
1364 VkBuffer buffer,
1365 uint32_t offset,
1366 VkDeviceMemory buffer_memory
1367);
1368
1369
1370//TODO
1371/**
1372 * @brief Reads data from a Vulkan memory object.
1373 *
1374 * This function reads data from a specified offset in a Vulkan memory object into a user-provided buffer.
1375 *
1376 * @param device Valid Vulkan device.
1377 * @param memory Valid Vulkan device memory to read from.
1378 * @param offset Offset in the memory to start reading from.
1379 * @param data_size Number of bytes to read.
1380 * @param p_data Valid destination pointer to a buffer to store the read data.
1381 *
1382 * @return 1 if successful, 0 otherwise.
1383 */
1384extern uint8_t shReadMemory(
1385 VkDevice device,
1386 VkDeviceMemory memory,
1387 uint32_t offset,
1388 uint64_t data_size,
1389 void** pp_map_data,
1390 void* p_dst_data
1391);
1392
1393//TODO documentation
1394extern uint8_t shUnmapMemory(
1395 VkDevice device,
1396 VkDeviceMemory memory
1397);
1398
1399/**
1400 * @brief Writes data to a Vulkan memory object.
1401 *
1402 * This function writes data from a user-provided buffer to a specified offset in a Vulkan memory object.
1403 *
1404 * @param device Valid Vulkan device.
1405 * @param memory Valid Vulkan device memory to write to.
1406 * @param offset Offset in the memory to start writing to.
1407 * @param data_size Number of bytes to write.
1408 * @param p_data Valid pointer to a buffer containing the data to write.
1409 *
1410 * @return 1 if successful, 0 otherwise.
1411 */
1412extern uint8_t shWriteMemory(
1413 VkDevice device,
1414 VkDeviceMemory memory,
1415 uint32_t offset,
1416 uint32_t data_size,
1417 void* p_data
1418);
1419
1420/**
1421 * @brief Clears memory associated with a Vulkan buffer.
1422 *
1423 * This function clears the memory bound to a Vulkan buffer.
1424 *
1425 * @param device Valid Vulkan device.
1426 * @param buffer Valid Vulkan buffer.
1427 * @param memory Valid Vulkan device memory bound to the buffer.
1428 *
1429 * @return 1 if successful, 0 otherwise.
1430 */
1431extern uint8_t shClearBufferMemory(
1432 VkDevice device,
1433 VkBuffer buffer,
1434 VkDeviceMemory memory
1435);
1436
1437/**
1438 * @brief Creates a Vulkan image.
1439 *
1440 * This function creates a Vulkan image with the specified parameters.
1441 *
1442 * @param device Valid Vulkan device.
1443 * @param type Vulkan image type.
1444 * @param x Width of the image.
1445 * @param y Height of the image.
1446 * @param z Depth of the image.
1447 * @param format Vulkan image format.
1448 * @param mip_levels Number of mipmap levels.
1449 * @param sample_count Vulkan sample count flag bits.
1450 * @param image_tiling Vulkan image tiling mode.
1451 * @param usage Vulkan image usage flags.
1452 * @param sharing_mode Vulkan sharing mode.
1453 * @param p_image Valid destination pointer to the newly created Vulkan image.
1454 *
1455 * @return 1 if successful, 0 otherwise.
1456 */
1457extern uint8_t shCreateImage(
1458 VkDevice device,
1459 VkImageType type,
1460 uint32_t x,
1461 uint32_t y,
1462 uint32_t z,
1463 VkFormat format,
1464 uint32_t mip_levels,
1465 VkSampleCountFlagBits sample_count,
1466 VkImageTiling image_tiling,
1467 VkImageUsageFlags usage,
1468 VkSharingMode sharing_mode,
1469 VkImage* p_image
1470);
1471
1472/**
1473 * @brief Allocates memory for a Vulkan image.
1474 *
1475 * This function allocates memory for a specified Vulkan image with the desired memory properties.
1476 *
1477 * @param device Valid Vulkan device.
1478 * @param physical_device Valid Vulkan physical device.
1479 * @param image Valid Vulkan image for which memory is to be allocated.
1480 * @param memory_property_flags Vulkan memory property flags for the allocated memory.
1481 * @param p_image_memory Valid destination pointer to the newly allocated Vulkan device memory.
1482 *
1483 * @return 1 if successful, 0 otherwise.
1484 */
1486 VkDevice device,
1487 VkPhysicalDevice physical_device,
1488 VkImage image,
1489 VkMemoryPropertyFlags memory_property_flags,
1490 VkDeviceMemory* p_image_memory
1491);
1492
1493/**
1494 * @brief Binds a Vulkan image to a specified memory offset.
1495 *
1496 * This function binds a Vulkan image to a specific memory offset.
1497 *
1498 * @param device Valid Vulkan device.
1499 * @param image Valid Vulkan image to bind.
1500 * @param offset Offset in the memory where the image will be bound.
1501 * @param image_memory Valid Vulkan device memory to bind to the image.
1502 *
1503 * @return 1 if successful, 0 otherwise.
1504 */
1505extern uint8_t shBindImageMemory(
1506 VkDevice device,
1507 VkImage image,
1508 uint32_t offset,
1509 VkDeviceMemory image_memory
1510);
1511
1512/**
1513 * @brief Clears memory associated with a Vulkan image.
1514 *
1515 * This function clears the memory bound to a Vulkan image.
1516 *
1517 * @param device Valid Vulkan device.
1518 * @param image Valid Vulkan image.
1519 * @param image_memory Valid Vulkan device memory bound to the image.
1520 *
1521 * @return 1 if successful, 0 otherwise.
1522 */
1523extern uint8_t shClearImageMemory(
1524 VkDevice device,
1525 VkImage image,
1526 VkDeviceMemory image_memory
1527);
1528
1529//TODO documentation
1531 VkDevice device,
1532 VkImage image,
1533 VkImageAspectFlags image_aspect_mask,
1534 VkSubresourceLayout* p_subresource_layout
1535);
1536
1537/**
1538 * @brief Creates a buffer memory barrier
1539 *
1540 * This function creates a buffer memory barrier to synchronize buffer memory access (e.g. read, write, transfer).
1541 *
1542 * @param device Valid Vulkan device.
1543 * @param cmd_buffer Valid Vulkan command buffer.
1544 * @param buffer Valid Vulkan buffer (target of the barrier).
1545 * @param access_before_barrier Memory access flag before the barrier.
1546 * @param access_after_barrier Memory access flag sfter the barrier.
1547 * @param performing_queue_family_index_before_barrier Performing queue family index before the barrier.
1548 * @param performing_queue_family_index_after_barrier Performing queue family index before the barrier.
1549 * @param pipeline_stage_before_barrier Pipeline stage flag before the barrier.
1550 * @param pipeline_stage_after_barrier Pipeline stage flag after the barrier.
1551 *
1552 * @return 1 if successful, 0 otherwise.
1553 */
1555 VkDevice device,
1556 VkCommandBuffer cmd_buffer,
1557 VkBuffer buffer,
1558 VkAccessFlags access_before_barrier,
1559 VkAccessFlags access_after_barrier,
1560 uint32_t performing_queue_family_index_before_barrier,
1561 uint32_t performing_queue_family_index_after_barrier,
1562 VkPipelineStageFlags pipeline_stage_before_barrier,
1563 VkPipelineStageFlags pipeline_stage_after_barrier
1564);
1565
1566/**
1567 * @brief Creates an image memory barrier
1568 *
1569 * This function creates an image memory barrier to synchronize image memory access (e.g. read, write, transfer).
1570 *
1571 * @param device Valid Vulkan device.
1572 * @param cmd_buffer Valid Vulkan command buffer.
1573 * @param image Valid Vulkan image (target of the barrier).
1574 * @param image_aspect_mask Target image aspect mask.
1575 * @param access_before_barrier Memory access flag before the barrier.
1576 * @param access_after_barrier Memory access flag sfter the barrier.
1577 * @param image_layout_before_barrier Image layout before the barrier.
1578 * @param image_layout_after_barrier Image layout before the barrier.
1579 * @param performing_queue_family_index_before_barrier Performing queue family index before the barrier.
1580 * @param performing_queue_family_index_after_barrier Performing queue family index before the barrier.
1581 * @param pipeline_stage_before_barrier Pipeline stage flag before the barrier.
1582 * @param pipeline_stage_after_barrier Pipeline stage flag after the barrier.
1583 *
1584 * @return 1 if successful, 0 otherwise.
1585 */
1587 VkDevice device,
1588 VkCommandBuffer cmd_buffer,
1589 VkImage image,
1590 VkImageAspectFlags image_aspect_mask,
1591 VkAccessFlags access_before_barrier,
1592 VkAccessFlags access_after_barrier,
1593 VkImageLayout image_layout_before_barrier,
1594 VkImageLayout image_layout_after_barrier,
1595 uint32_t performing_queue_family_index_before_barrier,
1596 uint32_t performing_queue_family_index_after_barrier,
1597 VkPipelineStageFlags pipeline_stage_before_barrier,
1598 VkPipelineStageFlags pipeline_stage_after_barrier
1599);
1600
1601/**
1602 * @brief Retrieves memory budget properties for a Vulkan physical device.
1603 *
1604 * This function retrieves memory budget properties for a Vulkan physical device.
1605 *
1606 * @param physical_device Valid Vulkan physical device.
1607 * @param p_memory_budget_properties Valid destination pointer to Vulkan memory budget properties.
1608 *
1609 * @return 1 if successful, 0 otherwise.
1610 */
1612 VkPhysicalDevice physical_device,
1613 VkPhysicalDeviceMemoryBudgetPropertiesEXT* p_memory_budget_properties
1614);
1615
1616/**
1617 * @brief Binds vertex buffers to a Vulkan command buffer.
1618 *
1619 * This function binds one or more vertex buffers to a Vulkan command buffer.
1620 *
1621 * @param graphics_cmd_buffer Valid Vulkan command buffer to bind vertex buffers to.
1622 * @param first_binding Binding index to start from.
1623 * @param binding_count Number of vertex buffers to bind.
1624 * @param p_vertex_buffers Valid pointer to an array of Vulkan vertex buffers.
1625 * @param p_vertex_offsets Valid pointer to an array of offsets for each vertex buffer.
1626 *
1627 * @return 1 if successful, 0 otherwise.
1628 */
1629extern uint8_t shBindVertexBuffers(
1630 VkCommandBuffer graphics_cmd_buffer,
1631 uint32_t first_binding,
1632 uint32_t binding_count,
1633 VkBuffer* p_vertex_buffers,
1634 VkDeviceSize* p_vertex_offsets
1635);
1636
1637/**
1638 * @brief Binds an index buffer to a Vulkan command buffer.
1639 *
1640 * This function binds an index buffer to a Vulkan command buffer.
1641 *
1642 * @param graphics_cmd_buffer Valid Vulkan command buffer to bind the index buffer to.
1643 * @param index_offset Offset in the index buffer.
1644 * @param index_buffer Valid Vulkan index buffer to bind.
1645 *
1646 * @return 1 if successful, 0 otherwise.
1647 */
1648extern uint8_t shBindIndexBuffer(
1649 VkCommandBuffer graphics_cmd_buffer,
1650 uint32_t index_offset,
1651 VkBuffer index_buffer
1652);
1653
1654/**
1655 * @brief Sets the vertex input binding description.
1656 *
1657 * This function sets the vertex input binding description with the specified parameters.
1658 *
1659 * @param binding Binding index for the vertex input binding.
1660 * @param size Size of the vertex buffer in bytes.
1661 * @param input_rate Vertex input rate (e.g., per vertex or per instance).
1662 * @param p_vertex_input_binding Valid destination pointer to the Vulkan vertex input binding description.
1663 *
1664 * @return 1 if successful, 0 otherwise.
1665 */
1666extern uint8_t shSetVertexBinding(
1667 uint32_t binding,
1668 uint32_t size,
1669 VkVertexInputRate input_rate,
1670 VkVertexInputBindingDescription* p_vertex_input_binding
1671);
1672
1673/**
1674 * @brief Sets the vertex attribute description.
1675 *
1676 * This function sets the vertex attribute description with the specified parameters.
1677 *
1678 * @param location Location of the vertex attribute.
1679 * @param binding Binding index of the vertex attribute.
1680 * @param format Vulkan format of the vertex attribute.
1681 * @param offset Offset in the vertex buffer where the attribute starts.
1682 * @param p_vertex_input_attribute Valid destination pointer to the Vulkan vertex input attribute description.
1683 *
1684 * @return 1 if successful, 0 otherwise.
1685 */
1687 uint32_t location,
1688 uint32_t binding,
1689 VkFormat format,
1690 uint32_t offset,
1691 VkVertexInputAttributeDescription* p_vertex_input_attribute
1692);
1693
1694/**
1695 * @brief Sets the vertex input state for a pipeline.
1696 *
1697 * This function sets the vertex input state, including bindings and attributes, for a Vulkan pipeline.
1698 *
1699 * @param vertex_binding_count Number of vertex input bindings.
1700 * @param p_vertex_bindings Valid pointer to an array of Vulkan vertex input binding descriptions.
1701 * @param vertex_attribute_count Number of vertex input attributes.
1702 * @param p_vertex_attributes Valid pointer to an array of Vulkan vertex input attribute descriptions.
1703 * @param p_vertex_input_state Valid destination pointer to the Vulkan pipeline vertex input state create info.
1704 *
1705 * @return 1 if successful, 0 otherwise.
1706 */
1708 uint32_t vertex_binding_count,
1709 VkVertexInputBindingDescription* p_vertex_bindings,
1710 uint32_t vertex_attribute_count,
1711 VkVertexInputAttributeDescription* p_vertex_attributes,
1712 VkPipelineVertexInputStateCreateInfo* p_vertex_input_state
1713);
1714
1715/**
1716 * @brief Creates the input assembly state for a pipeline.
1717 *
1718 * This function creates the input assembly state with the specified topology and restart enable flag.
1719 *
1720 * @param primitive_topology Vulkan primitive topology type.
1721 * @param primitive_restart_enable Boolean flag to enable or disable primitive restart.
1722 * @param p_input_assembly Valid destination pointer to the Vulkan pipeline input assembly state create info.
1723 *
1724 * @return 1 if successful, 0 otherwise.
1725 */
1727 VkPrimitiveTopology primitive_topology,
1728 VkBool32 primitive_restart_enable,
1729 VkPipelineInputAssemblyStateCreateInfo* p_input_assembly
1730);
1731
1732/**
1733 * @brief Creates the rasterization state for a pipeline.
1734 *
1735 * This function creates the rasterization state with the specified polygon mode and cull mode.
1736 *
1737 * @param polygon_mode Vulkan polygon mode for rasterization.
1738 * @param cull_mode Vulkan cull mode flag bits.
1739 * @param p_rasterizer Valid destination pointer to the Vulkan pipeline rasterization state create info.
1740 *
1741 * @return 1 if successful, 0 otherwise.
1742 */
1743extern uint8_t shCreateRasterizer(
1744 VkPolygonMode polygon_mode,
1745 VkCullModeFlagBits cull_mode,
1746 VkPipelineRasterizationStateCreateInfo* p_rasterizer
1747);
1748
1749/**
1750 * @brief Sets the multisample state for a pipeline.
1751 *
1752 * This function sets the multisample state, including sample count and minimum sample shading, for a Vulkan pipeline.
1753 *
1754 * @param sample_count Vulkan sample count flag bits.
1755 * @param min_sample_shading_size Minimum sample shading size.
1756 * @param p_multisample_state Valid destination pointer to the Vulkan pipeline multisample state create info.
1757 *
1758 * @return 1 if successful, 0 otherwise.
1759 */
1761 VkSampleCountFlagBits sample_count,
1762 float min_sample_shading_size,
1763 VkPipelineMultisampleStateCreateInfo* p_multisample_state
1764);
1765
1766/**
1767 * @brief Sets the viewport and scissor state for a pipeline.
1768 *
1769 * This function sets the viewport and scissor parameters for a Vulkan pipeline.
1770 *
1771 * @param viewport_pos_x X position of the viewport.
1772 * @param viewport_pos_y Y position of the viewport.
1773 * @param viewport_width Width of the viewport.
1774 * @param viewport_height Height of the viewport.
1775 * @param p_viewport Valid destination pointer to the Vulkan viewport.
1776 * @param scissors_pos_x X position of the scissor.
1777 * @param scissors_pos_y Y position of the scissor.
1778 * @param scissors_width Width of the scissor.
1779 * @param scissors_height Height of the scissor.
1780 * @param p_scissors Valid destination pointer to the Vulkan scissor rectangle.
1781 * @param p_viewport_state Valid destination pointer to the Vulkan pipeline viewport state create info.
1782 *
1783 * @return 1 if successful, 0 otherwise.
1784 */
1785extern uint8_t shSetViewport(
1786 uint32_t viewport_pos_x,
1787 uint32_t viewport_pos_y,
1788 uint32_t viewport_width,
1789 uint32_t viewport_height,
1790 VkViewport* p_viewport,
1791 uint32_t scissors_pos_x,
1792 uint32_t scissors_pos_y,
1793 uint32_t scissors_width,
1794 uint32_t scissors_height,
1795 VkRect2D* p_scissors,
1796 VkPipelineViewportStateCreateInfo* p_viewport_state
1797);
1798
1799/**
1800 * @brief Configures color blending and alpha blending states.
1801 *
1802 * This function configures the color blending and alpha blending states for a Vulkan pipeline.
1803 *
1804 * @param enable_color_blending Boolean flag to enable or disable color blending.
1805 * @param enable_alpha_blending Boolean flag to enable or disable alpha blending.
1806 * @param subpass_color_attachment_count Number of color attachments in the subpass.
1807 * @param p_color_blend_attachment_states Valid pointer to an array of Vulkan color blend attachment states.
1808 * @param p_color_blend_state Valid destination pointer to the Vulkan pipeline color blend state create info.
1809 *
1810 * @return 1 if successful, 0 otherwise.
1811 */
1813 uint8_t enable_color_blending,
1814 uint8_t enable_alpha_blending,
1815 uint32_t subpass_color_attachment_count,
1816 VkPipelineColorBlendAttachmentState* p_color_blend_attachment_states,
1817 VkPipelineColorBlendStateCreateInfo* p_color_blend_state
1818);
1819
1820/**
1821 * @brief Creates a Vulkan shader module.
1822 *
1823 * This function creates a shader module from the provided shader code.
1824 *
1825 * @param device Valid Vulkan device.
1826 * @param size Size of the shader code in bytes.
1827 * @param code Pointer to the shader code.
1828 * @param p_shader_module Valid destination pointer to the newly created Vulkan shader module.
1829 *
1830 * @return 1 if successful, 0 otherwise.
1831 */
1833 VkDevice device,
1834 uint32_t size,
1835 char* code,
1836 VkShaderModule* p_shader_module
1837);
1838
1839/**
1840 * @brief Creates a Vulkan shader stage.
1841 *
1842 * This function creates a shader stage using the provided shader module and stage flag.
1843 *
1844 * @param shader_module Valid Vulkan shader module.
1845 * @param shader_stage_flag Vulkan shader stage flag (e.g., vertex, fragment).
1846 * @param p_shader_stage Valid destination pointer to the Vulkan pipeline shader stage create info.
1847 *
1848 * @return 1 if successful, 0 otherwise.
1849 */
1850extern uint8_t shCreateShaderStage(
1851 VkShaderModule shader_module,
1852 VkShaderStageFlags shader_stage_flag,
1853 VkPipelineShaderStageCreateInfo* p_shader_stage
1854);
1855
1856/**
1857 * @brief Sets push constants for a shader stage.
1858 *
1859 * This function sets push constants for a specified shader stage.
1860 *
1861 * @param shader_stage Vulkan shader stage flags (e.g., vertex, fragment).
1862 * @param offset Offset in bytes from the start of the push constant range.
1863 * @param size Size of the push constants in bytes.
1864 * @param p_push_constant_range Valid destination pointer to the Vulkan push constant range.
1865 *
1866 * @return 1 if successful, 0 otherwise.
1867 */
1868extern uint8_t shSetPushConstants(
1869 VkShaderStageFlags shader_stage,
1870 uint32_t offset,
1871 uint32_t size,
1872 VkPushConstantRange* p_push_constant_range
1873);
1874
1875/**
1876 * @brief Creates a descriptor set layout binding.
1877 *
1878 * This function creates a descriptor set layout binding with the specified parameters.
1879 *
1880 * @param binding Binding index for the descriptor set layout.
1881 * @param descriptor_type Vulkan descriptor type (e.g., uniform buffer, sampled image).
1882 * @param descriptor_set_count Number of descriptors in the set.
1883 * @param shader_stage Vulkan shader stage flags that use this descriptor.
1884 * @param p_binding Valid destination pointer to the Vulkan descriptor set layout binding.
1885 *
1886 * @return 1 if successful, 0 otherwise.
1887 */
1889 uint32_t binding,
1890 VkDescriptorType descriptor_type,
1891 uint32_t descriptor_set_count,
1892 VkShaderStageFlags shader_stage,
1893 VkDescriptorSetLayoutBinding* p_binding
1894);
1895
1896/**
1897 * @brief Creates a descriptor set layout.
1898 *
1899 * This function creates a descriptor set layout with the specified bindings.
1900 *
1901 * @param device Valid Vulkan device.
1902 * @param binding_count Number of descriptor set layout bindings.
1903 * @param p_bindings Valid pointer to an array of Vulkan descriptor set layout bindings.
1904 * @param p_descriptor_set_layout Valid destination pointer to the newly created Vulkan descriptor set layout.
1905 *
1906 * @return 1 if successful, 0 otherwise.
1907 */
1909 VkDevice device,
1910 uint32_t binding_count,
1911 VkDescriptorSetLayoutBinding* p_bindings,
1912 VkDescriptorSetLayout* p_descriptor_set_layout
1913);
1914
1915/**
1916 * @brief Creates a descriptor pool.
1917 *
1918 * This function creates a descriptor pool with the specified pool sizes.
1919 *
1920 * @param device Valid Vulkan device.
1921 * @param pool_size_count Number of pool sizes.
1922 * @param p_pool_sizes Valid pointer to an array of Vulkan descriptor pool sizes.
1923 * @param p_descriptor_pool Valid destination pointer to the newly created Vulkan descriptor pool.
1924 *
1925 * @return 1 if successful, 0 otherwise.
1926 */
1928 VkDevice device,
1929 uint32_t pool_size_count,
1930 VkDescriptorPoolSize* p_pool_sizes,
1931 VkDescriptorPool* p_descriptor_pool
1932);
1933
1934/**
1935 * @brief Sets buffer information for a descriptor buffer.
1936 *
1937 * This function sets buffer information for a descriptor buffer.
1938 *
1939 * @param buffer Valid Vulkan buffer.
1940 * @param buffer_offset Offset in the buffer.
1941 * @param buffer_size Size of the buffer.
1942 * @param p_buffer_info Valid destination pointer to the Vulkan descriptor buffer info.
1943 *
1944 * @return 1 if successful, 0 otherwise.
1945 */
1947 VkBuffer buffer,
1948 uint32_t buffer_offset,
1949 uint32_t buffer_size,
1950 VkDescriptorBufferInfo* p_buffer_info
1951);
1952
1953/**
1954 * @brief Allocates descriptor sets from a descriptor pool.
1955 *
1956 * This function allocates descriptor sets of the specified type from the given descriptor pool.
1957 *
1958 * @param device Valid Vulkan device.
1959 * @param descriptor_pool Valid Vulkan descriptor pool from which to allocate descriptor sets.
1960 * @param descriptor_type Vulkan descriptor type (e.g., uniform buffer, sampled image).
1961 * @param binding Binding index for the descriptor sets.
1962 * @param descriptor_set_unit_count Number of descriptor sets to allocate.
1963 * @param p_descriptor_set_layouts Valid pointer to an array of Vulkan descriptor set layouts.
1964 * @param p_descriptor_sets Valid destination pointer to an array of Vulkan descriptor sets.
1965 * @param p_buffer_infos Valid pointer to an array of Vulkan descriptor buffer info structures.
1966 * @param p_write_descriptor_sets Valid pointer to an array of Vulkan write descriptor set structures.
1967 *
1968 * @return 1 if successful, 0 otherwise.
1969 */
1971 VkDevice device,
1972 VkDescriptorPool descriptor_pool,
1973 VkDescriptorType descriptor_type,
1974 uint32_t binding,
1975 uint32_t descriptor_set_unit_count,
1976 VkDescriptorSetLayout* p_descriptor_set_layouts,
1977 VkDescriptorSet* p_descriptor_sets,
1978 VkDescriptorBufferInfo* p_buffer_infos,
1979 VkWriteDescriptorSet* p_write_descriptor_sets
1980);
1981
1982/**
1983 * @brief Creates a pipeline layout.
1984 *
1985 * This function creates a Vulkan pipeline layout with the specified push constant ranges and descriptor set layouts.
1986 *
1987 * @param device Valid Vulkan device.
1988 * @param push_constant_range_count Number of push constant ranges.
1989 * @param p_push_constants_range Valid pointer to an array of Vulkan push constant ranges.
1990 * @param src_descriptor_set_layout_count Number of descriptor set layouts.
1991 * @param p_src_descriptor_set_layouts Valid pointer to an array of Vulkan descriptor set layouts.
1992 * @param p_pipeline_layout Valid destination pointer to the newly created Vulkan pipeline layout.
1993 *
1994 * @return 1 if successful, 0 otherwise.
1995 */
1997 VkDevice device,
1998 uint32_t push_constant_range_count,
1999 VkPushConstantRange* p_push_constants_range,
2000 uint32_t src_descriptor_set_layout_count,
2001 VkDescriptorSetLayout* p_src_descriptor_set_layouts,
2002 VkPipelineLayout* p_pipeline_layout
2003);
2004
2005/**
2006 * @brief Destroys a Vulkan descriptor pool.
2007 *
2008 * This function destroys the specified Vulkan descriptor pool.
2009 *
2010 * @param device Valid Vulkan device.
2011 * @param descriptor_pool Vulkan descriptor pool to destroy.
2012 *
2013 * @return 1 if successful, 0 otherwise.
2014 */
2016 VkDevice device,
2017 VkDescriptorPool descriptor_pool
2018);
2019
2020/**
2021 * @brief Destroys a Vulkan descriptor set layout.
2022 *
2023 * This function destroys the specified Vulkan descriptor set layout.
2024 *
2025 * @param device Valid Vulkan device.
2026 * @param descriptor_set_layout Vulkan descriptor set layout to destroy.
2027 *
2028 * @return 1 if successful, 0 otherwise.
2029 */
2031 VkDevice device,
2032 VkDescriptorSetLayout descriptor_set_layout
2033);
2034
2035/**
2036 * @brief Destroys a Vulkan shader module.
2037 *
2038 * This function destroys the specified Vulkan shader module.
2039 *
2040 * @param device Valid Vulkan device.
2041 * @param shader_module Vulkan shader module to destroy.
2042 *
2043 * @return 1 if successful, 0 otherwise.
2044 */
2046 VkDevice device,
2047 VkShaderModule shader_module
2048);
2049
2050/**
2051 * @brief Destroys a Vulkan pipeline layout.
2052 *
2053 * This function destroys the specified Vulkan pipeline layout.
2054 *
2055 * @param device Valid Vulkan device.
2056 * @param pipeline_layout Vulkan pipeline layout to destroy.
2057 *
2058 * @return 1 if successful, 0 otherwise.
2059 */
2061 VkDevice device,
2062 VkPipelineLayout pipeline_layout
2063);
2064
2065/**
2066 * @brief Destroys a Vulkan pipeline.
2067 *
2068 * This function destroys the specified Vulkan pipeline.
2069 *
2070 * @param device Valid Vulkan device.
2071 * @param pipeline Vulkan pipeline to destroy.
2072 *
2073 * @return 1 if successful, 0 otherwise.
2074 */
2075extern uint8_t shDestroyPipeline(
2076 VkDevice device,
2077 VkPipeline pipeline
2078);
2079
2080
2081
2082#define SH_MAX_PIPELINE_VERTEX_BINDING_COUNT 32
2083#define SH_MAX_PIPELINE_VERTEX_ATTRIBUTE_COUNT 32
2084
2085#define SH_MAX_PIPELINE_SHADER_STAGE_COUNT 6
2086
2087#define SH_MAX_PIPELINE_SUBPASS_COLOR_ATTACHMENT_COUNT 9
2088
2089
2090/**
2091 * @brief Structure representing a Vulkan pipeline.
2092 *
2093 * This structure holds all the necessary state and configuration for creating and managing a Vulkan pipeline.
2094 */
2095typedef struct ShVkPipeline {
2096 /*Vertex inputs*/
2097 uint32_t vertex_binding_count; ///< Number of vertex bindings.
2098 VkVertexInputBindingDescription vertex_bindings[SH_MAX_PIPELINE_VERTEX_BINDING_COUNT]; ///< Array of vertex input bindings.
2099 uint32_t vertex_attribute_count; ///< Number of vertex attributes.
2100 VkVertexInputAttributeDescription vertex_attributes[SH_MAX_PIPELINE_VERTEX_ATTRIBUTE_COUNT]; ///< Array of vertex input attributes.
2101 VkPipelineVertexInputStateCreateInfo vertex_input_state_info; ///< Vertex input state information.
2102 VkPipelineInputAssemblyStateCreateInfo input_assembly; ///< Input assembly state information.
2103 /*Shaders*/
2104 uint32_t shader_module_count; ///< Number of shader modules.
2105 VkShaderModule shader_modules[SH_MAX_PIPELINE_SHADER_STAGE_COUNT]; ///< Array of shader modules.
2106 uint32_t shader_stage_count; ///< Number of shader stages.
2107 VkPipelineShaderStageCreateInfo shader_stages[SH_MAX_PIPELINE_SHADER_STAGE_COUNT]; ///< Array of shader stage create info.
2108 /*Push constants*/
2109 VkPushConstantRange push_constant_range; ///< Push constant range information.
2110 /*Rasterizer*/
2111 VkPipelineRasterizationStateCreateInfo rasterizer; ///< Rasterizer state information.
2112 /*Viewport*/
2113 VkViewport viewport; ///< Viewport information.
2114 VkRect2D scissors; ///< Scissor rectangle information.
2115 VkPipelineViewportStateCreateInfo viewport_state; ///< Viewport state information.
2116 /*Color blending*/
2117 VkPipelineColorBlendAttachmentState color_blend_attachment_states[SH_MAX_PIPELINE_SUBPASS_COLOR_ATTACHMENT_COUNT]; ///< Array of color blend attachment states.
2118 VkPipelineColorBlendStateCreateInfo color_blend_state; ///< Color blend state information.
2119 /*Multisample state*/
2120 VkPipelineMultisampleStateCreateInfo multisample_state_info; ///< Multisample state information.
2121 /*Pipeline*/
2122 VkPipelineLayout pipeline_layout; ///< Vulkan pipeline layout.
2123 VkPipeline pipeline; ///< Vulkan pipeline.
2125
2126
2127
2129
2130
2131
2132/**
2133 * @brief Clears the pipeline structure.
2134 *
2135 * This function resets all fields of the ShVkPipeline structure to their default values.
2136 *
2137 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to be cleared.
2138 *
2139 * @return 1 if successful, 0 otherwise.
2140 */
2141extern uint8_t shClearPipeline(
2142 ShVkPipeline* p_pipeline
2143);
2144
2145/**
2146 * @brief Sets vertex binding information in the pipeline.
2147 *
2148 * This function sets the vertex binding description for a specific binding index in the ShVkPipeline structure.
2149 *
2150 * @param binding Binding index.
2151 * @param size Size of the vertex binding.
2152 * @param input_rate Vertex input rate.
2153 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2154 *
2155 * @return 1 if successful, 0 otherwise.
2156 */
2158 uint32_t binding,
2159 uint32_t size,
2160 VkVertexInputRate input_rate,
2161 ShVkPipeline* p_pipeline
2162);
2163
2164/**
2165 * @brief Sets vertex attribute information in the pipeline.
2166 *
2167 * This function sets the vertex attribute description for a specific location in the ShVkPipeline structure.
2168 *
2169 * @param location Location index.
2170 * @param binding Binding index.
2171 * @param format Vertex attribute format.
2172 * @param offset Offset of the vertex attribute.
2173 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2174 *
2175 * @return 1 if successful, 0 otherwise.
2176 */
2178 uint32_t location,
2179 uint32_t binding,
2180 VkFormat format,
2181 uint32_t offset,
2182 ShVkPipeline* p_pipeline
2183);
2184
2185/**
2186 * @brief Sets vertex input state information in the pipeline.
2187 *
2188 * This function sets the vertex input state information in the ShVkPipeline structure.
2189 *
2190 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2191 *
2192 * @return 1 if successful, 0 otherwise.
2193 */
2195 ShVkPipeline* p_pipeline
2196);
2197
2198/**
2199 * @brief Creates input assembly state information for the pipeline.
2200 *
2201 * This function sets the input assembly state information in the ShVkPipeline structure.
2202 *
2203 * @param primitive_topology Primitive topology used in the input assembly.
2204 * @param primitive_restart_enable Flag indicating if primitive restart is enabled.
2205 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2206 *
2207 * @return 1 if successful, 0 otherwise.
2208 */
2210 VkPrimitiveTopology primitive_topology,
2211 VkBool32 primitive_restart_enable,
2212 ShVkPipeline* p_pipeline
2213);
2214
2215/**
2216 * @brief Creates rasterizer state information for the pipeline.
2217 *
2218 * This function sets the rasterizer state information in the ShVkPipeline structure.
2219 *
2220 * @param polygon_mode Polygon mode used in rasterization.
2221 * @param cull_mode Culling mode used in rasterization.
2222 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2223 *
2224 * @return 1 if successful, 0 otherwise.
2225 */
2227 VkPolygonMode polygon_mode,
2228 VkCullModeFlagBits cull_mode,
2229 ShVkPipeline* p_pipeline
2230);
2231
2232/**
2233 * @brief Sets multisample state information in the pipeline.
2234 *
2235 * This function sets the multisample state information in the ShVkPipeline structure.
2236 *
2237 * @param sample_count Number of samples used in multisampling.
2238 * @param min_sample_shading_size Minimum sample shading size.
2239 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2240 *
2241 * @return 1 if successful, 0 otherwise.
2242 */
2244 VkSampleCountFlagBits sample_count,
2245 float min_sample_shading_size,
2246 ShVkPipeline* p_pipeline
2247);
2248
2249/**
2250 * @brief Sets viewport and scissor information in the pipeline.
2251 *
2252 * This function sets the viewport and scissor information in the ShVkPipeline structure.
2253 *
2254 * @param viewport_pos_x X position of the viewport.
2255 * @param viewport_pos_y Y position of the viewport.
2256 * @param viewport_width Width of the viewport.
2257 * @param viewport_height Height of the viewport.
2258 * @param scissors_pos_x X position of the scissors rectangle.
2259 * @param scissors_pos_y Y position of the scissors rectangle.
2260 * @param scissors_width Width of the scissors rectangle.
2261 * @param scissors_height Height of the scissors rectangle.
2262 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2263 *
2264 * @return 1 if successful, 0 otherwise.
2265 */
2267 uint32_t viewport_pos_x,
2268 uint32_t viewport_pos_y,
2269 uint32_t viewport_width,
2270 uint32_t viewport_height,
2271 uint32_t scissors_pos_x,
2272 uint32_t scissors_pos_y,
2273 uint32_t scissors_width,
2274 uint32_t scissors_height,
2275 ShVkPipeline* p_pipeline
2276);
2277
2278/**
2279 * @brief Configures color blending settings in the pipeline.
2280 *
2281 * This function sets color blending and alpha blending settings in the ShVkPipeline structure.
2282 *
2283 * @param enable_color_blending Flag indicating if color blending is enabled.
2284 * @param enable_alpha_blending Flag indicating if alpha blending is enabled.
2285 * @param subpass_color_attachment_count Number of color attachments for the subpass.
2286 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2287 *
2288 * @return 1 if successful, 0 otherwise.
2289 */
2291 uint8_t enable_color_blending,
2292 uint8_t enable_alpha_blending,
2293 uint32_t subpass_color_attachment_count,
2294 ShVkPipeline* p_pipeline
2295);
2296
2297/**
2298 * @brief Creates a shader module and adds it to the pipeline.
2299 *
2300 * This function creates a Vulkan shader module and updates the ShVkPipeline structure.
2301 *
2302 * @param device Valid Vulkan device.
2303 * @param size Size of the shader code.
2304 * @param code Pointer to the shader code.
2305 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2306 *
2307 * @return 1 if successful, 0 otherwise.
2308 */
2310 VkDevice device,
2311 uint32_t size,
2312 char* code,
2313 ShVkPipeline* p_pipeline
2314);
2315
2316/**
2317 * @brief Creates a shader stage and adds it to the pipeline.
2318 *
2319 * This function creates a Vulkan shader stage and updates the ShVkPipeline structure.
2320 *
2321 * @param shader_stage Vulkan shader stage flags (e.g., vertex, fragment).
2322 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2323 *
2324 * @return 1 if successful, 0 otherwise.
2325 */
2327 VkShaderStageFlags shader_stage,
2328 ShVkPipeline* p_pipeline
2329);
2330
2331/**
2332 * @brief Sets push constants in the pipeline.
2333 *
2334 * This function sets the push constant range for a specific shader stage in the ShVkPipeline structure.
2335 *
2336 * @param shader_stage Vulkan shader stage flags (e.g., vertex, fragment).
2337 * @param offset Offset of the push constants.
2338 * @param size Size of the push constants.
2339 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2340 *
2341 * @return 1 if successful, 0 otherwise.
2342 */
2344 VkShaderStageFlags shader_stage,
2345 uint32_t offset,
2346 uint32_t size,
2347 ShVkPipeline* p_pipeline
2348);
2349
2350/**
2351 * @brief Creates a pipeline layout and updates the pipeline structure.
2352 *
2353 * This function creates a Vulkan pipeline layout using the specified descriptor set layouts and updates the ShVkPipeline structure.
2354 *
2355 * @param device Valid Vulkan device.
2356 * @param first_descriptor_set_layout Index of the first descriptor set layout.
2357 * @param descriptor_set_layout_count Number of descriptor set layouts.
2358 * @param p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2359 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to update.
2360 *
2361 * @return 1 if successful, 0 otherwise.
2362 */
2364 VkDevice device,
2365 uint32_t first_descriptor_set_layout,
2366 uint32_t descriptor_set_layout_count,
2367 ShVkPipelinePool* p_pipeline_pool,
2368 ShVkPipeline* p_pipeline
2369);
2370
2371/**
2372 * @brief Sets up a compute pipeline.
2373 *
2374 * This function sets up a Vulkan compute pipeline using the ShVkPipeline structure.
2375 *
2376 * @param device Valid Vulkan device.
2377 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to setup.
2378 *
2379 * @return 1 if successful, 0 otherwise.
2380 */
2382 VkDevice device,
2383 ShVkPipeline* p_pipeline
2384);
2385
2386/**
2387 * @brief Sets up a graphics pipeline.
2388 *
2389 * This function sets up a Vulkan graphics pipeline using the ShVkPipeline structure and the specified render pass.
2390 *
2391 * @param device Valid Vulkan device.
2392 * @param render_pass Valid Vulkan render pass.
2393 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to setup.
2394 *
2395 * @return 1 if successful, 0 otherwise.
2396 */
2398 VkDevice device,
2399 VkRenderPass render_pass,
2400 ShVkPipeline* p_pipeline
2401);
2402
2403/**
2404 * @brief Pushes constants to a pipeline using the command buffer.
2405 *
2406 * This function updates the push constants for a pipeline within a command buffer.
2407 *
2408 * @param cmd_buffer Valid Vulkan command buffer.
2409 * @param p_data Pointer to the data to be pushed to the constants.
2410 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure containing push constants information.
2411 *
2412 * @return 1 if successful, 0 otherwise.
2413 */
2415 VkCommandBuffer cmd_buffer,
2416 void* p_data,
2417 ShVkPipeline* p_pipeline
2418);
2419
2420/**
2421 * @brief Binds a pipeline to a command buffer.
2422 *
2423 * This function binds a pipeline (graphics or compute) to the command buffer for subsequent commands.
2424 *
2425 * @param cmd_buffer Valid Vulkan command buffer.
2426 * @param bind_point Pipeline bind point (e.g., VK_PIPELINE_BIND_POINT_GRAPHICS).
2427 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure to be bound.
2428 *
2429 * @return 1 if successful, 0 otherwise.
2430 */
2431extern uint8_t shBindPipeline(
2432 VkCommandBuffer cmd_buffer,
2433 VkPipelineBindPoint bind_point,
2434 ShVkPipeline* p_pipeline
2435);
2436
2437/**
2438 * @brief Binds descriptor set units to a pipeline within a command buffer.
2439 *
2440 * This function binds descriptor set units to a pipeline and command buffer, specifying dynamic offsets if needed.
2441 *
2442 * @param cmd_buffer Valid Vulkan command buffer.
2443 * @param first_descriptor_set Index of the first descriptor set.
2444 * @param first_descriptor_set_unit_idx Index of the first descriptor set unit.
2445 * @param descriptor_set_unit_count Number of descriptor set units to bind.
2446 * @param bind_point Pipeline bind point (e.g., VK_PIPELINE_BIND_POINT_GRAPHICS).
2447 * @param dynamic_descriptors_count Number of dynamic descriptors.
2448 * @param p_dynamic_offsets Array of dynamic offsets for the descriptors.
2449 * @param p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2450 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure.
2451 *
2452 * @return 1 if successful, 0 otherwise.
2453 */
2455 VkCommandBuffer cmd_buffer,
2456 uint32_t first_descriptor_set,
2457 uint32_t first_descriptor_set_unit_idx,
2459 VkPipelineBindPoint bind_point,
2460 uint32_t dynamic_descriptors_count,
2461 uint32_t* p_dynamic_offsets,
2462 ShVkPipelinePool* p_pipeline_pool,
2463 ShVkPipeline* p_pipeline
2464);
2465
2466/**
2467 * @brief Destroys shader modules associated with the pipeline.
2468 *
2469 * This function destroys a range of shader modules that are part of the ShVkPipeline structure.
2470 *
2471 * @param device Valid Vulkan device.
2472 * @param first_module Index of the first shader module to destroy.
2473 * @param module_count Number of shader modules to destroy.
2474 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure.
2475 *
2476 * @return 1 if successful, 0 otherwise.
2477 */
2479 VkDevice device,
2480 uint32_t first_module,
2481 uint32_t module_count,
2482 ShVkPipeline* p_pipeline
2483);
2484
2485/**
2486 * @brief Destroys the pipeline layout associated with the pipeline.
2487 *
2488 * This function destroys the pipeline layout used by the ShVkPipeline structure.
2489 *
2490 * @param device Valid Vulkan device.
2491 * @param p_pipeline Valid destination pointer to the ShVkPipeline structure.
2492 *
2493 * @return 1 if successful, 0 otherwise.
2494 */
2496 VkDevice device,
2497 ShVkPipeline* p_pipeline
2498);
2499
2500
2501
2502#define SH_PIPELINE_POOL_MAX_PIPELINE_COUNT 64
2503#define SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT 64
2504
2505
2506/**
2507 * @brief Represents a collection of Vulkan pipeline objects and their related resources.
2508 *
2509 * This structure holds arrays of Vulkan pipelines, descriptor set layouts, descriptor pools,
2510 * and other related resources required to manage and use Vulkan pipelines in a pipeline pool.
2511 */
2512typedef struct ShVkPipelinePool {
2513 ShVkPipeline pipelines[SH_PIPELINE_POOL_MAX_PIPELINE_COUNT]; ///< Array of Vulkan pipelines managed by the pool.
2514
2515 uint32_t descriptor_set_layout_binding_count; ///< Total number of descriptor set layout bindings in the pool.
2516 uint32_t src_descriptor_set_layout_count; ///< Number of source descriptor set layouts for copying or setup.
2517 uint32_t descriptor_pool_count; ///< Total number of descriptor pools created and managed by the pool.
2518 uint32_t descriptor_count; ///< Combined total of all descriptors in the descriptor pools.
2519 uint32_t write_descriptor_set_count; ///< Total number of write descriptor sets used for updates.
2520 uint32_t descriptor_set_unit_count; ///< Number of descriptor set units, equal to write_descriptor_set_count.
2521
2522 VkDescriptorSetLayoutBinding descriptor_set_layout_bindings[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Descriptor set layout bindings.
2523
2524 VkDescriptorSetLayout descriptor_set_layouts[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Descriptor set layouts.
2525
2526 VkDescriptorPool descriptor_pools[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Descriptor pools.
2527
2528 VkDescriptorSet descriptor_sets[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Descriptor sets.
2529
2530 VkDescriptorBufferInfo descriptor_buffer_infos[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Descriptor buffer info.
2531
2532 VkWriteDescriptorSet write_descriptor_sets[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]; ///< Write descriptor sets.
2533
2535
2536
2537
2538
2539/**
2540 * @brief Allocates a new ShVkPipelinePool structure.
2541 *
2542 * This macro allocates heap memory for a new ShVkPipelinePool structure and initializes it to zero.
2543 *
2544 * @return Pointer to the newly allocated ShVkPipelinePool structure, or NULL if allocation fails.
2545 */
2546#define shAllocatePipelinePool() ((ShVkPipelinePool*)calloc(1, sizeof(ShVkPipelinePool)))
2547
2548/**
2549 * @brief Frees the memory of an ShVkPipelinePool structure.
2550 *
2551 * This macro frees the memory allocated on the heap for an ShVkPipelinePool structure.
2552 *
2553 * @param ptr Pointer to the ShVkPipelinePool structure to be freed.
2554 */
2555#define shFreePipelinePool free
2556
2557
2558/**
2559 * @brief Creates a descriptor set layout binding for the pipeline pool.
2560 *
2561 * This function initializes a descriptor set layout binding in the pipeline pool.
2562 *
2563 * @param binding Binding index in the descriptor set layout.
2564 * @param descriptor_type Type of the descriptor (e.g., VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER).
2565 * @param descriptor_set_count Number of descriptor sets.
2566 * @param shader_stage Shader stages that use this descriptor.
2567 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2568 *
2569 * @return 1 if successful, 0 otherwise.
2570 */
2572 uint32_t binding,
2573 VkDescriptorType descriptor_type,
2574 uint32_t descriptor_set_count,
2575 VkShaderStageFlags shader_stage,
2576 ShVkPipelinePool* p_pipeline_pool
2577);
2578
2579/**
2580 * @brief Creates descriptor set layouts in the pipeline pool.
2581 *
2582 * This function initializes descriptor set layouts in the pipeline pool.
2583 *
2584 * @param device Valid Vulkan device.
2585 * @param first_binding_idx Index of the first binding in the layout.
2586 * @param binding_count Number of bindings.
2587 * @param set_layout_idx Index of the set layout to initialize.
2588 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2589 *
2590 * @return 1 if successful, 0 otherwise.
2591 */
2593 VkDevice device,
2594 uint32_t first_binding_idx,
2595 uint32_t binding_count,
2596 uint32_t set_layout_idx,//set_idx
2597 ShVkPipelinePool* p_pipeline_pool
2598);
2599
2600/**
2601 * @brief Copies descriptor set layouts within the pipeline pool.
2602 *
2603 * This function copies descriptor set layouts from source indices to destination indices in the pipeline pool.
2604 *
2605 * @param src_set_layout_idx Index of the source descriptor set layout.
2606 * @param first_dst_set_layout_idx Index of the first destination descriptor set layout.
2607 * @param dst_set_layout_count Number of destination descriptor set layouts.
2608 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2609 *
2610 * @return 1 if successful, 0 otherwise.
2611 */
2613 uint32_t src_set_layout_idx,
2614 uint32_t first_dst_set_layout_idx,
2615 uint32_t dst_set_layout_count,
2616 ShVkPipelinePool* p_pipeline_pool
2617);
2618
2619/**
2620 * @brief Creates a descriptor pool in the pipeline pool.
2621 *
2622 * This function initializes a descriptor pool in the pipeline pool.
2623 *
2624 * @param device Valid Vulkan device.
2625 * @param pool_idx Index of the pool to initialize.
2626 * @param descriptor_type Type of the descriptor (e.g., VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER).
2627 * @param descriptor_count Number of descriptors in the pool.
2628 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2629 *
2630 * @return 1 if successful, 0 otherwise.
2631 */
2633 VkDevice device,
2634 uint32_t pool_idx,
2635 VkDescriptorType descriptor_type,
2636 uint32_t descriptor_count,
2637 ShVkPipelinePool* p_pipeline_pool
2638);
2639
2640/**
2641 * @brief Allocates descriptor set units in the pipeline pool.
2642 *
2643 * This function allocates descriptor set units for the pipeline pool.
2644 *
2645 * @param device Valid Vulkan device.
2646 * @param binding Binding index in the descriptor set layout.
2647 * @param pool_idx Index of the descriptor pool.
2648 * @param descriptor_type Type of the descriptor (e.g., VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER).
2649 * @param first_descriptor_set_unit Index of the first descriptor set unit to allocate.
2650 * @param descriptor_set_unit_count Number of descriptor set units to allocate.
2651 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2652 *
2653 * @return 1 if successful, 0 otherwise.
2654 */
2656 VkDevice device,
2657 uint32_t binding,
2658 uint32_t pool_idx,
2659 VkDescriptorType descriptor_type,
2660 uint32_t first_descriptor_set_unit,
2661 uint32_t descriptor_set_unit_count,
2662 ShVkPipelinePool* p_pipeline_pool
2663);
2664
2665/**
2666 * @brief Sets descriptor buffer infos in the pipeline pool.
2667 *
2668 * This function sets the buffer information for descriptors in the pipeline pool.
2669 *
2670 * @param first_descriptor Index of the first descriptor to set.
2671 * @param descriptor_count Number of descriptors to update.
2672 * @param buffer Vulkan buffer to associate with the descriptors.
2673 * @param buffer_offset Offset into the buffer.
2674 * @param buffer_size Size of the buffer.
2675 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2676 *
2677 * @return 1 if successful, 0 otherwise.
2678 */
2680 uint32_t first_descriptor,
2681 uint32_t descriptor_count,
2682 VkBuffer buffer,
2683 uint32_t buffer_offset,
2684 uint32_t buffer_size,
2685 ShVkPipelinePool* p_pipeline_pool
2686);
2687
2688/**
2689 * @brief Destroys descriptor set layouts in the pipeline pool.
2690 *
2691 * This function destroys a range of descriptor set layouts in the pipeline pool.
2692 *
2693 * @param device Valid Vulkan device.
2694 * @param first_set_layout Index of the first descriptor set layout to destroy.
2695 * @param set_layout_count Number of descriptor set layouts to destroy.
2696 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2697 *
2698 * @return 1 if successful, 0 otherwise.
2699 */
2701 VkDevice device,
2702 uint32_t first_set_layout,
2703 uint32_t set_layout_count,
2704 ShVkPipelinePool* p_pipeline_pool
2705);
2706
2707/**
2708 * @brief Destroys descriptor pools in the pipeline pool.
2709 *
2710 * This function destroys a range of descriptor pools in the pipeline pool.
2711 *
2712 * @param device Valid Vulkan device.
2713 * @param first_pool Index of the first descriptor pool to destroy.
2714 * @param pool_count Number of descriptor pools to destroy.
2715 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2716 *
2717 * @return 1 if successful, 0 otherwise.
2718 */
2720 VkDevice device,
2721 uint32_t first_pool,
2722 uint32_t pool_count,
2723 ShVkPipelinePool* p_pipeline_pool
2724);
2725
2726/**
2727 * @brief Updates descriptor set units in the pipeline pool.
2728 *
2729 * This function updates the descriptor set units within the pipeline pool.
2730 *
2731 * @param device Valid Vulkan device.
2732 * @param first_descriptor_set_unit Index of the first descriptor set unit to update.
2733 * @param descriptor_set_unit_count Number of descriptor set units to update.
2734 * @param[in,out] p_pipeline_pool Valid pointer to the ShVkPipelinePool structure.
2735 *
2736 * @return 1 if successful, 0 otherwise.
2737 */
2739 VkDevice device,
2740 uint32_t first_descriptor_set_unit,
2741 uint32_t descriptor_set_unit_count,
2742 ShVkPipelinePool* p_pipeline_pool
2743);
2744
2745
2746
2747#ifdef __cplusplus
2748}
2749#endif//__cplusplus
2750
2751#endif//SH_VULKAN_H
uint8_t shGetQueueFamilySurfaceSupport(VkPhysicalDevice physical_device, uint32_t queue_family_index, VkSurfaceKHR surface, uint8_t *p_support)
Checks if a queue family supports presenting to a surface.
uint8_t shDestroyFences(VkDevice device, uint32_t fence_count, VkFence *p_fences)
Destroys Vulkan fences.
uint8_t shPipelineSetVertexBinding(uint32_t binding, uint32_t size, VkVertexInputRate input_rate, ShVkPipeline *p_pipeline)
Sets vertex binding information in the pipeline.
uint8_t shSetupGraphicsPipeline(VkDevice device, VkRenderPass render_pass, ShVkPipeline *p_pipeline)
Sets up a graphics pipeline.
#define SH_MAX_PIPELINE_VERTEX_ATTRIBUTE_COUNT
Definition shVulkan.h:2083
uint8_t shDrawIndexed(VkCommandBuffer graphics_cmd_buffer, uint32_t index_count, uint32_t instance_count, uint32_t first_index, int32_t vertex_offset, uint32_t first_instance)
Records an indexed draw command into a Vulkan command buffer.
uint8_t shDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptor_set_layout)
Destroys a Vulkan descriptor set layout.
uint8_t shSetVertexAttribute(uint32_t location, uint32_t binding, VkFormat format, uint32_t offset, VkVertexInputAttributeDescription *p_vertex_input_attribute)
Sets the vertex attribute description.
uint8_t shEndRenderpass(VkCommandBuffer graphics_cmd_buffer)
Ends a Vulkan render pass.
uint8_t shPipelineCreateShaderStage(VkShaderStageFlags shader_stage, ShVkPipeline *p_pipeline)
Creates a shader stage and adds it to the pipeline.
uint8_t shCopyBufferRegions(VkCommandBuffer transfer_cmd_buffer, VkBuffer src_buffer, uint32_t region_count, uint32_t *p_src_offsets, uint32_t *p_dst_offsets, uint32_t *p_sizes, VkBuffer dst_buffer)
Copies multiple regions of data from one Vulkan buffer to another.
uint8_t shCreateRenderpassAttachmentReference(uint32_t attachment_idx, VkImageLayout layout, VkAttachmentReference *p_attachment_reference)
Creates a Vulkan render pass attachment reference.
uint8_t shUnmapMemory(VkDevice device, VkDeviceMemory memory)
uint8_t shDestroyRenderpass(VkDevice device, VkRenderPass render_pass)
Destroys a Vulkan render pass.
uint8_t shCombineMaxSamples(VkPhysicalDeviceProperties physical_device_properties, uint32_t sample_count, uint8_t combine_color_sample, uint8_t combine_depth_sample, uint32_t *p_sample_count)
Combines sample counts based on physical device properties.
uint8_t shCreateDescriptorPool(VkDevice device, uint32_t pool_size_count, VkDescriptorPoolSize *p_pool_sizes, VkDescriptorPool *p_descriptor_pool)
Creates a descriptor pool.
uint8_t shQueuePresentSwapchainImage(VkQueue present_queue, uint32_t semaphores_to_wait_for_count, VkSemaphore *p_semaphores_to_wait_for, VkSwapchainKHR swapchain, uint32_t swapchain_image_idx)
Presents an image from a Vulkan swapchain to the screen.
uint8_t shWaitDeviceIdle(VkDevice device)
Waits for a Vulkan device to become idle.
uint8_t shFindSupportedDeviceColorFormats(VkPhysicalDevice physical_device, uint32_t min_channel_count, uint32_t max_channel_count, uint32_t min_channel_size, uint32_t max_channel_size, ShImageChannelTypeFlags channel_types, uint32_t *p_supported_format_count, VkFormat *p_supported_formats, uint32_t *p_channels_count, uint32_t *p_single_channels_sizes, uint32_t *p_channels_types)
uint8_t shDraw(VkCommandBuffer graphics_cmd_buffer, uint32_t vertex_count, uint32_t first_vertex, uint32_t instance_count, uint32_t first_instance)
Records a draw command into a Vulkan command buffer.
uint8_t shCreateRenderpass(VkDevice device, uint32_t attachment_count, VkAttachmentDescription *p_attachments_descriptions, uint32_t subpass_count, VkSubpassDescription *p_subpasses, VkRenderPass *p_renderpass)
Creates a Vulkan render pass.
uint8_t shPipelinePushConstants(VkCommandBuffer cmd_buffer, void *p_data, ShVkPipeline *p_pipeline)
Pushes constants to a pipeline using the command buffer.
uint8_t shPipelineSetViewport(uint32_t viewport_pos_x, uint32_t viewport_pos_y, uint32_t viewport_width, uint32_t viewport_height, uint32_t scissors_pos_x, uint32_t scissors_pos_y, uint32_t scissors_width, uint32_t scissors_height, ShVkPipeline *p_pipeline)
Sets viewport and scissor information in the pipeline.
uint8_t shCreateFramebuffer(VkDevice device, VkRenderPass renderpass, uint32_t image_view_count, VkImageView *p_image_views, uint32_t x, uint32_t y, uint32_t z, VkFramebuffer *p_framebuffer)
Creates a Vulkan framebuffer.
uint8_t shCreateSwapchainImageViews(VkDevice device, VkFormat format, uint32_t swapchain_image_count, VkImage *p_swapchain_images, VkImageView *p_swapchain_image_views)
Creates image views for swapchain images.
uint8_t shGetMemoryType(VkDevice device, VkPhysicalDevice physical_device, VkMemoryPropertyFlags property_flags, uint32_t *p_memory_type_index)
Retrieves the memory type index that supports the specified memory properties.
uint8_t shGetPhysicalDeviceSurfaceCapabilities(VkPhysicalDevice physical_device, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *p_surface_capabilities, uint32_t clamp_current_extent_width_value, uint32_t clamp_current_extent_height_value)
Retrieves the surface capabilities of a physical device.
uint8_t shPipelineColorBlendSettings(uint8_t enable_color_blending, uint8_t enable_alpha_blending, uint32_t subpass_color_attachment_count, ShVkPipeline *p_pipeline)
Configures color blending settings in the pipeline.
uint8_t shPipelinePoolCreateDescriptorSetLayout(VkDevice device, uint32_t first_binding_idx, uint32_t binding_count, uint32_t set_layout_idx, ShVkPipelinePool *p_pipeline_pool)
Creates descriptor set layouts in the pipeline pool.
uint8_t shPipelineSetPushConstants(VkShaderStageFlags shader_stage, uint32_t offset, uint32_t size, ShVkPipeline *p_pipeline)
Sets push constants in the pipeline.
uint8_t shCreateDescriptorSetLayoutBinding(uint32_t binding, VkDescriptorType descriptor_type, uint32_t descriptor_set_count, VkShaderStageFlags shader_stage, VkDescriptorSetLayoutBinding *p_binding)
Creates a descriptor set layout binding.
uint8_t shPipelineCreateInputAssembly(VkPrimitiveTopology primitive_topology, VkBool32 primitive_restart_enable, ShVkPipeline *p_pipeline)
Creates input assembly state information for the pipeline.
uint8_t shSetupComputePipeline(VkDevice device, ShVkPipeline *p_pipeline)
Sets up a compute pipeline.
uint8_t shWriteMemory(VkDevice device, VkDeviceMemory memory, uint32_t offset, uint32_t data_size, void *p_data)
Writes data to a Vulkan memory object.
uint8_t shSetDescriptorBufferInfo(VkBuffer buffer, uint32_t buffer_offset, uint32_t buffer_size, VkDescriptorBufferInfo *p_buffer_info)
Sets buffer information for a descriptor buffer.
uint8_t shBindIndexBuffer(VkCommandBuffer graphics_cmd_buffer, uint32_t index_offset, VkBuffer index_buffer)
Binds an index buffer to a Vulkan command buffer.
uint8_t shGetPhysicalDeviceSurfaceSupport(VkPhysicalDevice physical_device, uint32_t queue_family_index, VkSurfaceKHR surface, uint8_t *p_supported)
Queries if a queue family supports presenting to a surface.
uint8_t shSelectPhysicalDevice(VkInstance instance, VkSurfaceKHR surface, VkQueueFlags requirements, VkPhysicalDevice *p_physical_device, VkPhysicalDeviceProperties *p_physical_device_properties, VkPhysicalDeviceFeatures *p_physical_device_features, VkPhysicalDeviceMemoryProperties *p_physical_device_memory_properties)
Selects a physical device that meets specified requirements.
uint8_t shDestroySemaphores(VkDevice device, uint32_t semaphore_count, VkSemaphore *p_semaphores)
Destroys Vulkan semaphores.
#define SH_MAX_PIPELINE_SUBPASS_COLOR_ATTACHMENT_COUNT
Definition shVulkan.h:2087
uint8_t shSetPushConstants(VkShaderStageFlags shader_stage, uint32_t offset, uint32_t size, VkPushConstantRange *p_push_constant_range)
Sets push constants for a shader stage.
uint8_t shDestroyInstance(VkInstance instance)
Destroys a Vulkan instance.
uint8_t shPipelinePoolDestroyDescriptorSetLayouts(VkDevice device, uint32_t first_set_layout, uint32_t set_layout_count, ShVkPipelinePool *p_pipeline_pool)
Destroys descriptor set layouts in the pipeline pool.
uint8_t shDestroyCommandBuffers(VkDevice device, VkCommandPool cmd_pool, uint32_t cmd_buffer_count, VkCommandBuffer *p_cmd_buffers)
Destroys Vulkan command buffers.
uint8_t shAcquireSwapchainImage(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout_ns, VkSemaphore acquired_signal_semaphore, VkFence acquired_signal_fence, uint32_t *p_swapchain_image_index, uint8_t *p_swapchain_suboptimal)
Acquires an image from the Vulkan swapchain.
uint8_t shEndCommandBuffer(VkCommandBuffer cmd_buffer)
Ends recording commands into a Vulkan command buffer.
uint8_t shPipelineCreateShaderModule(VkDevice device, uint32_t size, char *code, ShVkPipeline *p_pipeline)
Creates a shader module and adds it to the pipeline.
#define SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT
Definition shVulkan.h:2503
uint8_t shPipelinePoolAllocateDescriptorSetUnits(VkDevice device, uint32_t binding, uint32_t pool_idx, VkDescriptorType descriptor_type, uint32_t first_descriptor_set_unit, uint32_t descriptor_set_unit_count, ShVkPipelinePool *p_pipeline_pool)
Allocates descriptor set units in the pipeline pool.
uint8_t shGetImageSubresourceLayout(VkDevice device, VkImage image, VkImageAspectFlags image_aspect_mask, VkSubresourceLayout *p_subresource_layout)
uint8_t shCreateRasterizer(VkPolygonMode polygon_mode, VkCullModeFlagBits cull_mode, VkPipelineRasterizationStateCreateInfo *p_rasterizer)
Creates the rasterization state for a pipeline.
uint8_t shGetSwapchainImages(VkDevice device, VkSwapchainKHR swapchain, uint32_t *p_swapchain_image_count, VkImage *p_swapchain_images)
Retrieves the images in a swapchain.
uint8_t shPipelinePoolSetDescriptorBufferInfos(uint32_t first_descriptor, uint32_t descriptor_count, VkBuffer buffer, uint32_t buffer_offset, uint32_t buffer_size, ShVkPipelinePool *p_pipeline_pool)
Sets descriptor buffer infos in the pipeline pool.
uint8_t shCreateSubpass(VkPipelineBindPoint bind_point, uint32_t input_attachment_count, VkAttachmentReference *p_input_attachments_reference, uint32_t color_attachment_count, VkAttachmentReference *p_color_attachments_reference, VkAttachmentReference *p_depth_stencil_attachment_reference, VkAttachmentReference *p_resolve_attachment_reference, uint32_t preserve_attachment_count, uint32_t *p_preserve_attachments, VkSubpassDescription *p_subpass)
Creates a Vulkan subpass description.
uint8_t shPipelineCreateLayout(VkDevice device, uint32_t first_descriptor_set_layout, uint32_t descriptor_set_layout_count, ShVkPipelinePool *p_pipeline_pool, ShVkPipeline *p_pipeline)
Creates a pipeline layout and updates the pipeline structure.
uint8_t shBeginRenderpass(VkCommandBuffer graphics_cmd_buffer, VkRenderPass renderpass, int32_t render_offset_x, int32_t render_offset_y, uint32_t render_size_x, uint32_t render_size_y, uint32_t clear_value_count, VkClearValue *p_clear_values, VkFramebuffer framebuffer)
Begins a Vulkan render pass.
uint8_t shPipelineDestroyShaderModules(VkDevice device, uint32_t first_module, uint32_t module_count, ShVkPipeline *p_pipeline)
Destroys shader modules associated with the pipeline.
uint8_t shCreateFences(VkDevice device, uint32_t fence_count, uint8_t signaled, VkFence *p_fences)
Creates Vulkan fences.
uint8_t shQueryForDeviceQueueInfo(uint32_t queue_family_index, uint32_t queue_count, float *p_queue_priorities, uint8_t protected, VkDeviceQueueCreateInfo *p_device_queue_info)
Queries information for device queue creation.
uint8_t shFindValidationLayer(const char *validation_layer_name)
Searches for a specific Vulkan validation layer.
uint8_t shAllocateDescriptorSetUnits(VkDevice device, VkDescriptorPool descriptor_pool, VkDescriptorType descriptor_type, uint32_t binding, uint32_t descriptor_set_unit_count, VkDescriptorSetLayout *p_descriptor_set_layouts, VkDescriptorSet *p_descriptor_sets, VkDescriptorBufferInfo *p_buffer_infos, VkWriteDescriptorSet *p_write_descriptor_sets)
Allocates descriptor sets from a descriptor pool.
uint8_t shDestroyDevice(VkDevice device)
Destroys a Vulkan device.
uint8_t shPipelinePoolCreateDescriptorSetLayoutBinding(uint32_t binding, VkDescriptorType descriptor_type, uint32_t descriptor_set_count, VkShaderStageFlags shader_stage, ShVkPipelinePool *p_pipeline_pool)
Creates a descriptor set layout binding for the pipeline pool.
uint8_t shQueueSubmit(uint32_t cmd_buffer_count, VkCommandBuffer *p_cmd_buffers, VkQueue queue, VkFence fence, uint32_t semaphores_to_wait_for_count, VkSemaphore *p_semaphores_to_wait_for, VkPipelineStageFlags wait_stage, uint32_t signal_semaphore_count, VkSemaphore *p_signal_semaphores)
Submits command buffers to a Vulkan queue.
uint8_t shCreatePipelineLayout(VkDevice device, uint32_t push_constant_range_count, VkPushConstantRange *p_push_constants_range, uint32_t src_descriptor_set_layout_count, VkDescriptorSetLayout *p_src_descriptor_set_layouts, VkPipelineLayout *p_pipeline_layout)
Creates a pipeline layout.
uint8_t shBindVertexBuffers(VkCommandBuffer graphics_cmd_buffer, uint32_t first_binding, uint32_t binding_count, VkBuffer *p_vertex_buffers, VkDeviceSize *p_vertex_offsets)
Binds vertex buffers to a Vulkan command buffer.
uint8_t shSetBufferMemoryBarrier(VkDevice device, VkCommandBuffer cmd_buffer, VkBuffer buffer, VkAccessFlags access_before_barrier, VkAccessFlags access_after_barrier, uint32_t performing_queue_family_index_before_barrier, uint32_t performing_queue_family_index_after_barrier, VkPipelineStageFlags pipeline_stage_before_barrier, VkPipelineStageFlags pipeline_stage_after_barrier)
Creates a buffer memory barrier.
uint8_t shGetMemoryBudgetProperties(VkPhysicalDevice physical_device, VkPhysicalDeviceMemoryBudgetPropertiesEXT *p_memory_budget_properties)
Retrieves memory budget properties for a Vulkan physical device.
uint8_t shSetImageMemoryBarrier(VkDevice device, VkCommandBuffer cmd_buffer, VkImage image, VkImageAspectFlags image_aspect_mask, VkAccessFlags access_before_barrier, VkAccessFlags access_after_barrier, VkImageLayout image_layout_before_barrier, VkImageLayout image_layout_after_barrier, uint32_t performing_queue_family_index_before_barrier, uint32_t performing_queue_family_index_after_barrier, VkPipelineStageFlags pipeline_stage_before_barrier, VkPipelineStageFlags pipeline_stage_after_barrier)
Creates an image memory barrier.
uint8_t shSetViewport(uint32_t viewport_pos_x, uint32_t viewport_pos_y, uint32_t viewport_width, uint32_t viewport_height, VkViewport *p_viewport, uint32_t scissors_pos_x, uint32_t scissors_pos_y, uint32_t scissors_width, uint32_t scissors_height, VkRect2D *p_scissors, VkPipelineViewportStateCreateInfo *p_viewport_state)
Sets the viewport and scissor state for a pipeline.
uint8_t shCreateSemaphores(VkDevice device, uint32_t semaphore_count, VkSemaphore *p_semaphores)
Creates Vulkan semaphores.
uint8_t shCmdDispatch(VkCommandBuffer cmd_buffer, uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z)
Dispatches compute work from a Vulkan command buffer.
uint8_t shCopyBuffer(VkCommandBuffer transfer_cmd_buffer, VkBuffer src_buffer, uint32_t src_offset, uint32_t dst_offset, uint64_t size, VkBuffer dst_buffer)
Copies data from one Vulkan buffer to another.
uint8_t shSetMultisampleState(VkSampleCountFlagBits sample_count, float min_sample_shading_size, VkPipelineMultisampleStateCreateInfo *p_multisample_state)
Sets the multisample state for a pipeline.
uint8_t shDestroyImageViews(VkDevice device, uint32_t image_view_count, VkImageView *p_image_views)
Destroys Vulkan image views.
uint8_t shCreateShaderStage(VkShaderModule shader_module, VkShaderStageFlags shader_stage_flag, VkPipelineShaderStageCreateInfo *p_shader_stage)
Creates a Vulkan shader stage.
uint8_t shDestroySurface(VkInstance instance, VkSurfaceKHR surface)
Destroys a Vulkan surface.
uint8_t shSetVertexBinding(uint32_t binding, uint32_t size, VkVertexInputRate input_rate, VkVertexInputBindingDescription *p_vertex_input_binding)
Sets the vertex input binding description.
uint8_t shCreateBuffer(VkDevice device, uint32_t size, VkBufferUsageFlags usage, VkSharingMode sharing_mode, VkBuffer *p_buffer)
Creates a Vulkan buffer.
uint8_t shPipelineDestroyLayout(VkDevice device, ShVkPipeline *p_pipeline)
Destroys the pipeline layout associated with the pipeline.
uint8_t shBindImageMemory(VkDevice device, VkImage image, uint32_t offset, VkDeviceMemory image_memory)
Binds a Vulkan image to a specified memory offset.
uint8_t shPipelinePoolDestroyDescriptorPools(VkDevice device, uint32_t first_pool, uint32_t pool_count, ShVkPipelinePool *p_pipeline_pool)
Destroys descriptor pools in the pipeline pool.
uint8_t shCreateImage(VkDevice device, VkImageType type, uint32_t x, uint32_t y, uint32_t z, VkFormat format, uint32_t mip_levels, VkSampleCountFlagBits sample_count, VkImageTiling image_tiling, VkImageUsageFlags usage, VkSharingMode sharing_mode, VkImage *p_image)
Creates a Vulkan image.
uint8_t shPipelineSetVertexInputState(ShVkPipeline *p_pipeline)
Sets vertex input state information in the pipeline.
uint8_t shDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipeline_layout)
Destroys a Vulkan pipeline layout.
ShImageChannelTypeFlags
Definition shVulkan.h:360
@ SH_IMAGE_CHANNEL_TYPE_SFLOAT
Definition shVulkan.h:365
@ SH_IMAGE_CHANNEL_TYPE_SNORM
Definition shVulkan.h:362
@ SH_IMAGE_CHANNEL_TYPE_UNORM
Definition shVulkan.h:361
@ SH_IMAGE_CHANNEL_TYPE_UINT
Definition shVulkan.h:363
@ SH_IMAGE_CHANNEL_TYPE_UNDEFINED
Definition shVulkan.h:366
@ SH_IMAGE_CHANNEL_TYPE_SINT
Definition shVulkan.h:364
uint8_t shResetFences(VkDevice device, uint32_t fence_count, VkFence *p_fences)
Resets Vulkan fences.
uint8_t shDestroyShaderModule(VkDevice device, VkShaderModule shader_module)
Destroys a Vulkan shader module.
uint8_t shGetPhysicalDeviceQueueFamilies(VkPhysicalDevice physical_device, VkSurfaceKHR surface, uint32_t *p_queue_family_count, uint32_t *p_graphics_queue_family_count, uint32_t *p_surface_queue_family_count, uint32_t *p_compute_queue_family_count, uint32_t *p_transfer_queue_family_count, uint32_t *p_graphics_queue_family_indices, uint32_t *p_surface_queue_family_indices, uint32_t *p_compute_queue_family_indices, uint32_t *p_transfer_queue_family_indices, VkQueueFamilyProperties *p_queue_families_properties)
Retrieves the queue family indices for a physical device.
uint8_t shReadMemory(VkDevice device, VkDeviceMemory memory, uint32_t offset, uint64_t data_size, void **pp_map_data, void *p_dst_data)
Reads data from a Vulkan memory object.
uint8_t shResetSemaphores(VkDevice device, uint32_t semaphore_count, VkSemaphore *p_semaphores)
Resets Vulkan semaphores.
uint8_t shPipelinePoolUpdateDescriptorSetUnits(VkDevice device, uint32_t first_descriptor_set_unit, uint32_t descriptor_set_unit_count, ShVkPipelinePool *p_pipeline_pool)
Updates descriptor set units in the pipeline pool.
uint8_t shSetLogicalDevice(VkPhysicalDevice physical_device, VkDevice *p_device, uint32_t extension_count, char **pp_extension_names, uint32_t device_queue_count, VkDeviceQueueCreateInfo *p_device_queue_infos)
Sets up a Vulkan logical device.
uint8_t shDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptor_pool)
Destroys a Vulkan descriptor pool.
uint8_t shDestroyPipeline(VkDevice device, VkPipeline pipeline)
Destroys a Vulkan pipeline.
uint8_t shWaitForSemaphores(VkDevice device, uint32_t semaphore_count, VkSemaphore *p_semaphores, uint8_t wait_for_all, uint64_t timeout_ns, uint64_t *p_semaphores_values)
Waits for Vulkan semaphores to become signaled.
uint8_t shAllocateBufferMemory(VkDevice device, VkPhysicalDevice physical_device, VkBuffer buffer, VkMemoryPropertyFlags property_flags, VkDeviceMemory *p_memory)
Allocates memory for a Vulkan buffer.
uint8_t shDestroyCommandPool(VkDevice device, VkCommandPool cmd_pool)
Destroys a Vulkan command pool.
uint8_t shPipelineCreateRasterizer(VkPolygonMode polygon_mode, VkCullModeFlagBits cull_mode, ShVkPipeline *p_pipeline)
Creates rasterizer state information for the pipeline.
const char * shTranslateVkResult(VkResult vk_result)
Translates a VkResult enum into a literal string.
uint8_t shCreateImageView(VkDevice device, VkImage image, VkImageViewType view_type, VkImageAspectFlagBits image_aspect, uint32_t mip_levels, VkFormat format, VkImageView *p_image_view)
Creates a Vulkan image view.
uint8_t shCreateShaderModule(VkDevice device, uint32_t size, char *code, VkShaderModule *p_shader_module)
Creates a Vulkan shader module.
uint8_t shPipelinePoolCreateDescriptorPool(VkDevice device, uint32_t pool_idx, VkDescriptorType descriptor_type, uint32_t descriptor_count, ShVkPipelinePool *p_pipeline_pool)
Creates a descriptor pool in the pipeline pool.
uint8_t shBindPipeline(VkCommandBuffer cmd_buffer, VkPipelineBindPoint bind_point, ShVkPipeline *p_pipeline)
Binds a pipeline to a command buffer.
uint8_t shCreateSwapchain(VkDevice device, VkPhysicalDevice physical_device, VkSurfaceCapabilitiesKHR surface_capabilities, VkSurfaceKHR surface, VkFormat image_format, VkFormat *p_image_format, uint32_t swapchain_image_count, VkSharingMode image_sharing_mode, uint8_t vsync, uint32_t *p_swapchain_image_count, VkSwapchainKHR *p_swapchain)
Creates a Vulkan swapchain.
uint8_t shCheckSupportedDeviceColorFormat(VkPhysicalDevice physical_device, VkFormat format, uint8_t *p_color_attachment_supported)
uint8_t shCreateCommandPool(VkDevice device, uint32_t queue_family_index, VkCommandPool *p_cmd_pool)
Creates a Vulkan command pool.
uint8_t shCreateInputAssembly(VkPrimitiveTopology primitive_topology, VkBool32 primitive_restart_enable, VkPipelineInputAssemblyStateCreateInfo *p_input_assembly)
Creates the input assembly state for a pipeline.
uint8_t shDestroyFramebuffers(VkDevice device, uint32_t framebuffer_count, VkFramebuffer *p_framebuffers)
Destroys Vulkan framebuffers.
uint8_t shAllocateImageMemory(VkDevice device, VkPhysicalDevice physical_device, VkImage image, VkMemoryPropertyFlags memory_property_flags, VkDeviceMemory *p_image_memory)
Allocates memory for a Vulkan image.
uint8_t shCopyImage(VkCommandBuffer transfer_cmd_buffer, uint32_t width, uint32_t height, VkImageAspectFlags src_image_aspect, VkImageAspectFlags dst_image_aspect, VkImage src_image, VkImage dst_image)
uint8_t shWaitForFences(VkDevice device, uint32_t fence_count, VkFence *p_fences, uint8_t wait_for_all, uint64_t timeout_ns)
Waits for Vulkan fences to become signaled.
uint8_t shClearPipeline(ShVkPipeline *p_pipeline)
Clears the pipeline structure.
uint8_t shResetCommandBuffer(VkCommandBuffer cmd_buffer)
Resets a Vulkan command buffer.
uint8_t shCreateRenderpassAttachment(VkFormat format, uint32_t sample_count, VkAttachmentLoadOp load_treatment, VkAttachmentStoreOp store_treatment, VkAttachmentLoadOp stencil_load_treatment, VkAttachmentStoreOp stencil_store_treatment, VkImageLayout initial_layout, VkImageLayout final_layout, VkAttachmentDescription *p_attachment_description)
Creates a Vulkan render pass attachment description.
uint8_t shPipelineSetMultisampleState(VkSampleCountFlagBits sample_count, float min_sample_shading_size, ShVkPipeline *p_pipeline)
Sets multisample state information in the pipeline.
uint8_t shClearImageMemory(VkDevice device, VkImage image, VkDeviceMemory image_memory)
Clears memory associated with a Vulkan image.
uint8_t shPipelinePoolCopyDescriptorSetLayout(uint32_t src_set_layout_idx, uint32_t first_dst_set_layout_idx, uint32_t dst_set_layout_count, ShVkPipelinePool *p_pipeline_pool)
Copies descriptor set layouts within the pipeline pool.
uint8_t shAllocateCommandBuffers(VkDevice device, VkCommandPool cmd_pool, uint32_t cmd_buffer_count, VkCommandBuffer *p_cmd_buffer)
Allocates command buffers from a command pool.
uint8_t shColorBlendSettings(uint8_t enable_color_blending, uint8_t enable_alpha_blending, uint32_t subpass_color_attachment_count, VkPipelineColorBlendAttachmentState *p_color_blend_attachment_states, VkPipelineColorBlendStateCreateInfo *p_color_blend_state)
Configures color blending and alpha blending states.
uint8_t shCreateInstance(const char *application_name, const char *engine_name, const uint8_t enable_validation_layers, const uint32_t extension_count, const char **pp_extension_names, uint32_t api_version, VkInstance *p_instance)
Creates a Vulkan instance.
#define SH_PIPELINE_POOL_MAX_PIPELINE_COUNT
Definition shVulkan.h:2502
uint8_t shPipelineBindDescriptorSetUnits(VkCommandBuffer cmd_buffer, uint32_t first_descriptor_set, uint32_t first_descriptor_set_unit_idx, uint32_t descriptor_set_unit_count, VkPipelineBindPoint bind_point, uint32_t dynamic_descriptors_count, uint32_t *p_dynamic_offsets, ShVkPipelinePool *p_pipeline_pool, ShVkPipeline *p_pipeline)
Binds descriptor set units to a pipeline within a command buffer.
uint8_t shGetDeviceQueues(VkDevice device, uint32_t queue_count, uint32_t *p_queue_family_indices, VkQueue *p_queues)
Retrieves the Vulkan queues from a device.
uint8_t shPipelineSetVertexAttribute(uint32_t location, uint32_t binding, VkFormat format, uint32_t offset, ShVkPipeline *p_pipeline)
Sets vertex attribute information in the pipeline.
uint8_t shDestroySwapchain(VkDevice device, VkSwapchainKHR swapchain)
Destroys a Vulkan swapchain.
uint8_t shClearBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory)
Clears memory associated with a Vulkan buffer.
#define SH_MAX_PIPELINE_SHADER_STAGE_COUNT
Definition shVulkan.h:2085
uint8_t shBeginCommandBuffer(VkCommandBuffer cmd_buffer)
Begins recording commands into a Vulkan command buffer.
uint8_t shWaitForQueue(VkQueue queue)
Waits for a Vulkan queue to become idle.
#define SH_MAX_PIPELINE_VERTEX_BINDING_COUNT
Definition shVulkan.h:2082
uint8_t shBindBufferMemory(VkDevice device, VkBuffer buffer, uint32_t offset, VkDeviceMemory buffer_memory)
Binds a Vulkan buffer to a specified memory offset.
uint8_t shCreateDescriptorSetLayout(VkDevice device, uint32_t binding_count, VkDescriptorSetLayoutBinding *p_bindings, VkDescriptorSetLayout *p_descriptor_set_layout)
Creates a descriptor set layout.
uint8_t shSetVertexInputState(uint32_t vertex_binding_count, VkVertexInputBindingDescription *p_vertex_bindings, uint32_t vertex_attribute_count, VkVertexInputAttributeDescription *p_vertex_attributes, VkPipelineVertexInputStateCreateInfo *p_vertex_input_state)
Sets the vertex input state for a pipeline.
Represents a collection of Vulkan pipeline objects and their related resources.
Definition shVulkan.h:2512
VkDescriptorSetLayout descriptor_set_layouts[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Descriptor set layouts.
Definition shVulkan.h:2524
uint32_t descriptor_count
Combined total of all descriptors in the descriptor pools.
Definition shVulkan.h:2518
ShVkPipeline pipelines[SH_PIPELINE_POOL_MAX_PIPELINE_COUNT]
Array of Vulkan pipelines managed by the pool.
Definition shVulkan.h:2513
VkDescriptorPool descriptor_pools[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Descriptor pools.
Definition shVulkan.h:2526
uint32_t descriptor_pool_count
Total number of descriptor pools created and managed by the pool.
Definition shVulkan.h:2517
uint32_t descriptor_set_layout_binding_count
Total number of descriptor set layout bindings in the pool.
Definition shVulkan.h:2515
uint32_t write_descriptor_set_count
Total number of write descriptor sets used for updates.
Definition shVulkan.h:2519
uint32_t descriptor_set_unit_count
Number of descriptor set units, equal to write_descriptor_set_count.
Definition shVulkan.h:2520
uint32_t src_descriptor_set_layout_count
Number of source descriptor set layouts for copying or setup.
Definition shVulkan.h:2516
VkDescriptorSet descriptor_sets[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Descriptor sets.
Definition shVulkan.h:2528
VkDescriptorSetLayoutBinding descriptor_set_layout_bindings[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Descriptor set layout bindings.
Definition shVulkan.h:2522
VkWriteDescriptorSet write_descriptor_sets[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Write descriptor sets.
Definition shVulkan.h:2532
VkDescriptorBufferInfo descriptor_buffer_infos[SH_MAX_PIPELINE_POOL_DESCRIPTOR_COUNT]
Descriptor buffer info.
Definition shVulkan.h:2530
Structure representing a Vulkan pipeline.
Definition shVulkan.h:2095
VkPushConstantRange push_constant_range
Push constant range information.
Definition shVulkan.h:2109
VkPipelineInputAssemblyStateCreateInfo input_assembly
Input assembly state information.
Definition shVulkan.h:2102
VkPipeline pipeline
Vulkan pipeline.
Definition shVulkan.h:2123
uint32_t vertex_attribute_count
Number of vertex attributes.
Definition shVulkan.h:2099
VkPipelineColorBlendStateCreateInfo color_blend_state
Color blend state information.
Definition shVulkan.h:2118
VkRect2D scissors
Scissor rectangle information.
Definition shVulkan.h:2114
VkShaderModule shader_modules[SH_MAX_PIPELINE_SHADER_STAGE_COUNT]
Array of shader modules.
Definition shVulkan.h:2105
VkPipelineVertexInputStateCreateInfo vertex_input_state_info
Vertex input state information.
Definition shVulkan.h:2101
VkVertexInputAttributeDescription vertex_attributes[SH_MAX_PIPELINE_VERTEX_ATTRIBUTE_COUNT]
Array of vertex input attributes.
Definition shVulkan.h:2100
VkPipelineViewportStateCreateInfo viewport_state
Viewport state information.
Definition shVulkan.h:2115
VkPipelineShaderStageCreateInfo shader_stages[SH_MAX_PIPELINE_SHADER_STAGE_COUNT]
Array of shader stage create info.
Definition shVulkan.h:2107
VkVertexInputBindingDescription vertex_bindings[SH_MAX_PIPELINE_VERTEX_BINDING_COUNT]
Array of vertex input bindings.
Definition shVulkan.h:2098
VkViewport viewport
Viewport information.
Definition shVulkan.h:2113
uint32_t vertex_binding_count
Number of vertex bindings.
Definition shVulkan.h:2097
uint32_t shader_module_count
Number of shader modules.
Definition shVulkan.h:2104
VkPipelineMultisampleStateCreateInfo multisample_state_info
Multisample state information.
Definition shVulkan.h:2120
VkPipelineRasterizationStateCreateInfo rasterizer
Rasterizer state information.
Definition shVulkan.h:2111
uint32_t shader_stage_count
Number of shader stages.
Definition shVulkan.h:2106
VkPipelineColorBlendAttachmentState color_blend_attachment_states[SH_MAX_PIPELINE_SUBPASS_COLOR_ATTACHMENT_COUNT]
Array of color blend attachment states.
Definition shVulkan.h:2117
VkPipelineLayout pipeline_layout
Vulkan pipeline layout.
Definition shVulkan.h:2122