23 #include <vulkan/vulkan.h>
25 char *
sgets(
char * str,
int num,
char const **
input);
27 #ifdef VKPT_DEVICE_GROUPS
28 #define VKPT_MAX_GPUS 2
30 #define VKPT_MAX_GPUS 1
44 VkBufferUsageFlags usage,
45 VkMemoryPropertyFlags mem_properties);
52 uint32_t
get_memory_type(uint32_t mem_req_type_bits, VkMemoryPropertyFlags mem_prop);
55 #define IMAGE_BARRIER(cmd_buf, ...) \
57 VkImageMemoryBarrier img_mem_barrier = { \
58 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, \
59 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
60 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
63 vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, \
64 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, \
65 1, &img_mem_barrier); \
68 #define BUFFER_BARRIER(cmd_buf, ...) \
70 VkBufferMemoryBarrier buf_mem_barrier = { \
71 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER, \
72 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
73 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, \
76 vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, \
77 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 1, &buf_mem_barrier, \
82 #define CREATE_PIPELINE_LAYOUT(dev, layout, ...) \
84 VkPipelineLayoutCreateInfo pipeline_layout_info = { \
85 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, \
88 _VK(vkCreatePipelineLayout(dev, &pipeline_layout_info, NULL, layout)); \
96 #ifdef VKPT_ENABLE_VALIDATION
97 #define ATTACH_LABEL_VARIABLE(a, type) \
100 VkDebugMarkerObjectNameInfoEXT name_info = { \
101 .sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, \
102 .object = (uint64_t) a, \
103 .objectType = VK_DEBUG_REPORT_OBJECT_TYPE_##type##_EXT, \
106 qvkDebugMarkerSetObjectNameEXT(qvk.device, &name_info); \
109 #define ATTACH_LABEL_VARIABLE_NAME(a, type, name) \
112 VkDebugMarkerObjectNameInfoEXT name_info = { \
113 .sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT, \
114 .object = (uint64_t) a, \
115 .objectType = VK_DEBUG_REPORT_OBJECT_TYPE_##type##_EXT, \
116 .pObjectName = name, \
118 qvkDebugMarkerSetObjectNameEXT(qvk.device, &name_info); \
121 #define BEGIN_CMD_LABEL(cmd_buf, label) \
123 VkDebugUtilsLabelEXT label_info; \
124 label_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT; \
125 label_info.pNext = NULL; \
126 label_info.pLabelName = label; \
127 label_info.color[0] = label_info.color[1] = label_info.color[2] = label_info.color[3] = 1.0f; \
128 qvkCmdBeginDebugUtilsLabelEXT(cmd_buf, &label_info); \
131 #define END_CMD_LABEL(cmd_buf) \
133 qvkCmdEndDebugUtilsLabelEXT(cmd_buf); \
137 #define ATTACH_LABEL_VARIABLE(a, type) do{}while(0)
138 #define ATTACH_LABEL_VARIABLE_NAME(a, type, name) do{}while(0)
139 #define BEGIN_CMD_LABEL(cmd_buf, label) do{}while(0)
140 #define END_CMD_LABEL(cmd_buf) do{}while(0)
143 static inline size_t align(
size_t x,
size_t alignment)
145 return (x + (alignment - 1)) & ~(alignment - 1);
148 #ifdef VKPT_IMAGE_DUMPS
149 void save_to_pfm_file(
char* prefix, uint64_t frame_counter, uint64_t
width, uint64_t
height,
char* data, uint64_t rowPitch, int32_t type);