13 #ifndef VULKAN_RUNTIME_H
14 #define VULKAN_RUNTIME_H
18 #include <unordered_map>
20 #include <vulkan/vulkan.h>
30 VkDescriptorType descriptorType{VK_DESCRIPTOR_TYPE_MAX_ENUM};
31 VkDescriptorBufferInfo bufferInfo{};
32 VkBuffer hostBuffer{VK_NULL_HANDLE};
33 VkDeviceMemory hostMemory{VK_NULL_HANDLE};
34 VkBuffer deviceBuffer{VK_NULL_HANDLE};
35 VkDeviceMemory deviceMemory{VK_NULL_HANDLE};
36 uint32_t bufferSize{0};
60 uint32_t descriptorSize{0};
62 VkDescriptorType descriptorType{VK_DESCRIPTOR_TYPE_MAX_ENUM};
68 std::unordered_map<BindingIndex, VulkanHostMemoryBuffer>>;
82 std::unordered_map<BindingIndex, SPIRVStorageClass>>;
104 void setShaderModule(uint8_t *shader, uint32_t size);
105 void setNumWorkGroups(
const NumWorkGroups &numberWorkGroups);
106 void setResourceStorageClassBindingMap(
108 void setEntryPoint(
const char *entryPointName);
111 LogicalResult initRuntime();
117 LogicalResult updateHostMemoryBuffers();
120 LogicalResult destroy();
127 LogicalResult createInstance();
128 LogicalResult createDevice();
129 LogicalResult getBestComputeQueue();
130 LogicalResult createMemoryBuffers();
131 LogicalResult createShaderModule();
132 void initDescriptorSetLayoutBindingMap();
133 LogicalResult createDescriptorSetLayout();
134 LogicalResult createPipelineLayout();
135 LogicalResult createComputePipeline();
136 LogicalResult createDescriptorPool();
137 LogicalResult allocateDescriptorSets();
138 LogicalResult setWriteDescriptors();
139 LogicalResult createCommandPool();
140 LogicalResult createQueryPool();
141 LogicalResult createComputeCommandBuffer();
142 LogicalResult submitCommandBuffersToQueue();
145 LogicalResult copyResource(
bool deviceToHost);
154 VkDescriptorType &descriptorType);
159 VkBufferUsageFlagBits &bufferUsage);
161 LogicalResult countDeviceMemorySize();
167 VkInstance instance{VK_NULL_HANDLE};
168 VkPhysicalDevice physicalDevice{VK_NULL_HANDLE};
169 VkDevice device{VK_NULL_HANDLE};
170 VkQueue queue{VK_NULL_HANDLE};
173 std::unordered_map<DescriptorSetIndex, std::vector<VulkanDeviceMemoryBuffer>>
174 deviceMemoryBufferMap;
177 VkShaderModule shaderModule{VK_NULL_HANDLE};
181 std::vector<VkDescriptorSetLayoutBinding>>
182 descriptorSetLayoutBindingMap;
185 std::vector<VkDescriptorSetLayout> descriptorSetLayouts;
186 VkPipelineLayout pipelineLayout{VK_NULL_HANDLE};
189 std::vector<VkDescriptorSet> descriptorSets;
193 std::vector<DescriptorSetInfo> descriptorSetInfoPool;
194 VkDescriptorPool descriptorPool{VK_NULL_HANDLE};
197 VkQueryPool queryPool{VK_NULL_HANDLE};
199 float timestampPeriod{0.f};
202 VkPipeline pipeline{VK_NULL_HANDLE};
203 VkCommandPool commandPool{VK_NULL_HANDLE};
204 std::vector<VkCommandBuffer> commandBuffers;
210 uint32_t queueFamilyIndex{0};
211 VkQueueFamilyProperties queueFamilyProperties{};
212 uint32_t hostMemoryTypeIndex{VK_MAX_MEMORY_TYPES};
213 uint32_t deviceMemoryTypeIndex{VK_MAX_MEMORY_TYPES};
214 VkDeviceSize memorySize{0};
221 const char *entryPoint{
nullptr};
222 uint8_t *binary{
nullptr};
223 uint32_t binarySize{0};
uint32_t DescriptorSetIndex
SPIRVStorageClass
SPIR-V storage classes.
std::unordered_map< DescriptorSetIndex, std::unordered_map< BindingIndex, VulkanHostMemoryBuffer > > ResourceData
VulkanHostMemoryBuffer mapped into a descriptor set and a binding.
std::unordered_map< DescriptorSetIndex, std::unordered_map< BindingIndex, SPIRVStorageClass > > ResourceStorageClassBindingMap
StorageClass mapped into a descriptor set and a binding.
VulkanRuntime(const VulkanRuntime &)=delete
VulkanRuntime & operator=(const VulkanRuntime &)=delete
Include the generated interface declarations.
Struct containing information regarding a descriptor set.
Struct containing the number of local workgroups to dispatch for each dimension.
Struct containing information regarding to a device memory buffer.
Struct containing information regarding to a host memory buffer.