blob: 88b0312efb91f100c3439727acdf51936e0eceee [file] [log] [blame]
Alexis Hetud73b8712018-09-21 15:14:43 -04001// 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
Alexis Hetu38ff8302018-10-18 15:08:13 -040015#include "VkBuffer.hpp"
16#include "VkBufferView.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040017#include "VkCommandBuffer.hpp"
Alexis Hetu9c4ecae2018-11-20 16:26:10 -050018#include "VkCommandPool.hpp"
Alexis Hetu000df8b2018-10-24 15:22:41 -040019#include "VkConfig.h"
Alexis Hetud73b8712018-09-21 15:14:43 -040020#include "VkDebug.hpp"
Alexis Hetuc8176632019-01-22 17:01:28 -050021#include "VkDescriptorPool.hpp"
22#include "VkDescriptorSetLayout.hpp"
Alexis Hetuf705cec2019-01-29 14:09:36 -050023#include "VkDescriptorUpdateTemplate.hpp"
Alexis Hetue70c3512018-10-17 13:18:04 -040024#include "VkDestroy.h"
Alexis Hetu767b41b2018-09-26 11:25:46 -040025#include "VkDevice.hpp"
Alexis Hetu38ff8302018-10-18 15:08:13 -040026#include "VkDeviceMemory.hpp"
Alexis Hetu1f23d8c2018-10-16 14:40:19 -040027#include "VkEvent.hpp"
28#include "VkFence.hpp"
Alexis Hetu8f631c82018-11-15 15:11:36 -050029#include "VkFramebuffer.hpp"
Alexis Hetud73b8712018-09-21 15:14:43 -040030#include "VkGetProcAddress.h"
Alexis Hetuf62f3752018-11-15 14:51:15 -050031#include "VkImage.hpp"
Alexis Hetu9fbaf692018-11-19 11:30:43 -050032#include "VkImageView.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040033#include "VkInstance.hpp"
34#include "VkPhysicalDevice.hpp"
Alexis Hetu000df8b2018-10-24 15:22:41 -040035#include "VkPipeline.hpp"
Alexis Hetu18a84252018-11-19 11:30:43 -050036#include "VkPipelineCache.hpp"
Alexis Hetu000df8b2018-10-24 15:22:41 -040037#include "VkPipelineLayout.hpp"
Alexis Hetu86f8bdb2019-01-22 12:07:24 -050038#include "VkQueryPool.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040039#include "VkQueue.hpp"
Alexis Hetu5174c572018-11-19 11:30:43 -050040#include "VkSampler.hpp"
Alexis Hetu1f23d8c2018-10-16 14:40:19 -040041#include "VkSemaphore.hpp"
Alexis Hetu259ad3d2018-11-15 13:44:31 -050042#include "VkShaderModule.hpp"
Alexis Hetub16f9892018-11-15 15:18:41 -050043#include "VkRenderPass.hpp"
Nicolas Capens50b10592018-10-26 10:34:20 -040044
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080045#ifdef VK_USE_PLATFORM_XLIB_KHR
46#include "WSI/XlibSurfaceKHR.hpp"
47#endif
48
Hernan Liatisc7943e92019-02-25 19:29:54 -080049#include "WSI/VkSwapchainKHR.hpp"
50
Alexis Hetu000df8b2018-10-24 15:22:41 -040051#include <algorithm>
Chris Forbes3d27f2e2018-09-26 09:24:39 -070052#include <cstring>
Alexis Hetu767b41b2018-09-26 11:25:46 -040053#include <string>
Alexis Hetud73b8712018-09-21 15:14:43 -040054
Alexis Hetud6fae382019-04-05 13:19:46 -040055namespace
56{
57
58bool HasExtensionProperty(const char* extensionName, const VkExtensionProperties* extensionProperties, uint32_t extensionPropertiesCount)
59{
60 for(uint32_t j = 0; j < extensionPropertiesCount; ++j)
61 {
62 if(strcmp(extensionName, extensionProperties[j].extensionName) == 0)
63 {
64 return true;
65 }
66 }
67
68 return false;
69}
70
71}
72
Alexis Hetud73b8712018-09-21 15:14:43 -040073extern "C"
74{
75VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName)
76{
Ben Claytonfb280672019-04-25 11:16:15 +010077 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -050078
79 return vk::GetInstanceProcAddr(instance, pName);
Alexis Hetud73b8712018-09-21 15:14:43 -040080}
81
Hernan Liatisb2841fe2019-02-21 12:57:52 -080082VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion)
83{
84 *pSupportedVersion = 3;
85 return VK_SUCCESS;
86}
87
Hernan Liatis2bb08642019-02-08 14:08:21 -080088static const VkExtensionProperties instanceExtensionProperties[] =
89{
90 { VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION },
91 { VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION },
92 { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION },
93 { VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION },
94 { VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -070095#ifndef __ANDROID__
Hernan Liatis2bb08642019-02-08 14:08:21 -080096 { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -070097#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -080098#ifdef VK_USE_PLATFORM_XLIB_KHR
99 { VK_KHR_XLIB_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_SPEC_VERSION },
100#endif
101};
102
103static const VkExtensionProperties deviceExtensionProperties[] =
104{
105 { VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION },
106 { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION },
107 { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION },
108 { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION },
109 { VK_KHR_DEVICE_GROUP_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_SPEC_VERSION },
110 { VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_SPEC_VERSION },
111 { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION },
112 { VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION },
113 { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION },
114 { VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_SPEC_VERSION },
115 { VK_KHR_MAINTENANCE2_EXTENSION_NAME, VK_KHR_MAINTENANCE2_SPEC_VERSION },
116 { VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_KHR_MAINTENANCE3_SPEC_VERSION },
117 { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION },
118 { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION },
119 { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION },
120 { VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION },
121 { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION },
122 { VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700123#ifndef __ANDROID__
Hernan Liatiscff8c002019-02-25 15:56:36 -0800124 { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700125#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800126};
127
Alexis Hetud73b8712018-09-21 15:14:43 -0400128VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
129{
Ben Claytonfb280672019-04-25 11:16:15 +0100130 TRACE("(const VkInstanceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkInstance* pInstance = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400131 pCreateInfo, pAllocator, pInstance);
132
Alexis Hetu767b41b2018-09-26 11:25:46 -0400133 if(pCreateInfo->enabledLayerCount)
134 {
Ben Clayton00424c12019-03-17 17:29:30 +0000135 UNIMPLEMENTED("pCreateInfo->enabledLayerCount");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400136 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400137
Alexis Hetud6fae382019-04-05 13:19:46 -0400138 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Hernan Liatis2bb08642019-02-08 14:08:21 -0800139 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400140 {
Alexis Hetud6fae382019-04-05 13:19:46 -0400141 if (!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], instanceExtensionProperties, extensionPropertiesCount))
Hernan Liatis2bb08642019-02-08 14:08:21 -0800142 {
143 return VK_ERROR_EXTENSION_NOT_PRESENT;
144 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400145 }
146
147 if(pCreateInfo->pNext)
148 {
149 switch(*reinterpret_cast<const VkStructureType*>(pCreateInfo->pNext))
150 {
151 case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO:
152 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
153 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
154 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
155 // internal use by the loader, and do not have corresponding
156 // Vulkan structures in this Specification."
157 break;
158 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000159 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400160 }
161 }
162
163 *pInstance = VK_NULL_HANDLE;
164 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
165
166 VkResult result = vk::DispatchablePhysicalDevice::Create(pAllocator, pCreateInfo, &physicalDevice);
167 if(result != VK_SUCCESS)
168 {
169 return result;
170 }
171
172 vk::Instance::CreateInfo info =
173 {
174 pCreateInfo,
175 physicalDevice
176 };
177
178 result = vk::DispatchableInstance::Create(pAllocator, &info, pInstance);
179 if(result != VK_SUCCESS)
180 {
181 vk::destroy(physicalDevice, pAllocator);
182 return result;
183 }
184
185 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -0400186}
187
188VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
189{
Ben Claytonfb280672019-04-25 11:16:15 +0100190 TRACE("(VkInstance instance = %p, const VkAllocationCallbacks* pAllocator = %p)", instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400191
Alexis Hetu767b41b2018-09-26 11:25:46 -0400192 vk::destroy(instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400193}
194
195VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices)
196{
Ben Claytonfb280672019-04-25 11:16:15 +0100197 TRACE("(VkInstance instance = %p, uint32_t* pPhysicalDeviceCount = %p, VkPhysicalDevice* pPhysicalDevices = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400198 instance, pPhysicalDeviceCount, pPhysicalDevices);
199
Alexis Hetu767b41b2018-09-26 11:25:46 -0400200 if(!pPhysicalDevices)
201 {
202 *pPhysicalDeviceCount = vk::Cast(instance)->getPhysicalDeviceCount();
203 }
204 else
205 {
206 vk::Cast(instance)->getPhysicalDevices(*pPhysicalDeviceCount, pPhysicalDevices);
207 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400208
209 return VK_SUCCESS;
210}
211
212VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures)
213{
Ben Claytonfb280672019-04-25 11:16:15 +0100214 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures* pFeatures = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400215 physicalDevice, pFeatures);
216
Alexis Hetu767b41b2018-09-26 11:25:46 -0400217 *pFeatures = vk::Cast(physicalDevice)->getFeatures();
Alexis Hetud73b8712018-09-21 15:14:43 -0400218}
219
220VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties)
221{
Ben Claytonfb280672019-04-25 11:16:15 +0100222 TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties* pFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400223 physicalDevice, (int)format, pFormatProperties);
224
Alexis Hetu767b41b2018-09-26 11:25:46 -0400225 vk::Cast(physicalDevice)->getFormatProperties(format, pFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400226}
227
228VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties)
229{
Ben Claytonfb280672019-04-25 11:16:15 +0100230 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkImageType type = %d, VkImageTiling tiling = %d, VkImageUsageFlags usage = %d, VkImageCreateFlags flags = %d, VkImageFormatProperties* pImageFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400231 physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
232
Chris Forbes57378332019-01-16 15:17:24 -0800233 VkFormatProperties properties;
234 vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
235
236 switch (tiling)
237 {
238 case VK_IMAGE_TILING_LINEAR:
239 if (properties.linearTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
240 break;
241
242 case VK_IMAGE_TILING_OPTIMAL:
243 if (properties.optimalTilingFeatures == 0) return VK_ERROR_FORMAT_NOT_SUPPORTED;
244 break;
245
246 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000247 UNIMPLEMENTED("tiling");
Chris Forbes57378332019-01-16 15:17:24 -0800248 }
249
Alexis Hetu767b41b2018-09-26 11:25:46 -0400250 vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400251
252 return VK_SUCCESS;
253}
254
255VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties)
256{
Ben Claytonfb280672019-04-25 11:16:15 +0100257 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties* pProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400258 physicalDevice, pProperties);
259
Alexis Hetu767b41b2018-09-26 11:25:46 -0400260 *pProperties = vk::Cast(physicalDevice)->getProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400261}
262
263VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties)
264{
Ben Claytonfb280672019-04-25 11:16:15 +0100265 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties* pQueueFamilyProperties = %p))", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400266
Alexis Hetu767b41b2018-09-26 11:25:46 -0400267 if(!pQueueFamilyProperties)
268 {
269 *pQueueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
270 }
271 else
272 {
273 vk::Cast(physicalDevice)->getQueueFamilyProperties(*pQueueFamilyPropertyCount, pQueueFamilyProperties);
274 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400275}
276
277VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties)
278{
Ben Claytonfb280672019-04-25 11:16:15 +0100279 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400280
Alexis Hetu767b41b2018-09-26 11:25:46 -0400281 *pMemoryProperties = vk::Cast(physicalDevice)->getMemoryProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400282}
283
284VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName)
285{
Ben Claytonfb280672019-04-25 11:16:15 +0100286 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500287
288 return vk::GetInstanceProcAddr(instance, pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400289}
290
291VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* pName)
292{
Ben Claytonfb280672019-04-25 11:16:15 +0100293 TRACE("(VkDevice device = %p, const char* pName = %p)", device, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500294
295 return vk::GetDeviceProcAddr(device, pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400296}
297
298VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
299{
Ben Claytonfb280672019-04-25 11:16:15 +0100300 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkDeviceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDevice* pDevice = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400301 physicalDevice, pCreateInfo, pAllocator, pDevice);
302
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500303 if(pCreateInfo->enabledLayerCount)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400304 {
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500305 // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
Ben Clayton00424c12019-03-17 17:29:30 +0000306 UNIMPLEMENTED("pCreateInfo->enabledLayerCount"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
Alexis Hetu767b41b2018-09-26 11:25:46 -0400307 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400308
Alexis Hetud6fae382019-04-05 13:19:46 -0400309 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Hernan Liatiscff8c002019-02-25 15:56:36 -0800310 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
311 {
Alexis Hetud6fae382019-04-05 13:19:46 -0400312 if (!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], deviceExtensionProperties, extensionPropertiesCount))
Hernan Liatiscff8c002019-02-25 15:56:36 -0800313 {
314 return VK_ERROR_EXTENSION_NOT_PRESENT;
315 }
316 }
317
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500318 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
319
320 while(extensionCreateInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400321 {
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500322 switch(extensionCreateInfo->sType)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400323 {
324 case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
325 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
326 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
327 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
328 // internal use by the loader, and do not have corresponding
329 // Vulkan structures in this Specification."
330 break;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500331 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
332 {
333 ASSERT(!pCreateInfo->pEnabledFeatures); // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
334
335 const VkPhysicalDeviceFeatures2* physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2*>(extensionCreateInfo);
336
337 if(!vk::Cast(physicalDevice)->hasFeatures(physicalDeviceFeatures2->features))
338 {
339 return VK_ERROR_FEATURE_NOT_PRESENT;
340 }
341 }
342 break;
343 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
344 {
345 const VkPhysicalDeviceSamplerYcbcrConversionFeatures* samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionCreateInfo);
346
347 if(samplerYcbcrConversionFeatures->samplerYcbcrConversion == VK_TRUE)
348 {
349 return VK_ERROR_FEATURE_NOT_PRESENT;
350 }
351 }
352 break;
353 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
354 {
355 const VkPhysicalDevice16BitStorageFeatures* storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures*>(extensionCreateInfo);
356
357 if(storage16BitFeatures->storageBuffer16BitAccess == VK_TRUE ||
358 storage16BitFeatures->uniformAndStorageBuffer16BitAccess == VK_TRUE ||
359 storage16BitFeatures->storagePushConstant16 == VK_TRUE ||
360 storage16BitFeatures->storageInputOutput16 == VK_TRUE)
361 {
362 return VK_ERROR_FEATURE_NOT_PRESENT;
363 }
364 }
365 break;
366 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
367 {
368 const VkPhysicalDeviceVariablePointerFeatures* variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures*>(extensionCreateInfo);
369
370 if(variablePointerFeatures->variablePointersStorageBuffer == VK_TRUE ||
371 variablePointerFeatures->variablePointers == VK_TRUE)
372 {
373 return VK_ERROR_FEATURE_NOT_PRESENT;
374 }
375 }
376 break;
Alexis Hetu5ebd2c02019-01-22 17:17:27 -0500377 case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO:
378 {
379 const VkDeviceGroupDeviceCreateInfo* groupDeviceCreateInfo = reinterpret_cast<const VkDeviceGroupDeviceCreateInfo*>(extensionCreateInfo);
380
381 if((groupDeviceCreateInfo->physicalDeviceCount != 1) ||
382 (groupDeviceCreateInfo->pPhysicalDevices[0] != physicalDevice))
383 {
384 return VK_ERROR_FEATURE_NOT_PRESENT;
385 }
386 }
387 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400388 default:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500389 // "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]"
Ben Clayton00424c12019-03-17 17:29:30 +0000390 UNIMPLEMENTED("extensionCreateInfo->sType"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500391 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400392 }
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500393
394 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400395 }
396
397 ASSERT(pCreateInfo->queueCreateInfoCount > 0);
398
Nicolas Capensd5f14892018-11-13 14:06:37 -0500399 if(pCreateInfo->pEnabledFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400400 {
Nicolas Capensd5f14892018-11-13 14:06:37 -0500401 if(!vk::Cast(physicalDevice)->hasFeatures(*(pCreateInfo->pEnabledFeatures)))
402 {
Ben Clayton00424c12019-03-17 17:29:30 +0000403 UNIMPLEMENTED("pCreateInfo->pEnabledFeatures");
Nicolas Capensd5f14892018-11-13 14:06:37 -0500404 return VK_ERROR_FEATURE_NOT_PRESENT;
405 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400406 }
407
408 uint32_t queueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
409
410 for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
411 {
412 const VkDeviceQueueCreateInfo& queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
413 if(queueCreateInfo.pNext || queueCreateInfo.flags)
414 {
Ben Clayton00424c12019-03-17 17:29:30 +0000415 UNIMPLEMENTED("queueCreateInfo.pNext || queueCreateInfo.flags");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400416 }
417
418 ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500419 (void)queueFamilyPropertyCount; // Silence unused variable warning
Alexis Hetu767b41b2018-09-26 11:25:46 -0400420 }
421
422 vk::Device::CreateInfo deviceCreateInfo =
423 {
424 pCreateInfo,
425 physicalDevice
426 };
427
428 return vk::DispatchableDevice::Create(pAllocator, &deviceCreateInfo, pDevice);
Alexis Hetud73b8712018-09-21 15:14:43 -0400429}
430
431VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
432{
Ben Claytonfb280672019-04-25 11:16:15 +0100433 TRACE("(VkDevice device = %p, const VkAllocationCallbacks* pAllocator = %p)", device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400434
Alexis Hetu767b41b2018-09-26 11:25:46 -0400435 vk::destroy(device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400436}
437
438VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
439{
Ben Claytonfb280672019-04-25 11:16:15 +0100440 TRACE("(const char* pLayerName = %p, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400441 pLayerName, pPropertyCount, pProperties);
442
Hernan Liatis2bb08642019-02-08 14:08:21 -0800443 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700444
Alexis Hetud73b8712018-09-21 15:14:43 -0400445 if(!pProperties)
446 {
Chris Forbes59781502018-10-25 11:19:54 -0700447 *pPropertyCount = extensionPropertiesCount;
Alexis Hetud73b8712018-09-21 15:14:43 -0400448 return VK_SUCCESS;
449 }
450
Chris Forbes59781502018-10-25 11:19:54 -0700451 for(uint32_t i = 0; i < std::min(*pPropertyCount, extensionPropertiesCount); i++)
Alexis Hetud73b8712018-09-21 15:14:43 -0400452 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800453 pProperties[i] = instanceExtensionProperties[i];
Alexis Hetud73b8712018-09-21 15:14:43 -0400454 }
455
Chris Forbes59781502018-10-25 11:19:54 -0700456 return (*pPropertyCount < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400457}
458
459VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
460{
Ben Claytonfb280672019-04-25 11:16:15 +0100461 TRACE("(VkPhysicalDevice physicalDevice = %p, const char* pLayerName, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400462
Hernan Liatis2bb08642019-02-08 14:08:21 -0800463 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700464
Alexis Hetu767b41b2018-09-26 11:25:46 -0400465 if(!pProperties)
466 {
Chris Forbes59781502018-10-25 11:19:54 -0700467 *pPropertyCount = extensionPropertiesCount;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400468 return VK_SUCCESS;
469 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400470
Chris Forbes59781502018-10-25 11:19:54 -0700471 for(uint32_t i = 0; i < std::min(*pPropertyCount, extensionPropertiesCount); i++)
472 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800473 pProperties[i] = deviceExtensionProperties[i];
Chris Forbes59781502018-10-25 11:19:54 -0700474 }
475
476 return (*pPropertyCount < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400477}
478
479VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties)
480{
Ben Claytonfb280672019-04-25 11:16:15 +0100481 TRACE("(uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400482
Alexis Hetu767b41b2018-09-26 11:25:46 -0400483 if(!pProperties)
484 {
485 *pPropertyCount = 0;
486 return VK_SUCCESS;
487 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400488
489 return VK_SUCCESS;
490}
491
492VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
493{
Ben Claytonfb280672019-04-25 11:16:15 +0100494 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400495
Alexis Hetu767b41b2018-09-26 11:25:46 -0400496 if(!pProperties)
497 {
498 *pPropertyCount = 0;
499 return VK_SUCCESS;
500 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400501
502 return VK_SUCCESS;
503}
504
505VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue)
506{
Ben Claytonfb280672019-04-25 11:16:15 +0100507 TRACE("(VkDevice device = %p, uint32_t queueFamilyIndex = %d, uint32_t queueIndex = %d, VkQueue* pQueue = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400508 device, queueFamilyIndex, queueIndex, pQueue);
509
Alexis Hetu767b41b2018-09-26 11:25:46 -0400510 *pQueue = vk::Cast(device)->getQueue(queueFamilyIndex, queueIndex);
Alexis Hetud73b8712018-09-21 15:14:43 -0400511}
512
513VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence)
514{
Ben Claytonfb280672019-04-25 11:16:15 +0100515 TRACE("(VkQueue queue = %p, uint32_t submitCount = %d, const VkSubmitInfo* pSubmits = %p, VkFence fence = %p)",
Alexis Hetu072dc0d2018-10-31 11:41:25 -0400516 queue, submitCount, pSubmits, fence);
517
518 vk::Cast(queue)->submit(submitCount, pSubmits, fence);
519
Alexis Hetud73b8712018-09-21 15:14:43 -0400520 return VK_SUCCESS;
521}
522
Nicolas Capensde16f322019-02-12 00:32:31 -0500523VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
524{
Ben Claytonfb280672019-04-25 11:16:15 +0100525 TRACE("(VkQueue queue = %p)", queue);
Nicolas Capensde16f322019-02-12 00:32:31 -0500526
527 vk::Cast(queue)->waitIdle();
528
529 return VK_SUCCESS;
530}
531
532VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
533{
Ben Claytonfb280672019-04-25 11:16:15 +0100534 TRACE("(VkDevice device = %p)", device);
Nicolas Capensde16f322019-02-12 00:32:31 -0500535
536 vk::Cast(device)->waitIdle();
537
538 return VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400539}
540
541VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory)
542{
Ben Claytonfb280672019-04-25 11:16:15 +0100543 TRACE("(VkDevice device = %p, const VkMemoryAllocateInfo* pAllocateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDeviceMemory* pMemory = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400544 device, pAllocateInfo, pAllocator, pMemory);
545
Alexis Hetu00835732019-04-10 16:36:31 -0400546 const VkBaseInStructure* allocationInfo = reinterpret_cast<const VkBaseInStructure*>(pAllocateInfo->pNext);
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500547 while(allocationInfo)
Alexis Hetu38ff8302018-10-18 15:08:13 -0400548 {
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500549 switch(allocationInfo->sType)
550 {
551 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
552 // This can safely be ignored, as the Vulkan spec mentions:
553 // "If the pNext chain includes a VkMemoryDedicatedAllocateInfo structure, then that structure
554 // includes a handle of the sole buffer or image resource that the memory *can* be bound to."
555 break;
556 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000557 UNIMPLEMENTED("allocationInfo->sType");
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500558 break;
559 }
560
561 allocationInfo = allocationInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -0400562 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400563
Alexis Hetu38ff8302018-10-18 15:08:13 -0400564 VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
565 if(result != VK_SUCCESS)
566 {
567 return result;
568 }
569
570 // Make sure the memory allocation is done now so that OOM errors can be checked now
571 result = vk::Cast(*pMemory)->allocate();
572 if(result != VK_SUCCESS)
573 {
574 vk::destroy(*pMemory, pAllocator);
575 *pMemory = VK_NULL_HANDLE;
576 }
577
578 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -0400579}
580
581VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator)
582{
Ben Claytonfb280672019-04-25 11:16:15 +0100583 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400584 device, memory, pAllocator);
585
Alexis Hetu38ff8302018-10-18 15:08:13 -0400586 vk::destroy(memory, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400587}
588
589VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)
590{
Ben Claytonfb280672019-04-25 11:16:15 +0100591 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = %d, void** ppData = %p)",
592 device, memory, int(offset), int(size), flags, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -0400593
Alexis Hetu38ff8302018-10-18 15:08:13 -0400594 return vk::Cast(memory)->map(offset, size, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -0400595}
596
597VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
598{
Ben Claytonfb280672019-04-25 11:16:15 +0100599 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p)", device, memory);
Alexis Hetud73b8712018-09-21 15:14:43 -0400600
Alexis Hetu38ff8302018-10-18 15:08:13 -0400601 // Noop, memory will be released when the DeviceMemory object is released
Alexis Hetud73b8712018-09-21 15:14:43 -0400602}
603
604VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
605{
Ben Claytonfb280672019-04-25 11:16:15 +0100606 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400607 device, memoryRangeCount, pMemoryRanges);
608
Alexis Hetu38ff8302018-10-18 15:08:13 -0400609 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -0400610
611 return VK_SUCCESS;
612}
613
614VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
615{
Ben Claytonfb280672019-04-25 11:16:15 +0100616 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400617 device, memoryRangeCount, pMemoryRanges);
618
Alexis Hetu38ff8302018-10-18 15:08:13 -0400619 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -0400620
621 return VK_SUCCESS;
622}
623
Alexis Hetu38ff8302018-10-18 15:08:13 -0400624VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize* pCommittedMemoryInBytes)
Alexis Hetud73b8712018-09-21 15:14:43 -0400625{
Ben Claytonfb280672019-04-25 11:16:15 +0100626 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize* pCommittedMemoryInBytes = %p)",
Alexis Hetu38ff8302018-10-18 15:08:13 -0400627 pDevice, pMemory, pCommittedMemoryInBytes);
628
629 auto memory = vk::Cast(pMemory);
630
631#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
632 const auto& memoryProperties = vk::Cast(vk::Cast(pDevice)->getPhysicalDevice())->getMemoryProperties();
633 uint32_t typeIndex = memory->getMemoryTypeIndex();
634 ASSERT(typeIndex < memoryProperties.memoryTypeCount);
635 ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
636#endif
637
638 *pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
Alexis Hetud73b8712018-09-21 15:14:43 -0400639}
640
641VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
642{
Ben Claytonfb280672019-04-25 11:16:15 +0100643 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
644 device, buffer, memory, int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -0400645
Alexis Hetu38ff8302018-10-18 15:08:13 -0400646 vk::Cast(buffer)->bind(memory, memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -0400647
648 return VK_SUCCESS;
649}
650
651VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
652{
Ben Claytonfb280672019-04-25 11:16:15 +0100653 TRACE("(VkDevice device = %p, VkImage image = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
654 device, image, memory, int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -0400655
Alexis Hetua233cea2018-12-07 11:53:19 -0500656 vk::Cast(image)->bind(memory, memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -0400657
658 return VK_SUCCESS;
659}
660
661VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements)
662{
Ben Claytonfb280672019-04-25 11:16:15 +0100663 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400664 device, buffer, pMemoryRequirements);
665
Alexis Hetu38ff8302018-10-18 15:08:13 -0400666 *pMemoryRequirements = vk::Cast(buffer)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -0400667}
668
669VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements)
670{
Ben Claytonfb280672019-04-25 11:16:15 +0100671 TRACE("(VkDevice device = %p, VkImage image = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400672 device, image, pMemoryRequirements);
673
Alexis Hetua233cea2018-12-07 11:53:19 -0500674 *pMemoryRequirements = vk::Cast(image)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -0400675}
676
677VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements)
678{
Ben Claytonfb280672019-04-25 11:16:15 +0100679 TRACE("(VkDevice device = %p, VkImage image = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements* pSparseMemoryRequirements = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -0400680 device, image, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
Alexis Hetu9e4d0402018-10-16 15:44:12 -0400681
Nicolas Capens5028a582018-11-13 15:03:35 -0500682 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
683 // "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."
684 *pSparseMemoryRequirementCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -0400685}
686
687VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties)
688{
Ben Claytonfb280672019-04-25 11:16:15 +0100689 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkImageType type = %d, VkSampleCountFlagBits samples = %d, VkImageUsageFlags usage = %d, VkImageTiling tiling = %d, uint32_t* pPropertyCount = %p, VkSparseImageFormatProperties* pProperties = %p)",
Chris Forbes2c25b142019-03-05 14:47:16 -0800690 physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
691
692 // We do not support sparse images.
693 *pPropertyCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -0400694}
695
696VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence)
697{
698 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +0000699 UNIMPLEMENTED("vkQueueBindSparse");
Alexis Hetud73b8712018-09-21 15:14:43 -0400700 return VK_SUCCESS;
701}
702
703VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
704{
Ben Claytonfb280672019-04-25 11:16:15 +0100705 TRACE("(VkDevice device = %p, const VkFenceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFence* pFence = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400706 device, pCreateInfo, pAllocator, pFence);
707
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400708 if(pCreateInfo->pNext)
709 {
Ben Clayton00424c12019-03-17 17:29:30 +0000710 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400711 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400712
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400713 return vk::Fence::Create(pAllocator, pCreateInfo, pFence);
Alexis Hetud73b8712018-09-21 15:14:43 -0400714}
715
716VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
717{
Ben Claytonfb280672019-04-25 11:16:15 +0100718 TRACE("(VkDevice device = %p, VkFence fence = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400719 device, fence, pAllocator);
Alexis Hetu767b41b2018-09-26 11:25:46 -0400720
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400721
722 vk::destroy(fence, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400723}
724
725VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences)
726{
Ben Claytonfb280672019-04-25 11:16:15 +0100727 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400728 device, fenceCount, pFences);
729
730 for(uint32_t i = 0; i < fenceCount; i++)
731 {
732 vk::Cast(pFences[i])->reset();
733 }
734
Alexis Hetud73b8712018-09-21 15:14:43 -0400735 return VK_SUCCESS;
736}
737
738VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
739{
Ben Claytonfb280672019-04-25 11:16:15 +0100740 TRACE("(VkDevice device = %p, VkFence fence = %p)", device, fence);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400741
742 return vk::Cast(fence)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -0400743}
744
745VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
746{
Ben Claytonfb280672019-04-25 11:16:15 +0100747 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p, VkBool32 waitAll = %d, uint64_t timeout = %d)",
748 device, int(fenceCount), pFences, int(waitAll), int(timeout));
Alexis Hetuc4bd9df2018-12-07 11:28:40 -0500749
750 vk::Cast(device)->waitForFences(fenceCount, pFences, waitAll, timeout);
751
Alexis Hetud73b8712018-09-21 15:14:43 -0400752 return VK_SUCCESS;
753}
754
755VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore)
756{
Ben Claytonfb280672019-04-25 11:16:15 +0100757 TRACE("(VkDevice device = %p, const VkSemaphoreCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSemaphore* pSemaphore = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400758 device, pCreateInfo, pAllocator, pSemaphore);
759
760 if(pCreateInfo->pNext || pCreateInfo->flags)
761 {
Ben Clayton00424c12019-03-17 17:29:30 +0000762 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400763 }
764
765 return vk::Semaphore::Create(pAllocator, pCreateInfo, pSemaphore);
Alexis Hetud73b8712018-09-21 15:14:43 -0400766}
767
768VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator)
769{
Ben Claytonfb280672019-04-25 11:16:15 +0100770 TRACE("(VkDevice device = %p, VkSemaphore semaphore = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400771 device, semaphore, pAllocator);
772
773 vk::destroy(semaphore, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400774}
775
776VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent)
777{
Ben Claytonfb280672019-04-25 11:16:15 +0100778 TRACE("(VkDevice device = %p, const VkEventCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkEvent* pEvent = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400779 device, pCreateInfo, pAllocator, pEvent);
780
781 if(pCreateInfo->pNext || pCreateInfo->flags)
782 {
Ben Clayton00424c12019-03-17 17:29:30 +0000783 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400784 }
785
786 return vk::Event::Create(pAllocator, pCreateInfo, pEvent);
Alexis Hetud73b8712018-09-21 15:14:43 -0400787}
788
789VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator)
790{
Ben Claytonfb280672019-04-25 11:16:15 +0100791 TRACE("(VkDevice device = %p, VkEvent event = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400792 device, event, pAllocator);
793
794 vk::destroy(event, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400795}
796
797VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
798{
Ben Claytonfb280672019-04-25 11:16:15 +0100799 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, event);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400800
801 return vk::Cast(event)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -0400802}
803
804VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event)
805{
Ben Claytonfb280672019-04-25 11:16:15 +0100806 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, event);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400807
808 vk::Cast(event)->signal();
809
Alexis Hetud73b8712018-09-21 15:14:43 -0400810 return VK_SUCCESS;
811}
812
813VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event)
814{
Ben Claytonfb280672019-04-25 11:16:15 +0100815 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, event);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400816
817 vk::Cast(event)->reset();
818
Alexis Hetud73b8712018-09-21 15:14:43 -0400819 return VK_SUCCESS;
820}
821
822VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool)
823{
Ben Claytonfb280672019-04-25 11:16:15 +0100824 TRACE("(VkDevice device = %p, const VkQueryPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkQueryPool* pQueryPool = %p)",
Alexis Hetu86f8bdb2019-01-22 12:07:24 -0500825 device, pCreateInfo, pAllocator, pQueryPool);
826
827 if(pCreateInfo->pNext || pCreateInfo->flags)
828 {
Ben Clayton00424c12019-03-17 17:29:30 +0000829 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu86f8bdb2019-01-22 12:07:24 -0500830 }
831
832 return vk::QueryPool::Create(pAllocator, pCreateInfo, pQueryPool);
Alexis Hetud73b8712018-09-21 15:14:43 -0400833}
834
835VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator)
836{
Ben Claytonfb280672019-04-25 11:16:15 +0100837 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu86f8bdb2019-01-22 12:07:24 -0500838 device, queryPool, pAllocator);
839
840 vk::destroy(queryPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400841}
842
843VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags)
844{
Ben Claytonfb280672019-04-25 11:16:15 +0100845 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d, size_t dataSize = %d, void* pData = %p, VkDeviceSize stride = %d, VkQueryResultFlags flags = %d)",
846 device, queryPool, int(firstQuery), int(queryCount), int(dataSize), pData, int(stride), flags);
Alexis Hetu86f8bdb2019-01-22 12:07:24 -0500847
Alexis Hetuf0aa9d52019-04-01 17:06:47 -0400848 return vk::Cast(queryPool)->getResults(firstQuery, queryCount, dataSize, pData, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -0400849}
850
851VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer)
852{
Ben Claytonfb280672019-04-25 11:16:15 +0100853 TRACE("(VkDevice device = %p, const VkBufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBuffer* pBuffer = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400854 device, pCreateInfo, pAllocator, pBuffer);
855
Alexis Hetu38ff8302018-10-18 15:08:13 -0400856 if(pCreateInfo->pNext)
857 {
Ben Clayton00424c12019-03-17 17:29:30 +0000858 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu38ff8302018-10-18 15:08:13 -0400859 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400860
Alexis Hetu38ff8302018-10-18 15:08:13 -0400861 return vk::Buffer::Create(pAllocator, pCreateInfo, pBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -0400862}
863
864VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator)
865{
Ben Claytonfb280672019-04-25 11:16:15 +0100866 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400867 device, buffer, pAllocator);
868
Alexis Hetu38ff8302018-10-18 15:08:13 -0400869 vk::destroy(buffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400870}
871
872VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)
873{
Ben Claytonfb280672019-04-25 11:16:15 +0100874 TRACE("(VkDevice device = %p, const VkBufferViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBufferView* pView = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -0400875 device, pCreateInfo, pAllocator, pView);
Alexis Hetu38ff8302018-10-18 15:08:13 -0400876
877 if(pCreateInfo->pNext || pCreateInfo->flags)
878 {
Ben Clayton00424c12019-03-17 17:29:30 +0000879 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu38ff8302018-10-18 15:08:13 -0400880 }
881
882 return vk::BufferView::Create(pAllocator, pCreateInfo, pView);
Alexis Hetud73b8712018-09-21 15:14:43 -0400883}
884
885VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)
886{
Ben Claytonfb280672019-04-25 11:16:15 +0100887 TRACE("(VkDevice device = %p, VkBufferView bufferView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -0400888 device, bufferView, pAllocator);
Alexis Hetu38ff8302018-10-18 15:08:13 -0400889
890 vk::destroy(bufferView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400891}
892
893VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage)
894{
Ben Claytonfb280672019-04-25 11:16:15 +0100895 TRACE("(VkDevice device = %p, const VkImageCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImage* pImage = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400896 device, pCreateInfo, pAllocator, pImage);
897
Alexis Hetuf62f3752018-11-15 14:51:15 -0500898 if(pCreateInfo->pNext)
899 {
Ben Clayton00424c12019-03-17 17:29:30 +0000900 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetuf62f3752018-11-15 14:51:15 -0500901 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400902
Alexis Hetu0da99f52019-02-27 12:54:52 -0500903 vk::Image::CreateInfo imageCreateInfo =
904 {
905 pCreateInfo,
906 device
907 };
908
909 return vk::Image::Create(pAllocator, &imageCreateInfo, pImage);
Alexis Hetud73b8712018-09-21 15:14:43 -0400910}
911
912VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
913{
Ben Claytonfb280672019-04-25 11:16:15 +0100914 TRACE("(VkDevice device = %p, VkImage image = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400915 device, image, pAllocator);
916
Alexis Hetuf62f3752018-11-15 14:51:15 -0500917 vk::destroy(image, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400918}
919
920VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)
921{
Ben Claytonfb280672019-04-25 11:16:15 +0100922 TRACE("(VkDevice device = %p, VkImage image = %p, const VkImageSubresource* pSubresource = %p, VkSubresourceLayout* pLayout = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -0400923 device, image, pSubresource, pLayout);
Alexis Hetu6ab37b02019-01-24 17:02:45 -0500924
925 vk::Cast(image)->getSubresourceLayout(pSubresource, pLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -0400926}
927
928VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
929{
Ben Claytonfb280672019-04-25 11:16:15 +0100930 TRACE("(VkDevice device = %p, const VkImageViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImageView* pView = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400931 device, pCreateInfo, pAllocator, pView);
932
Alexis Hetu60da1582019-04-05 16:34:38 -0400933 if(pCreateInfo->flags)
Alexis Hetu9fbaf692018-11-19 11:30:43 -0500934 {
Alexis Hetu60da1582019-04-05 16:34:38 -0400935 UNIMPLEMENTED("pCreateInfo->flags");
936 }
937
938 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
939
940 while(extensionCreateInfo)
941 {
942 switch(extensionCreateInfo->sType)
943 {
944 case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR:
945 {
946 const VkImageViewUsageCreateInfo* multiviewCreateInfo = reinterpret_cast<const VkImageViewUsageCreateInfo*>(extensionCreateInfo);
947 ASSERT(!(~vk::Cast(pCreateInfo->image)->getUsage() & multiviewCreateInfo->usage));
948 }
949 break;
950 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
951 {
952 const VkSamplerYcbcrConversionInfo* ycbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo*>(extensionCreateInfo);
953 if(ycbcrConversionInfo->conversion != VK_NULL_HANDLE)
954 {
955 ASSERT((pCreateInfo->components.r == VK_COMPONENT_SWIZZLE_IDENTITY) &&
956 (pCreateInfo->components.g == VK_COMPONENT_SWIZZLE_IDENTITY) &&
957 (pCreateInfo->components.b == VK_COMPONENT_SWIZZLE_IDENTITY) &&
958 (pCreateInfo->components.a == VK_COMPONENT_SWIZZLE_IDENTITY));
959 }
960 }
961 break;
962 default:
963 UNIMPLEMENTED("extensionCreateInfo->sType");
964 break;
965 }
966
967 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu9fbaf692018-11-19 11:30:43 -0500968 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400969
Alexis Hetu9fbaf692018-11-19 11:30:43 -0500970 return vk::ImageView::Create(pAllocator, pCreateInfo, pView);
Alexis Hetud73b8712018-09-21 15:14:43 -0400971}
972
973VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
974{
Ben Claytonfb280672019-04-25 11:16:15 +0100975 TRACE("(VkDevice device = %p, VkImageView imageView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu9fbaf692018-11-19 11:30:43 -0500976 device, imageView, pAllocator);
977
978 vk::destroy(imageView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400979}
980
981VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
982{
Ben Claytonfb280672019-04-25 11:16:15 +0100983 TRACE("(VkDevice device = %p, const VkShaderModuleCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkShaderModule* pShaderModule = %p)",
Alexis Hetu9fbaf692018-11-19 11:30:43 -0500984 device, pCreateInfo, pAllocator, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -0400985
Alexis Hetu259ad3d2018-11-15 13:44:31 -0500986 if(pCreateInfo->pNext || pCreateInfo->flags)
987 {
Ben Clayton00424c12019-03-17 17:29:30 +0000988 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu259ad3d2018-11-15 13:44:31 -0500989 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400990
Alexis Hetu259ad3d2018-11-15 13:44:31 -0500991 return vk::ShaderModule::Create(pAllocator, pCreateInfo, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -0400992}
993
994VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
995{
Ben Claytonfb280672019-04-25 11:16:15 +0100996 TRACE("(VkDevice device = %p, VkShaderModule shaderModule = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu5174c572018-11-19 11:30:43 -0500997 device, shaderModule, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400998
Alexis Hetu259ad3d2018-11-15 13:44:31 -0500999 vk::destroy(shaderModule, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001000}
1001
1002VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)
1003{
Ben Claytonfb280672019-04-25 11:16:15 +01001004 TRACE("(VkDevice device = %p, const VkPipelineCacheCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineCache* pPipelineCache = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04001005 device, pCreateInfo, pAllocator, pPipelineCache);
Alexis Hetu18a84252018-11-19 11:30:43 -05001006
1007 if(pCreateInfo->pNext || pCreateInfo->flags)
1008 {
Ben Clayton00424c12019-03-17 17:29:30 +00001009 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu18a84252018-11-19 11:30:43 -05001010 }
1011
1012 return vk::PipelineCache::Create(pAllocator, pCreateInfo, pPipelineCache);
Alexis Hetud73b8712018-09-21 15:14:43 -04001013}
1014
1015VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator)
1016{
Ben Claytonfb280672019-04-25 11:16:15 +01001017 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04001018 device, pipelineCache, pAllocator);
Alexis Hetu18a84252018-11-19 11:30:43 -05001019
1020 vk::destroy(pipelineCache, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001021}
1022
1023VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData)
1024{
Ben Claytonfb280672019-04-25 11:16:15 +01001025 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, size_t* pDataSize = %p, void* pData = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04001026 device, pipelineCache, pDataSize, pData);
1027
1028 return vk::Cast(pipelineCache)->getData(pDataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001029}
1030
1031VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches)
1032{
Ben Claytonfb280672019-04-25 11:16:15 +01001033 TRACE("(VkDevice device = %p, VkPipelineCache dstCache = %p, uint32_t srcCacheCount = %d, const VkPipelineCache* pSrcCaches = %p)",
1034 device, dstCache, int(srcCacheCount), pSrcCaches);
Alexis Hetu1424ef62019-04-05 18:03:53 -04001035
1036 return vk::Cast(dstCache)->merge(srcCacheCount, pSrcCaches);
Alexis Hetud73b8712018-09-21 15:14:43 -04001037}
1038
1039VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1040{
Ben Claytonfb280672019-04-25 11:16:15 +01001041 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkGraphicsPipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
1042 device, pipelineCache, int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001043
Alexis Hetu85bd6132019-01-29 16:13:17 -05001044 // TODO (b/123588002): Optimize based on pipelineCache.
Alexis Hetud73b8712018-09-21 15:14:43 -04001045
Alexis Hetu000df8b2018-10-24 15:22:41 -04001046 VkResult errorResult = VK_SUCCESS;
1047 for(uint32_t i = 0; i < createInfoCount; i++)
1048 {
1049 VkResult result = vk::GraphicsPipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i]);
Ben Claytonf2be26a2019-03-08 12:02:05 +00001050 if(result == VK_SUCCESS)
1051 {
1052 static_cast<vk::GraphicsPipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i]);
1053 }
1054 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001055 {
1056 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1057 // "When an application attempts to create many pipelines in a single command,
1058 // it is possible that some subset may fail creation. In that case, the
1059 // corresponding entries in the pPipelines output array will be filled with
1060 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1061 // out of memory errors), the vkCreate*Pipelines commands will return an
1062 // error code. The implementation will attempt to create all pipelines, and
1063 // only return VK_NULL_HANDLE values for those that actually failed."
1064 pPipelines[i] = VK_NULL_HANDLE;
1065 errorResult = result;
1066 }
1067 }
1068
1069 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001070}
1071
1072VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1073{
Ben Claytonfb280672019-04-25 11:16:15 +01001074 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkComputePipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
1075 device, pipelineCache, int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001076
Alexis Hetu85bd6132019-01-29 16:13:17 -05001077 // TODO (b/123588002): Optimize based on pipelineCache.
Alexis Hetud73b8712018-09-21 15:14:43 -04001078
Alexis Hetu000df8b2018-10-24 15:22:41 -04001079 VkResult errorResult = VK_SUCCESS;
1080 for(uint32_t i = 0; i < createInfoCount; i++)
1081 {
1082 VkResult result = vk::ComputePipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i]);
Ben Claytonf2be26a2019-03-08 12:02:05 +00001083 if(result == VK_SUCCESS)
1084 {
1085 static_cast<vk::ComputePipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i]);
1086 }
1087 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001088 {
1089 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1090 // "When an application attempts to create many pipelines in a single command,
1091 // it is possible that some subset may fail creation. In that case, the
1092 // corresponding entries in the pPipelines output array will be filled with
1093 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1094 // out of memory errors), the vkCreate*Pipelines commands will return an
1095 // error code. The implementation will attempt to create all pipelines, and
1096 // only return VK_NULL_HANDLE values for those that actually failed."
1097 pPipelines[i] = VK_NULL_HANDLE;
1098 errorResult = result;
1099 }
1100 }
1101
1102 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001103}
1104
1105VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator)
1106{
Ben Claytonfb280672019-04-25 11:16:15 +01001107 TRACE("(VkDevice device = %p, VkPipeline pipeline = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001108 device, pipeline, pAllocator);
1109
Alexis Hetu000df8b2018-10-24 15:22:41 -04001110 vk::destroy(pipeline, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001111}
1112
1113VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout)
1114{
Ben Claytonfb280672019-04-25 11:16:15 +01001115 TRACE("(VkDevice device = %p, const VkPipelineLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineLayout* pPipelineLayout = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001116 device, pCreateInfo, pAllocator, pPipelineLayout);
1117
Alexis Hetu000df8b2018-10-24 15:22:41 -04001118 if(pCreateInfo->pNext || pCreateInfo->flags)
1119 {
Ben Clayton00424c12019-03-17 17:29:30 +00001120 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu000df8b2018-10-24 15:22:41 -04001121 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001122
Alexis Hetu000df8b2018-10-24 15:22:41 -04001123 return vk::PipelineLayout::Create(pAllocator, pCreateInfo, pPipelineLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001124}
1125
1126VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator)
1127{
Ben Claytonfb280672019-04-25 11:16:15 +01001128 TRACE("(VkDevice device = %p, VkPipelineLayout pipelineLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001129 device, pipelineLayout, pAllocator);
1130
Alexis Hetu000df8b2018-10-24 15:22:41 -04001131 vk::destroy(pipelineLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001132}
1133
1134VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
1135{
Ben Claytonfb280672019-04-25 11:16:15 +01001136 TRACE("(VkDevice device = %p, const VkSamplerCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSampler* pSampler = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001137 device, pCreateInfo, pAllocator, pSampler);
1138
Alexis Hetu5174c572018-11-19 11:30:43 -05001139 if(pCreateInfo->pNext || pCreateInfo->flags)
1140 {
Ben Clayton00424c12019-03-17 17:29:30 +00001141 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu5174c572018-11-19 11:30:43 -05001142 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001143
Alexis Hetu5174c572018-11-19 11:30:43 -05001144 return vk::Sampler::Create(pAllocator, pCreateInfo, pSampler);
Alexis Hetud73b8712018-09-21 15:14:43 -04001145}
1146
1147VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
1148{
Ben Claytonfb280672019-04-25 11:16:15 +01001149 TRACE("(VkDevice device = %p, VkSampler sampler = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001150 device, sampler, pAllocator);
1151
Alexis Hetu5174c572018-11-19 11:30:43 -05001152 vk::destroy(sampler, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001153}
1154
1155VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout)
1156{
Ben Claytonfb280672019-04-25 11:16:15 +01001157 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorSetLayout* pSetLayout = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001158 device, pCreateInfo, pAllocator, pSetLayout);
1159
1160 if(pCreateInfo->pNext)
1161 {
Ben Clayton00424c12019-03-17 17:29:30 +00001162 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetuc8176632019-01-22 17:01:28 -05001163 }
1164
1165 return vk::DescriptorSetLayout::Create(pAllocator, pCreateInfo, pSetLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001166}
1167
1168VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator)
1169{
Ben Claytonfb280672019-04-25 11:16:15 +01001170 TRACE("(VkDevice device = %p, VkDescriptorSetLayout descriptorSetLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001171 device, descriptorSetLayout, pAllocator);
1172
1173 vk::destroy(descriptorSetLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001174}
1175
1176VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool)
1177{
Ben Claytonfb280672019-04-25 11:16:15 +01001178 TRACE("(VkDevice device = %p, const VkDescriptorPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorPool* pDescriptorPool = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001179 device, pCreateInfo, pAllocator, pDescriptorPool);
1180
1181 if(pCreateInfo->pNext)
1182 {
Ben Clayton00424c12019-03-17 17:29:30 +00001183 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetuc8176632019-01-22 17:01:28 -05001184 }
1185
1186 return vk::DescriptorPool::Create(pAllocator, pCreateInfo, pDescriptorPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001187}
1188
1189VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator)
1190{
Ben Claytonfb280672019-04-25 11:16:15 +01001191 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001192 device, descriptorPool, pAllocator);
1193
1194 vk::destroy(descriptorPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001195}
1196
1197VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
1198{
Ben Claytonfb280672019-04-25 11:16:15 +01001199 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, VkDescriptorPoolResetFlags flags = 0x%x)",
1200 device, descriptorPool, int(flags));
Alexis Hetuc8176632019-01-22 17:01:28 -05001201
1202 if(flags)
1203 {
Ben Clayton00424c12019-03-17 17:29:30 +00001204 UNIMPLEMENTED("flags");
Alexis Hetuc8176632019-01-22 17:01:28 -05001205 }
1206
1207 return vk::Cast(descriptorPool)->reset();
Alexis Hetud73b8712018-09-21 15:14:43 -04001208}
1209
1210VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
1211{
Ben Claytonfb280672019-04-25 11:16:15 +01001212 TRACE("(VkDevice device = %p, const VkDescriptorSetAllocateInfo* pAllocateInfo = %p, VkDescriptorSet* pDescriptorSets = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001213 device, pAllocateInfo, pDescriptorSets);
1214
1215 if(pAllocateInfo->pNext)
1216 {
Ben Clayton00424c12019-03-17 17:29:30 +00001217 UNIMPLEMENTED("pAllocateInfo->pNext");
Alexis Hetuc8176632019-01-22 17:01:28 -05001218 }
1219
1220 return vk::Cast(pAllocateInfo->descriptorPool)->allocateSets(
1221 pAllocateInfo->descriptorSetCount, pAllocateInfo->pSetLayouts, pDescriptorSets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001222}
1223
1224VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
1225{
Ben Claytonfb280672019-04-25 11:16:15 +01001226 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001227 device, descriptorPool, descriptorSetCount, pDescriptorSets);
1228
1229 vk::Cast(descriptorPool)->freeSets(descriptorSetCount, pDescriptorSets);
1230
Alexis Hetud73b8712018-09-21 15:14:43 -04001231 return VK_SUCCESS;
1232}
1233
1234VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
1235{
Ben Claytonfb280672019-04-25 11:16:15 +01001236 TRACE("(VkDevice device = %p, uint32_t descriptorWriteCount = %d, const VkWriteDescriptorSet* pDescriptorWrites = %p, uint32_t descriptorCopyCount = %d, const VkCopyDescriptorSet* pDescriptorCopies = %p)",
Alexis Hetu048974f2019-02-15 15:28:37 -05001237 device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
1238
1239 vk::Cast(device)->updateDescriptorSets(descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
Alexis Hetud73b8712018-09-21 15:14:43 -04001240}
1241
1242VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer)
1243{
Ben Claytonfb280672019-04-25 11:16:15 +01001244 TRACE("(VkDevice device = %p, const VkFramebufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFramebuffer* pFramebuffer = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001245 device, pCreateInfo, pAllocator, pFramebuffer);
1246
Alexis Hetu8f631c82018-11-15 15:11:36 -05001247 if(pCreateInfo->pNext || pCreateInfo->flags)
1248 {
Ben Clayton00424c12019-03-17 17:29:30 +00001249 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu8f631c82018-11-15 15:11:36 -05001250 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001251
Alexis Hetu8f631c82018-11-15 15:11:36 -05001252 return vk::Framebuffer::Create(pAllocator, pCreateInfo, pFramebuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001253}
1254
1255VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator)
1256{
Ben Claytonfb280672019-04-25 11:16:15 +01001257 TRACE("(VkDevice device = %p, VkFramebuffer framebuffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
1258 device, framebuffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001259
Alexis Hetu8f631c82018-11-15 15:11:36 -05001260 vk::destroy(framebuffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001261}
1262
1263VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass)
1264{
Ben Claytonfb280672019-04-25 11:16:15 +01001265 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001266 device, pCreateInfo, pAllocator, pRenderPass);
1267
Alexis Hetu67806a12019-04-05 14:12:27 -04001268 if(pCreateInfo->flags)
Alexis Hetub16f9892018-11-15 15:18:41 -05001269 {
Alexis Hetu67806a12019-04-05 14:12:27 -04001270 UNIMPLEMENTED("pCreateInfo->flags");
1271 }
1272
1273 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
1274
1275 while(extensionCreateInfo)
1276 {
1277 switch(extensionCreateInfo->sType)
1278 {
1279 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO:
1280 {
1281 const VkRenderPassInputAttachmentAspectCreateInfo* inputAttachmentAspectCreateInfo = reinterpret_cast<const VkRenderPassInputAttachmentAspectCreateInfo*>(extensionCreateInfo);
1282
1283 for(uint32_t i = 0; i < inputAttachmentAspectCreateInfo->aspectReferenceCount; i++)
1284 {
1285 const VkInputAttachmentAspectReference& aspectReference = inputAttachmentAspectCreateInfo->pAspectReferences[i];
1286 ASSERT(aspectReference.subpass < pCreateInfo->subpassCount);
1287 const VkSubpassDescription& subpassDescription = pCreateInfo->pSubpasses[aspectReference.subpass];
1288 ASSERT(aspectReference.inputAttachmentIndex < subpassDescription.inputAttachmentCount);
1289 const VkAttachmentReference& attachmentReference = subpassDescription.pInputAttachments[aspectReference.inputAttachmentIndex];
1290 if(attachmentReference.attachment != VK_ATTACHMENT_UNUSED)
1291 {
1292 // If the pNext chain includes an instance of VkRenderPassInputAttachmentAspectCreateInfo, for any
1293 // element of the pInputAttachments member of any element of pSubpasses where the attachment member
1294 // is not VK_ATTACHMENT_UNUSED, the aspectMask member of the corresponding element of
1295 // VkRenderPassInputAttachmentAspectCreateInfo::pAspectReferences must only include aspects that are
1296 // present in images of the format specified by the element of pAttachments at attachment
1297 vk::Format format(pCreateInfo->pAttachments[attachmentReference.attachment].format);
1298 bool isDepth = format.isDepth();
1299 bool isStencil = format.isStencil();
1300 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) || (!isDepth && !isStencil));
1301 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || isDepth);
1302 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) || isStencil);
1303 }
1304 }
1305 }
1306 break;
1307 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
1308 {
1309 const VkRenderPassMultiviewCreateInfo* multiviewCreateInfo = reinterpret_cast<const VkRenderPassMultiviewCreateInfo*>(extensionCreateInfo);
1310 ASSERT((multiviewCreateInfo->subpassCount == 0) || (multiviewCreateInfo->subpassCount == pCreateInfo->subpassCount));
1311 ASSERT((multiviewCreateInfo->dependencyCount == 0) || (multiviewCreateInfo->dependencyCount == pCreateInfo->dependencyCount));
1312
1313 bool zeroMask = (multiviewCreateInfo->pViewMasks[0] == 0);
1314 for(uint32_t i = 1; i < multiviewCreateInfo->subpassCount; i++)
1315 {
1316 ASSERT((multiviewCreateInfo->pViewMasks[i] == 0) == zeroMask);
1317 }
1318
1319 if(zeroMask)
1320 {
1321 ASSERT(multiviewCreateInfo->correlationMaskCount == 0);
1322 }
1323
1324 for(uint32_t i = 0; i < multiviewCreateInfo->dependencyCount; i++)
1325 {
1326 const VkSubpassDependency &dependency = pCreateInfo->pDependencies[i];
1327 if(multiviewCreateInfo->pViewOffsets[i] != 0)
1328 {
1329 ASSERT(dependency.srcSubpass != dependency.dstSubpass);
1330 ASSERT(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT);
1331 }
1332 if(zeroMask)
1333 {
1334 ASSERT(!(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT));
1335 }
1336 }
1337
1338 // If the pNext chain includes an instance of VkRenderPassMultiviewCreateInfo,
1339 // each element of its pViewMask member must not include a bit at a position
1340 // greater than the value of VkPhysicalDeviceLimits::maxFramebufferLayers
1341 // pViewMask is a 32 bit value. If maxFramebufferLayers > 32, it's impossible
1342 // for pViewMask to contain a bit at an illegal position
1343 // Note: Verify pViewMask values instead if we hit this assert
1344 ASSERT(vk::Cast(vk::Cast(device)->getPhysicalDevice())->getProperties().limits.maxFramebufferLayers >= 32);
1345 }
1346 break;
1347 default:
1348 UNIMPLEMENTED("extensionCreateInfo->sType");
1349 break;
1350 }
1351
1352 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetub16f9892018-11-15 15:18:41 -05001353 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001354
Alexis Hetub16f9892018-11-15 15:18:41 -05001355 return vk::RenderPass::Create(pAllocator, pCreateInfo, pRenderPass);
Alexis Hetud73b8712018-09-21 15:14:43 -04001356}
1357
1358VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator)
1359{
Ben Claytonfb280672019-04-25 11:16:15 +01001360 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001361 device, renderPass, pAllocator);
1362
Alexis Hetub16f9892018-11-15 15:18:41 -05001363 vk::destroy(renderPass, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001364}
1365
1366VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity)
1367{
Ben Claytonfb280672019-04-25 11:16:15 +01001368 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, VkExtent2D* pGranularity = %p)",
Hernan Liatisc7943e92019-02-25 19:29:54 -08001369 device, renderPass, pGranularity);
1370
Alexis Hetu6d74ab82019-02-15 14:42:38 -05001371 vk::Cast(renderPass)->getRenderAreaGranularity(pGranularity);
Alexis Hetud73b8712018-09-21 15:14:43 -04001372}
1373
1374VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool)
1375{
Ben Claytonfb280672019-04-25 11:16:15 +01001376 TRACE("(VkDevice device = %p, const VkCommandPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkCommandPool* pCommandPool = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001377 device, pCreateInfo, pAllocator, pCommandPool);
1378
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001379 if(pCreateInfo->pNext)
1380 {
Ben Clayton00424c12019-03-17 17:29:30 +00001381 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001382 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001383
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001384 return vk::CommandPool::Create(pAllocator, pCreateInfo, pCommandPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001385}
1386
1387VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator)
1388{
Ben Claytonfb280672019-04-25 11:16:15 +01001389 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001390 device, commandPool, pAllocator);
1391
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001392 vk::destroy(commandPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001393}
1394
1395VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
1396{
Ben Claytonfb280672019-04-25 11:16:15 +01001397 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolResetFlags flags = %d)",
1398 device, commandPool, int(flags));
Alexis Hetucd610c92019-02-01 16:47:51 -05001399
1400 return vk::Cast(commandPool)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001401}
1402
1403VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers)
1404{
Ben Claytonfb280672019-04-25 11:16:15 +01001405 TRACE("(VkDevice device = %p, const VkCommandBufferAllocateInfo* pAllocateInfo = %p, VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001406 device, pAllocateInfo, pCommandBuffers);
1407
Alexis Hetubffee5e2018-11-19 11:30:43 -05001408 if(pAllocateInfo->pNext)
1409 {
Ben Clayton00424c12019-03-17 17:29:30 +00001410 UNIMPLEMENTED("pAllocateInfo->pNext");
Alexis Hetubffee5e2018-11-19 11:30:43 -05001411 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001412
Alexis Hetubffee5e2018-11-19 11:30:43 -05001413 return vk::Cast(pAllocateInfo->commandPool)->allocateCommandBuffers(
1414 pAllocateInfo->level, pAllocateInfo->commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001415}
1416
1417VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
1418{
Ben Claytonfb280672019-04-25 11:16:15 +01001419 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
1420 device, commandPool, int(commandBufferCount), pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001421
Alexis Hetubffee5e2018-11-19 11:30:43 -05001422 vk::Cast(commandPool)->freeCommandBuffers(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001423}
1424
1425VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo)
1426{
Ben Claytonfb280672019-04-25 11:16:15 +01001427 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCommandBufferBeginInfo* pBeginInfo = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001428 commandBuffer, pBeginInfo);
1429
Alexis Hetua9999ce2018-10-17 08:00:43 -04001430 if(pBeginInfo->pNext)
1431 {
Ben Clayton00424c12019-03-17 17:29:30 +00001432 UNIMPLEMENTED("pBeginInfo->pNext");
Alexis Hetua9999ce2018-10-17 08:00:43 -04001433 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001434
Alexis Hetua9999ce2018-10-17 08:00:43 -04001435 return vk::Cast(commandBuffer)->begin(pBeginInfo->flags, pBeginInfo->pInheritanceInfo);
Alexis Hetud73b8712018-09-21 15:14:43 -04001436}
1437
1438VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
1439{
Ben Claytonfb280672019-04-25 11:16:15 +01001440 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001441
Alexis Hetua9999ce2018-10-17 08:00:43 -04001442 return vk::Cast(commandBuffer)->end();
Alexis Hetud73b8712018-09-21 15:14:43 -04001443}
1444
1445VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags)
1446{
Ben Claytonfb280672019-04-25 11:16:15 +01001447 TRACE("VkCommandBuffer commandBuffer = %p, VkCommandBufferResetFlags flags = %d", commandBuffer, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001448
1449 return vk::Cast(commandBuffer)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001450}
1451
1452VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
1453{
Ben Claytonfb280672019-04-25 11:16:15 +01001454 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineBindPoint pipelineBindPoint = %d, VkPipeline pipeline = %p)",
1455 commandBuffer, int(pipelineBindPoint), pipeline);
Alexis Hetud73b8712018-09-21 15:14:43 -04001456
Alexis Hetua9999ce2018-10-17 08:00:43 -04001457 vk::Cast(commandBuffer)->bindPipeline(pipelineBindPoint, pipeline);
Alexis Hetud73b8712018-09-21 15:14:43 -04001458}
1459
1460VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
1461{
Ben Claytonfb280672019-04-25 11:16:15 +01001462 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstViewport = %d, uint32_t viewportCount = %d, const VkViewport* pViewports = %p)",
1463 commandBuffer, int(firstViewport), int(viewportCount), pViewports);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001464
1465 vk::Cast(commandBuffer)->setViewport(firstViewport, viewportCount, pViewports);
Alexis Hetud73b8712018-09-21 15:14:43 -04001466}
1467
1468VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
1469{
Ben Claytonfb280672019-04-25 11:16:15 +01001470 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstScissor = %d, uint32_t scissorCount = %d, const VkRect2D* pScissors = %p)",
1471 commandBuffer, int(firstScissor), int(scissorCount), pScissors);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001472
1473 vk::Cast(commandBuffer)->setScissor(firstScissor, scissorCount, pScissors);
Alexis Hetud73b8712018-09-21 15:14:43 -04001474}
1475
1476VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
1477{
Ben Claytonfb280672019-04-25 11:16:15 +01001478 TRACE("(VkCommandBuffer commandBuffer = %p, float lineWidth = %f)", commandBuffer, lineWidth);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001479
1480 vk::Cast(commandBuffer)->setLineWidth(lineWidth);
Alexis Hetud73b8712018-09-21 15:14:43 -04001481}
1482
1483VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
1484{
Ben Claytonfb280672019-04-25 11:16:15 +01001485 TRACE("(VkCommandBuffer commandBuffer = %p, float depthBiasConstantFactor = %f, float depthBiasClamp = %f, float depthBiasSlopeFactor = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001486 commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
1487
1488 vk::Cast(commandBuffer)->setDepthBias(depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
Alexis Hetud73b8712018-09-21 15:14:43 -04001489}
1490
1491VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
1492{
Ben Claytonfb280672019-04-25 11:16:15 +01001493 TRACE("(VkCommandBuffer commandBuffer = %p, const float blendConstants[4] = {%f, %f, %f, %f})",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001494 commandBuffer, blendConstants[0], blendConstants[1], blendConstants[2], blendConstants[3]);
1495
1496 vk::Cast(commandBuffer)->setBlendConstants(blendConstants);
Alexis Hetud73b8712018-09-21 15:14:43 -04001497}
1498
1499VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
1500{
Ben Claytonfb280672019-04-25 11:16:15 +01001501 TRACE("(VkCommandBuffer commandBuffer = %p, float minDepthBounds = %f, float maxDepthBounds = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001502 commandBuffer, minDepthBounds, maxDepthBounds);
1503
1504 vk::Cast(commandBuffer)->setDepthBounds(minDepthBounds, maxDepthBounds);
Alexis Hetud73b8712018-09-21 15:14:43 -04001505}
1506
1507VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
1508{
Ben Claytonfb280672019-04-25 11:16:15 +01001509 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t compareMask = %d)",
1510 commandBuffer, int(faceMask), int(compareMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001511
1512 vk::Cast(commandBuffer)->setStencilCompareMask(faceMask, compareMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001513}
1514
1515VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
1516{
Ben Claytonfb280672019-04-25 11:16:15 +01001517 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t writeMask = %d)",
1518 commandBuffer, int(faceMask), int(writeMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001519
1520 vk::Cast(commandBuffer)->setStencilWriteMask(faceMask, writeMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001521}
1522
1523VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
1524{
Ben Claytonfb280672019-04-25 11:16:15 +01001525 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t reference = %d)",
1526 commandBuffer, int(faceMask), int(reference));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001527
1528 vk::Cast(commandBuffer)->setStencilReference(faceMask, reference);
Alexis Hetud73b8712018-09-21 15:14:43 -04001529}
1530
1531VKAPI_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)
1532{
Ben Claytonfb280672019-04-25 11:16:15 +01001533 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineBindPoint pipelineBindPoint = %d, VkPipelineLayout layout = %p, uint32_t firstSet = %d, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = %p, uint32_t dynamicOffsetCount = %d, const uint32_t* pDynamicOffsets = %p)",
1534 commandBuffer, int(pipelineBindPoint), layout, int(firstSet), int(descriptorSetCount), pDescriptorSets, int(dynamicOffsetCount), pDynamicOffsets);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001535
1536 vk::Cast(commandBuffer)->bindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001537}
1538
1539VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
1540{
Ben Claytonfb280672019-04-25 11:16:15 +01001541 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkIndexType indexType = %d)",
1542 commandBuffer, buffer, int(offset), int(indexType));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001543
1544 vk::Cast(commandBuffer)->bindIndexBuffer(buffer, offset, indexType);
Alexis Hetud73b8712018-09-21 15:14:43 -04001545}
1546
1547VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
1548{
Ben Claytonfb280672019-04-25 11:16:15 +01001549 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = %p, const VkDeviceSize* pOffsets = %p)",
1550 commandBuffer, int(firstBinding), int(bindingCount), pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001551
Alexis Hetua9999ce2018-10-17 08:00:43 -04001552 vk::Cast(commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001553}
1554
1555VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
1556{
Ben Claytonfb280672019-04-25 11:16:15 +01001557 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t vertexCount = %d, uint32_t instanceCount = %d, uint32_t firstVertex = %d, uint32_t firstInstance = %d)",
1558 commandBuffer, int(vertexCount), int(instanceCount), int(firstVertex), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04001559
Alexis Hetua9999ce2018-10-17 08:00:43 -04001560 vk::Cast(commandBuffer)->draw(vertexCount, instanceCount, firstVertex, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04001561}
1562
1563VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
1564{
Ben Claytonfb280672019-04-25 11:16:15 +01001565 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t indexCount = %d, uint32_t instanceCount = %d, uint32_t firstIndex = %d, int32_t vertexOffset = %d, uint32_t firstInstance = %d)",
1566 commandBuffer, int(indexCount), int(instanceCount), int(firstIndex), int(vertexOffset), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04001567
Alexis Hetua9999ce2018-10-17 08:00:43 -04001568 vk::Cast(commandBuffer)->drawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04001569}
1570
1571VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1572{
Ben Claytonfb280672019-04-25 11:16:15 +01001573 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
1574 commandBuffer, buffer, int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04001575
Alexis Hetua9999ce2018-10-17 08:00:43 -04001576 vk::Cast(commandBuffer)->drawIndirect(buffer, offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04001577}
1578
1579VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1580{
Ben Claytonfb280672019-04-25 11:16:15 +01001581 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
1582 commandBuffer, buffer, int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04001583
Alexis Hetua9999ce2018-10-17 08:00:43 -04001584 vk::Cast(commandBuffer)->drawIndexedIndirect(buffer, offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04001585}
1586
1587VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
1588{
Ben Claytonfb280672019-04-25 11:16:15 +01001589 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t groupCountX = %d, uint32_t groupCountY = %d, uint32_t groupCountZ = %d)",
1590 commandBuffer, int(groupCountX), int(groupCountY), int(groupCountZ));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001591
1592 vk::Cast(commandBuffer)->dispatch(groupCountX, groupCountY, groupCountZ);
Alexis Hetud73b8712018-09-21 15:14:43 -04001593}
1594
1595VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
1596{
Ben Claytonfb280672019-04-25 11:16:15 +01001597 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d)",
1598 commandBuffer, buffer, int(offset));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001599
1600 vk::Cast(commandBuffer)->dispatchIndirect(buffer, offset);
Alexis Hetud73b8712018-09-21 15:14:43 -04001601}
1602
1603VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
1604{
Ben Claytonfb280672019-04-25 11:16:15 +01001605 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferCopy* pRegions = %p)",
1606 commandBuffer, srcBuffer, dstBuffer, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001607
1608 vk::Cast(commandBuffer)->copyBuffer(srcBuffer, dstBuffer, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001609}
1610
1611VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions)
1612{
Ben Claytonfb280672019-04-25 11:16:15 +01001613 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageCopy* pRegions = %p)",
1614 commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001615
1616 vk::Cast(commandBuffer)->copyImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001617}
1618
1619VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter)
1620{
Ben Claytonfb280672019-04-25 11:16:15 +01001621 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageBlit* pRegions = %p, VkFilter filter = %d)",
1622 commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, int(regionCount), pRegions, filter);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001623
1624 vk::Cast(commandBuffer)->blitImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
Alexis Hetud73b8712018-09-21 15:14:43 -04001625}
1626
1627VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1628{
Ben Claytonfb280672019-04-25 11:16:15 +01001629 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
1630 commandBuffer, srcBuffer, dstImage, dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001631
1632 vk::Cast(commandBuffer)->copyBufferToImage(srcBuffer, dstImage, dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001633}
1634
1635VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1636{
Ben Claytonfb280672019-04-25 11:16:15 +01001637 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
1638 commandBuffer, srcImage, int(srcImageLayout), dstBuffer, int(regionCount), pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001639
Alexis Hetua9999ce2018-10-17 08:00:43 -04001640 vk::Cast(commandBuffer)->copyImageToBuffer(srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001641}
1642
1643VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)
1644{
Ben Claytonfb280672019-04-25 11:16:15 +01001645 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize dataSize = %d, const void* pData = %p)",
1646 commandBuffer, dstBuffer, int(dstOffset), int(dataSize), pData);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001647
1648 vk::Cast(commandBuffer)->updateBuffer(dstBuffer, dstOffset, dataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001649}
1650
1651VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
1652{
Ben Claytonfb280672019-04-25 11:16:15 +01001653 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize size = %d, uint32_t data = %d)",
1654 commandBuffer, dstBuffer, int(dstOffset), int(size), data);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001655
1656 vk::Cast(commandBuffer)->fillBuffer(dstBuffer, dstOffset, size, data);
Alexis Hetud73b8712018-09-21 15:14:43 -04001657}
1658
1659VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1660{
Ben Claytonfb280672019-04-25 11:16:15 +01001661 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearColorValue* pColor = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
1662 commandBuffer, image, int(imageLayout), pColor, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001663
1664 vk::Cast(commandBuffer)->clearColorImage(image, imageLayout, pColor, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001665}
1666
1667VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1668{
Ben Claytonfb280672019-04-25 11:16:15 +01001669 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearDepthStencilValue* pDepthStencil = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
1670 commandBuffer, image, int(imageLayout), pDepthStencil, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001671
1672 vk::Cast(commandBuffer)->clearDepthStencilImage(image, imageLayout, pDepthStencil, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001673}
1674
1675VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects)
1676{
Ben Claytonfb280672019-04-25 11:16:15 +01001677 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t attachmentCount = %d, const VkClearAttachment* pAttachments = %p, uint32_t rectCount = %d, const VkClearRect* pRects = %p)",
1678 commandBuffer, int(attachmentCount), pAttachments, int(rectCount), pRects);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001679
1680 vk::Cast(commandBuffer)->clearAttachments(attachmentCount, pAttachments, rectCount, pRects);
Alexis Hetud73b8712018-09-21 15:14:43 -04001681}
1682
1683VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions)
1684{
Ben Claytonfb280672019-04-25 11:16:15 +01001685 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageResolve* pRegions = %p)",
1686 commandBuffer, srcImage, int(srcImageLayout), dstImage, int(dstImageLayout), regionCount, pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001687
1688 vk::Cast(commandBuffer)->resolveImage(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001689}
1690
1691VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1692{
Ben Claytonfb280672019-04-25 11:16:15 +01001693 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
1694 commandBuffer, event, int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001695
1696 vk::Cast(commandBuffer)->setEvent(event, stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001697}
1698
1699VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1700{
Ben Claytonfb280672019-04-25 11:16:15 +01001701 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
1702 commandBuffer, event, int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001703
1704 vk::Cast(commandBuffer)->resetEvent(event, stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001705}
1706
1707VKAPI_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)
1708{
Ben Claytonfb280672019-04-25 11:16:15 +01001709 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t eventCount = %d, const VkEvent* pEvents = %p, VkPipelineStageFlags srcStageMask = 0x%x, VkPipelineStageFlags dstStageMask = 0x%x, uint32_t memoryBarrierCount = %d, const VkMemoryBarrier* pMemoryBarriers = %p, uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
1710 commandBuffer, int(eventCount), pEvents, int(srcStageMask), int(dstStageMask), int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001711
1712 vk::Cast(commandBuffer)->waitEvents(eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001713}
1714
1715VKAPI_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)
1716{
Ben Claytonfb280672019-04-25 11:16:15 +01001717 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlags srcStageMask = 0x%x, VkPipelineStageFlags dstStageMask = 0x%x, VkDependencyFlags dependencyFlags = %d, uint32_t memoryBarrierCount = %d, onst VkMemoryBarrier* pMemoryBarriers = %p,"
1718 " uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
1719 commandBuffer, int(srcStageMask), int(dstStageMask), dependencyFlags, int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001720
Alexis Hetua9999ce2018-10-17 08:00:43 -04001721 vk::Cast(commandBuffer)->pipelineBarrier(srcStageMask, dstStageMask, dependencyFlags,
1722 memoryBarrierCount, pMemoryBarriers,
1723 bufferMemoryBarrierCount, pBufferMemoryBarriers,
1724 imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001725}
1726
1727VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
1728{
Ben Claytonfb280672019-04-25 11:16:15 +01001729 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d, VkQueryControlFlags flags = %d)",
1730 commandBuffer, queryPool, query, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001731
1732 vk::Cast(commandBuffer)->beginQuery(queryPool, query, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001733}
1734
1735VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
1736{
Ben Claytonfb280672019-04-25 11:16:15 +01001737 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d)",
1738 commandBuffer, queryPool, int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001739
1740 vk::Cast(commandBuffer)->endQuery(queryPool, query);
Alexis Hetud73b8712018-09-21 15:14:43 -04001741}
1742
1743VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
1744{
Ben Claytonfb280672019-04-25 11:16:15 +01001745 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
1746 commandBuffer, queryPool, int(firstQuery), int(queryCount));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001747
1748 vk::Cast(commandBuffer)->resetQueryPool(queryPool, firstQuery, queryCount);
Alexis Hetud73b8712018-09-21 15:14:43 -04001749}
1750
1751VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
1752{
Ben Claytonfb280672019-04-25 11:16:15 +01001753 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlagBits pipelineStage = %d, VkQueryPool queryPool = %p, uint32_t query = %d)",
1754 commandBuffer, int(pipelineStage), queryPool, int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001755
1756 vk::Cast(commandBuffer)->writeTimestamp(pipelineStage, queryPool, query);
Alexis Hetud73b8712018-09-21 15:14:43 -04001757}
1758
1759VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
1760{
Ben Claytonfb280672019-04-25 11:16:15 +01001761 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize stride = %d, VkQueryResultFlags flags = %d)",
1762 commandBuffer, queryPool, int(firstQuery), int(queryCount), dstBuffer, int(dstOffset), int(stride), int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001763
1764 vk::Cast(commandBuffer)->copyQueryPoolResults(queryPool, firstQuery, queryCount, dstBuffer, dstOffset, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001765}
1766
1767VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues)
1768{
Ben Claytonfb280672019-04-25 11:16:15 +01001769 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineLayout layout = %p, VkShaderStageFlags stageFlags = %d, uint32_t offset = %d, uint32_t size = %d, const void* pValues = %p)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001770 commandBuffer, layout, stageFlags, offset, size, pValues);
1771
1772 vk::Cast(commandBuffer)->pushConstants(layout, stageFlags, offset, size, pValues);
Alexis Hetud73b8712018-09-21 15:14:43 -04001773}
1774
1775VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents)
1776{
Ben Claytonfb280672019-04-25 11:16:15 +01001777 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderPassBeginInfo* pRenderPassBegin = %p, VkSubpassContents contents = %d)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04001778 commandBuffer, pRenderPassBegin, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04001779
Alexis Hetua9999ce2018-10-17 08:00:43 -04001780 if(pRenderPassBegin->pNext)
1781 {
Ben Clayton00424c12019-03-17 17:29:30 +00001782 UNIMPLEMENTED("pRenderPassBegin->pNext");
Alexis Hetua9999ce2018-10-17 08:00:43 -04001783 }
1784
1785 vk::Cast(commandBuffer)->beginRenderPass(pRenderPassBegin->renderPass, pRenderPassBegin->framebuffer,
1786 pRenderPassBegin->renderArea, pRenderPassBegin->clearValueCount,
1787 pRenderPassBegin->pClearValues, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04001788}
1789
1790VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
1791{
Ben Claytonfb280672019-04-25 11:16:15 +01001792 TRACE("(VkCommandBuffer commandBuffer = %p, VkSubpassContents contents = %d)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001793 commandBuffer, contents);
1794
1795 vk::Cast(commandBuffer)->nextSubpass(contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04001796}
1797
1798VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
1799{
Ben Claytonfb280672019-04-25 11:16:15 +01001800 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001801
Alexis Hetua9999ce2018-10-17 08:00:43 -04001802 vk::Cast(commandBuffer)->endRenderPass();
Alexis Hetud73b8712018-09-21 15:14:43 -04001803}
1804
1805VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
1806{
Ben Claytonfb280672019-04-25 11:16:15 +01001807 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001808 commandBuffer, commandBufferCount, pCommandBuffers);
1809
1810 vk::Cast(commandBuffer)->executeCommands(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001811}
1812
1813VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion)
1814{
Ben Claytonfb280672019-04-25 11:16:15 +01001815 TRACE("(uint32_t* pApiVersion = %p)", pApiVersion);
Nicolas Capensee841c52018-11-13 14:18:26 -05001816 *pApiVersion = vk::API_VERSION;
Alexis Hetud73b8712018-09-21 15:14:43 -04001817 return VK_SUCCESS;
1818}
1819
1820VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos)
1821{
Ben Claytonfb280672019-04-25 11:16:15 +01001822 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = %p)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04001823 device, bindInfoCount, pBindInfos);
1824
1825 for(uint32_t i = 0; i < bindInfoCount; i++)
1826 {
1827 if(pBindInfos[i].pNext)
1828 {
Ben Clayton00424c12019-03-17 17:29:30 +00001829 UNIMPLEMENTED("pBindInfos[%d].pNext", i);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001830 }
1831
1832 vk::Cast(pBindInfos[i].buffer)->bind(pBindInfos[i].memory, pBindInfos[i].memoryOffset);
1833 }
1834
Alexis Hetud73b8712018-09-21 15:14:43 -04001835 return VK_SUCCESS;
1836}
1837
1838VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos)
1839{
1840 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +00001841 UNIMPLEMENTED("vkBindImageMemory2");
Alexis Hetud73b8712018-09-21 15:14:43 -04001842 return VK_SUCCESS;
1843}
1844
1845VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures)
1846{
Ben Claytonfb280672019-04-25 11:16:15 +01001847 TRACE("(VkDevice device = %p, uint32_t heapIndex = %d, uint32_t localDeviceIndex = %d, uint32_t remoteDeviceIndex = %d, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001848 device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
1849
Nicolas Capens5028a582018-11-13 15:03:35 -05001850 ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
Ben Clayton00424c12019-03-17 17:29:30 +00001851 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.
Alexis Hetud73b8712018-09-21 15:14:43 -04001852}
1853
1854VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
1855{
1856 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +00001857 UNIMPLEMENTED("vkCmdSetDeviceMask");
Alexis Hetud73b8712018-09-21 15:14:43 -04001858}
1859
1860VKAPI_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)
1861{
1862 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +00001863 UNIMPLEMENTED("vkCmdDispatchBase");
Alexis Hetud73b8712018-09-21 15:14:43 -04001864}
1865
1866VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties)
1867{
Ben Claytonfb280672019-04-25 11:16:15 +01001868 TRACE("VkInstance instance = %p, uint32_t* pPhysicalDeviceGroupCount = %p, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = %p",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001869 instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
1870
1871 if(!pPhysicalDeviceGroupProperties)
1872 {
1873 *pPhysicalDeviceGroupCount = vk::Cast(instance)->getPhysicalDeviceGroupCount();
1874 }
1875 else
1876 {
1877 vk::Cast(instance)->getPhysicalDeviceGroups(*pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
1878 }
1879
Alexis Hetud73b8712018-09-21 15:14:43 -04001880 return VK_SUCCESS;
1881}
1882
1883VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
1884{
Ben Claytonfb280672019-04-25 11:16:15 +01001885 TRACE("(VkDevice device = %p, const VkImageMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001886 device, pInfo, pMemoryRequirements);
1887
Alexis Hetu42761d22019-04-08 11:25:59 -04001888 if(pInfo->pNext)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001889 {
Alexis Hetu42761d22019-04-08 11:25:59 -04001890 UNIMPLEMENTED("pInfo->pNext");
1891 }
1892
1893 VkBaseOutStructure* extensionRequirements = reinterpret_cast<VkBaseOutStructure*>(pMemoryRequirements->pNext);
1894 while(extensionRequirements)
1895 {
1896 switch(extensionRequirements->sType)
1897 {
1898 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
1899 {
1900 auto& requirements = *reinterpret_cast<VkMemoryDedicatedRequirements*>(extensionRequirements);
1901 requirements.prefersDedicatedAllocation = VK_FALSE;
1902 requirements.requiresDedicatedAllocation = VK_FALSE;
1903 }
1904 break;
1905 default:
1906 UNIMPLEMENTED("extensionRequirements->sType");
1907 break;
1908 }
1909
1910 extensionRequirements = extensionRequirements->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001911 }
1912
1913 vkGetImageMemoryRequirements(device, pInfo->image, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04001914}
1915
1916VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
1917{
Ben Claytonfb280672019-04-25 11:16:15 +01001918 TRACE("(VkDevice device = %p, const VkBufferMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001919 device, pInfo, pMemoryRequirements);
1920
Alexis Hetu1e6a9892019-03-15 12:12:00 -04001921 if(pInfo->pNext)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001922 {
Ben Clayton00424c12019-03-17 17:29:30 +00001923 UNIMPLEMENTED("pInfo->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001924 }
1925
Alexis Hetu1e6a9892019-03-15 12:12:00 -04001926 VkBaseOutStructure* extensionRequirements = reinterpret_cast<VkBaseOutStructure*>(pMemoryRequirements->pNext);
1927 while(extensionRequirements)
1928 {
1929 switch(extensionRequirements->sType)
1930 {
1931 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
1932 {
1933 auto& requirements = *reinterpret_cast<VkMemoryDedicatedRequirements*>(extensionRequirements);
1934 requirements.prefersDedicatedAllocation = VK_FALSE;
1935 requirements.requiresDedicatedAllocation = VK_FALSE;
1936 }
1937 break;
1938 default:
Ben Clayton00424c12019-03-17 17:29:30 +00001939 UNIMPLEMENTED("extensionRequirements->sType");
Alexis Hetu1e6a9892019-03-15 12:12:00 -04001940 break;
1941 }
1942
1943 extensionRequirements = extensionRequirements->pNext;
1944 }
1945
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001946 vkGetBufferMemoryRequirements(device, pInfo->buffer, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04001947}
1948
1949VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements)
1950{
Ben Claytonfb280672019-04-25 11:16:15 +01001951 TRACE("(VkDevice device = %p, const VkImageSparseMemoryRequirementsInfo2* pInfo = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001952 device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
1953
1954 if(pInfo->pNext || pSparseMemoryRequirements->pNext)
1955 {
Ben Clayton00424c12019-03-17 17:29:30 +00001956 UNIMPLEMENTED("pInfo->pNext || pSparseMemoryRequirements->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001957 }
1958
1959 vkGetImageSparseMemoryRequirements(device, pInfo->image, pSparseMemoryRequirementCount, &(pSparseMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04001960}
1961
1962VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures)
1963{
Ben Claytonfb280672019-04-25 11:16:15 +01001964 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures2* pFeatures = %p)", physicalDevice, pFeatures);
Alexis Hetud73b8712018-09-21 15:14:43 -04001965
Nicolas Capensae8d4642018-11-13 15:17:16 -05001966 VkBaseOutStructure* extensionFeatures = reinterpret_cast<VkBaseOutStructure*>(pFeatures->pNext);
1967 while(extensionFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -04001968 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001969 switch(extensionFeatures->sType)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001970 {
1971 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
1972 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001973 auto& features = *reinterpret_cast<VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001974 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001975 }
1976 break;
1977 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
1978 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001979 auto& features = *reinterpret_cast<VkPhysicalDevice16BitStorageFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001980 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001981 }
1982 break;
1983 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
1984 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001985 auto& features = *reinterpret_cast<VkPhysicalDeviceVariablePointerFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001986 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001987 }
1988 break;
1989 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR:
1990 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001991 auto& features = *reinterpret_cast<VkPhysicalDevice8BitStorageFeaturesKHR*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001992 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001993 }
1994 break;
1995 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
1996 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05001997 auto& features = *reinterpret_cast<VkPhysicalDeviceMultiviewFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001998 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001999 }
2000 break;
2001 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
2002 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002003 auto& features = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002004 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002005 }
2006 break;
Chris Forbes6408c552019-04-15 12:59:34 -07002007 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES:
2008 {
2009 auto& features = *reinterpret_cast<VkPhysicalDeviceShaderDrawParameterFeatures*>(extensionFeatures);
2010 vk::Cast(physicalDevice)->getFeatures(&features);
2011 }
2012 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002013 default:
Nicolas Capensae8d4642018-11-13 15:17:16 -05002014 // "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]"
Ben Clayton00424c12019-03-17 17:29:30 +00002015 UNIMPLEMENTED("extensionFeatures->sType"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
Nicolas Capensae8d4642018-11-13 15:17:16 -05002016 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002017 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05002018
2019 extensionFeatures = extensionFeatures->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002020 }
2021
2022 vkGetPhysicalDeviceFeatures(physicalDevice, &(pFeatures->features));
Alexis Hetud73b8712018-09-21 15:14:43 -04002023}
2024
2025VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties)
2026{
Ben Claytonfb280672019-04-25 11:16:15 +01002027 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties2* pProperties = %p)", physicalDevice, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002028
Nicolas Capensae8d4642018-11-13 15:17:16 -05002029 VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pProperties->pNext);
2030 while(extensionProperties)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002031 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002032 switch(extensionProperties->sType)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002033 {
2034 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
2035 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002036 auto& properties = *reinterpret_cast<VkPhysicalDeviceIDProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002037 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002038 }
2039 break;
2040 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
2041 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002042 auto& properties = *reinterpret_cast<VkPhysicalDeviceMaintenance3Properties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002043 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002044 }
2045 break;
2046 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
2047 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002048 auto& properties = *reinterpret_cast<VkPhysicalDeviceMultiviewProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002049 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002050 }
2051 break;
2052 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
2053 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002054 auto& properties = *reinterpret_cast<VkPhysicalDevicePointClippingProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002055 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002056 }
2057 break;
2058 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
2059 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002060 auto& properties = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002061 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002062 }
2063 break;
2064 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
2065 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002066 auto& properties = *reinterpret_cast<VkPhysicalDeviceSubgroupProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002067 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002068 }
2069 break;
Alexis Hetud6fae382019-04-05 13:19:46 -04002070 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT:
2071 // Explicitly ignored, since VK_EXT_sample_locations is not supported
2072 ASSERT(!HasExtensionProperty(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME, deviceExtensionProperties,
2073 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2074 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002075 default:
Nicolas Capensae8d4642018-11-13 15:17:16 -05002076 // "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]"
Ben Clayton00424c12019-03-17 17:29:30 +00002077 UNIMPLEMENTED("extensionProperties->sType"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
Nicolas Capensae8d4642018-11-13 15:17:16 -05002078 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002079 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05002080
2081 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002082 }
2083
2084 vkGetPhysicalDeviceProperties(physicalDevice, &(pProperties->properties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002085}
2086
2087VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties)
2088{
Ben Claytonfb280672019-04-25 11:16:15 +01002089 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties2* pFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002090 physicalDevice, format, pFormatProperties);
2091
Alexis Hetu767b41b2018-09-26 11:25:46 -04002092 if(pFormatProperties->pNext)
2093 {
Ben Clayton00424c12019-03-17 17:29:30 +00002094 UNIMPLEMENTED("pFormatProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002095 }
2096
2097 vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &(pFormatProperties->formatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002098}
2099
2100VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties)
2101{
Ben Claytonfb280672019-04-25 11:16:15 +01002102 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo = %p, VkImageFormatProperties2* pImageFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002103 physicalDevice, pImageFormatInfo, pImageFormatProperties);
2104
Alexis Hetu00835732019-04-10 16:36:31 -04002105 const VkBaseInStructure* extensionFormatInfo = reinterpret_cast<const VkBaseInStructure*>(pImageFormatInfo->pNext);
2106
2107 const VkExternalMemoryHandleTypeFlagBits* handleType = nullptr;
2108 while(extensionFormatInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002109 {
Alexis Hetu00835732019-04-10 16:36:31 -04002110 switch(extensionFormatInfo->sType)
2111 {
2112 case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR:
2113 {
2114 // Explicitly ignored, since VK_KHR_image_format_list is not supported
2115 ASSERT(!HasExtensionProperty(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, deviceExtensionProperties,
2116 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2117 }
2118 break;
2119 case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT:
2120 {
2121 // Explicitly ignored, since VK_EXT_separate_stencil_usage is not supported
2122 ASSERT(!HasExtensionProperty(VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME, deviceExtensionProperties,
2123 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2124 }
2125 break;
2126 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
2127 {
2128 const VkPhysicalDeviceExternalImageFormatInfo* imageFormatInfo = reinterpret_cast<const VkPhysicalDeviceExternalImageFormatInfo*>(extensionFormatInfo);
2129 handleType = &(imageFormatInfo->handleType);
2130 }
2131 break;
2132 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
2133 {
2134 // Explicitly ignored, since VK_EXT_image_drm_format_modifier is not supported
2135 ASSERT(!HasExtensionProperty(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, deviceExtensionProperties,
2136 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2137 }
2138 break;
2139 default:
2140 UNIMPLEMENTED("extensionFormatInfo->sType");
2141 break;
2142 }
2143
2144 extensionFormatInfo = extensionFormatInfo->pNext;
2145 }
2146
2147 VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pImageFormatProperties->pNext);
2148
2149 while(extensionProperties)
2150 {
2151 switch(extensionProperties->sType)
2152 {
2153 case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
2154 {
2155 auto& properties = *reinterpret_cast<VkExternalImageFormatProperties*>(extensionProperties);
2156 vk::Cast(physicalDevice)->getProperties(handleType, &properties);
2157 }
2158 break;
2159 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
2160 {
2161 auto& properties = *reinterpret_cast<VkSamplerYcbcrConversionImageFormatProperties*>(extensionProperties);
2162 vk::Cast(physicalDevice)->getProperties(&properties);
2163 }
2164 break;
2165 case VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD:
2166 {
2167 // Explicitly ignored, since VK_AMD_texture_gather_bias_lod is not supported
2168 ASSERT(!HasExtensionProperty(VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME, deviceExtensionProperties,
2169 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2170 }
2171 break;
2172 default:
2173 UNIMPLEMENTED("extensionProperties->sType");
2174 break;
2175 }
2176
2177 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002178 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002179
Alexis Hetu767b41b2018-09-26 11:25:46 -04002180 return vkGetPhysicalDeviceImageFormatProperties(physicalDevice,
2181 pImageFormatInfo->format,
2182 pImageFormatInfo->type,
2183 pImageFormatInfo->tiling,
2184 pImageFormatInfo->usage,
2185 pImageFormatInfo->flags,
2186 &(pImageFormatProperties->imageFormatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002187}
2188
2189VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties)
2190{
Ben Claytonfb280672019-04-25 11:16:15 +01002191 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties2* pQueueFamilyProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002192 physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
2193
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002194 if(pQueueFamilyProperties && pQueueFamilyProperties->pNext)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002195 {
Ben Clayton00424c12019-03-17 17:29:30 +00002196 UNIMPLEMENTED("pQueueFamilyProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002197 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04002198
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002199 vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount,
2200 pQueueFamilyProperties ? &(pQueueFamilyProperties->queueFamilyProperties) : nullptr);
Alexis Hetud73b8712018-09-21 15:14:43 -04002201}
2202
2203VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties)
2204{
Ben Claytonfb280672019-04-25 11:16:15 +01002205 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties2* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002206
Alexis Hetu767b41b2018-09-26 11:25:46 -04002207 if(pMemoryProperties->pNext)
2208 {
Ben Clayton00424c12019-03-17 17:29:30 +00002209 UNIMPLEMENTED("pMemoryProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002210 }
2211
2212 vkGetPhysicalDeviceMemoryProperties(physicalDevice, &(pMemoryProperties->memoryProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002213}
2214
2215VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties)
2216{
Ben Claytonfb280672019-04-25 11:16:15 +01002217 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo = %p, uint32_t* pPropertyCount = %p, VkSparseImageFormatProperties2* pProperties = %p)",
Alexis Hetu767b41b2018-09-26 11:25:46 -04002218 physicalDevice, pFormatInfo, pPropertyCount, pProperties);
2219
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002220 if(pProperties && pProperties->pNext)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002221 {
Ben Clayton00424c12019-03-17 17:29:30 +00002222 UNIMPLEMENTED("pProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002223 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04002224
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002225 vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, pFormatInfo->format, pFormatInfo->type,
2226 pFormatInfo->samples, pFormatInfo->usage, pFormatInfo->tiling,
2227 pPropertyCount, pProperties ? &(pProperties->properties) : nullptr);
Alexis Hetud73b8712018-09-21 15:14:43 -04002228}
2229
2230VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags)
2231{
Ben Claytonfb280672019-04-25 11:16:15 +01002232 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolTrimFlags flags = %d)",
Nicolas Capensde16f322019-02-12 00:32:31 -05002233 device, commandPool, flags);
2234
Alexis Hetucd610c92019-02-01 16:47:51 -05002235 vk::Cast(commandPool)->trim(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002236}
2237
2238VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue)
2239{
Ben Claytonfb280672019-04-25 11:16:15 +01002240 TRACE("(VkDevice device = %p, const VkDeviceQueueInfo2* pQueueInfo = %p, VkQueue* pQueue = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002241 device, pQueueInfo, pQueue);
2242
2243 if(pQueueInfo->pNext)
2244 {
Ben Clayton00424c12019-03-17 17:29:30 +00002245 UNIMPLEMENTED("pQueueInfo->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002246 }
2247
Nicolas Capens50b10592018-10-26 10:34:20 -04002248 // The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002249 // According to the Vulkan spec, 4.3.1. Queue Family Properties:
2250 // "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
2251 // protected-capable queue. If the protected memory feature is not enabled,
2252 // the VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT bit of flags must not be set."
2253 if(pQueueInfo->flags)
2254 {
2255 *pQueue = VK_NULL_HANDLE;
2256 }
2257 else
2258 {
2259 vkGetDeviceQueue(device, pQueueInfo->queueFamilyIndex, pQueueInfo->queueIndex, pQueue);
2260 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002261}
2262
2263VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion)
2264{
2265 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +00002266 UNIMPLEMENTED("vkCreateSamplerYcbcrConversion");
Alexis Hetud73b8712018-09-21 15:14:43 -04002267 return VK_SUCCESS;
2268}
2269
2270VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator)
2271{
2272 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +00002273 UNIMPLEMENTED("vkDestroySamplerYcbcrConversion");
Alexis Hetud73b8712018-09-21 15:14:43 -04002274}
2275
2276VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate)
2277{
Ben Claytonfb280672019-04-25 11:16:15 +01002278 TRACE("(VkDevice device = %p, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = %p)",
Alexis Hetuf705cec2019-01-29 14:09:36 -05002279 device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
2280
2281 if(pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET))
2282 {
Ben Clayton00424c12019-03-17 17:29:30 +00002283 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)");
Alexis Hetuf705cec2019-01-29 14:09:36 -05002284 }
2285
2286 return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, pDescriptorUpdateTemplate);
Alexis Hetud73b8712018-09-21 15:14:43 -04002287}
2288
2289VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator)
2290{
Ben Claytonfb280672019-04-25 11:16:15 +01002291 TRACE("(VkDevice device = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetuf705cec2019-01-29 14:09:36 -05002292 device, descriptorUpdateTemplate, pAllocator);
2293
2294 vk::destroy(descriptorUpdateTemplate, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002295}
2296
2297VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData)
2298{
Ben Claytonfb280672019-04-25 11:16:15 +01002299 TRACE("(VkDevice device = %p, VkDescriptorSet descriptorSet = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const void* pData = %p)",
Alexis Hetuf705cec2019-01-29 14:09:36 -05002300 device, descriptorSet, descriptorUpdateTemplate, pData);
2301
2302 vk::Cast(descriptorUpdateTemplate)->updateDescriptorSet(descriptorSet, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04002303}
2304
2305VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties)
2306{
Ben Claytonfb280672019-04-25 11:16:15 +01002307 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo = %p, VkExternalBufferProperties* pExternalBufferProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002308 physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
2309
Alexis Hetu00835732019-04-10 16:36:31 -04002310 vk::Cast(physicalDevice)->getProperties(pExternalBufferInfo, pExternalBufferProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002311}
2312
2313VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties)
2314{
Ben Claytonfb280672019-04-25 11:16:15 +01002315 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo = %p, VkExternalFenceProperties* pExternalFenceProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002316 physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
2317
Alexis Hetu00835732019-04-10 16:36:31 -04002318 vk::Cast(physicalDevice)->getProperties(pExternalFenceInfo, pExternalFenceProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002319}
2320
2321VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties)
2322{
Ben Claytonfb280672019-04-25 11:16:15 +01002323 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo = %p, VkExternalSemaphoreProperties* pExternalSemaphoreProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002324 physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
2325
Alexis Hetu00835732019-04-10 16:36:31 -04002326 vk::Cast(physicalDevice)->getProperties(pExternalSemaphoreInfo, pExternalSemaphoreProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002327}
2328
2329VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport)
2330{
Ben Claytonfb280672019-04-25 11:16:15 +01002331 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, VkDescriptorSetLayoutSupport* pSupport = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04002332 device, pCreateInfo, pSupport);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002333
2334 vk::Cast(device)->getDescriptorSetLayoutSupport(pCreateInfo, pSupport);
Alexis Hetud73b8712018-09-21 15:14:43 -04002335}
2336
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002337#ifdef VK_USE_PLATFORM_XLIB_KHR
2338VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2339{
Ben Claytonfb280672019-04-25 11:16:15 +01002340 TRACE("(VkInstance instance = %p, VkXlibSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002341 instance, pCreateInfo, pAllocator, pSurface);
2342
2343 return vk::XlibSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
2344}
2345#endif
2346
Chris Forbes1d667d62019-04-05 08:25:18 -07002347#ifndef __ANDROID__
2348VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator)
2349{
Ben Claytonfb280672019-04-25 11:16:15 +01002350 TRACE("(VkInstance instance = %p, VkSurfaceKHR surface = %p, const VkAllocationCallbacks* pAllocator = %p)",
Chris Forbes1d667d62019-04-05 08:25:18 -07002351 instance, surface, pAllocator);
2352
2353 vk::destroy(surface, pAllocator);
2354}
2355
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002356VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported)
2357{
Ben Claytonfb280672019-04-25 11:16:15 +01002358 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, VkSurface surface = %p, VKBool32* pSupported = %p)",
2359 physicalDevice, int(queueFamilyIndex), surface, pSupported);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002360
2361 *pSupported = VK_TRUE;
2362 return VK_SUCCESS;
2363}
2364
2365
2366VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
2367{
Ben Claytonfb280672019-04-25 11:16:15 +01002368 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = %p)",
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002369 physicalDevice, surface, pSurfaceCapabilities);
2370
2371 vk::Cast(surface)->getSurfaceCapabilities(pSurfaceCapabilities);
2372 return VK_SUCCESS;
2373}
2374
2375VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats)
2376{
Ben Claytonfb280672019-04-25 11:16:15 +01002377 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p. uint32_t* pSurfaceFormatCount = %p, VkSurfaceFormatKHR* pSurfaceFormats = %p)",
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002378 physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
2379
2380 if(!pSurfaceFormats)
2381 {
2382 *pSurfaceFormatCount = vk::Cast(surface)->getSurfaceFormatsCount();
2383 return VK_SUCCESS;
2384 }
2385
2386 return vk::Cast(surface)->getSurfaceFormats(pSurfaceFormatCount, pSurfaceFormats);
2387}
2388
2389VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes)
2390{
Ben Claytonfb280672019-04-25 11:16:15 +01002391 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p uint32_t* pPresentModeCount = %p, VkPresentModeKHR* pPresentModes = %p)",
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002392 physicalDevice, surface, pPresentModeCount, pPresentModes);
2393
2394 if(!pPresentModes)
2395 {
2396 *pPresentModeCount = vk::Cast(surface)->getPresentModeCount();
2397 return VK_SUCCESS;
2398 }
2399
2400 return vk::Cast(surface)->getPresentModes(pPresentModeCount, pPresentModes);
2401}
2402
Hernan Liatisc7943e92019-02-25 19:29:54 -08002403VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain)
2404{
Ben Claytonfb280672019-04-25 11:16:15 +01002405 TRACE("(VkDevice device = %p, const VkSwapchainCreateInfoKHR* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSwapchainKHR* pSwapchain = %p)",
Hernan Liatisc7943e92019-02-25 19:29:54 -08002406 device, pCreateInfo, pAllocator, pSwapchain);
2407
Hernan Liatis43be7162019-03-08 17:57:41 -08002408 if(pCreateInfo->oldSwapchain)
2409 {
2410 vk::Cast(pCreateInfo->oldSwapchain)->retire();
2411 }
2412
2413 if(vk::Cast(pCreateInfo->surface)->getAssociatedSwapchain() != VK_NULL_HANDLE)
2414 {
2415 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
2416 }
2417
Hernan Liatisc7943e92019-02-25 19:29:54 -08002418 VkResult status = vk::SwapchainKHR::Create(pAllocator, pCreateInfo, pSwapchain);
2419
2420 if(status != VK_SUCCESS)
2421 {
2422 return status;
2423 }
2424
2425 status = vk::Cast(*pSwapchain)->createImages(device);
2426
2427 if(status != VK_SUCCESS)
2428 {
2429 vk::destroy(*pSwapchain, pAllocator);
2430 return status;
2431 }
2432
Hernan Liatis43be7162019-03-08 17:57:41 -08002433 vk::Cast(pCreateInfo->surface)->associateSwapchain(*pSwapchain);
2434
Hernan Liatisc7943e92019-02-25 19:29:54 -08002435 return VK_SUCCESS;
2436}
2437
2438VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator)
2439{
Ben Claytonfb280672019-04-25 11:16:15 +01002440 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, const VkAllocationCallbacks* pAllocator = %p)",
Hernan Liatisc7943e92019-02-25 19:29:54 -08002441 device, swapchain, pAllocator);
2442
2443 vk::destroy(swapchain, pAllocator);
2444}
2445
Hernan Liatisd00375a2019-02-26 11:19:27 -08002446VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages)
2447{
Ben Claytonfb280672019-04-25 11:16:15 +01002448 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint32_t* pSwapchainImageCount = %p, VkImage* pSwapchainImages = %p)",
Hernan Liatisd00375a2019-02-26 11:19:27 -08002449 device, swapchain, pSwapchainImageCount, pSwapchainImages);
2450
2451 if(!pSwapchainImages)
2452 {
2453 *pSwapchainImageCount = vk::Cast(swapchain)->getImageCount();
2454 return VK_SUCCESS;
2455 }
2456
2457 return vk::Cast(swapchain)->getImages(pSwapchainImageCount, pSwapchainImages);
2458}
2459
Hernan Liatis6b12a502019-03-01 15:06:13 -08002460VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex)
2461{
Ben Claytonfb280672019-04-25 11:16:15 +01002462 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint64_t timeout = %d, VkSemaphore semaphore = %p, VkFence fence = %p, uint32_t* pImageIndex = %p)",
2463 device, swapchain, int(timeout), semaphore, fence, pImageIndex);
Hernan Liatis6b12a502019-03-01 15:06:13 -08002464
2465 return vk::Cast(swapchain)->getNextImage(timeout, semaphore, fence, pImageIndex);
2466}
2467
2468VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
2469{
Ben Claytonfb280672019-04-25 11:16:15 +01002470 TRACE("(VkQueue queue = %p, const VkPresentInfoKHR* pPresentInfo = %p)",
Hernan Liatis6b12a502019-03-01 15:06:13 -08002471 queue, pPresentInfo);
2472
2473 vk::Cast(queue)->present(pPresentInfo);
2474
2475 return VK_SUCCESS;
2476}
Chris Forbesf993de32019-04-15 09:45:34 -07002477
2478VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR *pDeviceGroupPresentCapabilities)
2479{
Ben Claytonfb280672019-04-25 11:16:15 +01002480 TRACE("(VkDevice device = %p, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities = %p)",
Chris Forbesf993de32019-04-15 09:45:34 -07002481 device, pDeviceGroupPresentCapabilities);
2482
2483 for (int i = 0; i < VK_MAX_DEVICE_GROUP_SIZE; i++)
2484 {
2485 // The only real physical device in the presentation group is device 0,
2486 // and it can present to itself.
2487 pDeviceGroupPresentCapabilities->presentMask[i] = (i == 0) ? 1 : 0;
2488 }
2489
2490 pDeviceGroupPresentCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
2491
2492 return VK_SUCCESS;
2493}
2494
2495VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *pModes)
2496{
Ben Claytonfb280672019-04-25 11:16:15 +01002497 TRACE("(VkDevice device = %p, VkSurfaceKHR surface = %p, VkDeviceGroupPresentModeFlagsKHR *pModes = %p)",
Chris Forbesf993de32019-04-15 09:45:34 -07002498 device, surface, pModes);
2499
2500 *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
2501 return VK_SUCCESS;
2502}
2503
Chris Forbes1d667d62019-04-05 08:25:18 -07002504#endif // ! __ANDROID__
Hernan Liatis6b12a502019-03-01 15:06:13 -08002505
Chris Forbes3d27f2e2018-09-26 09:24:39 -07002506}