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