OSDN Git Service

Dedicated allocation verification
[android-x86/external-swiftshader.git] / src / Vulkan / libVulkan.cpp
1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "VkBuffer.hpp"
16 #include "VkBufferView.hpp"
17 #include "VkCommandBuffer.hpp"
18 #include "VkCommandPool.hpp"
19 #include "VkConfig.h"
20 #include "VkDebug.hpp"
21 #include "VkDescriptorPool.hpp"
22 #include "VkDescriptorSetLayout.hpp"
23 #include "VkDescriptorUpdateTemplate.hpp"
24 #include "VkDestroy.h"
25 #include "VkDevice.hpp"
26 #include "VkDeviceMemory.hpp"
27 #include "VkEvent.hpp"
28 #include "VkFence.hpp"
29 #include "VkFramebuffer.hpp"
30 #include "VkGetProcAddress.h"
31 #include "VkImage.hpp"
32 #include "VkImageView.hpp"
33 #include "VkInstance.hpp"
34 #include "VkPhysicalDevice.hpp"
35 #include "VkPipeline.hpp"
36 #include "VkPipelineCache.hpp"
37 #include "VkPipelineLayout.hpp"
38 #include "VkQueryPool.hpp"
39 #include "VkQueue.hpp"
40 #include "VkSampler.hpp"
41 #include "VkSemaphore.hpp"
42 #include "VkShaderModule.hpp"
43 #include "VkRenderPass.hpp"
44
45 #ifdef VK_USE_PLATFORM_XLIB_KHR
46 #include "WSI/XlibSurfaceKHR.hpp"
47 #endif
48
49 #include "WSI/VkSwapchainKHR.hpp"
50
51 #include <algorithm>
52 #include <cstring>
53 #include <string>
54
55 extern "C"
56 {
57 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName)
58 {
59         TRACE("(VkInstance instance = 0x%X, const char* pName = 0x%X)", instance, pName);
60
61         return vk::GetInstanceProcAddr(instance, pName);
62 }
63
64 VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion)
65 {
66         *pSupportedVersion = 3;
67         return VK_SUCCESS;
68 }
69
70 static const VkExtensionProperties instanceExtensionProperties[] =
71 {
72         { VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION },
73         { VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION },
74         { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION },
75         { VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION },
76         { VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION },
77         { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION },
78 #ifdef VK_USE_PLATFORM_XLIB_KHR
79         { VK_KHR_XLIB_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_SPEC_VERSION },
80 #endif
81 };
82
83 static const VkExtensionProperties deviceExtensionProperties[] =
84 {
85         { VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION },
86         { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION },
87         { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION },
88         { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION },
89         { VK_KHR_DEVICE_GROUP_EXTENSION_NAME,  VK_KHR_DEVICE_GROUP_SPEC_VERSION },
90         { VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_SPEC_VERSION },
91         { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION },
92         { VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION },
93         { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION },
94         { VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_SPEC_VERSION },
95         { VK_KHR_MAINTENANCE2_EXTENSION_NAME, VK_KHR_MAINTENANCE2_SPEC_VERSION },
96         { VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_KHR_MAINTENANCE3_SPEC_VERSION },
97         { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION },
98         { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION },
99         { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION },
100         { VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION },
101         { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION },
102         { VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION },
103         { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION },
104 };
105
106 VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
107 {
108         TRACE("(const VkInstanceCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkInstance* pInstance = 0x%X)",
109                         pCreateInfo, pAllocator, pInstance);
110
111         if(pCreateInfo->enabledLayerCount)
112         {
113                 UNIMPLEMENTED();
114         }
115
116         for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
117         {
118                 const char* currentExtensionName = pCreateInfo->ppEnabledExtensionNames[i];
119                 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
120                 bool foundExtension = false;
121
122                 for (uint32_t j = 0; j < extensionPropertiesCount; ++j)
123                 {
124                         if (strcmp(currentExtensionName, instanceExtensionProperties[j].extensionName) == 0)
125                         {
126                                 foundExtension = true;
127                                 break;
128                         }
129                 }
130
131                 if (!foundExtension)
132                 {
133                         return VK_ERROR_EXTENSION_NOT_PRESENT;
134                 }
135         }
136
137         if(pCreateInfo->pNext)
138         {
139                 switch(*reinterpret_cast<const VkStructureType*>(pCreateInfo->pNext))
140                 {
141                 case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO:
142                         // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
143                         // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
144                         //  VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
145                         //  internal use by the loader, and do not have corresponding
146                         //  Vulkan structures in this Specification."
147                         break;
148                 default:
149                         UNIMPLEMENTED();
150                 }
151         }
152
153         *pInstance = VK_NULL_HANDLE;
154         VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
155
156         VkResult result = vk::DispatchablePhysicalDevice::Create(pAllocator, pCreateInfo, &physicalDevice);
157         if(result != VK_SUCCESS)
158         {
159                 return result;
160         }
161
162         vk::Instance::CreateInfo info =
163         {
164                 pCreateInfo,
165                 physicalDevice
166         };
167
168         result = vk::DispatchableInstance::Create(pAllocator, &info, pInstance);
169         if(result != VK_SUCCESS)
170         {
171                 vk::destroy(physicalDevice, pAllocator);
172                 return result;
173         }
174
175         return result;
176 }
177
178 VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
179 {
180         TRACE("(VkInstance instance = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)", instance, pAllocator);
181
182         vk::destroy(instance, pAllocator);
183 }
184
185 VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices)
186 {
187         TRACE("(VkInstance instance = 0x%X, uint32_t* pPhysicalDeviceCount = 0x%X, VkPhysicalDevice* pPhysicalDevices = 0x%X)",
188                     instance, pPhysicalDeviceCount, pPhysicalDevices);
189
190         if(!pPhysicalDevices)
191         {
192                 *pPhysicalDeviceCount = vk::Cast(instance)->getPhysicalDeviceCount();
193         }
194         else
195         {
196                 vk::Cast(instance)->getPhysicalDevices(*pPhysicalDeviceCount, pPhysicalDevices);
197         }
198
199         return VK_SUCCESS;
200 }
201
202 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures)
203 {
204         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceFeatures* pFeatures = 0x%X)",
205                         physicalDevice, pFeatures);
206
207         *pFeatures = vk::Cast(physicalDevice)->getFeatures();
208 }
209
210 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties)
211 {
212         TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = 0x%X, VkFormat format = %d, VkFormatProperties* pFormatProperties = 0x%X)",
213                         physicalDevice, (int)format, pFormatProperties);
214
215         vk::Cast(physicalDevice)->getFormatProperties(format, pFormatProperties);
216 }
217
218 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties)
219 {
220         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkFormat format = %d, VkImageType type = %d, VkImageTiling tiling = %d, VkImageUsageFlags usage = %d, VkImageCreateFlags flags = %d, VkImageFormatProperties* pImageFormatProperties = 0x%X)",
221                         physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
222
223         VkFormatProperties properties;
224         vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
225
226         switch (tiling)
227         {
228         case VK_IMAGE_TILING_LINEAR:
229                 if (properties.linearTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
230                 break;
231
232         case VK_IMAGE_TILING_OPTIMAL:
233                 if (properties.optimalTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
234                 break;
235
236         default:
237                 UNIMPLEMENTED();
238         }
239
240         vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties);
241
242         return VK_SUCCESS;
243 }
244
245 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties)
246 {
247         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceProperties* pProperties = 0x%X)",
248                     physicalDevice, pProperties);
249
250         *pProperties = vk::Cast(physicalDevice)->getProperties();
251 }
252
253 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties)
254 {
255         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, uint32_t* pQueueFamilyPropertyCount = 0x%X, VkQueueFamilyProperties* pQueueFamilyProperties = 0x%X))", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
256
257         if(!pQueueFamilyProperties)
258         {
259                 *pQueueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
260         }
261         else
262         {
263                 vk::Cast(physicalDevice)->getQueueFamilyProperties(*pQueueFamilyPropertyCount, pQueueFamilyProperties);
264         }
265 }
266
267 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties)
268 {
269         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceMemoryProperties* pMemoryProperties = 0x%X)", physicalDevice, pMemoryProperties);
270
271         *pMemoryProperties = vk::Cast(physicalDevice)->getMemoryProperties();
272 }
273
274 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName)
275 {
276         TRACE("(VkInstance instance = 0x%X, const char* pName = 0x%X)", instance, pName);
277
278         return vk::GetInstanceProcAddr(instance, pName);
279 }
280
281 VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* pName)
282 {
283         TRACE("(VkDevice device = 0x%X, const char* pName = 0x%X)", device, pName);
284
285         return vk::GetDeviceProcAddr(device, pName);
286 }
287
288 VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
289 {
290         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkDeviceCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDevice* pDevice = 0x%X)",
291                 physicalDevice, pCreateInfo, pAllocator, pDevice);
292
293         if(pCreateInfo->enabledLayerCount)
294         {
295                 // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
296                 UNIMPLEMENTED();   // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
297         }
298
299
300         for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
301         {
302                 const char* currentExtensionName = pCreateInfo->ppEnabledExtensionNames[i];
303                 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
304                 bool foundExtension = false;
305
306                 for (uint32_t j = 0; j < extensionPropertiesCount; ++j)
307                 {
308                         if (strcmp(currentExtensionName, deviceExtensionProperties[j].extensionName) == 0)
309                         {
310                                 foundExtension = true;
311                                 break;
312                         }
313                 }
314
315                 if (!foundExtension)
316                 {
317                         return VK_ERROR_EXTENSION_NOT_PRESENT;
318                 }
319         }
320
321
322         const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
323
324         while(extensionCreateInfo)
325         {
326                 switch(extensionCreateInfo->sType)
327                 {
328                 case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
329                         // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
330                         // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
331                         //  VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
332                         //  internal use by the loader, and do not have corresponding
333                         //  Vulkan structures in this Specification."
334                         break;
335                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
336                         {
337                                 ASSERT(!pCreateInfo->pEnabledFeatures);   // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
338
339                                 const VkPhysicalDeviceFeatures2* physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2*>(extensionCreateInfo);
340
341                                 if(!vk::Cast(physicalDevice)->hasFeatures(physicalDeviceFeatures2->features))
342                                 {
343                                         return VK_ERROR_FEATURE_NOT_PRESENT;
344                                 }
345                         }
346                         break;
347                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
348                         {
349                                 const VkPhysicalDeviceSamplerYcbcrConversionFeatures* samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionCreateInfo);
350
351                                 if(samplerYcbcrConversionFeatures->samplerYcbcrConversion == VK_TRUE)
352                                 {
353                                         return VK_ERROR_FEATURE_NOT_PRESENT;
354                                 }
355                         }
356                         break;
357                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
358                         {
359                                 const VkPhysicalDevice16BitStorageFeatures* storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures*>(extensionCreateInfo);
360
361                                 if(storage16BitFeatures->storageBuffer16BitAccess == VK_TRUE ||
362                                    storage16BitFeatures->uniformAndStorageBuffer16BitAccess == VK_TRUE ||
363                                    storage16BitFeatures->storagePushConstant16 == VK_TRUE ||
364                                    storage16BitFeatures->storageInputOutput16 == VK_TRUE)
365                                 {
366                                         return VK_ERROR_FEATURE_NOT_PRESENT;
367                                 }
368                         }
369                         break;
370                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
371                         {
372                                 const VkPhysicalDeviceVariablePointerFeatures* variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures*>(extensionCreateInfo);
373
374                                 if(variablePointerFeatures->variablePointersStorageBuffer == VK_TRUE ||
375                                    variablePointerFeatures->variablePointers == VK_TRUE)
376                                 {
377                                         return VK_ERROR_FEATURE_NOT_PRESENT;
378                                 }
379                         }
380                         break;
381                 case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO:
382                         {
383                                 const VkDeviceGroupDeviceCreateInfo* groupDeviceCreateInfo = reinterpret_cast<const VkDeviceGroupDeviceCreateInfo*>(extensionCreateInfo);
384
385                                 if((groupDeviceCreateInfo->physicalDeviceCount != 1) ||
386                                    (groupDeviceCreateInfo->pPhysicalDevices[0] != physicalDevice))
387                                 {
388                                         return VK_ERROR_FEATURE_NOT_PRESENT;
389                                 }
390                         }
391                         break;
392                 default:
393                         // "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
394                         UNIMPLEMENTED();   // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
395                         break;
396                 }
397
398                 extensionCreateInfo = extensionCreateInfo->pNext;
399         }
400
401         ASSERT(pCreateInfo->queueCreateInfoCount > 0);
402
403         if(pCreateInfo->pEnabledFeatures)
404         {
405                 if(!vk::Cast(physicalDevice)->hasFeatures(*(pCreateInfo->pEnabledFeatures)))
406                 {
407                         UNIMPLEMENTED();
408                         return VK_ERROR_FEATURE_NOT_PRESENT;
409                 }
410         }
411
412         uint32_t queueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
413
414         for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
415         {
416                 const VkDeviceQueueCreateInfo& queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
417                 if(queueCreateInfo.pNext || queueCreateInfo.flags)
418                 {
419                         UNIMPLEMENTED();
420                 }
421
422                 ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
423                 (void)queueFamilyPropertyCount; // Silence unused variable warning
424         }
425
426         vk::Device::CreateInfo deviceCreateInfo =
427         {
428                 pCreateInfo,
429                 physicalDevice
430         };
431
432         return vk::DispatchableDevice::Create(pAllocator, &deviceCreateInfo, pDevice);
433 }
434
435 VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
436 {
437         TRACE("(VkDevice device = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)", device, pAllocator);
438
439         vk::destroy(device, pAllocator);
440 }
441
442 VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
443 {
444         TRACE("(const char* pLayerName = 0x%X, uint32_t* pPropertyCount = 0x%X, VkExtensionProperties* pProperties = 0x%X)",
445               pLayerName, pPropertyCount, pProperties);
446
447         uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
448
449         if(!pProperties)
450         {
451                 *pPropertyCount = extensionPropertiesCount;
452                 return VK_SUCCESS;
453         }
454
455         for(uint32_t i = 0; i < std::min(*pPropertyCount, extensionPropertiesCount); i++)
456         {
457                 pProperties[i] = instanceExtensionProperties[i];
458         }
459
460         return (*pPropertyCount < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
461 }
462
463 VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
464 {
465         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const char* pLayerName, uint32_t* pPropertyCount = 0x%X, VkExtensionProperties* pProperties = 0x%X)", physicalDevice, pPropertyCount, pProperties);
466
467         uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
468
469         if(!pProperties)
470         {
471                 *pPropertyCount = extensionPropertiesCount;
472                 return VK_SUCCESS;
473         }
474
475         for(uint32_t i = 0; i < std::min(*pPropertyCount, extensionPropertiesCount); i++)
476         {
477                 pProperties[i] = deviceExtensionProperties[i];
478         }
479
480         return (*pPropertyCount < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
481 }
482
483 VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties)
484 {
485         TRACE("(uint32_t* pPropertyCount = 0x%X, VkLayerProperties* pProperties = 0x%X)", pPropertyCount, pProperties);
486
487         if(!pProperties)
488         {
489                 *pPropertyCount = 0;
490                 return VK_SUCCESS;
491         }
492
493         return VK_SUCCESS;
494 }
495
496 VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
497 {
498         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, uint32_t* pPropertyCount = 0x%X, VkLayerProperties* pProperties = 0x%X)", physicalDevice, pPropertyCount, pProperties);
499
500         if(!pProperties)
501         {
502                 *pPropertyCount = 0;
503                 return VK_SUCCESS;
504         }
505
506         return VK_SUCCESS;
507 }
508
509 VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue)
510 {
511         TRACE("(VkDevice device = 0x%X, uint32_t queueFamilyIndex = %d, uint32_t queueIndex = %d, VkQueue* pQueue = 0x%X)",
512                     device, queueFamilyIndex, queueIndex, pQueue);
513
514         *pQueue = vk::Cast(device)->getQueue(queueFamilyIndex, queueIndex);
515 }
516
517 VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence)
518 {
519         TRACE("(VkQueue queue = 0x%X, uint32_t submitCount = %d, const VkSubmitInfo* pSubmits = 0x%X, VkFence fence = 0x%X)",
520               queue, submitCount, pSubmits, fence);
521
522         vk::Cast(queue)->submit(submitCount, pSubmits, fence);
523
524         return VK_SUCCESS;
525 }
526
527 VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
528 {
529         TRACE("(VkQueue queue = 0x%X)", queue);
530
531         vk::Cast(queue)->waitIdle();
532
533         return VK_SUCCESS;
534 }
535
536 VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
537 {
538         TRACE("(VkDevice device = 0x%X)", device);
539
540         vk::Cast(device)->waitIdle();
541
542         return VK_SUCCESS;
543 }
544
545 VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory)
546 {
547         TRACE("(VkDevice device = 0x%X, const VkMemoryAllocateInfo* pAllocateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDeviceMemory* pMemory = 0x%X)",
548                     device, pAllocateInfo, pAllocator, pMemory);
549
550         const VkBaseOutStructure* allocationInfo = reinterpret_cast<const VkBaseOutStructure*>(pAllocateInfo->pNext);
551         while(allocationInfo)
552         {
553                 switch(allocationInfo->sType)
554                 {
555                 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
556                         // This can safely be ignored, as the Vulkan spec mentions:
557                         // "If the pNext chain includes a VkMemoryDedicatedAllocateInfo structure, then that structure
558                         //  includes a handle of the sole buffer or image resource that the memory *can* be bound to."
559                         break;
560                 default:
561                         UNIMPLEMENTED();
562                         break;
563                 }
564
565                 allocationInfo = allocationInfo->pNext;
566         }
567
568         VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
569         if(result != VK_SUCCESS)
570         {
571                 return result;
572         }
573
574         // Make sure the memory allocation is done now so that OOM errors can be checked now
575         result = vk::Cast(*pMemory)->allocate();
576         if(result != VK_SUCCESS)
577         {
578                 vk::destroy(*pMemory, pAllocator);
579                 *pMemory = VK_NULL_HANDLE;
580         }
581
582         return result;
583 }
584
585 VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator)
586 {
587         TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
588                     device, memory, pAllocator);
589
590         vk::destroy(memory, pAllocator);
591 }
592
593 VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)
594 {
595         TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = 0x%X, void** ppData = 0x%X)",
596                     device, memory, offset, size, flags, ppData);
597
598         return vk::Cast(memory)->map(offset, size, ppData);
599 }
600
601 VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
602 {
603         TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X)", device, memory);
604
605         // Noop, memory will be released when the DeviceMemory object is released
606 }
607
608 VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
609 {
610         TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)",
611                     device, memoryRangeCount, pMemoryRanges);
612
613         // Noop, host and device memory are the same to SwiftShader
614
615         return VK_SUCCESS;
616 }
617
618 VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
619 {
620         TRACE("(VkDevice device = 0x%X, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = 0x%X)",
621                     device, memoryRangeCount, pMemoryRanges);
622
623         // Noop, host and device memory are the same to SwiftShader
624
625         return VK_SUCCESS;
626 }
627
628 VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize* pCommittedMemoryInBytes)
629 {
630         TRACE("(VkDevice device = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize* pCommittedMemoryInBytes = 0x%X)",
631               pDevice, pMemory, pCommittedMemoryInBytes);
632
633         auto memory = vk::Cast(pMemory);
634
635 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
636         const auto& memoryProperties = vk::Cast(vk::Cast(pDevice)->getPhysicalDevice())->getMemoryProperties();
637         uint32_t typeIndex = memory->getMemoryTypeIndex();
638         ASSERT(typeIndex < memoryProperties.memoryTypeCount);
639         ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
640 #endif
641
642         *pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
643 }
644
645 VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
646 {
647         TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize memoryOffset = %d)",
648                     device, buffer, memory, memoryOffset);
649
650         vk::Cast(buffer)->bind(memory, memoryOffset);
651
652         return VK_SUCCESS;
653 }
654
655 VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
656 {
657         TRACE("(VkDevice device = 0x%X, VkImage image = 0x%X, VkDeviceMemory memory = 0x%X, VkDeviceSize memoryOffset = %d)",
658                     device, image, memory, memoryOffset);
659
660         vk::Cast(image)->bind(memory, memoryOffset);
661
662         return VK_SUCCESS;
663 }
664
665 VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements)
666 {
667         TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, VkMemoryRequirements* pMemoryRequirements = 0x%X)",
668                     device, buffer, pMemoryRequirements);
669
670         *pMemoryRequirements = vk::Cast(buffer)->getMemoryRequirements();
671 }
672
673 VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements)
674 {
675         TRACE("(VkDevice device = 0x%X, VkImage image = 0x%X, VkMemoryRequirements* pMemoryRequirements = 0x%X)",
676                     device, image, pMemoryRequirements);
677
678         *pMemoryRequirements = vk::Cast(image)->getMemoryRequirements();
679 }
680
681 VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements)
682 {
683         TRACE("(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements)",
684               device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
685
686         // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
687         // "If the image was not created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then pSparseMemoryRequirementCount will be set to zero and pSparseMemoryRequirements will not be written to."
688         *pSparseMemoryRequirementCount = 0;
689 }
690
691 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties)
692 {
693         TRACE("(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties)",
694                         physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
695
696         // We do not support sparse images.
697         *pPropertyCount = 0;
698 }
699
700 VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence)
701 {
702         TRACE("()");
703         UNIMPLEMENTED();
704         return VK_SUCCESS;
705 }
706
707 VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
708 {
709         TRACE("(VkDevice device = 0x%X, const VkFenceCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkFence* pFence = 0x%X)",
710                     device, pCreateInfo, pAllocator, pFence);
711
712         if(pCreateInfo->pNext)
713         {
714                 UNIMPLEMENTED();
715         }
716
717         return vk::Fence::Create(pAllocator, pCreateInfo, pFence);
718 }
719
720 VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
721 {
722         TRACE("(VkDevice device = 0x%X, VkFence fence = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
723                     device, fence, pAllocator);
724
725
726         vk::destroy(fence, pAllocator);
727 }
728
729 VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences)
730 {
731         TRACE("(VkDevice device = 0x%X, uint32_t fenceCount = %d, const VkFence* pFences = 0x%X)",
732               device, fenceCount, pFences);
733
734         for(uint32_t i = 0; i < fenceCount; i++)
735         {
736                 vk::Cast(pFences[i])->reset();
737         }
738
739         return VK_SUCCESS;
740 }
741
742 VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
743 {
744         TRACE("(VkDevice device = 0x%X, VkFence fence = 0x%X)", device, fence);
745
746         return vk::Cast(fence)->getStatus();
747 }
748
749 VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
750 {
751         TRACE("(VkDevice device = 0x%X, uint32_t fenceCount = %d, const VkFence* pFences = 0x%X, VkBool32 waitAll = %d, uint64_t timeout = %d)",
752                 device, fenceCount, pFences, waitAll, timeout);
753
754         vk::Cast(device)->waitForFences(fenceCount, pFences, waitAll, timeout);
755
756         return VK_SUCCESS;
757 }
758
759 VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore)
760 {
761         TRACE("(VkDevice device = 0x%X, const VkSemaphoreCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkSemaphore* pSemaphore = 0x%X)",
762               device, pCreateInfo, pAllocator, pSemaphore);
763
764         if(pCreateInfo->pNext || pCreateInfo->flags)
765         {
766                 UNIMPLEMENTED();
767         }
768
769         return vk::Semaphore::Create(pAllocator, pCreateInfo, pSemaphore);
770 }
771
772 VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator)
773 {
774         TRACE("(VkDevice device = 0x%X, VkSemaphore semaphore = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
775               device, semaphore, pAllocator);
776
777         vk::destroy(semaphore, pAllocator);
778 }
779
780 VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent)
781 {
782         TRACE("(VkDevice device = 0x%X, const VkEventCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkEvent* pEvent = 0x%X)",
783               device, pCreateInfo, pAllocator, pEvent);
784
785         if(pCreateInfo->pNext || pCreateInfo->flags)
786         {
787                 UNIMPLEMENTED();
788         }
789
790         return vk::Event::Create(pAllocator, pCreateInfo, pEvent);
791 }
792
793 VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator)
794 {
795         TRACE("(VkDevice device = 0x%X, VkEvent event = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
796               device, event, pAllocator);
797
798         vk::destroy(event, pAllocator);
799 }
800
801 VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
802 {
803         TRACE("(VkDevice device = 0x%X, VkEvent event = 0x%X)", device, event);
804
805         return vk::Cast(event)->getStatus();
806 }
807
808 VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event)
809 {
810         TRACE("(VkDevice device = 0x%X, VkEvent event = 0x%X)", device, event);
811
812         vk::Cast(event)->signal();
813
814         return VK_SUCCESS;
815 }
816
817 VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event)
818 {
819         TRACE("(VkDevice device = 0x%X, VkEvent event = 0x%X)", device, event);
820
821         vk::Cast(event)->reset();
822
823         return VK_SUCCESS;
824 }
825
826 VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool)
827 {
828         TRACE("(VkDevice device = 0x%X, const VkQueryPoolCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkQueryPool* pQueryPool = 0x%X)",
829               device, pCreateInfo, pAllocator, pQueryPool);
830
831         if(pCreateInfo->pNext || pCreateInfo->flags)
832         {
833                 UNIMPLEMENTED();
834         }
835
836         return vk::QueryPool::Create(pAllocator, pCreateInfo, pQueryPool);
837 }
838
839 VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator)
840 {
841         TRACE("(VkDevice device = 0x%X, VkQueryPool queryPool = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
842               device, queryPool, pAllocator);
843
844         vk::destroy(queryPool, pAllocator);
845 }
846
847 VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags)
848 {
849         TRACE("(VkDevice device = 0x%X, VkQueryPool queryPool = 0x%X, uint32_t firstQuery = %d, uint32_t queryCount = %d, size_t dataSize = %d, void* pData = 0x%X, VkDeviceSize stride = 0x%X, VkQueryResultFlags flags = %d)",
850               device, queryPool, firstQuery, queryCount, dataSize, pData, stride, flags);
851
852         vk::Cast(queryPool)->getResults(firstQuery, queryCount, dataSize, pData, stride, flags);
853
854         return VK_SUCCESS;
855 }
856
857 VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer)
858 {
859         TRACE("(VkDevice device = 0x%X, const VkBufferCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkBuffer* pBuffer = 0x%X)",
860                     device, pCreateInfo, pAllocator, pBuffer);
861
862         if(pCreateInfo->pNext)
863         {
864                 UNIMPLEMENTED();
865         }
866
867         return vk::Buffer::Create(pAllocator, pCreateInfo, pBuffer);
868 }
869
870 VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator)
871 {
872         TRACE("(VkDevice device = 0x%X, VkBuffer buffer = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
873                     device, buffer, pAllocator);
874
875         vk::destroy(buffer, pAllocator);
876 }
877
878 VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)
879 {
880         TRACE("(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)",
881                 device, pCreateInfo, pAllocator, pView);
882
883         if(pCreateInfo->pNext || pCreateInfo->flags)
884         {
885                 UNIMPLEMENTED();
886         }
887
888         return vk::BufferView::Create(pAllocator, pCreateInfo, pView);
889 }
890
891 VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)
892 {
893         TRACE("(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)",
894               device, bufferView, pAllocator);
895
896         vk::destroy(bufferView, pAllocator);
897 }
898
899 VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage)
900 {
901         TRACE("(VkDevice device = 0x%X, const VkImageCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkImage* pImage = 0x%X)",
902                     device, pCreateInfo, pAllocator, pImage);
903
904         if(pCreateInfo->pNext)
905         {
906                 UNIMPLEMENTED();
907         }
908
909         vk::Image::CreateInfo imageCreateInfo =
910         {
911                 pCreateInfo,
912                 device
913         };
914
915         return vk::Image::Create(pAllocator, &imageCreateInfo, pImage);
916 }
917
918 VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
919 {
920         TRACE("(VkDevice device = 0x%X, VkImage image = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
921                     device, image, pAllocator);
922
923         vk::destroy(image, pAllocator);
924 }
925
926 VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)
927 {
928         TRACE("(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)",
929                 device, image, pSubresource, pLayout);
930
931         vk::Cast(image)->getSubresourceLayout(pSubresource, pLayout);
932 }
933
934 VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
935 {
936         TRACE("(VkDevice device = 0x%X, const VkImageViewCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkImageView* pView = 0x%X)",
937                     device, pCreateInfo, pAllocator, pView);
938
939         if(pCreateInfo->pNext || pCreateInfo->flags)
940         {
941                 UNIMPLEMENTED();
942         }
943
944         return vk::ImageView::Create(pAllocator, pCreateInfo, pView);
945 }
946
947 VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
948 {
949         TRACE("(VkDevice device = 0x%X, VkImageView imageView = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
950               device, imageView, pAllocator);
951
952         vk::destroy(imageView, pAllocator);
953 }
954
955 VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
956 {
957         TRACE("(VkDevice device = 0x%X, const VkShaderModuleCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkShaderModule* pShaderModule = 0x%X)",
958                     device, pCreateInfo, pAllocator, pShaderModule);
959
960         if(pCreateInfo->pNext || pCreateInfo->flags)
961         {
962                 UNIMPLEMENTED();
963         }
964
965         return vk::ShaderModule::Create(pAllocator, pCreateInfo, pShaderModule);
966 }
967
968 VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
969 {
970         TRACE("(VkDevice device = 0x%X, VkShaderModule shaderModule = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
971                     device, shaderModule, pAllocator);
972
973         vk::destroy(shaderModule, pAllocator);
974 }
975
976 VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)
977 {
978         TRACE("(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)",
979               device, pCreateInfo, pAllocator, pPipelineCache);
980
981         if(pCreateInfo->pNext || pCreateInfo->flags)
982         {
983                 UNIMPLEMENTED();
984         }
985
986         return vk::PipelineCache::Create(pAllocator, pCreateInfo, pPipelineCache);
987 }
988
989 VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator)
990 {
991         TRACE("(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator)",
992               device, pipelineCache, pAllocator);
993
994         vk::destroy(pipelineCache, pAllocator);
995 }
996
997 VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData)
998 {
999         TRACE("()");
1000         UNIMPLEMENTED();
1001         return VK_SUCCESS;
1002 }
1003
1004 VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches)
1005 {
1006         TRACE("()");
1007         UNIMPLEMENTED();
1008         return VK_SUCCESS;
1009 }
1010
1011 VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1012 {
1013         TRACE("(VkDevice device = 0x%X, VkPipelineCache pipelineCache = 0x%X, uint32_t createInfoCount = %d, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator = 0x%X, VkPipeline* pPipelines = 0x%X)",
1014                     device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
1015
1016         // TODO (b/123588002): Optimize based on pipelineCache.
1017
1018         VkResult errorResult = VK_SUCCESS;
1019         for(uint32_t i = 0; i < createInfoCount; i++)
1020         {
1021                 VkResult result = vk::GraphicsPipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i]);
1022                 if(result == VK_SUCCESS)
1023                 {
1024                         static_cast<vk::GraphicsPipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i]);
1025                 }
1026                 else
1027                 {
1028                         // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1029                         // "When an application attempts to create many pipelines in a single command,
1030                         //  it is possible that some subset may fail creation. In that case, the
1031                         //  corresponding entries in the pPipelines output array will be filled with
1032                         //  VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1033                         //  out of memory errors), the vkCreate*Pipelines commands will return an
1034                         //  error code. The implementation will attempt to create all pipelines, and
1035                         //  only return VK_NULL_HANDLE values for those that actually failed."
1036                         pPipelines[i] = VK_NULL_HANDLE;
1037                         errorResult = result;
1038                 }
1039         }
1040
1041         return errorResult;
1042 }
1043
1044 VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1045 {
1046         TRACE("(VkDevice device = 0x%X, VkPipelineCache pipelineCache = 0x%X, uint32_t createInfoCount = %d, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator = 0x%X, VkPipeline* pPipelines = 0x%X)",
1047                 device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
1048
1049         // TODO (b/123588002): Optimize based on pipelineCache.
1050
1051         VkResult errorResult = VK_SUCCESS;
1052         for(uint32_t i = 0; i < createInfoCount; i++)
1053         {
1054                 VkResult result = vk::ComputePipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i]);
1055                 if(result == VK_SUCCESS)
1056                 {
1057                         static_cast<vk::ComputePipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i]);
1058                 }
1059                 else
1060                 {
1061                         // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1062                         // "When an application attempts to create many pipelines in a single command,
1063                         //  it is possible that some subset may fail creation. In that case, the
1064                         //  corresponding entries in the pPipelines output array will be filled with
1065                         //  VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1066                         //  out of memory errors), the vkCreate*Pipelines commands will return an
1067                         //  error code. The implementation will attempt to create all pipelines, and
1068                         //  only return VK_NULL_HANDLE values for those that actually failed."
1069                         pPipelines[i] = VK_NULL_HANDLE;
1070                         errorResult = result;
1071                 }
1072         }
1073
1074         return errorResult;
1075 }
1076
1077 VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator)
1078 {
1079         TRACE("(VkDevice device = 0x%X, VkPipeline pipeline = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1080                     device, pipeline, pAllocator);
1081
1082         vk::destroy(pipeline, pAllocator);
1083 }
1084
1085 VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout)
1086 {
1087         TRACE("(VkDevice device = 0x%X, const VkPipelineLayoutCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkPipelineLayout* pPipelineLayout = 0x%X)",
1088                     device, pCreateInfo, pAllocator, pPipelineLayout);
1089
1090         if(pCreateInfo->pNext || pCreateInfo->flags)
1091         {
1092                 UNIMPLEMENTED();
1093         }
1094
1095         return vk::PipelineLayout::Create(pAllocator, pCreateInfo, pPipelineLayout);
1096 }
1097
1098 VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator)
1099 {
1100         TRACE("(VkDevice device = 0x%X, VkPipelineLayout pipelineLayout = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1101                     device, pipelineLayout, pAllocator);
1102
1103         vk::destroy(pipelineLayout, pAllocator);
1104 }
1105
1106 VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
1107 {
1108         TRACE("(VkDevice device = 0x%X, const VkSamplerCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkSampler* pSampler = 0x%X)",
1109                     device, pCreateInfo, pAllocator, pSampler);
1110
1111         if(pCreateInfo->pNext || pCreateInfo->flags)
1112         {
1113                 UNIMPLEMENTED();
1114         }
1115
1116         return vk::Sampler::Create(pAllocator, pCreateInfo, pSampler);
1117 }
1118
1119 VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
1120 {
1121         TRACE("(VkDevice device = 0x%X, VkSampler sampler = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1122                     device, sampler, pAllocator);
1123
1124         vk::destroy(sampler, pAllocator);
1125 }
1126
1127 VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout)
1128 {
1129         TRACE("(VkDevice device = 0x%X, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDescriptorSetLayout* pSetLayout = 0x%X)",
1130               device, pCreateInfo, pAllocator, pSetLayout);
1131
1132         if(pCreateInfo->pNext)
1133         {
1134                 UNIMPLEMENTED();
1135         }
1136
1137         return vk::DescriptorSetLayout::Create(pAllocator, pCreateInfo, pSetLayout);
1138 }
1139
1140 VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator)
1141 {
1142         TRACE("(VkDevice device = 0x%X, VkDescriptorSetLayout descriptorSetLayout = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1143               device, descriptorSetLayout, pAllocator);
1144
1145         vk::destroy(descriptorSetLayout, pAllocator);
1146 }
1147
1148 VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool)
1149 {
1150         TRACE("(VkDevice device = 0x%X, const VkDescriptorPoolCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDescriptorPool* pDescriptorPool = 0x%X)",
1151               device, pCreateInfo, pAllocator, pDescriptorPool);
1152
1153         if(pCreateInfo->pNext)
1154         {
1155                 UNIMPLEMENTED();
1156         }
1157
1158         return vk::DescriptorPool::Create(pAllocator, pCreateInfo, pDescriptorPool);
1159 }
1160
1161 VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator)
1162 {
1163         TRACE("(VkDevice device = 0x%X, VkDescriptorPool descriptorPool = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1164               device, descriptorPool, pAllocator);
1165
1166         vk::destroy(descriptorPool, pAllocator);
1167 }
1168
1169 VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
1170 {
1171         TRACE("(VkDevice device = 0x%X, VkDescriptorPool descriptorPool = 0x%X, VkDescriptorPoolResetFlags flags = 0x%X)",
1172                 device, descriptorPool, flags);
1173
1174         if(flags)
1175         {
1176                 UNIMPLEMENTED();
1177         }
1178
1179         return vk::Cast(descriptorPool)->reset();
1180 }
1181
1182 VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
1183 {
1184         TRACE("(VkDevice device = 0x%X, const VkDescriptorSetAllocateInfo* pAllocateInfo = 0x%X, VkDescriptorSet* pDescriptorSets = 0x%X)",
1185                 device, pAllocateInfo, pDescriptorSets);
1186
1187         if(pAllocateInfo->pNext)
1188         {
1189                 UNIMPLEMENTED();
1190         }
1191
1192         return vk::Cast(pAllocateInfo->descriptorPool)->allocateSets(
1193                 pAllocateInfo->descriptorSetCount, pAllocateInfo->pSetLayouts, pDescriptorSets);
1194 }
1195
1196 VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
1197 {
1198         TRACE("(VkDevice device = 0x%X, VkDescriptorPool descriptorPool = 0x%X, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = 0x%X)",
1199                 device, descriptorPool, descriptorSetCount, pDescriptorSets);
1200
1201         vk::Cast(descriptorPool)->freeSets(descriptorSetCount, pDescriptorSets);
1202
1203         return VK_SUCCESS;
1204 }
1205
1206 VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
1207 {
1208         TRACE("(VkDevice device = 0x%X, uint32_t descriptorWriteCount = %d, const VkWriteDescriptorSet* pDescriptorWrites = 0x%X, uint32_t descriptorCopyCount = %d, const VkCopyDescriptorSet* pDescriptorCopies = 0x%X)",
1209               device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
1210
1211         vk::Cast(device)->updateDescriptorSets(descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
1212 }
1213
1214 VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer)
1215 {
1216         TRACE("(VkDevice device = 0x%X, const VkFramebufferCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkFramebuffer* pFramebuffer = 0x%X)",
1217                     device, pCreateInfo, pAllocator, pFramebuffer);
1218
1219         if(pCreateInfo->pNext || pCreateInfo->flags)
1220         {
1221                 UNIMPLEMENTED();
1222         }
1223
1224         return vk::Framebuffer::Create(pAllocator, pCreateInfo, pFramebuffer);
1225 }
1226
1227 VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator)
1228 {
1229         TRACE("(VkDevice device = 0x%X, VkFramebuffer framebuffer = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)");
1230
1231         vk::destroy(framebuffer, pAllocator);
1232 }
1233
1234 VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass)
1235 {
1236         TRACE("(VkDevice device = 0x%X, const VkRenderPassCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkRenderPass* pRenderPass = 0x%X)",
1237                     device, pCreateInfo, pAllocator, pRenderPass);
1238
1239         if(pCreateInfo->pNext || pCreateInfo->flags)
1240         {
1241                 UNIMPLEMENTED();
1242         }
1243
1244         return vk::RenderPass::Create(pAllocator, pCreateInfo, pRenderPass);
1245 }
1246
1247 VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator)
1248 {
1249         TRACE("(VkDevice device = 0x%X, VkRenderPass renderPass = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1250                     device, renderPass, pAllocator);
1251
1252         vk::destroy(renderPass, pAllocator);
1253 }
1254
1255 VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity)
1256 {
1257         TRACE("(VkDevice device = 0x%X, VkRenderPass renderPass = 0x%X, VkExtent2D* pGranularity = 0x%X)",
1258               device, renderPass, pGranularity);
1259
1260         vk::Cast(renderPass)->getRenderAreaGranularity(pGranularity);
1261 }
1262
1263 VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool)
1264 {
1265         TRACE("(VkDevice device = 0x%X, const VkCommandPoolCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkCommandPool* pCommandPool = 0x%X)",
1266                     device, pCreateInfo, pAllocator, pCommandPool);
1267
1268         if(pCreateInfo->pNext)
1269         {
1270                 UNIMPLEMENTED();
1271         }
1272
1273         return vk::CommandPool::Create(pAllocator, pCreateInfo, pCommandPool);
1274 }
1275
1276 VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator)
1277 {
1278         TRACE("(VkDevice device = 0x%X, VkCommandPool commandPool = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
1279                     device, commandPool, pAllocator);
1280
1281         vk::destroy(commandPool, pAllocator);
1282 }
1283
1284 VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
1285 {
1286         TRACE("(VkDevice device = 0x%X, VkCommandPool commandPool = 0x%X, VkCommandPoolResetFlags flags = %d )",
1287                 device, commandPool, flags);
1288
1289         return vk::Cast(commandPool)->reset(flags);
1290 }
1291
1292 VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers)
1293 {
1294         TRACE("(VkDevice device = 0x%X, const VkCommandBufferAllocateInfo* pAllocateInfo = 0x%X, VkCommandBuffer* pCommandBuffers = 0x%X)",
1295                     device, pAllocateInfo, pCommandBuffers);
1296
1297         if(pAllocateInfo->pNext)
1298         {
1299                 UNIMPLEMENTED();
1300         }
1301
1302         return vk::Cast(pAllocateInfo->commandPool)->allocateCommandBuffers(
1303                 pAllocateInfo->level, pAllocateInfo->commandBufferCount, pCommandBuffers);
1304 }
1305
1306 VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
1307 {
1308         TRACE("(VkDevice device = 0x%X, VkCommandPool commandPool = 0x%X, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = 0x%X)",
1309                     device, commandPool, commandBufferCount, pCommandBuffers);
1310
1311         vk::Cast(commandPool)->freeCommandBuffers(commandBufferCount, pCommandBuffers);
1312 }
1313
1314 VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo)
1315 {
1316         TRACE("(VkCommandBuffer commandBuffer = 0x%X, const VkCommandBufferBeginInfo* pBeginInfo = 0x%X)",
1317                     commandBuffer, pBeginInfo);
1318
1319         if(pBeginInfo->pNext)
1320         {
1321                 UNIMPLEMENTED();
1322         }
1323
1324         return vk::Cast(commandBuffer)->begin(pBeginInfo->flags, pBeginInfo->pInheritanceInfo);
1325 }
1326
1327 VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
1328 {
1329         TRACE("(VkCommandBuffer commandBuffer = 0x%X)", commandBuffer);
1330
1331         return vk::Cast(commandBuffer)->end();
1332 }
1333
1334 VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags)
1335 {
1336         TRACE("VkCommandBuffer commandBuffer = 0x%X, VkCommandBufferResetFlags flags = %d", commandBuffer, flags);
1337
1338         return vk::Cast(commandBuffer)->reset(flags);
1339 }
1340
1341 VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
1342 {
1343         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkPipelineBindPoint pipelineBindPoint = %d, VkPipeline pipeline = 0x%X)",
1344                     commandBuffer, pipelineBindPoint, pipeline);
1345
1346         vk::Cast(commandBuffer)->bindPipeline(pipelineBindPoint, pipeline);
1347 }
1348
1349 VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
1350 {
1351         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t firstViewport = %d, uint32_t viewportCount = %d, const VkViewport* pViewports = 0x%X)",
1352               commandBuffer, firstViewport, viewportCount, pViewports);
1353
1354         vk::Cast(commandBuffer)->setViewport(firstViewport, viewportCount, pViewports);
1355 }
1356
1357 VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
1358 {
1359         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t firstScissor = %d, uint32_t scissorCount = %d, const VkRect2D* pScissors = 0x%X)",
1360               commandBuffer, firstScissor, scissorCount, pScissors);
1361
1362         vk::Cast(commandBuffer)->setScissor(firstScissor, scissorCount, pScissors);
1363 }
1364
1365 VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
1366 {
1367         TRACE("(VkCommandBuffer commandBuffer = 0x%X, float lineWidth = %f)", commandBuffer, lineWidth);
1368
1369         vk::Cast(commandBuffer)->setLineWidth(lineWidth);
1370 }
1371
1372 VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
1373 {
1374         TRACE("(VkCommandBuffer commandBuffer = 0x%X, float depthBiasConstantFactor = %f, float depthBiasClamp = %f, float depthBiasSlopeFactor = %f)",
1375               commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
1376
1377         vk::Cast(commandBuffer)->setDepthBias(depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
1378 }
1379
1380 VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
1381 {
1382         TRACE("(VkCommandBuffer commandBuffer = 0x%X, const float blendConstants[4] = {%f, %f, %f, %f})",
1383               commandBuffer, blendConstants[0], blendConstants[1], blendConstants[2], blendConstants[3]);
1384
1385         vk::Cast(commandBuffer)->setBlendConstants(blendConstants);
1386 }
1387
1388 VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
1389 {
1390         TRACE("(VkCommandBuffer commandBuffer = 0x%X, float minDepthBounds = %f, float maxDepthBounds = %f)",
1391               commandBuffer, minDepthBounds, maxDepthBounds);
1392
1393         vk::Cast(commandBuffer)->setDepthBounds(minDepthBounds, maxDepthBounds);
1394 }
1395
1396 VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
1397 {
1398         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkStencilFaceFlags faceMask = %d, uint32_t compareMask = %d)",
1399               commandBuffer, faceMask, compareMask);
1400
1401         vk::Cast(commandBuffer)->setStencilCompareMask(faceMask, compareMask);
1402 }
1403
1404 VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
1405 {
1406         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkStencilFaceFlags faceMask = %d, uint32_t writeMask = %d)",
1407               commandBuffer, faceMask, writeMask);
1408
1409         vk::Cast(commandBuffer)->setStencilWriteMask(faceMask, writeMask);
1410 }
1411
1412 VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
1413 {
1414         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkStencilFaceFlags faceMask = %d, uint32_t reference = %d)",
1415               commandBuffer, faceMask, reference);
1416
1417         vk::Cast(commandBuffer)->setStencilReference(faceMask, reference);
1418 }
1419
1420 VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets)
1421 {
1422         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkPipelineBindPoint pipelineBindPoint = %d, VkPipelineLayout layout = 0x%X, uint32_t firstSet = %d, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = 0x%X, uint32_t dynamicOffsetCount = %d, const uint32_t* pDynamicOffsets = 0x%X)",
1423               commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
1424
1425         vk::Cast(commandBuffer)->bindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
1426 }
1427
1428 VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
1429 {
1430         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer buffer = 0x%X, VkDeviceSize offset = %d, VkIndexType indexType = %d)",
1431               commandBuffer, buffer, offset, indexType);
1432
1433         vk::Cast(commandBuffer)->bindIndexBuffer(buffer, offset, indexType);
1434 }
1435
1436 VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
1437 {
1438         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = 0x%X, const VkDeviceSize* pOffsets = 0x%X)",
1439                     commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets);
1440
1441         vk::Cast(commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets);
1442 }
1443
1444 VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
1445 {
1446         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t vertexCount = %d, uint32_t instanceCount = %d, uint32_t firstVertex = %d, uint32_t firstInstance = %d)",
1447                     commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance);
1448
1449         vk::Cast(commandBuffer)->draw(vertexCount, instanceCount, firstVertex, firstInstance);
1450 }
1451
1452 VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
1453 {
1454         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t indexCount = %d, uint32_t instanceCount = %d, uint32_t firstIndex = %d, int32_t vertexOffset = %d, uint32_t firstInstance = %d)",
1455                     commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
1456
1457         vk::Cast(commandBuffer)->drawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
1458 }
1459
1460 VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1461 {
1462         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer buffer = 0x%X, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
1463                     commandBuffer, buffer, offset, drawCount, stride);
1464
1465         vk::Cast(commandBuffer)->drawIndirect(buffer, offset, drawCount, stride);
1466 }
1467
1468 VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1469 {
1470         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer buffer = 0x%X, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
1471                     commandBuffer, buffer, offset, drawCount, stride);
1472
1473         vk::Cast(commandBuffer)->drawIndexedIndirect(buffer, offset, drawCount, stride);
1474 }
1475
1476 VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
1477 {
1478         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t groupCountX = %d, uint32_t groupCountY = %d, uint32_t groupCountZ = %d)",
1479               commandBuffer, groupCountX, groupCountY, groupCountZ);
1480
1481         vk::Cast(commandBuffer)->dispatch(groupCountX, groupCountY, groupCountZ);
1482 }
1483
1484 VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
1485 {
1486         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer buffer = 0x%X, VkDeviceSize offset = %d)",
1487               commandBuffer, buffer, offset);
1488
1489         vk::Cast(commandBuffer)->dispatchIndirect(buffer, offset);
1490 }
1491
1492 VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
1493 {
1494         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer srcBuffer = 0x%X, VkBuffer dstBuffer = 0x%X, uint32_t regionCount = %d, const VkBufferCopy* pRegions = 0x%X)",
1495               commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
1496
1497         vk::Cast(commandBuffer)->copyBuffer(srcBuffer, dstBuffer, regionCount, pRegions);
1498 }
1499
1500 VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions)
1501 {
1502         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage srcImage = 0x%X, VkImageLayout srcImageLayout = %d, VkImage dstImage = 0x%X, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageCopy* pRegions = 0x%X)",
1503               commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
1504
1505         vk::Cast(commandBuffer)->copyImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
1506 }
1507
1508 VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter)
1509 {
1510         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage srcImage = 0x%X, VkImageLayout srcImageLayout = %d, VkImage dstImage = 0x%X, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageBlit* pRegions = 0x%X, VkFilter filter = %d)",
1511               commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
1512
1513         vk::Cast(commandBuffer)->blitImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
1514 }
1515
1516 VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1517 {
1518         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer srcBuffer = 0x%X, VkImage dstImage = 0x%X, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = 0x%X)",
1519               commandBuffer, srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
1520
1521         vk::Cast(commandBuffer)->copyBufferToImage(srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
1522 }
1523
1524 VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1525 {
1526         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage srcImage = 0x%X, VkImageLayout srcImageLayout = %d, VkBuffer dstBuffer = 0x%X, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = 0x%X)",
1527                     commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
1528
1529         vk::Cast(commandBuffer)->copyImageToBuffer(srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
1530 }
1531
1532 VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)
1533 {
1534         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer dstBuffer = 0x%X, VkDeviceSize dstOffset = %d, VkDeviceSize dataSize = %d, const void* pData = 0x%X)",
1535               commandBuffer, dstBuffer, dstOffset, dataSize, pData);
1536
1537         vk::Cast(commandBuffer)->updateBuffer(dstBuffer, dstOffset, dataSize, pData);
1538 }
1539
1540 VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
1541 {
1542         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkBuffer dstBuffer = 0x%X, VkDeviceSize dstOffset = %d, VkDeviceSize size = %d, uint32_t data = %d)",
1543               commandBuffer, dstBuffer, dstOffset, size, data);
1544
1545         vk::Cast(commandBuffer)->fillBuffer(dstBuffer, dstOffset, size, data);
1546 }
1547
1548 VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1549 {
1550         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage image = 0x%X, VkImageLayout imageLayout = %d, const VkClearColorValue* pColor = 0x%X, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = 0x%X)",
1551               commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
1552
1553         vk::Cast(commandBuffer)->clearColorImage(image, imageLayout, pColor, rangeCount, pRanges);
1554 }
1555
1556 VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1557 {
1558         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage image = 0x%X, VkImageLayout imageLayout = %d, const VkClearDepthStencilValue* pDepthStencil = 0x%X, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = 0x%X)",
1559               commandBuffer, image, imageLayout, pDepthStencil, rangeCount, pRanges);
1560
1561         vk::Cast(commandBuffer)->clearDepthStencilImage(image, imageLayout, pDepthStencil, rangeCount, pRanges);
1562 }
1563
1564 VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects)
1565 {
1566         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t attachmentCount = %d, const VkClearAttachment* pAttachments = 0x%X, uint32_t rectCount = %d, const VkClearRect* pRects = 0x%X)",
1567               commandBuffer, attachmentCount, pAttachments, rectCount,  pRects);
1568
1569         vk::Cast(commandBuffer)->clearAttachments(attachmentCount, pAttachments, rectCount, pRects);
1570 }
1571
1572 VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions)
1573 {
1574         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkImage srcImage = 0x%X, VkImageLayout srcImageLayout = %d, VkImage dstImage = 0x%X, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageResolve* pRegions = 0x%X)",
1575               commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
1576
1577         vk::Cast(commandBuffer)->resolveImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
1578 }
1579
1580 VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1581 {
1582         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkEvent event = 0x%X, VkPipelineStageFlags stageMask = %d)",
1583               commandBuffer, event, stageMask);
1584
1585         vk::Cast(commandBuffer)->setEvent(event, stageMask);
1586 }
1587
1588 VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1589 {
1590         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkEvent event = 0x%X, VkPipelineStageFlags stageMask = %d)",
1591               commandBuffer, event, stageMask);
1592
1593         vk::Cast(commandBuffer)->resetEvent(event, stageMask);
1594 }
1595
1596 VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers)
1597 {
1598         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t eventCount = %d, const VkEvent* pEvents = 0x%X, VkPipelineStageFlags srcStageMask = %d, VkPipelineStageFlags dstStageMask = %d, uint32_t memoryBarrierCount = %d, const VkMemoryBarrier* pMemoryBarriers = 0x%X, uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = 0x%X, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = 0x%X)",
1599               commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
1600
1601         vk::Cast(commandBuffer)->waitEvents(eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
1602 }
1603
1604 VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers)
1605 {
1606         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkPipelineStageFlags srcStageMask = 0x%X, VkPipelineStageFlags dstStageMask = 0x%X, VkDependencyFlags dependencyFlags = %d, uint32_t memoryBarrierCount = %d, onst VkMemoryBarrier* pMemoryBarriers = 0x%X,"
1607               " uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = 0x%X, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = 0x%X)",
1608               commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
1609
1610         vk::Cast(commandBuffer)->pipelineBarrier(srcStageMask, dstStageMask, dependencyFlags,
1611                                                  memoryBarrierCount, pMemoryBarriers,
1612                                                  bufferMemoryBarrierCount, pBufferMemoryBarriers,
1613                                                  imageMemoryBarrierCount, pImageMemoryBarriers);
1614 }
1615
1616 VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
1617 {
1618         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkQueryPool queryPool = 0x%X, uint32_t query = %d, VkQueryControlFlags flags = %d)",
1619               commandBuffer, queryPool, query, flags);
1620
1621         vk::Cast(commandBuffer)->beginQuery(queryPool, query, flags);
1622 }
1623
1624 VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
1625 {
1626         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkQueryPool queryPool = 0x%X, uint32_t query = %d)",
1627               commandBuffer, queryPool, query);
1628
1629         vk::Cast(commandBuffer)->endQuery(queryPool, query);
1630 }
1631
1632 VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
1633 {
1634         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkQueryPool queryPool = 0x%X, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
1635               commandBuffer, queryPool, firstQuery, queryCount);
1636
1637         vk::Cast(commandBuffer)->resetQueryPool(queryPool, firstQuery, queryCount);
1638 }
1639
1640 VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
1641 {
1642         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkPipelineStageFlagBits pipelineStage = %d, VkQueryPool queryPool = 0x%X, uint32_t query = %d)",
1643               commandBuffer, pipelineStage, queryPool, query);
1644
1645         vk::Cast(commandBuffer)->writeTimestamp(pipelineStage, queryPool, query);
1646 }
1647
1648 VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
1649 {
1650         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkQueryPool queryPool = 0x%X, uint32_t firstQuery = %d, uint32_t queryCount = %d, VkBuffer dstBuffer = 0x%X, VkDeviceSize dstOffset = %d, VkDeviceSize stride = %d, VkQueryResultFlags flags = %d)",
1651               commandBuffer, queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
1652
1653         vk::Cast(commandBuffer)->copyQueryPoolResults(queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
1654 }
1655
1656 VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues)
1657 {
1658         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkPipelineLayout layout = 0x%X, VkShaderStageFlags stageFlags = %d, uint32_t offset = %d, uint32_t size = %d, const void* pValues = 0x%X)",
1659               commandBuffer, layout, stageFlags, offset, size, pValues);
1660
1661         vk::Cast(commandBuffer)->pushConstants(layout, stageFlags, offset, size, pValues);
1662 }
1663
1664 VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents)
1665 {
1666         TRACE("(VkCommandBuffer commandBuffer = 0x%X, const VkRenderPassBeginInfo* pRenderPassBegin = 0x%X, VkSubpassContents contents = %d)",
1667               commandBuffer, pRenderPassBegin, contents);
1668
1669         if(pRenderPassBegin->pNext)
1670         {
1671                 UNIMPLEMENTED();
1672         }
1673
1674         vk::Cast(commandBuffer)->beginRenderPass(pRenderPassBegin->renderPass, pRenderPassBegin->framebuffer,
1675                                                  pRenderPassBegin->renderArea, pRenderPassBegin->clearValueCount,
1676                                                  pRenderPassBegin->pClearValues, contents);
1677 }
1678
1679 VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
1680 {
1681         TRACE("(VkCommandBuffer commandBuffer = 0x%X, VkSubpassContents contents = %d)",
1682               commandBuffer, contents);
1683
1684         vk::Cast(commandBuffer)->nextSubpass(contents);
1685 }
1686
1687 VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
1688 {
1689         TRACE("(VkCommandBuffer commandBuffer = 0x%X)", commandBuffer);
1690
1691         vk::Cast(commandBuffer)->endRenderPass();
1692 }
1693
1694 VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
1695 {
1696         TRACE("(VkCommandBuffer commandBuffer = 0x%X, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = 0x%X)",
1697               commandBuffer, commandBufferCount, pCommandBuffers);
1698
1699         vk::Cast(commandBuffer)->executeCommands(commandBufferCount, pCommandBuffers);
1700 }
1701
1702 VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion)
1703 {
1704         TRACE("(uint32_t* pApiVersion = 0x%X)", pApiVersion);
1705         *pApiVersion = vk::API_VERSION;
1706         return VK_SUCCESS;
1707 }
1708
1709 VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos)
1710 {
1711         TRACE("(VkDevice device = 0x%X, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = 0x%X)",
1712               device, bindInfoCount, pBindInfos);
1713
1714         for(uint32_t i = 0; i < bindInfoCount; i++)
1715         {
1716                 if(pBindInfos[i].pNext)
1717                 {
1718                         UNIMPLEMENTED();
1719                 }
1720
1721                 vk::Cast(pBindInfos[i].buffer)->bind(pBindInfos[i].memory, pBindInfos[i].memoryOffset);
1722         }
1723
1724         return VK_SUCCESS;
1725 }
1726
1727 VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos)
1728 {
1729         TRACE("()");
1730         UNIMPLEMENTED();
1731         return VK_SUCCESS;
1732 }
1733
1734 VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures)
1735 {
1736         TRACE("(VkDevice device = 0x%X, uint32_t heapIndex = %d, uint32_t localDeviceIndex = %d, uint32_t remoteDeviceIndex = %d, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures = 0x%X)",
1737               device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
1738
1739         ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
1740         UNREACHABLE("remoteDeviceIndex: %d", int(remoteDeviceIndex));   // Only one physical device is supported, and since the device indexes can't be equal, this should never be called.
1741 }
1742
1743 VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
1744 {
1745         TRACE("()");
1746         UNIMPLEMENTED();
1747 }
1748
1749 VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
1750 {
1751         TRACE("()");
1752         UNIMPLEMENTED();
1753 }
1754
1755 VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties)
1756 {
1757         TRACE("VkInstance instance = 0x%X, uint32_t* pPhysicalDeviceGroupCount = 0x%X, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = 0x%X",
1758               instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
1759
1760         if(!pPhysicalDeviceGroupProperties)
1761         {
1762                 *pPhysicalDeviceGroupCount = vk::Cast(instance)->getPhysicalDeviceGroupCount();
1763         }
1764         else
1765         {
1766                 vk::Cast(instance)->getPhysicalDeviceGroups(*pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
1767         }
1768
1769         return VK_SUCCESS;
1770 }
1771
1772 VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
1773 {
1774         TRACE("(VkDevice device = 0x%X, const VkImageMemoryRequirementsInfo2* pInfo = 0x%X, VkMemoryRequirements2* pMemoryRequirements = 0x%X)",
1775               device, pInfo, pMemoryRequirements);
1776
1777         if(pInfo->pNext || pMemoryRequirements->pNext)
1778         {
1779                 UNIMPLEMENTED();
1780         }
1781
1782         vkGetImageMemoryRequirements(device, pInfo->image, &(pMemoryRequirements->memoryRequirements));
1783 }
1784
1785 VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
1786 {
1787         TRACE("(VkDevice device = 0x%X, const VkBufferMemoryRequirementsInfo2* pInfo = 0x%X, VkMemoryRequirements2* pMemoryRequirements = 0x%X)",
1788               device, pInfo, pMemoryRequirements);
1789
1790         if(pInfo->pNext)
1791         {
1792                 UNIMPLEMENTED();
1793         }
1794
1795         VkBaseOutStructure* extensionRequirements = reinterpret_cast<VkBaseOutStructure*>(pMemoryRequirements->pNext);
1796         while(extensionRequirements)
1797         {
1798                 switch(extensionRequirements->sType)
1799                 {
1800                 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
1801                         {
1802                                 auto& requirements = *reinterpret_cast<VkMemoryDedicatedRequirements*>(extensionRequirements);
1803                                 requirements.prefersDedicatedAllocation = VK_FALSE;
1804                                 requirements.requiresDedicatedAllocation = VK_FALSE;
1805                         }
1806                         break;
1807                 default:
1808                         UNIMPLEMENTED();
1809                         break;
1810                 }
1811
1812                 extensionRequirements = extensionRequirements->pNext;
1813         }
1814
1815         vkGetBufferMemoryRequirements(device, pInfo->buffer, &(pMemoryRequirements->memoryRequirements));
1816 }
1817
1818 VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements)
1819 {
1820         TRACE("(VkDevice device = 0x%X, const VkImageSparseMemoryRequirementsInfo2* pInfo = 0x%X, uint32_t* pSparseMemoryRequirementCount = 0x%X, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = 0x%X)",
1821               device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
1822
1823         if(pInfo->pNext || pSparseMemoryRequirements->pNext)
1824         {
1825                 UNIMPLEMENTED();
1826         }
1827
1828         vkGetImageSparseMemoryRequirements(device, pInfo->image, pSparseMemoryRequirementCount, &(pSparseMemoryRequirements->memoryRequirements));
1829 }
1830
1831 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures)
1832 {
1833         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceFeatures2* pFeatures = 0x%X)", physicalDevice, pFeatures);
1834
1835         VkBaseOutStructure* extensionFeatures = reinterpret_cast<VkBaseOutStructure*>(pFeatures->pNext);
1836         while(extensionFeatures)
1837         {
1838                 switch(extensionFeatures->sType)
1839                 {
1840                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
1841                         {
1842                                 auto& features = *reinterpret_cast<VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionFeatures);
1843                                 vk::Cast(physicalDevice)->getFeatures(&features);
1844                         }
1845                         break;
1846                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
1847                         {
1848                                 auto& features = *reinterpret_cast<VkPhysicalDevice16BitStorageFeatures*>(extensionFeatures);
1849                                 vk::Cast(physicalDevice)->getFeatures(&features);
1850                         }
1851                         break;
1852                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
1853                         {
1854                                 auto& features = *reinterpret_cast<VkPhysicalDeviceVariablePointerFeatures*>(extensionFeatures);
1855                                 vk::Cast(physicalDevice)->getFeatures(&features);
1856                         }
1857                         break;
1858                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR:
1859                         {
1860                                 auto& features = *reinterpret_cast<VkPhysicalDevice8BitStorageFeaturesKHR*>(extensionFeatures);
1861                                 vk::Cast(physicalDevice)->getFeatures(&features);
1862                         }
1863                         break;
1864                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
1865                         {
1866                                 auto& features = *reinterpret_cast<VkPhysicalDeviceMultiviewFeatures*>(extensionFeatures);
1867                                 vk::Cast(physicalDevice)->getFeatures(&features);
1868                         }
1869                         break;
1870                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
1871                         {
1872                                 auto& features = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryFeatures*>(extensionFeatures);
1873                                 vk::Cast(physicalDevice)->getFeatures(&features);
1874                         }
1875                         break;
1876                 default:
1877                         // "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
1878                         UNIMPLEMENTED();   // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
1879                         break;
1880                 }
1881
1882                 extensionFeatures = extensionFeatures->pNext;
1883         }
1884
1885         vkGetPhysicalDeviceFeatures(physicalDevice, &(pFeatures->features));
1886 }
1887
1888 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties)
1889 {
1890         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceProperties2* pProperties = 0x%X)", physicalDevice, pProperties);
1891
1892         VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pProperties->pNext);
1893         while(extensionProperties)
1894         {
1895                 switch(extensionProperties->sType)
1896                 {
1897                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
1898                         {
1899                                 auto& properties = *reinterpret_cast<VkPhysicalDeviceIDProperties*>(extensionProperties);
1900                                 vk::Cast(physicalDevice)->getProperties(&properties);
1901                         }
1902                         break;
1903                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
1904                         {
1905                                 auto& properties = *reinterpret_cast<VkPhysicalDeviceMaintenance3Properties*>(extensionProperties);
1906                                 vk::Cast(physicalDevice)->getProperties(&properties);
1907                         }
1908                         break;
1909                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
1910                         {
1911                                 auto& properties = *reinterpret_cast<VkPhysicalDeviceMultiviewProperties*>(extensionProperties);
1912                                 vk::Cast(physicalDevice)->getProperties(&properties);
1913                         }
1914                         break;
1915                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
1916                         {
1917                                 auto& properties = *reinterpret_cast<VkPhysicalDevicePointClippingProperties*>(extensionProperties);
1918                                 vk::Cast(physicalDevice)->getProperties(&properties);
1919                         }
1920                         break;
1921                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
1922                         {
1923                                 auto& properties = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryProperties*>(extensionProperties);
1924                                 vk::Cast(physicalDevice)->getProperties(&properties);
1925                         }
1926                         break;
1927                 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
1928                         {
1929                                 auto& properties = *reinterpret_cast<VkPhysicalDeviceSubgroupProperties*>(extensionProperties);
1930                                 vk::Cast(physicalDevice)->getProperties(&properties);
1931                         }
1932                         break;
1933                 default:
1934                         // "the [driver] must skip over, without processing (other than reading the sType and pNext members) any structures in the chain with sType values not defined by [supported extenions]"
1935                         UNIMPLEMENTED();   // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
1936                         break;
1937                 }
1938
1939                 extensionProperties = extensionProperties->pNext;
1940         }
1941
1942         vkGetPhysicalDeviceProperties(physicalDevice, &(pProperties->properties));
1943 }
1944
1945 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties)
1946 {
1947         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkFormat format = %d, VkFormatProperties2* pFormatProperties = 0x%X)",
1948                     physicalDevice, format, pFormatProperties);
1949
1950         if(pFormatProperties->pNext)
1951         {
1952                 UNIMPLEMENTED();
1953         }
1954
1955         vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &(pFormatProperties->formatProperties));
1956 }
1957
1958 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties)
1959 {
1960         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo = 0x%X, VkImageFormatProperties2* pImageFormatProperties = 0x%X)",
1961                     physicalDevice, pImageFormatInfo, pImageFormatProperties);
1962
1963         if(pImageFormatInfo->pNext || pImageFormatProperties->pNext)
1964         {
1965                 UNIMPLEMENTED();
1966         }
1967
1968         return vkGetPhysicalDeviceImageFormatProperties(physicalDevice,
1969                                                             pImageFormatInfo->format,
1970                                                             pImageFormatInfo->type,
1971                                                             pImageFormatInfo->tiling,
1972                                                             pImageFormatInfo->usage,
1973                                                             pImageFormatInfo->flags,
1974                                                             &(pImageFormatProperties->imageFormatProperties));
1975 }
1976
1977 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties)
1978 {
1979         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, uint32_t* pQueueFamilyPropertyCount = 0x%X, VkQueueFamilyProperties2* pQueueFamilyProperties = 0x%X)",
1980                 physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
1981
1982         if(pQueueFamilyProperties && pQueueFamilyProperties->pNext)
1983         {
1984                 UNIMPLEMENTED();
1985         }
1986
1987         vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount,
1988                 pQueueFamilyProperties ? &(pQueueFamilyProperties->queueFamilyProperties) : nullptr);
1989 }
1990
1991 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties)
1992 {
1993         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkPhysicalDeviceMemoryProperties2* pMemoryProperties = 0x%X)", physicalDevice, pMemoryProperties);
1994
1995         if(pMemoryProperties->pNext)
1996         {
1997                 UNIMPLEMENTED();
1998         }
1999
2000         vkGetPhysicalDeviceMemoryProperties(physicalDevice, &(pMemoryProperties->memoryProperties));
2001 }
2002
2003 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties)
2004 {
2005         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo = 0x%X, uint32_t* pPropertyCount = 0x%X, VkSparseImageFormatProperties2* pProperties = 0x%X)",
2006              physicalDevice, pFormatInfo, pPropertyCount, pProperties);
2007
2008         if(pProperties && pProperties->pNext)
2009         {
2010                 UNIMPLEMENTED();
2011         }
2012
2013         vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, pFormatInfo->format, pFormatInfo->type,
2014                                                        pFormatInfo->samples, pFormatInfo->usage, pFormatInfo->tiling,
2015                                                        pPropertyCount, pProperties ? &(pProperties->properties) : nullptr);
2016 }
2017
2018 VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags)
2019 {
2020         TRACE("(VkDevice device = 0x%X, VkCommandPool commandPool = 0x%X, VkCommandPoolTrimFlags flags = %d)",
2021               device, commandPool, flags);
2022
2023         vk::Cast(commandPool)->trim(flags);
2024 }
2025
2026 VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue)
2027 {
2028         TRACE("(VkDevice device = 0x%X, const VkDeviceQueueInfo2* pQueueInfo = 0x%X, VkQueue* pQueue = 0x%X)",
2029               device, pQueueInfo, pQueue);
2030
2031         if(pQueueInfo->pNext)
2032         {
2033                 UNIMPLEMENTED();
2034         }
2035
2036         // The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
2037         // According to the Vulkan spec, 4.3.1. Queue Family Properties:
2038         // "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
2039         //  protected-capable queue. If the protected memory feature is not enabled,
2040         //  the VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT bit of flags must not be set."
2041         if(pQueueInfo->flags)
2042         {
2043                 *pQueue = VK_NULL_HANDLE;
2044         }
2045         else
2046         {
2047                 vkGetDeviceQueue(device, pQueueInfo->queueFamilyIndex, pQueueInfo->queueIndex, pQueue);
2048         }
2049 }
2050
2051 VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion)
2052 {
2053         TRACE("()");
2054         UNIMPLEMENTED();
2055         return VK_SUCCESS;
2056 }
2057
2058 VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator)
2059 {
2060         TRACE("()");
2061         UNIMPLEMENTED();
2062 }
2063
2064 VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate)
2065 {
2066         TRACE("(VkDevice device = 0x%X, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = 0x%X)",
2067               device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
2068
2069         if(pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET))
2070         {
2071                 UNIMPLEMENTED();
2072         }
2073
2074         return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, pDescriptorUpdateTemplate);
2075 }
2076
2077 VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator)
2078 {
2079         TRACE("(VkDevice device = 0x%X, VkDescriptorUpdateTemplate descriptorUpdateTemplate = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
2080               device, descriptorUpdateTemplate, pAllocator);
2081
2082         vk::destroy(descriptorUpdateTemplate, pAllocator);
2083 }
2084
2085 VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData)
2086 {
2087         TRACE("(VkDevice device = 0x%X, VkDescriptorSet descriptorSet = 0x%X, VkDescriptorUpdateTemplate descriptorUpdateTemplate = 0x%X, const void* pData = 0x%X)",
2088               device, descriptorSet, descriptorUpdateTemplate, pData);
2089
2090         vk::Cast(descriptorUpdateTemplate)->updateDescriptorSet(descriptorSet, pData);
2091 }
2092
2093 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties)
2094 {
2095         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo = 0x%X, VkExternalBufferProperties* pExternalBufferProperties = 0x%X)",
2096               physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
2097
2098         UNIMPLEMENTED();
2099 }
2100
2101 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties)
2102 {
2103         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo = 0x%X, VkExternalFenceProperties* pExternalFenceProperties = 0x%X)",
2104               physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
2105
2106         UNIMPLEMENTED();
2107 }
2108
2109 VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties)
2110 {
2111         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo = 0x%X, VkExternalSemaphoreProperties* pExternalSemaphoreProperties = 0x%X)",
2112               physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
2113
2114         UNIMPLEMENTED();
2115 }
2116
2117 VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport)
2118 {
2119         TRACE("(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport)",
2120               device, pCreateInfo, pSupport);
2121
2122         vk::Cast(device)->getDescriptorSetLayoutSupport(pCreateInfo, pSupport);
2123 }
2124
2125 VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator)
2126 {
2127     TRACE("(VkInstance instance = 0x%X, VkSurfaceKHR surface = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
2128             instance, surface, pAllocator);
2129
2130     vk::destroy(surface, pAllocator);
2131 }
2132
2133 #ifdef VK_USE_PLATFORM_XLIB_KHR
2134 VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2135 {
2136         TRACE("(VkInstance instance = 0x%X, VkXlibSurfaceCreateInfoKHR* pCreateInfo = 0x%X, VkAllocationCallbacks* pAllocator = 0x%X, VkSurface* pSurface = 0x%X)",
2137                         instance, pCreateInfo, pAllocator, pSurface);
2138
2139         return vk::XlibSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
2140 }
2141 #endif
2142
2143 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported)
2144 {
2145         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, uint32_t queueFamilyIndex = 0x%X, VkSurface surface = 0x%X, VKBool32* pSupported = 0x%X)",
2146                         physicalDevice, queueFamilyIndex, surface, pSupported);
2147
2148         *pSupported =  VK_TRUE;
2149         return VK_SUCCESS;
2150 }
2151
2152
2153 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
2154 {
2155         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkSurfaceKHR surface = 0x%X, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = 0x%X)",
2156                         physicalDevice, surface, pSurfaceCapabilities);
2157
2158         vk::Cast(surface)->getSurfaceCapabilities(pSurfaceCapabilities);
2159         return VK_SUCCESS;
2160 }
2161
2162 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats)
2163 {
2164         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkSurfaceKHR surface = 0x%X. uint32_t* pSurfaceFormatCount = 0x%X, VkSurfaceFormatKHR* pSurfaceFormats)",
2165                         physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
2166
2167         if(!pSurfaceFormats)
2168         {
2169                 *pSurfaceFormatCount = vk::Cast(surface)->getSurfaceFormatsCount();
2170                 return VK_SUCCESS;
2171         }
2172
2173         return vk::Cast(surface)->getSurfaceFormats(pSurfaceFormatCount, pSurfaceFormats);
2174 }
2175
2176 VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes)
2177 {
2178         TRACE("(VkPhysicalDevice physicalDevice = 0x%X, VkSurfaceKHR surface = 0x%X uint32_t* pPresentModeCount = 0x%X, VkPresentModeKHR* pPresentModes = 0x%X)",
2179                         physicalDevice, surface, pPresentModeCount, pPresentModes);
2180
2181         if(!pPresentModes)
2182         {
2183                 *pPresentModeCount = vk::Cast(surface)->getPresentModeCount();
2184                 return VK_SUCCESS;
2185         }
2186
2187         return vk::Cast(surface)->getPresentModes(pPresentModeCount, pPresentModes);
2188 }
2189
2190 VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain)
2191 {
2192         TRACE("(VkDevice device = 0x%X, const VkSwapchainCreateInfoKHR* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkSwapchainKHR* pSwapchain = 0x%X)",
2193                         device, pCreateInfo, pAllocator, pSwapchain);
2194
2195         if(pCreateInfo->oldSwapchain)
2196         {
2197                 vk::Cast(pCreateInfo->oldSwapchain)->retire();
2198         }
2199
2200         if(vk::Cast(pCreateInfo->surface)->getAssociatedSwapchain() != VK_NULL_HANDLE)
2201         {
2202                 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
2203         }
2204
2205         VkResult status = vk::SwapchainKHR::Create(pAllocator, pCreateInfo, pSwapchain);
2206
2207         if(status != VK_SUCCESS)
2208         {
2209                 return status;
2210         }
2211
2212         status = vk::Cast(*pSwapchain)->createImages(device);
2213
2214         if(status != VK_SUCCESS)
2215         {
2216                 vk::destroy(*pSwapchain, pAllocator);
2217                 return status;
2218         }
2219
2220         vk::Cast(pCreateInfo->surface)->associateSwapchain(*pSwapchain);
2221
2222         return VK_SUCCESS;
2223 }
2224
2225 VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator)
2226 {
2227         TRACE("(VkDevice device = 0x%X, VkSwapchainKHR swapchain = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
2228                         device, swapchain, pAllocator);
2229
2230         vk::destroy(swapchain, pAllocator);
2231 }
2232
2233 VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages)
2234 {
2235         TRACE("(VkDevice device = 0x%X, VkSwapchainKHR swapchain = 0x%X, uint32_t* pSwapchainImageCount = 0x%X, VkImage* pSwapchainImages = 0x%X)",
2236                         device, swapchain, pSwapchainImageCount, pSwapchainImages);
2237
2238         if(!pSwapchainImages)
2239         {
2240                 *pSwapchainImageCount = vk::Cast(swapchain)->getImageCount();
2241                 return VK_SUCCESS;
2242         }
2243
2244         return vk::Cast(swapchain)->getImages(pSwapchainImageCount, pSwapchainImages);
2245 }
2246
2247 VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex)
2248 {
2249         TRACE("(VkDevice device = 0x%X, VkSwapchainKHR swapchain = 0x%X, uint64_t timeout = 0x%X, VkSemaphore semaphore = 0x%X, VkFence fence = 0x%X, uint32_t* pImageIndex = 0x%X)",
2250                         device, swapchain, timeout, semaphore, fence, pImageIndex);
2251
2252         return vk::Cast(swapchain)->getNextImage(timeout, semaphore, fence, pImageIndex);
2253 }
2254
2255 VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
2256 {
2257         TRACE("(VkQueue queue = 0x%X, const VkPresentInfoKHR* pPresentInfo = 0x%X)",
2258                         queue, pPresentInfo);
2259
2260         vk::Cast(queue)->present(pPresentInfo);
2261
2262         return VK_SUCCESS;
2263 }
2264
2265 }