1#ifndef HALIDE_RUNTIME_VULKAN_INTERNAL_H
2#define HALIDE_RUNTIME_VULKAN_INTERNAL_H
37void *vk_host_malloc(
void *user_context,
size_t size,
size_t alignment, VkSystemAllocationScope scope,
const VkAllocationCallbacks *callbacks =
nullptr);
38void vk_host_free(
void *user_context,
void *ptr,
const VkAllocationCallbacks *callbacks =
nullptr);
40VulkanMemoryAllocator *vk_create_memory_allocator(
void *user_context, VkDevice device, VkPhysicalDevice physical_device,
41 const VkAllocationCallbacks *alloc_callbacks);
43int vk_destroy_memory_allocator(
void *user_context, VulkanMemoryAllocator *
allocator);
44int vk_clear_device_buffer(
void *user_context,
46 VkCommandBuffer command_buffer,
47 VkQueue command_queue,
48 VkBuffer device_buffer);
58 VkPhysicalDevice *physical_device,
59 VkQueue *queue,
uint32_t *queue_family_index);
61int vk_destroy_context(
66 VkPhysicalDevice physical_device,
69int vk_find_compute_capability(
void *user_context,
int *major,
int *minor);
71int vk_create_instance(
void *user_context,
const StringTable &requested_layers, VkInstance *instance,
const VkAllocationCallbacks *alloc_callbacks);
72int vk_destroy_instance(
void *user_context, VkInstance instance,
const VkAllocationCallbacks *alloc_callbacks);
74int vk_select_device_for_context(
void *user_context,
75 VkInstance *instance, VkDevice *device,
76 VkPhysicalDevice *physical_device,
79int vk_create_device(
void *user_context,
const StringTable &requested_layers, VkInstance *instance, VkDevice *device, VkQueue *queue,
80 VkPhysicalDevice *physical_device,
uint32_t *queue_family_index,
const VkAllocationCallbacks *alloc_callbacks);
85uint32_t vk_get_requested_layers(
void *user_context, StringTable &layer_table);
86uint32_t vk_get_required_instance_extensions(
void *user_context, StringTable &ext_table);
87uint32_t vk_get_supported_instance_extensions(
void *user_context, StringTable &ext_table);
88uint32_t vk_get_required_device_extensions(
void *user_context, StringTable &ext_table);
89uint32_t vk_get_optional_device_extensions(
void *user_context, StringTable &ext_table);
90uint32_t vk_get_supported_device_extensions(
void *user_context, VkPhysicalDevice physical_device, StringTable &ext_table);
91bool vk_validate_required_extension_support(
void *user_context,
92 const StringTable &required_extensions,
93 const StringTable &supported_extensions);
100int vk_create_command_pool(
void *user_context, VulkanMemoryAllocator *
allocator,
uint32_t queue_index, VkCommandPool *command_pool);
101int vk_destroy_command_pool(
void *user_context, VulkanMemoryAllocator *
allocator, VkCommandPool command_pool);
104int vk_create_command_buffer(
void *user_context, VulkanMemoryAllocator *
allocator, VkCommandPool pool, VkCommandBuffer *command_buffer);
105int vk_destroy_command_buffer(
void *user_context, VulkanMemoryAllocator *
allocator, VkCommandPool command_pool, VkCommandBuffer command_buffer);
107struct ScopedVulkanCommandBufferAndPool;
109int vk_fill_command_buffer_with_dispatch_call(
void *user_context,
111 VkCommandBuffer command_buffer,
112 VkPipeline compute_pipeline,
113 VkPipelineLayout pipeline_layout,
114 VkDescriptorSet descriptor_set,
116 int blocksX,
int blocksY,
int blocksZ);
118int vk_submit_command_buffer(
void *user_context, VkQueue queue, VkCommandBuffer command_buffer);
121bool vk_needs_scalar_uniform_buffer(
void *user_context,
126size_t vk_estimate_scalar_uniform_buffer_size(
void *user_context,
131MemoryRegion *vk_create_scalar_uniform_buffer(
void *user_context,
133 size_t scalar_buffer_size);
135int vk_update_scalar_uniform_buffer(
void *user_context,
137 MemoryRegion *region,
142int vk_destroy_scalar_uniform_buffer(
void *user_context, VulkanMemoryAllocator *
allocator,
143 MemoryRegion *scalar_args_region);
145int vk_create_descriptor_pool(
void *user_context,
149 VkDescriptorPool *descriptor_pool);
151int vk_destroy_descriptor_pool(
void *user_context,
153 VkDescriptorPool descriptor_pool);
156uint32_t vk_count_bindings_for_descriptor_set(
void *user_context,
161int vk_create_descriptor_set_layout(
void *user_context,
165 VkDescriptorSetLayout *layout);
167int vk_destroy_descriptor_set_layout(
void *user_context,
169 VkDescriptorSetLayout descriptor_set_layout);
172int vk_create_descriptor_set(
void *user_context,
174 VkDescriptorSetLayout descriptor_set_layout,
175 VkDescriptorPool descriptor_pool,
176 VkDescriptorSet *descriptor_set);
178int vk_update_descriptor_set(
void *user_context,
180 VkBuffer *scalar_args_buffer,
181 size_t uniform_buffer_count,
182 size_t storage_buffer_count,
186 VkDescriptorSet descriptor_set);
189int vk_create_pipeline_layout(
void *user_context,
192 VkDescriptorSetLayout *descriptor_set_layouts,
193 VkPipelineLayout *pipeline_layout);
195int vk_destroy_pipeline_layout(
void *user_context,
197 VkPipelineLayout pipeline_layout);
199int vk_create_compute_pipeline(
void *user_context,
201 const char *pipeline_name,
202 VkShaderModule shader_module,
203 VkPipelineLayout pipeline_layout,
204 VkSpecializationInfo *specialization_info,
205 VkPipeline *compute_pipeline);
207int vk_setup_compute_pipeline(
void *user_context,
209 VulkanShaderBinding *shader_bindings,
210 VkShaderModule shader_module,
211 VkPipelineLayout pipeline_layout,
212 VkPipeline *compute_pipeline);
214int vk_destroy_compute_pipeline(
void *user_context,
216 VkPipeline compute_pipeline);
219VulkanCompilationCacheEntry *vk_compile_kernel_module(
void *user_context, VulkanMemoryAllocator *
allocator,
220 const char *ptr,
int size);
223VulkanShaderBinding *vk_decode_shader_bindings(
void *user_context, VulkanMemoryAllocator *
allocator,
226VulkanCompiledShaderModule *vk_compile_shader_module(
void *user_context, VulkanMemoryAllocator *
allocator,
227 const char *src,
int size);
229int vk_destroy_shader_modules(
void *user_context, VulkanMemoryAllocator *
allocator);
232int vk_do_multidimensional_copy(
void *user_context, VkCommandBuffer command_buffer,
234 int d,
bool from_host,
bool to_host);
240VkResult vk_create_debug_utils_messenger(
void *user_context, VkInstance instance, VulkanMemoryAllocator *
allocator, VkDebugUtilsMessengerEXT *messenger);
241void vk_destroy_debug_utils_messenger(
void *user_context, VkInstance instance, VulkanMemoryAllocator *
allocator, VkDebugUtilsMessengerEXT messenger);
244const char *vk_get_error_name(VkResult error) {
249 return "VK_NOT_READY";
253 return "VK_EVENT_SET";
255 return "VK_EVENT_RESET";
257 return "VK_INCOMPLETE";
258 case VK_ERROR_OUT_OF_HOST_MEMORY:
259 return "VK_ERROR_OUT_OF_HOST_MEMORY";
260 case VK_ERROR_OUT_OF_DEVICE_MEMORY:
261 return "VK_ERROR_OUT_OF_DEVICE_MEMORY";
262 case VK_ERROR_INITIALIZATION_FAILED:
263 return "VK_ERROR_INITIALIZATION_FAILED";
264 case VK_ERROR_DEVICE_LOST:
265 return "VK_ERROR_DEVICE_LOST";
266 case VK_ERROR_MEMORY_MAP_FAILED:
267 return "VK_ERROR_MEMORY_MAP_FAILED";
268 case VK_ERROR_LAYER_NOT_PRESENT:
269 return "VK_ERROR_LAYER_NOT_PRESENT";
270 case VK_ERROR_EXTENSION_NOT_PRESENT:
271 return "VK_ERROR_EXTENSION_NOT_PRESENT";
272 case VK_ERROR_FEATURE_NOT_PRESENT:
273 return "VK_ERROR_FEATURE_NOT_PRESENT";
274 case VK_ERROR_INCOMPATIBLE_DRIVER:
275 return "VK_ERROR_INCOMPATIBLE_DRIVER";
276 case VK_ERROR_TOO_MANY_OBJECTS:
277 return "VK_ERROR_TOO_MANY_OBJECTS";
278 case VK_ERROR_FORMAT_NOT_SUPPORTED:
279 return "VK_ERROR_FORMAT_NOT_SUPPORTED";
280 case VK_ERROR_FRAGMENTED_POOL:
281 return "VK_ERROR_FRAGMENTED_POOL";
282 case VK_ERROR_SURFACE_LOST_KHR:
283 return "VK_ERROR_SURFACE_LOST_KHR";
284 case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
285 return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR";
286 case VK_SUBOPTIMAL_KHR:
287 return "VK_SUBOPTIMAL_KHR";
288 case VK_ERROR_OUT_OF_DATE_KHR:
289 return "VK_ERROR_OUT_OF_DATE_KHR";
290 case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
291 return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR";
292 case VK_ERROR_VALIDATION_FAILED_EXT:
293 return "VK_ERROR_VALIDATION_FAILED_EXT";
294 case VK_ERROR_INVALID_SHADER_NV:
295 return "VK_ERROR_INVALID_SHADER_NV";
296 case VK_ERROR_OUT_OF_POOL_MEMORY_KHR:
297 return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR";
298 case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR:
299 return "VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR";
301 return "<Unknown Vulkan Result Code>";
struct halide_buffer_t halide_buffer_t
The raw representation of an image passed around by generated Halide code.
Vulkan Memory Allocator class interface for managing large memory requests stored as contiguous block...
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
unsigned __INT32_TYPE__ uint32_t
signed __INT8_TYPE__ int8_t
VulkanMemoryAllocator * allocator