blob: 7b1bd95487ef2c32747e841a8a99b65dbb26b548 [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
Alexis Hetu0662a4a2019-07-08 15:06:40 -040045#ifdef VK_USE_PLATFORM_MACOS_MVK
46#include "WSI/MacOSSurfaceMVK.h"
47#endif
48
Ben Claytona9af8832019-08-14 13:09:43 +010049#ifdef VK_USE_PLATFORM_XCB_KHR
50#include "WSI/XcbSurfaceKHR.hpp"
51#endif
52
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080053#ifdef VK_USE_PLATFORM_XLIB_KHR
54#include "WSI/XlibSurfaceKHR.hpp"
55#endif
56
Nicolas Capensd3545372019-08-09 13:59:18 -040057#ifdef VK_USE_PLATFORM_WIN32_KHR
58#include "WSI/Win32SurfaceKHR.hpp"
59#endif
60
Hernan Liatis8a91a352019-04-29 17:14:06 -070061#ifdef __ANDROID__
62#include <vulkan/vk_android_native_buffer.h>
Hernan Liatis628604e2019-05-07 15:30:18 -070063#include "System/GrallocAndroid.hpp"
Chris Forbes93ad3b82019-06-03 08:02:47 -070064#include <sync/sync.h>
Hernan Liatis8a91a352019-04-29 17:14:06 -070065#endif
66
Hernan Liatisc7943e92019-02-25 19:29:54 -080067#include "WSI/VkSwapchainKHR.hpp"
68
Ben Clayton056d6922019-07-04 12:41:13 +010069#include "Reactor/Nucleus.hpp"
70
Ben Claytond6c61362019-08-14 18:16:01 +010071#include "Yarn/Scheduler.hpp"
72#include "Yarn/Thread.hpp"
73
74#include "System/CPUID.hpp"
75
Alexis Hetu000df8b2018-10-24 15:22:41 -040076#include <algorithm>
Chris Forbes3d27f2e2018-09-26 09:24:39 -070077#include <cstring>
Alexis Hetu767b41b2018-09-26 11:25:46 -040078#include <string>
Hernan Liatis628604e2019-05-07 15:30:18 -070079#include <map>
Alexis Hetud73b8712018-09-21 15:14:43 -040080
Alexis Hetud6fae382019-04-05 13:19:46 -040081namespace
82{
83
84bool HasExtensionProperty(const char* extensionName, const VkExtensionProperties* extensionProperties, uint32_t extensionPropertiesCount)
85{
86 for(uint32_t j = 0; j < extensionPropertiesCount; ++j)
87 {
88 if(strcmp(extensionName, extensionProperties[j].extensionName) == 0)
89 {
90 return true;
91 }
92 }
93
94 return false;
95}
96
Ben Clayton056d6922019-07-04 12:41:13 +010097// setReactorDefaultConfig() sets the default configuration for Vulkan's use of
98// Reactor.
99void setReactorDefaultConfig()
100{
101 auto cfg = rr::Config::Edit()
Ben Claytonfc7bb8f2019-07-10 00:50:49 +0100102 .set(rr::Optimization::Level::Default)
103 .clearOptimizationPasses()
104 .add(rr::Optimization::Pass::ScalarReplAggregates)
105 .add(rr::Optimization::Pass::SCCP)
106 .add(rr::Optimization::Pass::CFGSimplification)
107 .add(rr::Optimization::Pass::EarlyCSEPass)
108 .add(rr::Optimization::Pass::CFGSimplification)
109 .add(rr::Optimization::Pass::InstructionCombining);
Ben Clayton056d6922019-07-04 12:41:13 +0100110
111 rr::Nucleus::adjustDefaultConfig(cfg);
112}
113
Ben Claytond6c61362019-08-14 18:16:01 +0100114void setCPUDefaults()
115{
116 sw::CPUID::setEnableSSE4_1(true);
117 sw::CPUID::setEnableSSSE3(true);
118 sw::CPUID::setEnableSSE3(true);
119 sw::CPUID::setEnableSSE2(true);
120 sw::CPUID::setEnableSSE(true);
121}
122
123yarn::Scheduler* getOrCreateScheduler()
124{
125 static auto scheduler = std::unique_ptr<yarn::Scheduler>(new yarn::Scheduler());
126 scheduler->setThreadInitializer([] {
127 sw::CPUID::setFlushToZero(true);
128 sw::CPUID::setDenormalsAreZero(true);
129 });
130 scheduler->setWorkerThreadCount(std::min<size_t>(yarn::Thread::numLogicalCPUs(), 16));
131 return scheduler.get();
132}
133
Ben Clayton056d6922019-07-04 12:41:13 +0100134// initializeLibrary() is called by vkCreateInstance() to perform one-off global
135// initialization of the swiftshader driver.
136void initializeLibrary()
137{
138 static bool doOnce = [] {
139 setReactorDefaultConfig();
Ben Claytond6c61362019-08-14 18:16:01 +0100140 setCPUDefaults();
Ben Clayton056d6922019-07-04 12:41:13 +0100141 return true;
142 }();
143 (void)doOnce;
144}
145
Alexis Hetud6fae382019-04-05 13:19:46 -0400146}
147
Alexis Hetud73b8712018-09-21 15:14:43 -0400148extern "C"
149{
David 'Digit' Turnere7256192019-06-19 07:08:04 +0200150VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName)
Alexis Hetud73b8712018-09-21 15:14:43 -0400151{
Ben Claytonfb280672019-04-25 11:16:15 +0100152 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500153
Alexis Hetu7d96f512019-06-13 18:23:56 -0400154 return vk::GetInstanceProcAddr(vk::Cast(instance), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400155}
156
David 'Digit' Turnere7256192019-06-19 07:08:04 +0200157VK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion)
Hernan Liatisb2841fe2019-02-21 12:57:52 -0800158{
159 *pSupportedVersion = 3;
160 return VK_SUCCESS;
161}
162
Hernan Liatis2bb08642019-02-08 14:08:21 -0800163static const VkExtensionProperties instanceExtensionProperties[] =
164{
165 { VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION },
166 { VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION },
167 { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION },
168 { VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION },
169 { 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 -0700170#ifndef __ANDROID__
Hernan Liatis2bb08642019-02-08 14:08:21 -0800171 { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700172#endif
Ben Claytona9af8832019-08-14 13:09:43 +0100173#ifdef VK_USE_PLATFORM_XCB_KHR
174 { VK_KHR_XCB_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_SPEC_VERSION },
175#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800176#ifdef VK_USE_PLATFORM_XLIB_KHR
177 { VK_KHR_XLIB_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_SPEC_VERSION },
178#endif
Alexis Hetu0662a4a2019-07-08 15:06:40 -0400179#ifdef VK_USE_PLATFORM_MACOS_MVK
180 { VK_MVK_MACOS_SURFACE_EXTENSION_NAME, VK_MVK_MACOS_SURFACE_SPEC_VERSION },
181#endif
Nicolas Capensd3545372019-08-09 13:59:18 -0400182#ifdef VK_USE_PLATFORM_WIN32_KHR
183 { VK_KHR_WIN32_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_SPEC_VERSION },
184#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800185};
186
187static const VkExtensionProperties deviceExtensionProperties[] =
188{
189 { VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION },
190 { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION },
191 { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION },
192 { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION },
193 { VK_KHR_DEVICE_GROUP_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_SPEC_VERSION },
194 { VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_SPEC_VERSION },
195 { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION },
196 { VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION },
197 { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION },
198 { VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_SPEC_VERSION },
199 { VK_KHR_MAINTENANCE2_EXTENSION_NAME, VK_KHR_MAINTENANCE2_SPEC_VERSION },
200 { VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_KHR_MAINTENANCE3_SPEC_VERSION },
201 { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION },
202 { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION },
203 { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION },
Chris Forbes83cdd252019-08-26 09:29:27 -0700204 // Only 1.1 core version of this is supported. The extension has additional requirements
205 //{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION },
Hernan Liatis2bb08642019-02-08 14:08:21 -0800206 { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION },
Chris Forbes83cdd252019-08-26 09:29:27 -0700207 // Only 1.1 core version of this is supported. The extension has additional requirements
208 //{ VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700209#ifndef __ANDROID__
Hernan Liatiscff8c002019-02-25 15:56:36 -0800210 { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION },
Hernan Liatis8a91a352019-04-29 17:14:06 -0700211#else
212 { VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME, VK_ANDROID_NATIVE_BUFFER_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700213#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800214};
215
Alexis Hetud73b8712018-09-21 15:14:43 -0400216VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
217{
Ben Claytonfb280672019-04-25 11:16:15 +0100218 TRACE("(const VkInstanceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkInstance* pInstance = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400219 pCreateInfo, pAllocator, pInstance);
220
Ben Clayton056d6922019-07-04 12:41:13 +0100221 initializeLibrary();
222
Alexis Hetu767b41b2018-09-26 11:25:46 -0400223 if(pCreateInfo->enabledLayerCount)
224 {
Ben Clayton00424c12019-03-17 17:29:30 +0000225 UNIMPLEMENTED("pCreateInfo->enabledLayerCount");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400226 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400227
Alexis Hetud6fae382019-04-05 13:19:46 -0400228 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Hernan Liatis2bb08642019-02-08 14:08:21 -0800229 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400230 {
Alexis Hetud6fae382019-04-05 13:19:46 -0400231 if (!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], instanceExtensionProperties, extensionPropertiesCount))
Hernan Liatis2bb08642019-02-08 14:08:21 -0800232 {
233 return VK_ERROR_EXTENSION_NOT_PRESENT;
234 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400235 }
236
237 if(pCreateInfo->pNext)
238 {
239 switch(*reinterpret_cast<const VkStructureType*>(pCreateInfo->pNext))
240 {
241 case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO:
242 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
243 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
244 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
245 // internal use by the loader, and do not have corresponding
246 // Vulkan structures in this Specification."
247 break;
248 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000249 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400250 }
251 }
252
253 *pInstance = VK_NULL_HANDLE;
254 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
255
256 VkResult result = vk::DispatchablePhysicalDevice::Create(pAllocator, pCreateInfo, &physicalDevice);
257 if(result != VK_SUCCESS)
258 {
259 return result;
260 }
261
Nicolas Capens0c736802019-05-27 12:53:31 -0400262 result = vk::DispatchableInstance::Create(pAllocator, pCreateInfo, pInstance, physicalDevice);
Alexis Hetu767b41b2018-09-26 11:25:46 -0400263 if(result != VK_SUCCESS)
264 {
265 vk::destroy(physicalDevice, pAllocator);
266 return result;
267 }
268
269 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -0400270}
271
272VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks* pAllocator)
273{
Ben Claytonfb280672019-04-25 11:16:15 +0100274 TRACE("(VkInstance instance = %p, const VkAllocationCallbacks* pAllocator = %p)", instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400275
Alexis Hetu767b41b2018-09-26 11:25:46 -0400276 vk::destroy(instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400277}
278
279VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices)
280{
Ben Claytonfb280672019-04-25 11:16:15 +0100281 TRACE("(VkInstance instance = %p, uint32_t* pPhysicalDeviceCount = %p, VkPhysicalDevice* pPhysicalDevices = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400282 instance, pPhysicalDeviceCount, pPhysicalDevices);
283
Chris Forbesdf84b942019-06-12 11:28:09 -0700284 return vk::Cast(instance)->getPhysicalDevices(pPhysicalDeviceCount, pPhysicalDevices);
Alexis Hetud73b8712018-09-21 15:14:43 -0400285}
286
287VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures)
288{
Ben Claytonfb280672019-04-25 11:16:15 +0100289 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures* pFeatures = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400290 physicalDevice, pFeatures);
291
Alexis Hetu767b41b2018-09-26 11:25:46 -0400292 *pFeatures = vk::Cast(physicalDevice)->getFeatures();
Alexis Hetud73b8712018-09-21 15:14:43 -0400293}
294
295VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties)
296{
Ben Claytonfb280672019-04-25 11:16:15 +0100297 TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties* pFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400298 physicalDevice, (int)format, pFormatProperties);
299
Alexis Hetu767b41b2018-09-26 11:25:46 -0400300 vk::Cast(physicalDevice)->getFormatProperties(format, pFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400301}
302
303VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties)
304{
Ben Claytonfb280672019-04-25 11:16:15 +0100305 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 -0400306 physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
307
Nicolas Capens7e01e4e2019-05-18 08:19:07 -0400308 // "If the combination of parameters to vkGetPhysicalDeviceImageFormatProperties is not supported by the implementation
309 // for use in vkCreateImage, then all members of VkImageFormatProperties will be filled with zero."
310 memset(pImageFormatProperties, 0, sizeof(VkImageFormatProperties));
311
Chris Forbes57378332019-01-16 15:17:24 -0800312 VkFormatProperties properties;
313 vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
314
Chris Forbes1bc77312019-05-09 14:02:26 -0700315 VkFormatFeatureFlags features;
Chris Forbes57378332019-01-16 15:17:24 -0800316 switch (tiling)
317 {
318 case VK_IMAGE_TILING_LINEAR:
Chris Forbes1bc77312019-05-09 14:02:26 -0700319 features = properties.linearTilingFeatures;
Chris Forbes57378332019-01-16 15:17:24 -0800320 break;
321
322 case VK_IMAGE_TILING_OPTIMAL:
Chris Forbes1bc77312019-05-09 14:02:26 -0700323 features = properties.optimalTilingFeatures;
Chris Forbes57378332019-01-16 15:17:24 -0800324 break;
325
326 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000327 UNIMPLEMENTED("tiling");
Chris Forbes1bc77312019-05-09 14:02:26 -0700328 features = 0;
329 }
330
331 if (features == 0)
332 {
333 return VK_ERROR_FORMAT_NOT_SUPPORTED;
334 }
335
336 // Check for usage conflict with features
337 if ((usage & VK_IMAGE_USAGE_SAMPLED_BIT) && !(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
338 {
339 return VK_ERROR_FORMAT_NOT_SUPPORTED;
Chris Forbes57378332019-01-16 15:17:24 -0800340 }
341
Chris Forbes0559bc42019-05-11 10:47:11 -0700342 if ((usage & VK_IMAGE_USAGE_STORAGE_BIT) && !(features & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
343 {
344 return VK_ERROR_FORMAT_NOT_SUPPORTED;
345 }
346
347 if ((usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && !(features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
348 {
349 return VK_ERROR_FORMAT_NOT_SUPPORTED;
350 }
351
352 if ((usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) && !(features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
353 {
354 return VK_ERROR_FORMAT_NOT_SUPPORTED;
355 }
356
357 if ((usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) && !(features & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)))
358 {
359 return VK_ERROR_FORMAT_NOT_SUPPORTED;
360 }
361
362 if ((usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) && !(features & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT))
363 {
364 return VK_ERROR_FORMAT_NOT_SUPPORTED;
365 }
366
367 if ((usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) && !(features & VK_FORMAT_FEATURE_TRANSFER_DST_BIT))
368 {
369 return VK_ERROR_FORMAT_NOT_SUPPORTED;
370 }
371
372 auto allRecognizedUsageBits = VK_IMAGE_USAGE_SAMPLED_BIT |
373 VK_IMAGE_USAGE_STORAGE_BIT |
374 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
375 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
376 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
377 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
378 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
379 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
380 ASSERT(!(usage & ~(allRecognizedUsageBits)));
381
Nicolas Capens7e01e4e2019-05-18 08:19:07 -0400382 // "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities
383 // compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL."
384 if(tiling == VK_IMAGE_TILING_LINEAR)
385 {
386 if(type != VK_IMAGE_TYPE_2D)
387 {
388 return VK_ERROR_FORMAT_NOT_SUPPORTED;
389 }
390
391 if(vk::Format(format).isDepth() || vk::Format(format).isStencil())
392 {
393 return VK_ERROR_FORMAT_NOT_SUPPORTED;
394 }
395 }
396
Hernan Liatisbd18d582019-05-29 15:38:58 -0700397 // "Images created with a format from one of those listed in Formats requiring sampler Y'CBCR conversion for VK_IMAGE_ASPECT_COLOR_BIT image views
Nicolas Capens7e01e4e2019-05-18 08:19:07 -0400398 // have further restrictions on their limits and capabilities compared to images created with other formats."
399 if(vk::Format(format).isYcbcrFormat())
400 {
401 if(type != VK_IMAGE_TYPE_2D)
402 {
403 return VK_ERROR_FORMAT_NOT_SUPPORTED;
404 }
405 }
406
Alexis Hetu767b41b2018-09-26 11:25:46 -0400407 vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400408
409 return VK_SUCCESS;
410}
411
412VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties)
413{
Ben Claytonfb280672019-04-25 11:16:15 +0100414 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties* pProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400415 physicalDevice, pProperties);
416
Alexis Hetu767b41b2018-09-26 11:25:46 -0400417 *pProperties = vk::Cast(physicalDevice)->getProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400418}
419
420VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties)
421{
Ben Claytonfb280672019-04-25 11:16:15 +0100422 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties* pQueueFamilyProperties = %p))", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400423
Alexis Hetu767b41b2018-09-26 11:25:46 -0400424 if(!pQueueFamilyProperties)
425 {
426 *pQueueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
427 }
428 else
429 {
430 vk::Cast(physicalDevice)->getQueueFamilyProperties(*pQueueFamilyPropertyCount, pQueueFamilyProperties);
431 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400432}
433
434VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties)
435{
Ben Claytonfb280672019-04-25 11:16:15 +0100436 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400437
Alexis Hetu767b41b2018-09-26 11:25:46 -0400438 *pMemoryProperties = vk::Cast(physicalDevice)->getMemoryProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400439}
440
Saman Samif4d2a442019-05-21 15:04:41 -0400441VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char* pName)
Alexis Hetud73b8712018-09-21 15:14:43 -0400442{
Ben Claytonfb280672019-04-25 11:16:15 +0100443 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500444
Alexis Hetu7d96f512019-06-13 18:23:56 -0400445 return vk::GetInstanceProcAddr(vk::Cast(instance), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400446}
447
448VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char* pName)
449{
Ben Claytonfb280672019-04-25 11:16:15 +0100450 TRACE("(VkDevice device = %p, const char* pName = %p)", device, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500451
Alexis Hetu7d96f512019-06-13 18:23:56 -0400452 return vk::GetDeviceProcAddr(vk::Cast(device), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400453}
454
455VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
456{
Ben Claytonfb280672019-04-25 11:16:15 +0100457 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkDeviceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDevice* pDevice = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400458 physicalDevice, pCreateInfo, pAllocator, pDevice);
459
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500460 if(pCreateInfo->enabledLayerCount)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400461 {
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500462 // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
Ben Clayton00424c12019-03-17 17:29:30 +0000463 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 -0400464 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400465
Alexis Hetud6fae382019-04-05 13:19:46 -0400466 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Hernan Liatiscff8c002019-02-25 15:56:36 -0800467 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
468 {
Alexis Hetud6fae382019-04-05 13:19:46 -0400469 if (!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], deviceExtensionProperties, extensionPropertiesCount))
Hernan Liatiscff8c002019-02-25 15:56:36 -0800470 {
471 return VK_ERROR_EXTENSION_NOT_PRESENT;
472 }
473 }
474
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500475 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
476
Nicolas Capensa29aa772019-06-26 00:36:28 -0400477 const VkPhysicalDeviceFeatures *enabledFeatures = pCreateInfo->pEnabledFeatures;
478
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500479 while(extensionCreateInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400480 {
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500481 switch(extensionCreateInfo->sType)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400482 {
483 case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
484 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
485 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
486 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
487 // internal use by the loader, and do not have corresponding
488 // Vulkan structures in this Specification."
489 break;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500490 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
491 {
492 ASSERT(!pCreateInfo->pEnabledFeatures); // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
493
494 const VkPhysicalDeviceFeatures2* physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2*>(extensionCreateInfo);
495
Nicolas Capensa29aa772019-06-26 00:36:28 -0400496 enabledFeatures = &physicalDeviceFeatures2->features;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500497 }
498 break;
499 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
500 {
501 const VkPhysicalDeviceSamplerYcbcrConversionFeatures* samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionCreateInfo);
502
Nicolas Capense2f5da42019-05-16 11:01:31 -0400503 // YCbCr conversion is supported.
504 // samplerYcbcrConversionFeatures->samplerYcbcrConversion can be VK_TRUE or VK_FALSE.
505 // No action needs to be taken on our end in either case; it's the apps responsibility that
Hernan Liatisbd18d582019-05-29 15:38:58 -0700506 // "To create a sampler Y'CbCr conversion, the samplerYcbcrConversion feature must be enabled."
Nicolas Capense2f5da42019-05-16 11:01:31 -0400507 (void)samplerYcbcrConversionFeatures->samplerYcbcrConversion;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500508 }
509 break;
510 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
511 {
512 const VkPhysicalDevice16BitStorageFeatures* storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures*>(extensionCreateInfo);
513
514 if(storage16BitFeatures->storageBuffer16BitAccess == VK_TRUE ||
515 storage16BitFeatures->uniformAndStorageBuffer16BitAccess == VK_TRUE ||
516 storage16BitFeatures->storagePushConstant16 == VK_TRUE ||
517 storage16BitFeatures->storageInputOutput16 == VK_TRUE)
518 {
519 return VK_ERROR_FEATURE_NOT_PRESENT;
520 }
521 }
522 break;
523 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
524 {
525 const VkPhysicalDeviceVariablePointerFeatures* variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures*>(extensionCreateInfo);
526
527 if(variablePointerFeatures->variablePointersStorageBuffer == VK_TRUE ||
528 variablePointerFeatures->variablePointers == VK_TRUE)
529 {
530 return VK_ERROR_FEATURE_NOT_PRESENT;
531 }
532 }
533 break;
Alexis Hetu5ebd2c02019-01-22 17:17:27 -0500534 case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO:
535 {
536 const VkDeviceGroupDeviceCreateInfo* groupDeviceCreateInfo = reinterpret_cast<const VkDeviceGroupDeviceCreateInfo*>(extensionCreateInfo);
537
538 if((groupDeviceCreateInfo->physicalDeviceCount != 1) ||
539 (groupDeviceCreateInfo->pPhysicalDevices[0] != physicalDevice))
540 {
541 return VK_ERROR_FEATURE_NOT_PRESENT;
542 }
543 }
544 break;
Chris Forbesaad8cfc2019-08-15 19:09:16 -0700545 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
546 {
547 const VkPhysicalDeviceMultiviewFeatures* multiviewFeatures = reinterpret_cast<const VkPhysicalDeviceMultiviewFeatures*>(extensionCreateInfo);
548
Chris Forbes02d4c0d2019-08-21 12:04:34 -0700549 if (multiviewFeatures->multiviewGeometryShader ||
Chris Forbesaad8cfc2019-08-15 19:09:16 -0700550 multiviewFeatures->multiviewTessellationShader)
551 {
552 return VK_ERROR_FEATURE_NOT_PRESENT;
553 }
554 }
555 break;
Chris Forbesd3353022019-08-15 19:21:55 -0700556 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES:
557 {
558 const VkPhysicalDeviceShaderDrawParametersFeatures* shaderDrawParametersFeatures = reinterpret_cast<const VkPhysicalDeviceShaderDrawParametersFeatures*>(extensionCreateInfo);
559
560 if (shaderDrawParametersFeatures->shaderDrawParameters)
561 {
562 return VK_ERROR_FEATURE_NOT_PRESENT;
563 }
564 }
565 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400566 default:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500567 // "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]"
Nicolas Capens6b63c802019-05-16 11:10:34 -0400568 UNIMPLEMENTED("extensionCreateInfo->sType %d", int(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 -0500569 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400570 }
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500571
572 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400573 }
574
575 ASSERT(pCreateInfo->queueCreateInfoCount > 0);
576
Nicolas Capensa29aa772019-06-26 00:36:28 -0400577 if(enabledFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400578 {
Nicolas Capensa29aa772019-06-26 00:36:28 -0400579 if(!vk::Cast(physicalDevice)->hasFeatures(*enabledFeatures))
Nicolas Capensd5f14892018-11-13 14:06:37 -0500580 {
581 return VK_ERROR_FEATURE_NOT_PRESENT;
582 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400583 }
584
585 uint32_t queueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
586
587 for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
588 {
589 const VkDeviceQueueCreateInfo& queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
590 if(queueCreateInfo.pNext || queueCreateInfo.flags)
591 {
Ben Clayton00424c12019-03-17 17:29:30 +0000592 UNIMPLEMENTED("queueCreateInfo.pNext || queueCreateInfo.flags");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400593 }
594
595 ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500596 (void)queueFamilyPropertyCount; // Silence unused variable warning
Alexis Hetu767b41b2018-09-26 11:25:46 -0400597 }
598
Ben Claytond6c61362019-08-14 18:16:01 +0100599 auto scheduler = getOrCreateScheduler();
600 return vk::DispatchableDevice::Create(pAllocator, pCreateInfo, pDevice, vk::Cast(physicalDevice), enabledFeatures, scheduler);
Alexis Hetud73b8712018-09-21 15:14:43 -0400601}
602
603VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks* pAllocator)
604{
Ben Claytonfb280672019-04-25 11:16:15 +0100605 TRACE("(VkDevice device = %p, const VkAllocationCallbacks* pAllocator = %p)", device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400606
Alexis Hetu767b41b2018-09-26 11:25:46 -0400607 vk::destroy(device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400608}
609
610VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
611{
Ben Claytonfb280672019-04-25 11:16:15 +0100612 TRACE("(const char* pLayerName = %p, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400613 pLayerName, pPropertyCount, pProperties);
614
Hernan Liatis2bb08642019-02-08 14:08:21 -0800615 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700616
Alexis Hetud73b8712018-09-21 15:14:43 -0400617 if(!pProperties)
618 {
Chris Forbes59781502018-10-25 11:19:54 -0700619 *pPropertyCount = extensionPropertiesCount;
Alexis Hetud73b8712018-09-21 15:14:43 -0400620 return VK_SUCCESS;
621 }
622
Chris Forbesdf84b942019-06-12 11:28:09 -0700623 auto toCopy = std::min(*pPropertyCount, extensionPropertiesCount);
624 for(uint32_t i = 0; i < toCopy; i++)
Alexis Hetud73b8712018-09-21 15:14:43 -0400625 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800626 pProperties[i] = instanceExtensionProperties[i];
Alexis Hetud73b8712018-09-21 15:14:43 -0400627 }
628
Chris Forbesdf84b942019-06-12 11:28:09 -0700629 *pPropertyCount = toCopy;
630 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400631}
632
633VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties)
634{
Ben Claytonfb280672019-04-25 11:16:15 +0100635 TRACE("(VkPhysicalDevice physicalDevice = %p, const char* pLayerName, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400636
Hernan Liatis2bb08642019-02-08 14:08:21 -0800637 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700638
Alexis Hetu767b41b2018-09-26 11:25:46 -0400639 if(!pProperties)
640 {
Chris Forbes59781502018-10-25 11:19:54 -0700641 *pPropertyCount = extensionPropertiesCount;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400642 return VK_SUCCESS;
643 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400644
Chris Forbesdf84b942019-06-12 11:28:09 -0700645 auto toCopy = std::min(*pPropertyCount, extensionPropertiesCount);
646 for(uint32_t i = 0; i < toCopy; i++)
Chris Forbes59781502018-10-25 11:19:54 -0700647 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800648 pProperties[i] = deviceExtensionProperties[i];
Chris Forbes59781502018-10-25 11:19:54 -0700649 }
650
Chris Forbesdf84b942019-06-12 11:28:09 -0700651 *pPropertyCount = toCopy;
652 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400653}
654
655VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t* pPropertyCount, VkLayerProperties* pProperties)
656{
Ben Claytonfb280672019-04-25 11:16:15 +0100657 TRACE("(uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400658
Alexis Hetu767b41b2018-09-26 11:25:46 -0400659 if(!pProperties)
660 {
661 *pPropertyCount = 0;
662 return VK_SUCCESS;
663 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400664
665 return VK_SUCCESS;
666}
667
668VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties)
669{
Ben Claytonfb280672019-04-25 11:16:15 +0100670 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400671
Alexis Hetu767b41b2018-09-26 11:25:46 -0400672 if(!pProperties)
673 {
674 *pPropertyCount = 0;
675 return VK_SUCCESS;
676 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400677
678 return VK_SUCCESS;
679}
680
681VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue)
682{
Ben Claytonfb280672019-04-25 11:16:15 +0100683 TRACE("(VkDevice device = %p, uint32_t queueFamilyIndex = %d, uint32_t queueIndex = %d, VkQueue* pQueue = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400684 device, queueFamilyIndex, queueIndex, pQueue);
685
Alexis Hetu767b41b2018-09-26 11:25:46 -0400686 *pQueue = vk::Cast(device)->getQueue(queueFamilyIndex, queueIndex);
Alexis Hetud73b8712018-09-21 15:14:43 -0400687}
688
689VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence)
690{
Ben Claytonfb280672019-04-25 11:16:15 +0100691 TRACE("(VkQueue queue = %p, uint32_t submitCount = %d, const VkSubmitInfo* pSubmits = %p, VkFence fence = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400692 queue, submitCount, pSubmits, static_cast<void*>(fence));
Alexis Hetu072dc0d2018-10-31 11:41:25 -0400693
Alexis Hetu7d96f512019-06-13 18:23:56 -0400694 return vk::Cast(queue)->submit(submitCount, pSubmits, vk::Cast(fence));
Alexis Hetud73b8712018-09-21 15:14:43 -0400695}
696
Nicolas Capensde16f322019-02-12 00:32:31 -0500697VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
698{
Ben Claytonfb280672019-04-25 11:16:15 +0100699 TRACE("(VkQueue queue = %p)", queue);
Nicolas Capensde16f322019-02-12 00:32:31 -0500700
Alexis Hetue1f51b92019-04-23 15:34:34 -0400701 return vk::Cast(queue)->waitIdle();
Nicolas Capensde16f322019-02-12 00:32:31 -0500702}
703
704VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
705{
Ben Claytonfb280672019-04-25 11:16:15 +0100706 TRACE("(VkDevice device = %p)", device);
Nicolas Capensde16f322019-02-12 00:32:31 -0500707
Alexis Hetue1f51b92019-04-23 15:34:34 -0400708 return vk::Cast(device)->waitIdle();
Alexis Hetud73b8712018-09-21 15:14:43 -0400709}
710
711VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory)
712{
Ben Claytonfb280672019-04-25 11:16:15 +0100713 TRACE("(VkDevice device = %p, const VkMemoryAllocateInfo* pAllocateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDeviceMemory* pMemory = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400714 device, pAllocateInfo, pAllocator, pMemory);
715
Alexis Hetu00835732019-04-10 16:36:31 -0400716 const VkBaseInStructure* allocationInfo = reinterpret_cast<const VkBaseInStructure*>(pAllocateInfo->pNext);
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500717 while(allocationInfo)
Alexis Hetu38ff8302018-10-18 15:08:13 -0400718 {
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500719 switch(allocationInfo->sType)
720 {
721 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
722 // This can safely be ignored, as the Vulkan spec mentions:
723 // "If the pNext chain includes a VkMemoryDedicatedAllocateInfo structure, then that structure
724 // includes a handle of the sole buffer or image resource that the memory *can* be bound to."
725 break;
Alexis Hetu026ceef2019-05-07 17:35:11 -0400726 case VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO:
727 // This extension controls on which physical devices the memory gets allocated.
728 // SwiftShader only has a single physical device, so this extension does nothing in this case.
729 break;
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500730 default:
Ben Clayton00424c12019-03-17 17:29:30 +0000731 UNIMPLEMENTED("allocationInfo->sType");
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500732 break;
733 }
734
735 allocationInfo = allocationInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -0400736 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400737
Alexis Hetu38ff8302018-10-18 15:08:13 -0400738 VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
739 if(result != VK_SUCCESS)
740 {
741 return result;
742 }
743
744 // Make sure the memory allocation is done now so that OOM errors can be checked now
745 result = vk::Cast(*pMemory)->allocate();
746 if(result != VK_SUCCESS)
747 {
748 vk::destroy(*pMemory, pAllocator);
749 *pMemory = VK_NULL_HANDLE;
750 }
751
752 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -0400753}
754
755VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator)
756{
Ben Claytonfb280672019-04-25 11:16:15 +0100757 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400758 device, static_cast<void*>(memory), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400759
Alexis Hetu38ff8302018-10-18 15:08:13 -0400760 vk::destroy(memory, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400761}
762
763VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData)
764{
Ben Claytonfb280672019-04-25 11:16:15 +0100765 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = %d, void** ppData = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400766 device, static_cast<void*>(memory), int(offset), int(size), flags, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -0400767
Alexis Hetu38ff8302018-10-18 15:08:13 -0400768 return vk::Cast(memory)->map(offset, size, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -0400769}
770
771VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
772{
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400773 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p)", device, static_cast<void*>(memory));
Alexis Hetud73b8712018-09-21 15:14:43 -0400774
Alexis Hetu38ff8302018-10-18 15:08:13 -0400775 // Noop, memory will be released when the DeviceMemory object is released
Alexis Hetud73b8712018-09-21 15:14:43 -0400776}
777
778VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
779{
Ben Claytonfb280672019-04-25 11:16:15 +0100780 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400781 device, memoryRangeCount, pMemoryRanges);
782
Alexis Hetu38ff8302018-10-18 15:08:13 -0400783 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -0400784
785 return VK_SUCCESS;
786}
787
788VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges)
789{
Ben Claytonfb280672019-04-25 11:16:15 +0100790 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400791 device, memoryRangeCount, pMemoryRanges);
792
Alexis Hetu38ff8302018-10-18 15:08:13 -0400793 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -0400794
795 return VK_SUCCESS;
796}
797
Alexis Hetu38ff8302018-10-18 15:08:13 -0400798VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize* pCommittedMemoryInBytes)
Alexis Hetud73b8712018-09-21 15:14:43 -0400799{
Ben Claytonfb280672019-04-25 11:16:15 +0100800 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize* pCommittedMemoryInBytes = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400801 pDevice, static_cast<void*>(pMemory), pCommittedMemoryInBytes);
Alexis Hetu38ff8302018-10-18 15:08:13 -0400802
803 auto memory = vk::Cast(pMemory);
804
805#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
Nicolas Capens0c736802019-05-27 12:53:31 -0400806 const auto& memoryProperties = vk::Cast(pDevice)->getPhysicalDevice()->getMemoryProperties();
Alexis Hetu38ff8302018-10-18 15:08:13 -0400807 uint32_t typeIndex = memory->getMemoryTypeIndex();
808 ASSERT(typeIndex < memoryProperties.memoryTypeCount);
809 ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
810#endif
811
812 *pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
Alexis Hetud73b8712018-09-21 15:14:43 -0400813}
814
815VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
816{
Ben Claytonfb280672019-04-25 11:16:15 +0100817 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400818 device, static_cast<void*>(buffer), static_cast<void*>(memory), int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -0400819
Alexis Hetu7d96f512019-06-13 18:23:56 -0400820 vk::Cast(buffer)->bind(vk::Cast(memory), memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -0400821
822 return VK_SUCCESS;
823}
824
825VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
826{
Ben Claytonfb280672019-04-25 11:16:15 +0100827 TRACE("(VkDevice device = %p, VkImage image = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400828 device, static_cast<void*>(image), static_cast<void*>(memory), int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -0400829
Alexis Hetu7d96f512019-06-13 18:23:56 -0400830 vk::Cast(image)->bind(vk::Cast(memory), memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -0400831
832 return VK_SUCCESS;
833}
834
835VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements)
836{
Ben Claytonfb280672019-04-25 11:16:15 +0100837 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400838 device, static_cast<void*>(buffer), pMemoryRequirements);
Alexis Hetud73b8712018-09-21 15:14:43 -0400839
Alexis Hetu38ff8302018-10-18 15:08:13 -0400840 *pMemoryRequirements = vk::Cast(buffer)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -0400841}
842
843VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements)
844{
Ben Claytonfb280672019-04-25 11:16:15 +0100845 TRACE("(VkDevice device = %p, VkImage image = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400846 device, static_cast<void*>(image), pMemoryRequirements);
Alexis Hetud73b8712018-09-21 15:14:43 -0400847
Alexis Hetua233cea2018-12-07 11:53:19 -0500848 *pMemoryRequirements = vk::Cast(image)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -0400849}
850
851VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements)
852{
Ben Claytonfb280672019-04-25 11:16:15 +0100853 TRACE("(VkDevice device = %p, VkImage image = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements* pSparseMemoryRequirements = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400854 device, static_cast<void*>(image), pSparseMemoryRequirementCount, pSparseMemoryRequirements);
Alexis Hetu9e4d0402018-10-16 15:44:12 -0400855
Nicolas Capens5028a582018-11-13 15:03:35 -0500856 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
857 // "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."
858 *pSparseMemoryRequirementCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -0400859}
860
861VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties)
862{
Ben Claytonfb280672019-04-25 11:16:15 +0100863 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 -0800864 physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
865
866 // We do not support sparse images.
867 *pPropertyCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -0400868}
869
870VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence)
871{
872 TRACE("()");
Ben Clayton00424c12019-03-17 17:29:30 +0000873 UNIMPLEMENTED("vkQueueBindSparse");
Alexis Hetud73b8712018-09-21 15:14:43 -0400874 return VK_SUCCESS;
875}
876
877VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence)
878{
Ben Claytonfb280672019-04-25 11:16:15 +0100879 TRACE("(VkDevice device = %p, const VkFenceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFence* pFence = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400880 device, pCreateInfo, pAllocator, pFence);
881
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400882 if(pCreateInfo->pNext)
883 {
Ben Clayton00424c12019-03-17 17:29:30 +0000884 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400885 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400886
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400887 return vk::Fence::Create(pAllocator, pCreateInfo, pFence);
Alexis Hetud73b8712018-09-21 15:14:43 -0400888}
889
890VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator)
891{
Ben Claytonfb280672019-04-25 11:16:15 +0100892 TRACE("(VkDevice device = %p, VkFence fence = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400893 device, static_cast<void*>(fence), pAllocator);
Alexis Hetu767b41b2018-09-26 11:25:46 -0400894
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400895 vk::destroy(fence, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400896}
897
898VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences)
899{
Ben Claytonfb280672019-04-25 11:16:15 +0100900 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400901 device, fenceCount, pFences);
902
903 for(uint32_t i = 0; i < fenceCount; i++)
904 {
905 vk::Cast(pFences[i])->reset();
906 }
907
Alexis Hetud73b8712018-09-21 15:14:43 -0400908 return VK_SUCCESS;
909}
910
911VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
912{
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400913 TRACE("(VkDevice device = %p, VkFence fence = %p)", device, static_cast<void*>(fence));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400914
915 return vk::Cast(fence)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -0400916}
917
918VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout)
919{
Ben Claytonfb280672019-04-25 11:16:15 +0100920 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p, VkBool32 waitAll = %d, uint64_t timeout = %d)",
921 device, int(fenceCount), pFences, int(waitAll), int(timeout));
Alexis Hetuc4bd9df2018-12-07 11:28:40 -0500922
Alexis Hetue1f51b92019-04-23 15:34:34 -0400923 return vk::Cast(device)->waitForFences(fenceCount, pFences, waitAll, timeout);
Alexis Hetud73b8712018-09-21 15:14:43 -0400924}
925
926VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore)
927{
Ben Claytonfb280672019-04-25 11:16:15 +0100928 TRACE("(VkDevice device = %p, const VkSemaphoreCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSemaphore* pSemaphore = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400929 device, pCreateInfo, pAllocator, pSemaphore);
930
931 if(pCreateInfo->pNext || pCreateInfo->flags)
932 {
Ben Clayton00424c12019-03-17 17:29:30 +0000933 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400934 }
935
936 return vk::Semaphore::Create(pAllocator, pCreateInfo, pSemaphore);
Alexis Hetud73b8712018-09-21 15:14:43 -0400937}
938
939VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator)
940{
Ben Claytonfb280672019-04-25 11:16:15 +0100941 TRACE("(VkDevice device = %p, VkSemaphore semaphore = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400942 device, static_cast<void*>(semaphore), pAllocator);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400943
944 vk::destroy(semaphore, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400945}
946
947VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent)
948{
Ben Claytonfb280672019-04-25 11:16:15 +0100949 TRACE("(VkDevice device = %p, const VkEventCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkEvent* pEvent = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400950 device, pCreateInfo, pAllocator, pEvent);
951
952 if(pCreateInfo->pNext || pCreateInfo->flags)
953 {
Ben Clayton00424c12019-03-17 17:29:30 +0000954 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400955 }
956
957 return vk::Event::Create(pAllocator, pCreateInfo, pEvent);
Alexis Hetud73b8712018-09-21 15:14:43 -0400958}
959
960VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator)
961{
Ben Claytonfb280672019-04-25 11:16:15 +0100962 TRACE("(VkDevice device = %p, VkEvent event = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400963 device, static_cast<void*>(event), pAllocator);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400964
965 vk::destroy(event, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400966}
967
968VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
969{
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400970 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void*>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400971
972 return vk::Cast(event)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -0400973}
974
975VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event)
976{
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400977 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void*>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400978
979 vk::Cast(event)->signal();
980
Alexis Hetud73b8712018-09-21 15:14:43 -0400981 return VK_SUCCESS;
982}
983
984VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event)
985{
Alexis Hetu2d77aea2019-06-17 13:43:50 -0400986 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void*>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -0400987
988 vk::Cast(event)->reset();
989
Alexis Hetud73b8712018-09-21 15:14:43 -0400990 return VK_SUCCESS;
991}
992
993VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool)
994{
Ben Claytonfb280672019-04-25 11:16:15 +0100995 TRACE("(VkDevice device = %p, const VkQueryPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkQueryPool* pQueryPool = %p)",
Alexis Hetu86f8bdb2019-01-22 12:07:24 -0500996 device, pCreateInfo, pAllocator, pQueryPool);
997
998 if(pCreateInfo->pNext || pCreateInfo->flags)
999 {
Ben Clayton00424c12019-03-17 17:29:30 +00001000 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001001 }
1002
1003 return vk::QueryPool::Create(pAllocator, pCreateInfo, pQueryPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001004}
1005
1006VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator)
1007{
Ben Claytonfb280672019-04-25 11:16:15 +01001008 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001009 device, static_cast<void*>(queryPool), pAllocator);
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001010
1011 vk::destroy(queryPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001012}
1013
1014VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags)
1015{
Ben Claytonfb280672019-04-25 11:16:15 +01001016 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)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001017 device, static_cast<void*>(queryPool), int(firstQuery), int(queryCount), int(dataSize), pData, int(stride), flags);
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001018
Alexis Hetuf0aa9d52019-04-01 17:06:47 -04001019 return vk::Cast(queryPool)->getResults(firstQuery, queryCount, dataSize, pData, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001020}
1021
1022VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer)
1023{
Ben Claytonfb280672019-04-25 11:16:15 +01001024 TRACE("(VkDevice device = %p, const VkBufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBuffer* pBuffer = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001025 device, pCreateInfo, pAllocator, pBuffer);
1026
Alexis Hetu38ff8302018-10-18 15:08:13 -04001027 if(pCreateInfo->pNext)
1028 {
Ben Clayton00424c12019-03-17 17:29:30 +00001029 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu38ff8302018-10-18 15:08:13 -04001030 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001031
Alexis Hetu38ff8302018-10-18 15:08:13 -04001032 return vk::Buffer::Create(pAllocator, pCreateInfo, pBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001033}
1034
1035VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator)
1036{
Ben Claytonfb280672019-04-25 11:16:15 +01001037 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001038 device, static_cast<void*>(buffer), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001039
Alexis Hetu38ff8302018-10-18 15:08:13 -04001040 vk::destroy(buffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001041}
1042
1043VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView)
1044{
Ben Claytonfb280672019-04-25 11:16:15 +01001045 TRACE("(VkDevice device = %p, const VkBufferViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBufferView* pView = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04001046 device, pCreateInfo, pAllocator, pView);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001047
1048 if(pCreateInfo->pNext || pCreateInfo->flags)
1049 {
Ben Clayton00424c12019-03-17 17:29:30 +00001050 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu38ff8302018-10-18 15:08:13 -04001051 }
1052
1053 return vk::BufferView::Create(pAllocator, pCreateInfo, pView);
Alexis Hetud73b8712018-09-21 15:14:43 -04001054}
1055
1056VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator)
1057{
Ben Claytonfb280672019-04-25 11:16:15 +01001058 TRACE("(VkDevice device = %p, VkBufferView bufferView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001059 device, static_cast<void*>(bufferView), pAllocator);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001060
1061 vk::destroy(bufferView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001062}
1063
Hernan Liatis628604e2019-05-07 15:30:18 -07001064#ifdef __ANDROID__
1065struct BackingMemory {
1066 buffer_handle_t nativeHandle;
1067 int stride;
Hernan Liatis3c735072019-06-10 15:07:18 -07001068 vk::DeviceMemory* imageMemory;
Hernan Liatis628604e2019-05-07 15:30:18 -07001069 VkSwapchainImageUsageFlagsANDROID androidUsage;
1070};
1071
1072static std::map<VkImage, BackingMemory> androidSwapchainMap;
1073#endif
1074
Alexis Hetud73b8712018-09-21 15:14:43 -04001075VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage)
1076{
Ben Claytonfb280672019-04-25 11:16:15 +01001077 TRACE("(VkDevice device = %p, const VkImageCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImage* pImage = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001078 device, pCreateInfo, pAllocator, pImage);
1079
Hernan Liatis628604e2019-05-07 15:30:18 -07001080 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
1081
1082#ifdef __ANDROID__
1083 BackingMemory backmem;
1084 bool swapchainImage = false;
1085#endif
1086
1087 while(extensionCreateInfo)
Alexis Hetuf62f3752018-11-15 14:51:15 -05001088 {
Hernan Liatis628604e2019-05-07 15:30:18 -07001089 switch((long)(extensionCreateInfo->sType))
1090 {
1091#ifdef __ANDROID__
1092 case VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID:
1093 {
1094 const VkSwapchainImageCreateInfoANDROID* swapImageCreateInfo = reinterpret_cast<const VkSwapchainImageCreateInfoANDROID*>(extensionCreateInfo);
1095 backmem.androidUsage = swapImageCreateInfo->usage;
1096 }
1097 break;
1098 case VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID:
1099 {
1100 const VkNativeBufferANDROID* nativeBufferInfo = reinterpret_cast<const VkNativeBufferANDROID*>(extensionCreateInfo);
1101 backmem.nativeHandle = nativeBufferInfo->handle;
1102 backmem.stride = nativeBufferInfo->stride;
Hernan Liatiscae8cde2019-05-22 14:24:45 -07001103 swapchainImage = true;
Hernan Liatis628604e2019-05-07 15:30:18 -07001104 }
1105 break;
1106#endif
1107 default:
1108 // "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]"
1109 UNIMPLEMENTED("extensionCreateInfo->sType"); // TODO(b/119321052): UNIMPLEMENTED() should be used only for features that must still be implemented. Use a more informational macro here.
1110 break;
1111 }
1112
1113 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetuf62f3752018-11-15 14:51:15 -05001114 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001115
Nicolas Capens0c736802019-05-27 12:53:31 -04001116 VkResult result = vk::Image::Create(pAllocator, pCreateInfo, pImage, vk::Cast(device));
Hernan Liatis628604e2019-05-07 15:30:18 -07001117
1118#ifdef __ANDROID__
1119 if (swapchainImage)
1120 {
1121 if (result != VK_SUCCESS)
1122 {
1123 return result;
1124 }
1125
1126 VkMemoryRequirements memRequirements = vk::Cast(*pImage)->getMemoryRequirements();
1127
1128 VkMemoryAllocateInfo allocInfo = {};
1129 allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
1130 allocInfo.allocationSize = memRequirements.size;
1131 allocInfo.memoryTypeIndex = 0;
1132
Alexis Hetu82feec72019-06-19 12:42:38 -04001133 VkDeviceMemory devmem = { VK_NULL_HANDLE };
Hernan Liatis3c735072019-06-10 15:07:18 -07001134 result = vkAllocateMemory(device, &allocInfo, nullptr, &devmem);
Hernan Liatis628604e2019-05-07 15:30:18 -07001135 if(result != VK_SUCCESS)
1136 {
1137 return result;
1138 }
1139
Hernan Liatis3c735072019-06-10 15:07:18 -07001140 backmem.imageMemory = vk::Cast(devmem);
1141 vkBindImageMemory(device, *pImage, devmem, 0);
1142
Hernan Liatis628604e2019-05-07 15:30:18 -07001143 androidSwapchainMap[*pImage] = backmem;
1144 }
1145#endif
1146
1147 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -04001148}
1149
1150VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator)
1151{
Ben Claytonfb280672019-04-25 11:16:15 +01001152 TRACE("(VkDevice device = %p, VkImage image = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001153 device, static_cast<void*>(image), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001154
Alexis Hetuf62f3752018-11-15 14:51:15 -05001155 vk::destroy(image, pAllocator);
Hernan Liatisf988cb52019-05-22 15:06:19 -07001156
1157#ifdef __ANDROID__
1158 auto it = androidSwapchainMap.find(image);
1159
1160 if (it != androidSwapchainMap.end())
1161 {
Hernan Liatis3c735072019-06-10 15:07:18 -07001162 vk::destroy(static_cast<VkDeviceMemory>(*((it->second).imageMemory)), nullptr);
Hernan Liatisf988cb52019-05-22 15:06:19 -07001163 androidSwapchainMap.erase(it);
1164 }
1165#endif
Alexis Hetud73b8712018-09-21 15:14:43 -04001166}
1167
1168VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout)
1169{
Ben Claytonfb280672019-04-25 11:16:15 +01001170 TRACE("(VkDevice device = %p, VkImage image = %p, const VkImageSubresource* pSubresource = %p, VkSubresourceLayout* pLayout = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001171 device, static_cast<void*>(image), pSubresource, pLayout);
Alexis Hetu6ab37b02019-01-24 17:02:45 -05001172
1173 vk::Cast(image)->getSubresourceLayout(pSubresource, pLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001174}
1175
1176VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView)
1177{
Ben Claytonfb280672019-04-25 11:16:15 +01001178 TRACE("(VkDevice device = %p, const VkImageViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImageView* pView = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001179 device, pCreateInfo, pAllocator, pView);
1180
Alexis Hetu60da1582019-04-05 16:34:38 -04001181 if(pCreateInfo->flags)
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001182 {
Alexis Hetu60da1582019-04-05 16:34:38 -04001183 UNIMPLEMENTED("pCreateInfo->flags");
1184 }
1185
1186 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
Nicolas Capens6b63c802019-05-16 11:10:34 -04001187 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
Alexis Hetu60da1582019-04-05 16:34:38 -04001188
1189 while(extensionCreateInfo)
1190 {
1191 switch(extensionCreateInfo->sType)
1192 {
1193 case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR:
1194 {
1195 const VkImageViewUsageCreateInfo* multiviewCreateInfo = reinterpret_cast<const VkImageViewUsageCreateInfo*>(extensionCreateInfo);
1196 ASSERT(!(~vk::Cast(pCreateInfo->image)->getUsage() & multiviewCreateInfo->usage));
1197 }
1198 break;
1199 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
1200 {
Nicolas Capens6b63c802019-05-16 11:10:34 -04001201 const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo*>(extensionCreateInfo);
1202 ycbcrConversion = vk::Cast(samplerYcbcrConversionInfo->conversion);
1203
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001204 if(ycbcrConversion)
Alexis Hetu60da1582019-04-05 16:34:38 -04001205 {
1206 ASSERT((pCreateInfo->components.r == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1207 (pCreateInfo->components.g == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1208 (pCreateInfo->components.b == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1209 (pCreateInfo->components.a == VK_COMPONENT_SWIZZLE_IDENTITY));
1210 }
1211 }
1212 break;
1213 default:
Nicolas Capens6b63c802019-05-16 11:10:34 -04001214 UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType));
Alexis Hetu60da1582019-04-05 16:34:38 -04001215 break;
1216 }
1217
1218 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001219 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001220
Nicolas Capens6b63c802019-05-16 11:10:34 -04001221 return vk::ImageView::Create(pAllocator, pCreateInfo, pView, ycbcrConversion);
Alexis Hetud73b8712018-09-21 15:14:43 -04001222}
1223
1224VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator)
1225{
Ben Claytonfb280672019-04-25 11:16:15 +01001226 TRACE("(VkDevice device = %p, VkImageView imageView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001227 device, static_cast<void*>(imageView), pAllocator);
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001228
1229 vk::destroy(imageView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001230}
1231
1232VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule)
1233{
Ben Claytonfb280672019-04-25 11:16:15 +01001234 TRACE("(VkDevice device = %p, const VkShaderModuleCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkShaderModule* pShaderModule = %p)",
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001235 device, pCreateInfo, pAllocator, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -04001236
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001237 if(pCreateInfo->pNext || pCreateInfo->flags)
1238 {
Ben Clayton00424c12019-03-17 17:29:30 +00001239 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001240 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001241
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001242 return vk::ShaderModule::Create(pAllocator, pCreateInfo, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -04001243}
1244
1245VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator)
1246{
Ben Claytonfb280672019-04-25 11:16:15 +01001247 TRACE("(VkDevice device = %p, VkShaderModule shaderModule = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001248 device, static_cast<void*>(shaderModule), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001249
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001250 vk::destroy(shaderModule, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001251}
1252
1253VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache)
1254{
Ben Claytonfb280672019-04-25 11:16:15 +01001255 TRACE("(VkDevice device = %p, const VkPipelineCacheCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineCache* pPipelineCache = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04001256 device, pCreateInfo, pAllocator, pPipelineCache);
Alexis Hetu18a84252018-11-19 11:30:43 -05001257
1258 if(pCreateInfo->pNext || pCreateInfo->flags)
1259 {
Ben Clayton00424c12019-03-17 17:29:30 +00001260 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu18a84252018-11-19 11:30:43 -05001261 }
1262
1263 return vk::PipelineCache::Create(pAllocator, pCreateInfo, pPipelineCache);
Alexis Hetud73b8712018-09-21 15:14:43 -04001264}
1265
1266VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator)
1267{
Ben Claytonfb280672019-04-25 11:16:15 +01001268 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001269 device, static_cast<void*>(pipelineCache), pAllocator);
Alexis Hetu18a84252018-11-19 11:30:43 -05001270
1271 vk::destroy(pipelineCache, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001272}
1273
1274VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData)
1275{
Ben Claytonfb280672019-04-25 11:16:15 +01001276 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, size_t* pDataSize = %p, void* pData = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001277 device, static_cast<void*>(pipelineCache), pDataSize, pData);
Alexis Hetu1424ef62019-04-05 18:03:53 -04001278
1279 return vk::Cast(pipelineCache)->getData(pDataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001280}
1281
1282VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches)
1283{
Ben Claytonfb280672019-04-25 11:16:15 +01001284 TRACE("(VkDevice device = %p, VkPipelineCache dstCache = %p, uint32_t srcCacheCount = %d, const VkPipelineCache* pSrcCaches = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001285 device, static_cast<void*>(dstCache), int(srcCacheCount), pSrcCaches);
Alexis Hetu1424ef62019-04-05 18:03:53 -04001286
1287 return vk::Cast(dstCache)->merge(srcCacheCount, pSrcCaches);
Alexis Hetud73b8712018-09-21 15:14:43 -04001288}
1289
1290VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1291{
Ben Claytonfb280672019-04-25 11:16:15 +01001292 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkGraphicsPipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001293 device, static_cast<void*>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001294
Alexis Hetu000df8b2018-10-24 15:22:41 -04001295 VkResult errorResult = VK_SUCCESS;
1296 for(uint32_t i = 0; i < createInfoCount; i++)
1297 {
Nicolas Capensa29aa772019-06-26 00:36:28 -04001298 VkResult result = vk::GraphicsPipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i], vk::Cast(device));
1299
Ben Claytonf2be26a2019-03-08 12:02:05 +00001300 if(result == VK_SUCCESS)
1301 {
Alexis Hetu52edb172019-06-26 10:17:18 -04001302 static_cast<vk::GraphicsPipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i], vk::Cast(pipelineCache));
Ben Claytonf2be26a2019-03-08 12:02:05 +00001303 }
1304 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001305 {
1306 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1307 // "When an application attempts to create many pipelines in a single command,
1308 // it is possible that some subset may fail creation. In that case, the
1309 // corresponding entries in the pPipelines output array will be filled with
1310 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1311 // out of memory errors), the vkCreate*Pipelines commands will return an
1312 // error code. The implementation will attempt to create all pipelines, and
1313 // only return VK_NULL_HANDLE values for those that actually failed."
1314 pPipelines[i] = VK_NULL_HANDLE;
1315 errorResult = result;
1316 }
1317 }
1318
1319 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001320}
1321
1322VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines)
1323{
Ben Claytonfb280672019-04-25 11:16:15 +01001324 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkComputePipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001325 device, static_cast<void*>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001326
Alexis Hetu000df8b2018-10-24 15:22:41 -04001327 VkResult errorResult = VK_SUCCESS;
1328 for(uint32_t i = 0; i < createInfoCount; i++)
1329 {
Nicolas Capensa29aa772019-06-26 00:36:28 -04001330 VkResult result = vk::ComputePipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i], vk::Cast(device));
1331
Ben Claytonf2be26a2019-03-08 12:02:05 +00001332 if(result == VK_SUCCESS)
1333 {
Alexis Hetu52edb172019-06-26 10:17:18 -04001334 static_cast<vk::ComputePipeline*>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i], vk::Cast(pipelineCache));
Ben Claytonf2be26a2019-03-08 12:02:05 +00001335 }
1336 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001337 {
1338 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1339 // "When an application attempts to create many pipelines in a single command,
1340 // it is possible that some subset may fail creation. In that case, the
1341 // corresponding entries in the pPipelines output array will be filled with
1342 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1343 // out of memory errors), the vkCreate*Pipelines commands will return an
1344 // error code. The implementation will attempt to create all pipelines, and
1345 // only return VK_NULL_HANDLE values for those that actually failed."
1346 pPipelines[i] = VK_NULL_HANDLE;
1347 errorResult = result;
1348 }
1349 }
1350
1351 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001352}
1353
1354VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator)
1355{
Ben Claytonfb280672019-04-25 11:16:15 +01001356 TRACE("(VkDevice device = %p, VkPipeline pipeline = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001357 device, static_cast<void*>(pipeline), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001358
Alexis Hetu000df8b2018-10-24 15:22:41 -04001359 vk::destroy(pipeline, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001360}
1361
1362VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout)
1363{
Ben Claytonfb280672019-04-25 11:16:15 +01001364 TRACE("(VkDevice device = %p, const VkPipelineLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineLayout* pPipelineLayout = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001365 device, pCreateInfo, pAllocator, pPipelineLayout);
1366
Alexis Hetu000df8b2018-10-24 15:22:41 -04001367 if(pCreateInfo->pNext || pCreateInfo->flags)
1368 {
Ben Clayton00424c12019-03-17 17:29:30 +00001369 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu000df8b2018-10-24 15:22:41 -04001370 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001371
Alexis Hetu000df8b2018-10-24 15:22:41 -04001372 return vk::PipelineLayout::Create(pAllocator, pCreateInfo, pPipelineLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001373}
1374
1375VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator)
1376{
Ben Claytonfb280672019-04-25 11:16:15 +01001377 TRACE("(VkDevice device = %p, VkPipelineLayout pipelineLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001378 device, static_cast<void*>(pipelineLayout), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001379
Alexis Hetu000df8b2018-10-24 15:22:41 -04001380 vk::destroy(pipelineLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001381}
1382
1383VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler)
1384{
Ben Claytonfb280672019-04-25 11:16:15 +01001385 TRACE("(VkDevice device = %p, const VkSamplerCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSampler* pSampler = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001386 device, pCreateInfo, pAllocator, pSampler);
1387
Nicolas Capens6b63c802019-05-16 11:10:34 -04001388 if(pCreateInfo->flags)
Alexis Hetu5174c572018-11-19 11:30:43 -05001389 {
Ben Clayton00424c12019-03-17 17:29:30 +00001390 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu5174c572018-11-19 11:30:43 -05001391 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001392
Nicolas Capens6b63c802019-05-16 11:10:34 -04001393 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
1394 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
1395
1396 while(extensionCreateInfo)
1397 {
1398 switch(extensionCreateInfo->sType)
1399 {
1400 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
1401 {
1402 const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo*>(extensionCreateInfo);
1403 ycbcrConversion = vk::Cast(samplerYcbcrConversionInfo->conversion);
1404 }
1405 break;
1406 default:
1407 UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType));
1408 break;
1409 }
1410
1411 extensionCreateInfo = extensionCreateInfo->pNext;
1412 }
1413
1414 return vk::Sampler::Create(pAllocator, pCreateInfo, pSampler, ycbcrConversion);
Alexis Hetud73b8712018-09-21 15:14:43 -04001415}
1416
1417VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator)
1418{
Ben Claytonfb280672019-04-25 11:16:15 +01001419 TRACE("(VkDevice device = %p, VkSampler sampler = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001420 device, static_cast<void*>(sampler), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001421
Alexis Hetu5174c572018-11-19 11:30:43 -05001422 vk::destroy(sampler, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001423}
1424
1425VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout)
1426{
Ben Claytonfb280672019-04-25 11:16:15 +01001427 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorSetLayout* pSetLayout = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001428 device, pCreateInfo, pAllocator, pSetLayout);
1429
Alexis Hetu1300ba12019-05-07 15:47:11 -04001430 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
1431
1432 while(extensionCreateInfo)
Alexis Hetuc8176632019-01-22 17:01:28 -05001433 {
Alexis Hetu1300ba12019-05-07 15:47:11 -04001434 switch(extensionCreateInfo->sType)
1435 {
1436 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT:
Alexis Hetu352791e2019-05-17 16:42:34 -04001437 ASSERT(!vk::Cast(device)->hasExtension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME));
Alexis Hetu1300ba12019-05-07 15:47:11 -04001438 break;
1439 default:
Nicolas Capens6b63c802019-05-16 11:10:34 -04001440 UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType));
Alexis Hetu1300ba12019-05-07 15:47:11 -04001441 break;
1442 }
1443
1444 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetuc8176632019-01-22 17:01:28 -05001445 }
1446
1447 return vk::DescriptorSetLayout::Create(pAllocator, pCreateInfo, pSetLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001448}
1449
1450VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator)
1451{
Ben Claytonfb280672019-04-25 11:16:15 +01001452 TRACE("(VkDevice device = %p, VkDescriptorSetLayout descriptorSetLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001453 device, static_cast<void*>(descriptorSetLayout), pAllocator);
Alexis Hetuc8176632019-01-22 17:01:28 -05001454
1455 vk::destroy(descriptorSetLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001456}
1457
1458VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool)
1459{
Ben Claytonfb280672019-04-25 11:16:15 +01001460 TRACE("(VkDevice device = %p, const VkDescriptorPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorPool* pDescriptorPool = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001461 device, pCreateInfo, pAllocator, pDescriptorPool);
1462
1463 if(pCreateInfo->pNext)
1464 {
Ben Clayton00424c12019-03-17 17:29:30 +00001465 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetuc8176632019-01-22 17:01:28 -05001466 }
1467
1468 return vk::DescriptorPool::Create(pAllocator, pCreateInfo, pDescriptorPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001469}
1470
1471VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator)
1472{
Ben Claytonfb280672019-04-25 11:16:15 +01001473 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001474 device, static_cast<void*>(descriptorPool), pAllocator);
Alexis Hetuc8176632019-01-22 17:01:28 -05001475
1476 vk::destroy(descriptorPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001477}
1478
1479VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
1480{
Ben Claytonfb280672019-04-25 11:16:15 +01001481 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, VkDescriptorPoolResetFlags flags = 0x%x)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001482 device, static_cast<void*>(descriptorPool), int(flags));
Alexis Hetuc8176632019-01-22 17:01:28 -05001483
1484 if(flags)
1485 {
Ben Clayton00424c12019-03-17 17:29:30 +00001486 UNIMPLEMENTED("flags");
Alexis Hetuc8176632019-01-22 17:01:28 -05001487 }
1488
1489 return vk::Cast(descriptorPool)->reset();
Alexis Hetud73b8712018-09-21 15:14:43 -04001490}
1491
1492VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets)
1493{
Ben Claytonfb280672019-04-25 11:16:15 +01001494 TRACE("(VkDevice device = %p, const VkDescriptorSetAllocateInfo* pAllocateInfo = %p, VkDescriptorSet* pDescriptorSets = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001495 device, pAllocateInfo, pDescriptorSets);
1496
1497 if(pAllocateInfo->pNext)
1498 {
Ben Clayton00424c12019-03-17 17:29:30 +00001499 UNIMPLEMENTED("pAllocateInfo->pNext");
Alexis Hetuc8176632019-01-22 17:01:28 -05001500 }
1501
1502 return vk::Cast(pAllocateInfo->descriptorPool)->allocateSets(
1503 pAllocateInfo->descriptorSetCount, pAllocateInfo->pSetLayouts, pDescriptorSets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001504}
1505
1506VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets)
1507{
Ben Claytonfb280672019-04-25 11:16:15 +01001508 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001509 device, static_cast<void*>(descriptorPool), descriptorSetCount, pDescriptorSets);
Alexis Hetuc8176632019-01-22 17:01:28 -05001510
1511 vk::Cast(descriptorPool)->freeSets(descriptorSetCount, pDescriptorSets);
1512
Alexis Hetud73b8712018-09-21 15:14:43 -04001513 return VK_SUCCESS;
1514}
1515
1516VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies)
1517{
Ben Claytonfb280672019-04-25 11:16:15 +01001518 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 -05001519 device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
1520
1521 vk::Cast(device)->updateDescriptorSets(descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
Alexis Hetud73b8712018-09-21 15:14:43 -04001522}
1523
1524VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer)
1525{
Ben Claytonfb280672019-04-25 11:16:15 +01001526 TRACE("(VkDevice device = %p, const VkFramebufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFramebuffer* pFramebuffer = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001527 device, pCreateInfo, pAllocator, pFramebuffer);
1528
Alexis Hetu8f631c82018-11-15 15:11:36 -05001529 if(pCreateInfo->pNext || pCreateInfo->flags)
1530 {
Ben Clayton00424c12019-03-17 17:29:30 +00001531 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags");
Alexis Hetu8f631c82018-11-15 15:11:36 -05001532 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001533
Alexis Hetu8f631c82018-11-15 15:11:36 -05001534 return vk::Framebuffer::Create(pAllocator, pCreateInfo, pFramebuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001535}
1536
1537VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator)
1538{
Ben Claytonfb280672019-04-25 11:16:15 +01001539 TRACE("(VkDevice device = %p, VkFramebuffer framebuffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001540 device, static_cast<void*>(framebuffer), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001541
Alexis Hetu8f631c82018-11-15 15:11:36 -05001542 vk::destroy(framebuffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001543}
1544
1545VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass)
1546{
Ben Claytonfb280672019-04-25 11:16:15 +01001547 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001548 device, pCreateInfo, pAllocator, pRenderPass);
1549
Alexis Hetu67806a12019-04-05 14:12:27 -04001550 if(pCreateInfo->flags)
Alexis Hetub16f9892018-11-15 15:18:41 -05001551 {
Alexis Hetu67806a12019-04-05 14:12:27 -04001552 UNIMPLEMENTED("pCreateInfo->flags");
1553 }
1554
1555 const VkBaseInStructure* extensionCreateInfo = reinterpret_cast<const VkBaseInStructure*>(pCreateInfo->pNext);
1556
1557 while(extensionCreateInfo)
1558 {
1559 switch(extensionCreateInfo->sType)
1560 {
1561 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO:
1562 {
1563 const VkRenderPassInputAttachmentAspectCreateInfo* inputAttachmentAspectCreateInfo = reinterpret_cast<const VkRenderPassInputAttachmentAspectCreateInfo*>(extensionCreateInfo);
1564
1565 for(uint32_t i = 0; i < inputAttachmentAspectCreateInfo->aspectReferenceCount; i++)
1566 {
1567 const VkInputAttachmentAspectReference& aspectReference = inputAttachmentAspectCreateInfo->pAspectReferences[i];
1568 ASSERT(aspectReference.subpass < pCreateInfo->subpassCount);
1569 const VkSubpassDescription& subpassDescription = pCreateInfo->pSubpasses[aspectReference.subpass];
1570 ASSERT(aspectReference.inputAttachmentIndex < subpassDescription.inputAttachmentCount);
1571 const VkAttachmentReference& attachmentReference = subpassDescription.pInputAttachments[aspectReference.inputAttachmentIndex];
1572 if(attachmentReference.attachment != VK_ATTACHMENT_UNUSED)
1573 {
1574 // If the pNext chain includes an instance of VkRenderPassInputAttachmentAspectCreateInfo, for any
1575 // element of the pInputAttachments member of any element of pSubpasses where the attachment member
1576 // is not VK_ATTACHMENT_UNUSED, the aspectMask member of the corresponding element of
1577 // VkRenderPassInputAttachmentAspectCreateInfo::pAspectReferences must only include aspects that are
1578 // present in images of the format specified by the element of pAttachments at attachment
1579 vk::Format format(pCreateInfo->pAttachments[attachmentReference.attachment].format);
1580 bool isDepth = format.isDepth();
1581 bool isStencil = format.isStencil();
1582 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) || (!isDepth && !isStencil));
1583 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || isDepth);
1584 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) || isStencil);
1585 }
1586 }
1587 }
1588 break;
1589 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
1590 {
1591 const VkRenderPassMultiviewCreateInfo* multiviewCreateInfo = reinterpret_cast<const VkRenderPassMultiviewCreateInfo*>(extensionCreateInfo);
1592 ASSERT((multiviewCreateInfo->subpassCount == 0) || (multiviewCreateInfo->subpassCount == pCreateInfo->subpassCount));
1593 ASSERT((multiviewCreateInfo->dependencyCount == 0) || (multiviewCreateInfo->dependencyCount == pCreateInfo->dependencyCount));
1594
1595 bool zeroMask = (multiviewCreateInfo->pViewMasks[0] == 0);
1596 for(uint32_t i = 1; i < multiviewCreateInfo->subpassCount; i++)
1597 {
1598 ASSERT((multiviewCreateInfo->pViewMasks[i] == 0) == zeroMask);
1599 }
1600
1601 if(zeroMask)
1602 {
1603 ASSERT(multiviewCreateInfo->correlationMaskCount == 0);
1604 }
1605
1606 for(uint32_t i = 0; i < multiviewCreateInfo->dependencyCount; i++)
1607 {
1608 const VkSubpassDependency &dependency = pCreateInfo->pDependencies[i];
1609 if(multiviewCreateInfo->pViewOffsets[i] != 0)
1610 {
1611 ASSERT(dependency.srcSubpass != dependency.dstSubpass);
1612 ASSERT(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT);
1613 }
1614 if(zeroMask)
1615 {
1616 ASSERT(!(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT));
1617 }
1618 }
1619
1620 // If the pNext chain includes an instance of VkRenderPassMultiviewCreateInfo,
1621 // each element of its pViewMask member must not include a bit at a position
1622 // greater than the value of VkPhysicalDeviceLimits::maxFramebufferLayers
1623 // pViewMask is a 32 bit value. If maxFramebufferLayers > 32, it's impossible
1624 // for pViewMask to contain a bit at an illegal position
1625 // Note: Verify pViewMask values instead if we hit this assert
Nicolas Capens0c736802019-05-27 12:53:31 -04001626 ASSERT(vk::Cast(device)->getPhysicalDevice()->getProperties().limits.maxFramebufferLayers >= 32);
Alexis Hetu67806a12019-04-05 14:12:27 -04001627 }
1628 break;
1629 default:
Nicolas Capens6b63c802019-05-16 11:10:34 -04001630 UNIMPLEMENTED("extensionCreateInfo->sType %d", int(extensionCreateInfo->sType));
Alexis Hetu67806a12019-04-05 14:12:27 -04001631 break;
1632 }
1633
1634 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetub16f9892018-11-15 15:18:41 -05001635 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001636
Alexis Hetub16f9892018-11-15 15:18:41 -05001637 return vk::RenderPass::Create(pAllocator, pCreateInfo, pRenderPass);
Alexis Hetud73b8712018-09-21 15:14:43 -04001638}
1639
1640VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator)
1641{
Ben Claytonfb280672019-04-25 11:16:15 +01001642 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001643 device, static_cast<void*>(renderPass), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001644
Alexis Hetub16f9892018-11-15 15:18:41 -05001645 vk::destroy(renderPass, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001646}
1647
1648VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity)
1649{
Ben Claytonfb280672019-04-25 11:16:15 +01001650 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, VkExtent2D* pGranularity = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001651 device, static_cast<void*>(renderPass), pGranularity);
Hernan Liatisc7943e92019-02-25 19:29:54 -08001652
Alexis Hetu6d74ab82019-02-15 14:42:38 -05001653 vk::Cast(renderPass)->getRenderAreaGranularity(pGranularity);
Alexis Hetud73b8712018-09-21 15:14:43 -04001654}
1655
1656VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool)
1657{
Ben Claytonfb280672019-04-25 11:16:15 +01001658 TRACE("(VkDevice device = %p, const VkCommandPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkCommandPool* pCommandPool = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001659 device, pCreateInfo, pAllocator, pCommandPool);
1660
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001661 if(pCreateInfo->pNext)
1662 {
Ben Clayton00424c12019-03-17 17:29:30 +00001663 UNIMPLEMENTED("pCreateInfo->pNext");
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001664 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001665
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001666 return vk::CommandPool::Create(pAllocator, pCreateInfo, pCommandPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001667}
1668
1669VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator)
1670{
Ben Claytonfb280672019-04-25 11:16:15 +01001671 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001672 device, static_cast<void*>(commandPool), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001673
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05001674 vk::destroy(commandPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001675}
1676
1677VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
1678{
Ben Claytonfb280672019-04-25 11:16:15 +01001679 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolResetFlags flags = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001680 device, static_cast<void*>(commandPool), int(flags));
Alexis Hetucd610c92019-02-01 16:47:51 -05001681
1682 return vk::Cast(commandPool)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001683}
1684
1685VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers)
1686{
Ben Claytonfb280672019-04-25 11:16:15 +01001687 TRACE("(VkDevice device = %p, const VkCommandBufferAllocateInfo* pAllocateInfo = %p, VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001688 device, pAllocateInfo, pCommandBuffers);
1689
Alexis Hetubffee5e2018-11-19 11:30:43 -05001690 if(pAllocateInfo->pNext)
1691 {
Ben Clayton00424c12019-03-17 17:29:30 +00001692 UNIMPLEMENTED("pAllocateInfo->pNext");
Alexis Hetubffee5e2018-11-19 11:30:43 -05001693 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001694
Alexis Hetubffee5e2018-11-19 11:30:43 -05001695 return vk::Cast(pAllocateInfo->commandPool)->allocateCommandBuffers(
1696 pAllocateInfo->level, pAllocateInfo->commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001697}
1698
1699VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
1700{
Ben Claytonfb280672019-04-25 11:16:15 +01001701 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001702 device, static_cast<void*>(commandPool), int(commandBufferCount), pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001703
Alexis Hetubffee5e2018-11-19 11:30:43 -05001704 vk::Cast(commandPool)->freeCommandBuffers(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001705}
1706
1707VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo)
1708{
Ben Claytonfb280672019-04-25 11:16:15 +01001709 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCommandBufferBeginInfo* pBeginInfo = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04001710 commandBuffer, pBeginInfo);
1711
Alexis Hetua9999ce2018-10-17 08:00:43 -04001712 if(pBeginInfo->pNext)
1713 {
Ben Clayton00424c12019-03-17 17:29:30 +00001714 UNIMPLEMENTED("pBeginInfo->pNext");
Alexis Hetua9999ce2018-10-17 08:00:43 -04001715 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001716
Alexis Hetua9999ce2018-10-17 08:00:43 -04001717 return vk::Cast(commandBuffer)->begin(pBeginInfo->flags, pBeginInfo->pInheritanceInfo);
Alexis Hetud73b8712018-09-21 15:14:43 -04001718}
1719
1720VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
1721{
Ben Claytonfb280672019-04-25 11:16:15 +01001722 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001723
Alexis Hetua9999ce2018-10-17 08:00:43 -04001724 return vk::Cast(commandBuffer)->end();
Alexis Hetud73b8712018-09-21 15:14:43 -04001725}
1726
1727VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags)
1728{
Ben Claytonfb280672019-04-25 11:16:15 +01001729 TRACE("VkCommandBuffer commandBuffer = %p, VkCommandBufferResetFlags flags = %d", commandBuffer, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001730
1731 return vk::Cast(commandBuffer)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001732}
1733
1734VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
1735{
Ben Claytonfb280672019-04-25 11:16:15 +01001736 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineBindPoint pipelineBindPoint = %d, VkPipeline pipeline = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001737 commandBuffer, int(pipelineBindPoint), static_cast<void*>(pipeline));
Alexis Hetud73b8712018-09-21 15:14:43 -04001738
Alexis Hetu7d96f512019-06-13 18:23:56 -04001739 vk::Cast(commandBuffer)->bindPipeline(pipelineBindPoint, vk::Cast(pipeline));
Alexis Hetud73b8712018-09-21 15:14:43 -04001740}
1741
1742VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports)
1743{
Ben Claytonfb280672019-04-25 11:16:15 +01001744 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstViewport = %d, uint32_t viewportCount = %d, const VkViewport* pViewports = %p)",
1745 commandBuffer, int(firstViewport), int(viewportCount), pViewports);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001746
1747 vk::Cast(commandBuffer)->setViewport(firstViewport, viewportCount, pViewports);
Alexis Hetud73b8712018-09-21 15:14:43 -04001748}
1749
1750VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors)
1751{
Ben Claytonfb280672019-04-25 11:16:15 +01001752 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstScissor = %d, uint32_t scissorCount = %d, const VkRect2D* pScissors = %p)",
1753 commandBuffer, int(firstScissor), int(scissorCount), pScissors);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001754
1755 vk::Cast(commandBuffer)->setScissor(firstScissor, scissorCount, pScissors);
Alexis Hetud73b8712018-09-21 15:14:43 -04001756}
1757
1758VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
1759{
Ben Claytonfb280672019-04-25 11:16:15 +01001760 TRACE("(VkCommandBuffer commandBuffer = %p, float lineWidth = %f)", commandBuffer, lineWidth);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001761
1762 vk::Cast(commandBuffer)->setLineWidth(lineWidth);
Alexis Hetud73b8712018-09-21 15:14:43 -04001763}
1764
1765VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
1766{
Ben Claytonfb280672019-04-25 11:16:15 +01001767 TRACE("(VkCommandBuffer commandBuffer = %p, float depthBiasConstantFactor = %f, float depthBiasClamp = %f, float depthBiasSlopeFactor = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001768 commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
1769
1770 vk::Cast(commandBuffer)->setDepthBias(depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
Alexis Hetud73b8712018-09-21 15:14:43 -04001771}
1772
1773VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
1774{
Ben Claytonfb280672019-04-25 11:16:15 +01001775 TRACE("(VkCommandBuffer commandBuffer = %p, const float blendConstants[4] = {%f, %f, %f, %f})",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001776 commandBuffer, blendConstants[0], blendConstants[1], blendConstants[2], blendConstants[3]);
1777
1778 vk::Cast(commandBuffer)->setBlendConstants(blendConstants);
Alexis Hetud73b8712018-09-21 15:14:43 -04001779}
1780
1781VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
1782{
Ben Claytonfb280672019-04-25 11:16:15 +01001783 TRACE("(VkCommandBuffer commandBuffer = %p, float minDepthBounds = %f, float maxDepthBounds = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04001784 commandBuffer, minDepthBounds, maxDepthBounds);
1785
1786 vk::Cast(commandBuffer)->setDepthBounds(minDepthBounds, maxDepthBounds);
Alexis Hetud73b8712018-09-21 15:14:43 -04001787}
1788
1789VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
1790{
Ben Claytonfb280672019-04-25 11:16:15 +01001791 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t compareMask = %d)",
1792 commandBuffer, int(faceMask), int(compareMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001793
1794 vk::Cast(commandBuffer)->setStencilCompareMask(faceMask, compareMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001795}
1796
1797VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
1798{
Ben Claytonfb280672019-04-25 11:16:15 +01001799 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t writeMask = %d)",
1800 commandBuffer, int(faceMask), int(writeMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001801
1802 vk::Cast(commandBuffer)->setStencilWriteMask(faceMask, writeMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001803}
1804
1805VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
1806{
Ben Claytonfb280672019-04-25 11:16:15 +01001807 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t reference = %d)",
1808 commandBuffer, int(faceMask), int(reference));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001809
1810 vk::Cast(commandBuffer)->setStencilReference(faceMask, reference);
Alexis Hetud73b8712018-09-21 15:14:43 -04001811}
1812
1813VKAPI_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)
1814{
Ben Claytonfb280672019-04-25 11:16:15 +01001815 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)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001816 commandBuffer, int(pipelineBindPoint), static_cast<void*>(layout), int(firstSet), int(descriptorSetCount), pDescriptorSets, int(dynamicOffsetCount), pDynamicOffsets);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001817
Alexis Hetu7d96f512019-06-13 18:23:56 -04001818 vk::Cast(commandBuffer)->bindDescriptorSets(pipelineBindPoint, vk::Cast(layout), firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001819}
1820
1821VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
1822{
Ben Claytonfb280672019-04-25 11:16:15 +01001823 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkIndexType indexType = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001824 commandBuffer, static_cast<void*>(buffer), int(offset), int(indexType));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001825
Alexis Hetu7d96f512019-06-13 18:23:56 -04001826 vk::Cast(commandBuffer)->bindIndexBuffer(vk::Cast(buffer), offset, indexType);
Alexis Hetud73b8712018-09-21 15:14:43 -04001827}
1828
1829VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets)
1830{
Ben Claytonfb280672019-04-25 11:16:15 +01001831 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = %p, const VkDeviceSize* pOffsets = %p)",
1832 commandBuffer, int(firstBinding), int(bindingCount), pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001833
Alexis Hetua9999ce2018-10-17 08:00:43 -04001834 vk::Cast(commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04001835}
1836
1837VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
1838{
Ben Claytonfb280672019-04-25 11:16:15 +01001839 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t vertexCount = %d, uint32_t instanceCount = %d, uint32_t firstVertex = %d, uint32_t firstInstance = %d)",
1840 commandBuffer, int(vertexCount), int(instanceCount), int(firstVertex), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04001841
Alexis Hetua9999ce2018-10-17 08:00:43 -04001842 vk::Cast(commandBuffer)->draw(vertexCount, instanceCount, firstVertex, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04001843}
1844
1845VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
1846{
Ben Claytonfb280672019-04-25 11:16:15 +01001847 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t indexCount = %d, uint32_t instanceCount = %d, uint32_t firstIndex = %d, int32_t vertexOffset = %d, uint32_t firstInstance = %d)",
1848 commandBuffer, int(indexCount), int(instanceCount), int(firstIndex), int(vertexOffset), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04001849
Alexis Hetua9999ce2018-10-17 08:00:43 -04001850 vk::Cast(commandBuffer)->drawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04001851}
1852
1853VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1854{
Ben Claytonfb280672019-04-25 11:16:15 +01001855 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001856 commandBuffer, static_cast<void*>(buffer), int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04001857
Alexis Hetu7d96f512019-06-13 18:23:56 -04001858 vk::Cast(commandBuffer)->drawIndirect(vk::Cast(buffer), offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04001859}
1860
1861VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
1862{
Ben Claytonfb280672019-04-25 11:16:15 +01001863 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001864 commandBuffer, static_cast<void*>(buffer), int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04001865
Alexis Hetu7d96f512019-06-13 18:23:56 -04001866 vk::Cast(commandBuffer)->drawIndexedIndirect(vk::Cast(buffer), offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04001867}
1868
1869VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
1870{
Ben Claytonfb280672019-04-25 11:16:15 +01001871 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t groupCountX = %d, uint32_t groupCountY = %d, uint32_t groupCountZ = %d)",
1872 commandBuffer, int(groupCountX), int(groupCountY), int(groupCountZ));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001873
1874 vk::Cast(commandBuffer)->dispatch(groupCountX, groupCountY, groupCountZ);
Alexis Hetud73b8712018-09-21 15:14:43 -04001875}
1876
1877VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
1878{
Ben Claytonfb280672019-04-25 11:16:15 +01001879 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001880 commandBuffer, static_cast<void*>(buffer), int(offset));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001881
Alexis Hetu7d96f512019-06-13 18:23:56 -04001882 vk::Cast(commandBuffer)->dispatchIndirect(vk::Cast(buffer), offset);
Alexis Hetud73b8712018-09-21 15:14:43 -04001883}
1884
1885VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
1886{
Ben Claytonfb280672019-04-25 11:16:15 +01001887 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferCopy* pRegions = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001888 commandBuffer, static_cast<void*>(srcBuffer), static_cast<void*>(dstBuffer), int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001889
Alexis Hetu7d96f512019-06-13 18:23:56 -04001890 vk::Cast(commandBuffer)->copyBuffer(vk::Cast(srcBuffer), vk::Cast(dstBuffer), regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001891}
1892
1893VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions)
1894{
Ben Claytonfb280672019-04-25 11:16:15 +01001895 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageCopy* pRegions = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001896 commandBuffer, static_cast<void*>(srcImage), srcImageLayout, static_cast<void*>(dstImage), dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001897
Alexis Hetu7d96f512019-06-13 18:23:56 -04001898 vk::Cast(commandBuffer)->copyImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001899}
1900
1901VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter)
1902{
Ben Claytonfb280672019-04-25 11:16:15 +01001903 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)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001904 commandBuffer, static_cast<void*>(srcImage), srcImageLayout, static_cast<void*>(dstImage), dstImageLayout, int(regionCount), pRegions, filter);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001905
Alexis Hetu7d96f512019-06-13 18:23:56 -04001906 vk::Cast(commandBuffer)->blitImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions, filter);
Alexis Hetud73b8712018-09-21 15:14:43 -04001907}
1908
1909VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1910{
Ben Claytonfb280672019-04-25 11:16:15 +01001911 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001912 commandBuffer, static_cast<void*>(srcBuffer), static_cast<void*>(dstImage), dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001913
Alexis Hetu7d96f512019-06-13 18:23:56 -04001914 vk::Cast(commandBuffer)->copyBufferToImage(vk::Cast(srcBuffer), vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001915}
1916
1917VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions)
1918{
Ben Claytonfb280672019-04-25 11:16:15 +01001919 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001920 commandBuffer, static_cast<void*>(srcImage), int(srcImageLayout), static_cast<void*>(dstBuffer), int(regionCount), pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001921
Alexis Hetu7d96f512019-06-13 18:23:56 -04001922 vk::Cast(commandBuffer)->copyImageToBuffer(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstBuffer), regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001923}
1924
1925VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData)
1926{
Ben Claytonfb280672019-04-25 11:16:15 +01001927 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize dataSize = %d, const void* pData = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001928 commandBuffer, static_cast<void*>(dstBuffer), int(dstOffset), int(dataSize), pData);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001929
Alexis Hetu7d96f512019-06-13 18:23:56 -04001930 vk::Cast(commandBuffer)->updateBuffer(vk::Cast(dstBuffer), dstOffset, dataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001931}
1932
1933VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
1934{
Ben Claytonfb280672019-04-25 11:16:15 +01001935 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize size = %d, uint32_t data = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001936 commandBuffer, static_cast<void*>(dstBuffer), int(dstOffset), int(size), data);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001937
Alexis Hetu7d96f512019-06-13 18:23:56 -04001938 vk::Cast(commandBuffer)->fillBuffer(vk::Cast(dstBuffer), dstOffset, size, data);
Alexis Hetud73b8712018-09-21 15:14:43 -04001939}
1940
1941VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1942{
Ben Claytonfb280672019-04-25 11:16:15 +01001943 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearColorValue* pColor = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001944 commandBuffer, static_cast<void*>(image), int(imageLayout), pColor, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001945
Alexis Hetu7d96f512019-06-13 18:23:56 -04001946 vk::Cast(commandBuffer)->clearColorImage(vk::Cast(image), imageLayout, pColor, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001947}
1948
1949VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
1950{
Ben Claytonfb280672019-04-25 11:16:15 +01001951 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearDepthStencilValue* pDepthStencil = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001952 commandBuffer, static_cast<void*>(image), int(imageLayout), pDepthStencil, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001953
Alexis Hetu7d96f512019-06-13 18:23:56 -04001954 vk::Cast(commandBuffer)->clearDepthStencilImage(vk::Cast(image), imageLayout, pDepthStencil, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001955}
1956
1957VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects)
1958{
Ben Claytonfb280672019-04-25 11:16:15 +01001959 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t attachmentCount = %d, const VkClearAttachment* pAttachments = %p, uint32_t rectCount = %d, const VkClearRect* pRects = %p)",
1960 commandBuffer, int(attachmentCount), pAttachments, int(rectCount), pRects);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001961
1962 vk::Cast(commandBuffer)->clearAttachments(attachmentCount, pAttachments, rectCount, pRects);
Alexis Hetud73b8712018-09-21 15:14:43 -04001963}
1964
1965VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions)
1966{
Ben Claytonfb280672019-04-25 11:16:15 +01001967 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageResolve* pRegions = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001968 commandBuffer, static_cast<void*>(srcImage), int(srcImageLayout), static_cast<void*>(dstImage), int(dstImageLayout), regionCount, pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001969
Alexis Hetu7d96f512019-06-13 18:23:56 -04001970 vk::Cast(commandBuffer)->resolveImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04001971}
1972
1973VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1974{
Ben Claytonfb280672019-04-25 11:16:15 +01001975 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001976 commandBuffer, static_cast<void*>(event), int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001977
Alexis Hetu7d96f512019-06-13 18:23:56 -04001978 vk::Cast(commandBuffer)->setEvent(vk::Cast(event), stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001979}
1980
1981VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
1982{
Ben Claytonfb280672019-04-25 11:16:15 +01001983 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04001984 commandBuffer, static_cast<void*>(event), int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04001985
Alexis Hetu7d96f512019-06-13 18:23:56 -04001986 vk::Cast(commandBuffer)->resetEvent(vk::Cast(event), stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04001987}
1988
1989VKAPI_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)
1990{
Ben Claytonfb280672019-04-25 11:16:15 +01001991 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)",
1992 commandBuffer, int(eventCount), pEvents, int(srcStageMask), int(dstStageMask), int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetua9999ce2018-10-17 08:00:43 -04001993
1994 vk::Cast(commandBuffer)->waitEvents(eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04001995}
1996
1997VKAPI_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)
1998{
Ben Claytonfb280672019-04-25 11:16:15 +01001999 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlags srcStageMask = 0x%x, VkPipelineStageFlags dstStageMask = 0x%x, VkDependencyFlags dependencyFlags = %d, uint32_t memoryBarrierCount = %d, onst VkMemoryBarrier* pMemoryBarriers = %p,"
2000 " uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
2001 commandBuffer, int(srcStageMask), int(dstStageMask), dependencyFlags, int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002002
Alexis Hetua9999ce2018-10-17 08:00:43 -04002003 vk::Cast(commandBuffer)->pipelineBarrier(srcStageMask, dstStageMask, dependencyFlags,
2004 memoryBarrierCount, pMemoryBarriers,
2005 bufferMemoryBarrierCount, pBufferMemoryBarriers,
2006 imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002007}
2008
2009VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
2010{
Ben Claytonfb280672019-04-25 11:16:15 +01002011 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d, VkQueryControlFlags flags = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002012 commandBuffer, static_cast<void*>(queryPool), query, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002013
Alexis Hetu7d96f512019-06-13 18:23:56 -04002014 vk::Cast(commandBuffer)->beginQuery(vk::Cast(queryPool), query, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002015}
2016
2017VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
2018{
Ben Claytonfb280672019-04-25 11:16:15 +01002019 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002020 commandBuffer, static_cast<void*>(queryPool), int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002021
Alexis Hetu7d96f512019-06-13 18:23:56 -04002022 vk::Cast(commandBuffer)->endQuery(vk::Cast(queryPool), query);
Alexis Hetud73b8712018-09-21 15:14:43 -04002023}
2024
2025VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
2026{
Ben Claytonfb280672019-04-25 11:16:15 +01002027 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002028 commandBuffer, static_cast<void*>(queryPool), int(firstQuery), int(queryCount));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002029
Alexis Hetu7d96f512019-06-13 18:23:56 -04002030 vk::Cast(commandBuffer)->resetQueryPool(vk::Cast(queryPool), firstQuery, queryCount);
Alexis Hetud73b8712018-09-21 15:14:43 -04002031}
2032
2033VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
2034{
Ben Claytonfb280672019-04-25 11:16:15 +01002035 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlagBits pipelineStage = %d, VkQueryPool queryPool = %p, uint32_t query = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002036 commandBuffer, int(pipelineStage), static_cast<void*>(queryPool), int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002037
Alexis Hetu7d96f512019-06-13 18:23:56 -04002038 vk::Cast(commandBuffer)->writeTimestamp(pipelineStage, vk::Cast(queryPool), query);
Alexis Hetud73b8712018-09-21 15:14:43 -04002039}
2040
2041VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
2042{
Ben Claytonfb280672019-04-25 11:16:15 +01002043 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)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002044 commandBuffer, static_cast<void*>(queryPool), int(firstQuery), int(queryCount), static_cast<void*>(dstBuffer), int(dstOffset), int(stride), int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002045
Alexis Hetu7d96f512019-06-13 18:23:56 -04002046 vk::Cast(commandBuffer)->copyQueryPoolResults(vk::Cast(queryPool), firstQuery, queryCount, vk::Cast(dstBuffer), dstOffset, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002047}
2048
2049VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues)
2050{
Ben Claytonfb280672019-04-25 11:16:15 +01002051 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineLayout layout = %p, VkShaderStageFlags stageFlags = %d, uint32_t offset = %d, uint32_t size = %d, const void* pValues = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002052 commandBuffer, static_cast<void*>(layout), stageFlags, offset, size, pValues);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002053
Alexis Hetu7d96f512019-06-13 18:23:56 -04002054 vk::Cast(commandBuffer)->pushConstants(vk::Cast(layout), stageFlags, offset, size, pValues);
Alexis Hetud73b8712018-09-21 15:14:43 -04002055}
2056
2057VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents)
2058{
Ben Claytonfb280672019-04-25 11:16:15 +01002059 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderPassBeginInfo* pRenderPassBegin = %p, VkSubpassContents contents = %d)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04002060 commandBuffer, pRenderPassBegin, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002061
Alexis Hetu026ceef2019-05-07 17:35:11 -04002062 const VkBaseInStructure* renderPassBeginInfo = reinterpret_cast<const VkBaseInStructure*>(pRenderPassBegin->pNext);
2063 while(renderPassBeginInfo)
Alexis Hetua9999ce2018-10-17 08:00:43 -04002064 {
Alexis Hetu026ceef2019-05-07 17:35:11 -04002065 switch(renderPassBeginInfo->sType)
2066 {
2067 case VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO:
Chris Forbes3e511442019-05-09 08:38:59 -07002068 // This extension controls which render area is used on which physical device,
2069 // in order to distribute rendering between multiple physical devices.
Alexis Hetu026ceef2019-05-07 17:35:11 -04002070 // SwiftShader only has a single physical device, so this extension does nothing in this case.
2071 break;
2072 default:
2073 UNIMPLEMENTED("renderPassBeginInfo->sType");
2074 break;
2075 }
2076
2077 renderPassBeginInfo = renderPassBeginInfo->pNext;
Alexis Hetua9999ce2018-10-17 08:00:43 -04002078 }
2079
Alexis Hetu7d96f512019-06-13 18:23:56 -04002080 vk::Cast(commandBuffer)->beginRenderPass(vk::Cast(pRenderPassBegin->renderPass), vk::Cast(pRenderPassBegin->framebuffer),
Alexis Hetua9999ce2018-10-17 08:00:43 -04002081 pRenderPassBegin->renderArea, pRenderPassBegin->clearValueCount,
2082 pRenderPassBegin->pClearValues, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002083}
2084
2085VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
2086{
Ben Claytonfb280672019-04-25 11:16:15 +01002087 TRACE("(VkCommandBuffer commandBuffer = %p, VkSubpassContents contents = %d)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002088 commandBuffer, contents);
2089
2090 vk::Cast(commandBuffer)->nextSubpass(contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002091}
2092
2093VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
2094{
Ben Claytonfb280672019-04-25 11:16:15 +01002095 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04002096
Alexis Hetua9999ce2018-10-17 08:00:43 -04002097 vk::Cast(commandBuffer)->endRenderPass();
Alexis Hetud73b8712018-09-21 15:14:43 -04002098}
2099
2100VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers)
2101{
Ben Claytonfb280672019-04-25 11:16:15 +01002102 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002103 commandBuffer, commandBufferCount, pCommandBuffers);
2104
2105 vk::Cast(commandBuffer)->executeCommands(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002106}
2107
2108VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t* pApiVersion)
2109{
Ben Claytonfb280672019-04-25 11:16:15 +01002110 TRACE("(uint32_t* pApiVersion = %p)", pApiVersion);
Nicolas Capensee841c52018-11-13 14:18:26 -05002111 *pApiVersion = vk::API_VERSION;
Alexis Hetud73b8712018-09-21 15:14:43 -04002112 return VK_SUCCESS;
2113}
2114
2115VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos)
2116{
Ben Claytonfb280672019-04-25 11:16:15 +01002117 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = %p)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04002118 device, bindInfoCount, pBindInfos);
2119
2120 for(uint32_t i = 0; i < bindInfoCount; i++)
2121 {
2122 if(pBindInfos[i].pNext)
2123 {
Ben Clayton00424c12019-03-17 17:29:30 +00002124 UNIMPLEMENTED("pBindInfos[%d].pNext", i);
Alexis Hetu38ff8302018-10-18 15:08:13 -04002125 }
2126
Alexis Hetu7d96f512019-06-13 18:23:56 -04002127 vk::Cast(pBindInfos[i].buffer)->bind(vk::Cast(pBindInfos[i].memory), pBindInfos[i].memoryOffset);
Alexis Hetu38ff8302018-10-18 15:08:13 -04002128 }
2129
Alexis Hetud73b8712018-09-21 15:14:43 -04002130 return VK_SUCCESS;
2131}
2132
2133VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos)
2134{
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002135 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindImageMemoryInfo* pBindInfos = %p)",
2136 device, bindInfoCount, pBindInfos);
Nicolas Capens71c012b2019-05-22 13:31:52 -04002137
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002138 for(uint32_t i = 0; i < bindInfoCount; i++)
2139 {
2140 if(pBindInfos[i].pNext)
2141 {
2142 UNIMPLEMENTED("pBindInfos[%d].pNext", i);
2143 }
2144
Alexis Hetu7d96f512019-06-13 18:23:56 -04002145 vk::Cast(pBindInfos[i].image)->bind(vk::Cast(pBindInfos[i].memory), pBindInfos[i].memoryOffset);
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002146 }
2147
Alexis Hetud73b8712018-09-21 15:14:43 -04002148 return VK_SUCCESS;
2149}
2150
2151VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures)
2152{
Ben Claytonfb280672019-04-25 11:16:15 +01002153 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 -04002154 device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
2155
Nicolas Capens5028a582018-11-13 15:03:35 -05002156 ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
Ben Clayton00424c12019-03-17 17:29:30 +00002157 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 -04002158}
2159
2160VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
2161{
Alexis Hetu026ceef2019-05-07 17:35:11 -04002162 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t deviceMask = %d", commandBuffer, deviceMask);
2163
2164 vk::Cast(commandBuffer)->setDeviceMask(deviceMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002165}
2166
2167VKAPI_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)
2168{
Chris Forbes4a4c2592019-05-13 08:53:36 -07002169 TRACE("(VkCommandBuffer commandBuffer = %p, baseGroupX = %u, baseGroupY = %u, baseGroupZ = %u, groupCountX = %u, groupCountY = %u, groupCountZ = %u)",
2170 commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
2171
2172 vk::Cast(commandBuffer)->dispatchBase(baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
Alexis Hetud73b8712018-09-21 15:14:43 -04002173}
2174
2175VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties)
2176{
Ben Claytonfb280672019-04-25 11:16:15 +01002177 TRACE("VkInstance instance = %p, uint32_t* pPhysicalDeviceGroupCount = %p, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = %p",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002178 instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
2179
Chris Forbesdf84b942019-06-12 11:28:09 -07002180 return vk::Cast(instance)->getPhysicalDeviceGroups(pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002181}
2182
2183VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
2184{
Ben Claytonfb280672019-04-25 11:16:15 +01002185 TRACE("(VkDevice device = %p, const VkImageMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002186 device, pInfo, pMemoryRequirements);
2187
Alexis Hetu42761d22019-04-08 11:25:59 -04002188 if(pInfo->pNext)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002189 {
Alexis Hetu42761d22019-04-08 11:25:59 -04002190 UNIMPLEMENTED("pInfo->pNext");
2191 }
2192
2193 VkBaseOutStructure* extensionRequirements = reinterpret_cast<VkBaseOutStructure*>(pMemoryRequirements->pNext);
2194 while(extensionRequirements)
2195 {
2196 switch(extensionRequirements->sType)
2197 {
2198 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
2199 {
2200 auto& requirements = *reinterpret_cast<VkMemoryDedicatedRequirements*>(extensionRequirements);
2201 requirements.prefersDedicatedAllocation = VK_FALSE;
2202 requirements.requiresDedicatedAllocation = VK_FALSE;
2203 }
2204 break;
2205 default:
2206 UNIMPLEMENTED("extensionRequirements->sType");
2207 break;
2208 }
2209
2210 extensionRequirements = extensionRequirements->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002211 }
2212
2213 vkGetImageMemoryRequirements(device, pInfo->image, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04002214}
2215
2216VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements)
2217{
Ben Claytonfb280672019-04-25 11:16:15 +01002218 TRACE("(VkDevice device = %p, const VkBufferMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002219 device, pInfo, pMemoryRequirements);
2220
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002221 if(pInfo->pNext)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002222 {
Ben Clayton00424c12019-03-17 17:29:30 +00002223 UNIMPLEMENTED("pInfo->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002224 }
2225
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002226 VkBaseOutStructure* extensionRequirements = reinterpret_cast<VkBaseOutStructure*>(pMemoryRequirements->pNext);
2227 while(extensionRequirements)
2228 {
2229 switch(extensionRequirements->sType)
2230 {
2231 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
2232 {
2233 auto& requirements = *reinterpret_cast<VkMemoryDedicatedRequirements*>(extensionRequirements);
2234 requirements.prefersDedicatedAllocation = VK_FALSE;
2235 requirements.requiresDedicatedAllocation = VK_FALSE;
2236 }
2237 break;
2238 default:
Ben Clayton00424c12019-03-17 17:29:30 +00002239 UNIMPLEMENTED("extensionRequirements->sType");
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002240 break;
2241 }
2242
2243 extensionRequirements = extensionRequirements->pNext;
2244 }
2245
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002246 vkGetBufferMemoryRequirements(device, pInfo->buffer, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04002247}
2248
2249VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements)
2250{
Ben Claytonfb280672019-04-25 11:16:15 +01002251 TRACE("(VkDevice device = %p, const VkImageSparseMemoryRequirementsInfo2* pInfo = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002252 device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
2253
2254 if(pInfo->pNext || pSparseMemoryRequirements->pNext)
2255 {
Ben Clayton00424c12019-03-17 17:29:30 +00002256 UNIMPLEMENTED("pInfo->pNext || pSparseMemoryRequirements->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002257 }
2258
2259 vkGetImageSparseMemoryRequirements(device, pInfo->image, pSparseMemoryRequirementCount, &(pSparseMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04002260}
2261
2262VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures)
2263{
Ben Claytonfb280672019-04-25 11:16:15 +01002264 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures2* pFeatures = %p)", physicalDevice, pFeatures);
Alexis Hetud73b8712018-09-21 15:14:43 -04002265
Nicolas Capensae8d4642018-11-13 15:17:16 -05002266 VkBaseOutStructure* extensionFeatures = reinterpret_cast<VkBaseOutStructure*>(pFeatures->pNext);
2267 while(extensionFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002268 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002269 switch(extensionFeatures->sType)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002270 {
2271 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
2272 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002273 auto& features = *reinterpret_cast<VkPhysicalDeviceSamplerYcbcrConversionFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002274 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002275 }
2276 break;
2277 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
2278 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002279 auto& features = *reinterpret_cast<VkPhysicalDevice16BitStorageFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002280 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002281 }
2282 break;
2283 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
2284 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002285 auto& features = *reinterpret_cast<VkPhysicalDeviceVariablePointerFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002286 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002287 }
2288 break;
2289 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR:
2290 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002291 auto& features = *reinterpret_cast<VkPhysicalDevice8BitStorageFeaturesKHR*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002292 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002293 }
2294 break;
2295 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
2296 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002297 auto& features = *reinterpret_cast<VkPhysicalDeviceMultiviewFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002298 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002299 }
2300 break;
2301 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
2302 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002303 auto& features = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryFeatures*>(extensionFeatures);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002304 vk::Cast(physicalDevice)->getFeatures(&features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002305 }
2306 break;
Chris Forbes6408c552019-04-15 12:59:34 -07002307 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES:
2308 {
2309 auto& features = *reinterpret_cast<VkPhysicalDeviceShaderDrawParameterFeatures*>(extensionFeatures);
2310 vk::Cast(physicalDevice)->getFeatures(&features);
2311 }
2312 break;
Chris Forbesc0c6ccf2019-05-17 17:38:19 -07002313 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT:
2314 ASSERT(!HasExtensionProperty(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, deviceExtensionProperties,
2315 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2316 break;
2317 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT:
2318 ASSERT(!HasExtensionProperty(VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME, deviceExtensionProperties,
2319 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2320 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002321 default:
Nicolas Capensae8d4642018-11-13 15:17:16 -05002322 // "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 +00002323 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 -05002324 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002325 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05002326
2327 extensionFeatures = extensionFeatures->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002328 }
2329
2330 vkGetPhysicalDeviceFeatures(physicalDevice, &(pFeatures->features));
Alexis Hetud73b8712018-09-21 15:14:43 -04002331}
2332
2333VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties)
2334{
Ben Claytonfb280672019-04-25 11:16:15 +01002335 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties2* pProperties = %p)", physicalDevice, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002336
Nicolas Capensae8d4642018-11-13 15:17:16 -05002337 VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pProperties->pNext);
2338 while(extensionProperties)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002339 {
Hernan Liatis83a3eb42019-04-29 17:16:10 -07002340 // Casting to a long since some structures, such as VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID
2341 // are not enumerated in the official Vulkan header
2342 switch((long)(extensionProperties->sType))
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002343 {
2344 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
2345 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002346 auto& properties = *reinterpret_cast<VkPhysicalDeviceIDProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002347 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002348 }
2349 break;
2350 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
2351 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002352 auto& properties = *reinterpret_cast<VkPhysicalDeviceMaintenance3Properties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002353 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002354 }
2355 break;
2356 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
2357 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002358 auto& properties = *reinterpret_cast<VkPhysicalDeviceMultiviewProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002359 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002360 }
2361 break;
2362 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
2363 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002364 auto& properties = *reinterpret_cast<VkPhysicalDevicePointClippingProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002365 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002366 }
2367 break;
2368 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
2369 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002370 auto& properties = *reinterpret_cast<VkPhysicalDeviceProtectedMemoryProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002371 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002372 }
2373 break;
2374 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
2375 {
Nicolas Capensae8d4642018-11-13 15:17:16 -05002376 auto& properties = *reinterpret_cast<VkPhysicalDeviceSubgroupProperties*>(extensionProperties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002377 vk::Cast(physicalDevice)->getProperties(&properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002378 }
2379 break;
Alexis Hetud6fae382019-04-05 13:19:46 -04002380 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT:
2381 // Explicitly ignored, since VK_EXT_sample_locations is not supported
2382 ASSERT(!HasExtensionProperty(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME, deviceExtensionProperties,
2383 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2384 break;
Alexis Hetud5ed0a32019-05-07 16:07:34 -04002385 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT:
2386 ASSERT(!HasExtensionProperty(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, deviceExtensionProperties,
2387 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2388 break;
Hernan Liatis83a3eb42019-04-29 17:16:10 -07002389#ifdef __ANDROID__
2390 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
2391 {
2392 auto& properties = *reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID*>(extensionProperties);
2393 vk::Cast(physicalDevice)->getProperties(&properties);
2394 }
2395 break;
2396#endif
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002397 default:
Nicolas Capensae8d4642018-11-13 15:17:16 -05002398 // "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 +00002399 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 -05002400 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002401 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05002402
2403 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002404 }
2405
2406 vkGetPhysicalDeviceProperties(physicalDevice, &(pProperties->properties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002407}
2408
2409VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties)
2410{
Ben Claytonfb280672019-04-25 11:16:15 +01002411 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties2* pFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002412 physicalDevice, format, pFormatProperties);
2413
Alexis Hetu767b41b2018-09-26 11:25:46 -04002414 if(pFormatProperties->pNext)
2415 {
Ben Clayton00424c12019-03-17 17:29:30 +00002416 UNIMPLEMENTED("pFormatProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002417 }
2418
2419 vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &(pFormatProperties->formatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002420}
2421
2422VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties)
2423{
Ben Claytonfb280672019-04-25 11:16:15 +01002424 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo = %p, VkImageFormatProperties2* pImageFormatProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002425 physicalDevice, pImageFormatInfo, pImageFormatProperties);
2426
Alexis Hetu00835732019-04-10 16:36:31 -04002427 const VkBaseInStructure* extensionFormatInfo = reinterpret_cast<const VkBaseInStructure*>(pImageFormatInfo->pNext);
2428
2429 const VkExternalMemoryHandleTypeFlagBits* handleType = nullptr;
2430 while(extensionFormatInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002431 {
Alexis Hetu00835732019-04-10 16:36:31 -04002432 switch(extensionFormatInfo->sType)
2433 {
2434 case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR:
2435 {
2436 // Explicitly ignored, since VK_KHR_image_format_list is not supported
2437 ASSERT(!HasExtensionProperty(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, deviceExtensionProperties,
2438 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2439 }
2440 break;
2441 case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT:
2442 {
2443 // Explicitly ignored, since VK_EXT_separate_stencil_usage is not supported
2444 ASSERT(!HasExtensionProperty(VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME, deviceExtensionProperties,
2445 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2446 }
2447 break;
2448 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
2449 {
2450 const VkPhysicalDeviceExternalImageFormatInfo* imageFormatInfo = reinterpret_cast<const VkPhysicalDeviceExternalImageFormatInfo*>(extensionFormatInfo);
2451 handleType = &(imageFormatInfo->handleType);
2452 }
2453 break;
2454 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
2455 {
2456 // Explicitly ignored, since VK_EXT_image_drm_format_modifier is not supported
2457 ASSERT(!HasExtensionProperty(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, deviceExtensionProperties,
2458 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2459 }
2460 break;
2461 default:
2462 UNIMPLEMENTED("extensionFormatInfo->sType");
2463 break;
2464 }
2465
2466 extensionFormatInfo = extensionFormatInfo->pNext;
2467 }
2468
2469 VkBaseOutStructure* extensionProperties = reinterpret_cast<VkBaseOutStructure*>(pImageFormatProperties->pNext);
2470
2471 while(extensionProperties)
2472 {
2473 switch(extensionProperties->sType)
2474 {
2475 case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
2476 {
2477 auto& properties = *reinterpret_cast<VkExternalImageFormatProperties*>(extensionProperties);
2478 vk::Cast(physicalDevice)->getProperties(handleType, &properties);
2479 }
2480 break;
2481 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
2482 {
2483 auto& properties = *reinterpret_cast<VkSamplerYcbcrConversionImageFormatProperties*>(extensionProperties);
2484 vk::Cast(physicalDevice)->getProperties(&properties);
2485 }
2486 break;
2487 case VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD:
2488 {
2489 // Explicitly ignored, since VK_AMD_texture_gather_bias_lod is not supported
2490 ASSERT(!HasExtensionProperty(VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME, deviceExtensionProperties,
2491 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2492 }
2493 break;
2494 default:
2495 UNIMPLEMENTED("extensionProperties->sType");
2496 break;
2497 }
2498
2499 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002500 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002501
Alexis Hetu767b41b2018-09-26 11:25:46 -04002502 return vkGetPhysicalDeviceImageFormatProperties(physicalDevice,
2503 pImageFormatInfo->format,
2504 pImageFormatInfo->type,
2505 pImageFormatInfo->tiling,
2506 pImageFormatInfo->usage,
2507 pImageFormatInfo->flags,
2508 &(pImageFormatProperties->imageFormatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002509}
2510
2511VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties)
2512{
Ben Claytonfb280672019-04-25 11:16:15 +01002513 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties2* pQueueFamilyProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -04002514 physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
2515
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002516 if(pQueueFamilyProperties && pQueueFamilyProperties->pNext)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002517 {
Ben Clayton00424c12019-03-17 17:29:30 +00002518 UNIMPLEMENTED("pQueueFamilyProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002519 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04002520
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002521 vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount,
2522 pQueueFamilyProperties ? &(pQueueFamilyProperties->queueFamilyProperties) : nullptr);
Alexis Hetud73b8712018-09-21 15:14:43 -04002523}
2524
2525VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties)
2526{
Ben Claytonfb280672019-04-25 11:16:15 +01002527 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties2* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002528
Alexis Hetu767b41b2018-09-26 11:25:46 -04002529 if(pMemoryProperties->pNext)
2530 {
Ben Clayton00424c12019-03-17 17:29:30 +00002531 UNIMPLEMENTED("pMemoryProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002532 }
2533
2534 vkGetPhysicalDeviceMemoryProperties(physicalDevice, &(pMemoryProperties->memoryProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04002535}
2536
2537VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties)
2538{
Ben Claytonfb280672019-04-25 11:16:15 +01002539 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo = %p, uint32_t* pPropertyCount = %p, VkSparseImageFormatProperties2* pProperties = %p)",
Alexis Hetu767b41b2018-09-26 11:25:46 -04002540 physicalDevice, pFormatInfo, pPropertyCount, pProperties);
2541
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002542 if(pProperties && pProperties->pNext)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002543 {
Ben Clayton00424c12019-03-17 17:29:30 +00002544 UNIMPLEMENTED("pProperties->pNext");
Alexis Hetu767b41b2018-09-26 11:25:46 -04002545 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04002546
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002547 vkGetPhysicalDeviceSparseImageFormatProperties(physicalDevice, pFormatInfo->format, pFormatInfo->type,
2548 pFormatInfo->samples, pFormatInfo->usage, pFormatInfo->tiling,
2549 pPropertyCount, pProperties ? &(pProperties->properties) : nullptr);
Alexis Hetud73b8712018-09-21 15:14:43 -04002550}
2551
2552VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags)
2553{
Ben Claytonfb280672019-04-25 11:16:15 +01002554 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolTrimFlags flags = %d)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002555 device, static_cast<void*>(commandPool), flags);
Nicolas Capensde16f322019-02-12 00:32:31 -05002556
Alexis Hetucd610c92019-02-01 16:47:51 -05002557 vk::Cast(commandPool)->trim(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002558}
2559
2560VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue)
2561{
Ben Claytonfb280672019-04-25 11:16:15 +01002562 TRACE("(VkDevice device = %p, const VkDeviceQueueInfo2* pQueueInfo = %p, VkQueue* pQueue = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002563 device, pQueueInfo, pQueue);
2564
2565 if(pQueueInfo->pNext)
2566 {
Ben Clayton00424c12019-03-17 17:29:30 +00002567 UNIMPLEMENTED("pQueueInfo->pNext");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002568 }
2569
Nicolas Capens50b10592018-10-26 10:34:20 -04002570 // The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002571 // According to the Vulkan spec, 4.3.1. Queue Family Properties:
2572 // "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
2573 // protected-capable queue. If the protected memory feature is not enabled,
2574 // the VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT bit of flags must not be set."
2575 if(pQueueInfo->flags)
2576 {
2577 *pQueue = VK_NULL_HANDLE;
2578 }
2579 else
2580 {
2581 vkGetDeviceQueue(device, pQueueInfo->queueFamilyIndex, pQueueInfo->queueIndex, pQueue);
2582 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002583}
2584
2585VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion)
2586{
Nicolas Capens6b63c802019-05-16 11:10:34 -04002587 TRACE("(VkDevice device = %p, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSamplerYcbcrConversion* pYcbcrConversion = %p)",
2588 device, pCreateInfo, pAllocator, pYcbcrConversion);
2589
2590 if(pCreateInfo->pNext)
2591 {
2592 UNIMPLEMENTED("pCreateInfo->pNext");
2593 }
2594
2595 return vk::SamplerYcbcrConversion::Create(pAllocator, pCreateInfo, pYcbcrConversion);
Alexis Hetud73b8712018-09-21 15:14:43 -04002596}
2597
2598VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator)
2599{
Nicolas Capens6b63c802019-05-16 11:10:34 -04002600 TRACE("(VkDevice device = %p, VkSamplerYcbcrConversion ycbcrConversion = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002601 device, static_cast<void*>(ycbcrConversion), pAllocator);
Nicolas Capens6b63c802019-05-16 11:10:34 -04002602
2603 vk::destroy(ycbcrConversion, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002604}
2605
2606VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate)
2607{
Ben Claytonfb280672019-04-25 11:16:15 +01002608 TRACE("(VkDevice device = %p, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = %p)",
Alexis Hetuf705cec2019-01-29 14:09:36 -05002609 device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
2610
2611 if(pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET))
2612 {
Ben Clayton00424c12019-03-17 17:29:30 +00002613 UNIMPLEMENTED("pCreateInfo->pNext || pCreateInfo->flags || (pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)");
Alexis Hetuf705cec2019-01-29 14:09:36 -05002614 }
2615
2616 return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, pDescriptorUpdateTemplate);
Alexis Hetud73b8712018-09-21 15:14:43 -04002617}
2618
2619VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator)
2620{
Ben Claytonfb280672019-04-25 11:16:15 +01002621 TRACE("(VkDevice device = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002622 device, static_cast<void*>(descriptorUpdateTemplate), pAllocator);
Alexis Hetuf705cec2019-01-29 14:09:36 -05002623
2624 vk::destroy(descriptorUpdateTemplate, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002625}
2626
2627VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData)
2628{
Ben Claytonfb280672019-04-25 11:16:15 +01002629 TRACE("(VkDevice device = %p, VkDescriptorSet descriptorSet = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const void* pData = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002630 device, static_cast<void*>(descriptorSet), static_cast<void*>(descriptorUpdateTemplate), pData);
Alexis Hetuf705cec2019-01-29 14:09:36 -05002631
Alexis Hetu6448bd62019-06-11 15:58:59 -04002632 vk::Cast(descriptorUpdateTemplate)->updateDescriptorSet(vk::Cast(device), descriptorSet, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04002633}
2634
2635VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties)
2636{
Ben Claytonfb280672019-04-25 11:16:15 +01002637 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo = %p, VkExternalBufferProperties* pExternalBufferProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002638 physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
2639
Alexis Hetu00835732019-04-10 16:36:31 -04002640 vk::Cast(physicalDevice)->getProperties(pExternalBufferInfo, pExternalBufferProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002641}
2642
2643VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties)
2644{
Ben Claytonfb280672019-04-25 11:16:15 +01002645 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo = %p, VkExternalFenceProperties* pExternalFenceProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002646 physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
2647
Alexis Hetu00835732019-04-10 16:36:31 -04002648 vk::Cast(physicalDevice)->getProperties(pExternalFenceInfo, pExternalFenceProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002649}
2650
2651VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties)
2652{
Ben Claytonfb280672019-04-25 11:16:15 +01002653 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo = %p, VkExternalSemaphoreProperties* pExternalSemaphoreProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002654 physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
2655
Alexis Hetu00835732019-04-10 16:36:31 -04002656 vk::Cast(physicalDevice)->getProperties(pExternalSemaphoreInfo, pExternalSemaphoreProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002657}
2658
2659VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport)
2660{
Ben Claytonfb280672019-04-25 11:16:15 +01002661 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, VkDescriptorSetLayoutSupport* pSupport = %p)",
Alexis Hetu1424ef62019-04-05 18:03:53 -04002662 device, pCreateInfo, pSupport);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002663
2664 vk::Cast(device)->getDescriptorSetLayoutSupport(pCreateInfo, pSupport);
Alexis Hetud73b8712018-09-21 15:14:43 -04002665}
2666
Ben Claytona9af8832019-08-14 13:09:43 +01002667#ifdef VK_USE_PLATFORM_XCB_KHR
2668VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2669{
2670 TRACE("(VkInstance instance = %p, VkXcbSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
2671 instance, pCreateInfo, pAllocator, pSurface);
2672
2673 return vk::XcbSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
2674}
2675
2676VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id)
2677{
2678 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, xcb_connection_t* connection = %p, xcb_visualid_t visual_id = %d)",
2679 physicalDevice, int(queueFamilyIndex), connection, int(visual_id));
2680
2681 return VK_TRUE;
2682}
2683#endif
2684
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002685#ifdef VK_USE_PLATFORM_XLIB_KHR
2686VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2687{
Ben Claytonfb280672019-04-25 11:16:15 +01002688 TRACE("(VkInstance instance = %p, VkXlibSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002689 instance, pCreateInfo, pAllocator, pSurface);
2690
2691 return vk::XlibSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
2692}
Hernan Liatisbd18d582019-05-29 15:38:58 -07002693
2694VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID)
2695{
2696 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, Display* dpy = %p, VisualID visualID = %lu)",
2697 physicalDevice, int(queueFamilyIndex), dpy, visualID);
2698
2699 return VK_TRUE;
2700}
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002701#endif
2702
Alexis Hetu0662a4a2019-07-08 15:06:40 -04002703#ifdef VK_USE_PLATFORM_MACOS_MVK
2704VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2705{
2706 TRACE("(VkInstance instance = %p, VkMacOSSurfaceCreateInfoMVK* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
2707 instance, pCreateInfo, pAllocator, pSurface);
2708
2709 return vk::MacOSSurfaceMVK::Create(pAllocator, pCreateInfo, pSurface);
2710}
2711#endif
2712
Nicolas Capensd3545372019-08-09 13:59:18 -04002713#ifdef VK_USE_PLATFORM_WIN32_KHR
2714VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface)
2715{
2716 TRACE("(VkInstance instance = %p, VkWin32SurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
2717 instance, pCreateInfo, pAllocator, pSurface);
2718
2719 return vk::Win32SurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
2720}
2721#endif
2722
Chris Forbes1d667d62019-04-05 08:25:18 -07002723#ifndef __ANDROID__
2724VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator)
2725{
Ben Claytonfb280672019-04-25 11:16:15 +01002726 TRACE("(VkInstance instance = %p, VkSurfaceKHR surface = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002727 instance, static_cast<void*>(surface), pAllocator);
Chris Forbes1d667d62019-04-05 08:25:18 -07002728
2729 vk::destroy(surface, pAllocator);
2730}
2731
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002732VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported)
2733{
Ben Claytonfb280672019-04-25 11:16:15 +01002734 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, VkSurface surface = %p, VKBool32* pSupported = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002735 physicalDevice, int(queueFamilyIndex), static_cast<void*>(surface), pSupported);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002736
2737 *pSupported = VK_TRUE;
2738 return VK_SUCCESS;
2739}
2740
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002741VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities)
2742{
Ben Claytonfb280672019-04-25 11:16:15 +01002743 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002744 physicalDevice, static_cast<void*>(surface), pSurfaceCapabilities);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002745
2746 vk::Cast(surface)->getSurfaceCapabilities(pSurfaceCapabilities);
2747 return VK_SUCCESS;
2748}
2749
2750VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats)
2751{
Ben Claytonfb280672019-04-25 11:16:15 +01002752 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p. uint32_t* pSurfaceFormatCount = %p, VkSurfaceFormatKHR* pSurfaceFormats = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002753 physicalDevice, static_cast<void*>(surface), pSurfaceFormatCount, pSurfaceFormats);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002754
2755 if(!pSurfaceFormats)
2756 {
2757 *pSurfaceFormatCount = vk::Cast(surface)->getSurfaceFormatsCount();
2758 return VK_SUCCESS;
2759 }
2760
2761 return vk::Cast(surface)->getSurfaceFormats(pSurfaceFormatCount, pSurfaceFormats);
2762}
2763
2764VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes)
2765{
Ben Claytonfb280672019-04-25 11:16:15 +01002766 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p uint32_t* pPresentModeCount = %p, VkPresentModeKHR* pPresentModes = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002767 physicalDevice, static_cast<void*>(surface), pPresentModeCount, pPresentModes);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08002768
2769 if(!pPresentModes)
2770 {
2771 *pPresentModeCount = vk::Cast(surface)->getPresentModeCount();
2772 return VK_SUCCESS;
2773 }
2774
2775 return vk::Cast(surface)->getPresentModes(pPresentModeCount, pPresentModes);
2776}
2777
Hernan Liatisc7943e92019-02-25 19:29:54 -08002778VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain)
2779{
Ben Claytonfb280672019-04-25 11:16:15 +01002780 TRACE("(VkDevice device = %p, const VkSwapchainCreateInfoKHR* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSwapchainKHR* pSwapchain = %p)",
Hernan Liatisc7943e92019-02-25 19:29:54 -08002781 device, pCreateInfo, pAllocator, pSwapchain);
2782
Hernan Liatis43be7162019-03-08 17:57:41 -08002783 if(pCreateInfo->oldSwapchain)
2784 {
2785 vk::Cast(pCreateInfo->oldSwapchain)->retire();
2786 }
2787
Alexis Hetu63ae9242019-06-06 13:52:15 -04002788 if(vk::Cast(pCreateInfo->surface)->hasAssociatedSwapchain())
Hernan Liatis43be7162019-03-08 17:57:41 -08002789 {
2790 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
2791 }
2792
Hernan Liatisc7943e92019-02-25 19:29:54 -08002793 VkResult status = vk::SwapchainKHR::Create(pAllocator, pCreateInfo, pSwapchain);
2794
2795 if(status != VK_SUCCESS)
2796 {
2797 return status;
2798 }
2799
Alexis Hetu7d96f512019-06-13 18:23:56 -04002800 auto swapchain = vk::Cast(*pSwapchain);
2801 status = swapchain->createImages(device, pCreateInfo);
Hernan Liatisc7943e92019-02-25 19:29:54 -08002802
2803 if(status != VK_SUCCESS)
2804 {
2805 vk::destroy(*pSwapchain, pAllocator);
2806 return status;
2807 }
2808
Alexis Hetu7d96f512019-06-13 18:23:56 -04002809 vk::Cast(pCreateInfo->surface)->associateSwapchain(swapchain);
Hernan Liatis43be7162019-03-08 17:57:41 -08002810
Hernan Liatisc7943e92019-02-25 19:29:54 -08002811 return VK_SUCCESS;
2812}
2813
2814VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator)
2815{
Ben Claytonfb280672019-04-25 11:16:15 +01002816 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, const VkAllocationCallbacks* pAllocator = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002817 device, static_cast<void*>(swapchain), pAllocator);
Hernan Liatisc7943e92019-02-25 19:29:54 -08002818
2819 vk::destroy(swapchain, pAllocator);
2820}
2821
Hernan Liatisd00375a2019-02-26 11:19:27 -08002822VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages)
2823{
Ben Claytonfb280672019-04-25 11:16:15 +01002824 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint32_t* pSwapchainImageCount = %p, VkImage* pSwapchainImages = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002825 device, static_cast<void*>(swapchain), pSwapchainImageCount, pSwapchainImages);
Hernan Liatisd00375a2019-02-26 11:19:27 -08002826
2827 if(!pSwapchainImages)
2828 {
2829 *pSwapchainImageCount = vk::Cast(swapchain)->getImageCount();
2830 return VK_SUCCESS;
2831 }
2832
2833 return vk::Cast(swapchain)->getImages(pSwapchainImageCount, pSwapchainImages);
2834}
2835
Hernan Liatis6b12a502019-03-01 15:06:13 -08002836VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex)
2837{
Ben Claytonfb280672019-04-25 11:16:15 +01002838 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint64_t timeout = %d, VkSemaphore semaphore = %p, VkFence fence = %p, uint32_t* pImageIndex = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002839 device, static_cast<void*>(swapchain), int(timeout), static_cast<void*>(semaphore), static_cast<void*>(fence), pImageIndex);
Hernan Liatis6b12a502019-03-01 15:06:13 -08002840
Alexis Hetu7d96f512019-06-13 18:23:56 -04002841 return vk::Cast(swapchain)->getNextImage(timeout, vk::Cast(semaphore), vk::Cast(fence), pImageIndex);
Hernan Liatis6b12a502019-03-01 15:06:13 -08002842}
2843
2844VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* pPresentInfo)
2845{
Ben Claytonfb280672019-04-25 11:16:15 +01002846 TRACE("(VkQueue queue = %p, const VkPresentInfoKHR* pPresentInfo = %p)",
Hernan Liatis6b12a502019-03-01 15:06:13 -08002847 queue, pPresentInfo);
2848
2849 vk::Cast(queue)->present(pPresentInfo);
2850
2851 return VK_SUCCESS;
2852}
Chris Forbesf993de32019-04-15 09:45:34 -07002853
2854VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR *pDeviceGroupPresentCapabilities)
2855{
Ben Claytonfb280672019-04-25 11:16:15 +01002856 TRACE("(VkDevice device = %p, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities = %p)",
Chris Forbesf993de32019-04-15 09:45:34 -07002857 device, pDeviceGroupPresentCapabilities);
2858
2859 for (int i = 0; i < VK_MAX_DEVICE_GROUP_SIZE; i++)
2860 {
2861 // The only real physical device in the presentation group is device 0,
2862 // and it can present to itself.
2863 pDeviceGroupPresentCapabilities->presentMask[i] = (i == 0) ? 1 : 0;
2864 }
2865
2866 pDeviceGroupPresentCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
2867
2868 return VK_SUCCESS;
2869}
2870
2871VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *pModes)
2872{
Ben Claytonfb280672019-04-25 11:16:15 +01002873 TRACE("(VkDevice device = %p, VkSurfaceKHR surface = %p, VkDeviceGroupPresentModeFlagsKHR *pModes = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002874 device, static_cast<void*>(surface), pModes);
Chris Forbesf993de32019-04-15 09:45:34 -07002875
2876 *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
2877 return VK_SUCCESS;
2878}
2879
Chris Forbesb52384b2019-08-28 12:01:29 -07002880VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects)
2881{
2882 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, uint32_t* pRectCount = %p, VkRect2D* pRects = %p)",
2883 physicalDevice, static_cast<void*>(surface), pRectCount, pRects);
2884
2885 return vk::Cast(surface)->getPresentRectangles(pRectCount, pRects);
2886}
2887
2888
Chris Forbes1d667d62019-04-05 08:25:18 -07002889#endif // ! __ANDROID__
Hernan Liatis6b12a502019-03-01 15:06:13 -08002890
Hernan Liatis8a91a352019-04-29 17:14:06 -07002891#ifdef __ANDROID__
2892
2893VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainUsage, uint64_t* grallocConsumerUsage, uint64_t* grallocProducerUsage)
2894{
Hernan Liatis628604e2019-05-07 15:30:18 -07002895 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, VkSwapchainImageUsageFlagsANDROID swapchainUsage = %d, uint64_t* grallocConsumerUsage = %p, uin64_t* grallocProducerUsage = %p)",
Hernan Liatis8a91a352019-04-29 17:14:06 -07002896 device, format, imageUsage, swapchainUsage, grallocConsumerUsage, grallocProducerUsage);
2897
Hernan Liatis788ea9f2019-05-01 11:10:36 -07002898 *grallocConsumerUsage = 0;
2899 *grallocProducerUsage = GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
2900
Hernan Liatis8a91a352019-04-29 17:14:06 -07002901 return VK_SUCCESS;
2902}
2903
2904VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int* grallocUsage)
2905{
Hernan Liatis628604e2019-05-07 15:30:18 -07002906 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, int* grallocUsage = %p)",
Hernan Liatis8a91a352019-04-29 17:14:06 -07002907 device, format, imageUsage, grallocUsage);
2908
Hernan Liatis3429bb52019-05-29 18:42:11 -07002909 *grallocUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
2910
Hernan Liatis8a91a352019-04-29 17:14:06 -07002911 return VK_SUCCESS;
2912}
2913
2914VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence)
2915{
Hernan Liatis628604e2019-05-07 15:30:18 -07002916 TRACE("(VkDevice device = %p, VkImage image = %p, int nativeFenceFd = %d, VkSemaphore semaphore = %p, VkFence fence = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002917 device, static_cast<void*>(image), nativeFenceFd, static_cast<void*>(semaphore), static_cast<void*>(fence));
Hernan Liatis8a91a352019-04-29 17:14:06 -07002918
Hernan Liatisd5f462c2019-05-24 15:45:05 -07002919 if(nativeFenceFd >= 0)
2920 {
2921 sync_wait(nativeFenceFd, -1);
2922 close(nativeFenceFd);
2923 }
2924
2925 if(fence != VK_NULL_HANDLE)
2926 {
2927 vk::Cast(fence)->complete();
2928 }
2929
2930 if(semaphore != VK_NULL_HANDLE)
2931 {
2932 vk::Cast(semaphore)->signal();
2933 }
2934
Hernan Liatis8a91a352019-04-29 17:14:06 -07002935 return VK_SUCCESS;
2936}
2937
2938VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd)
2939{
Hernan Liatis628604e2019-05-07 15:30:18 -07002940 TRACE("(VkQueue queue = %p, uint32_t waitSemaphoreCount = %d, const VkSemaphore* pWaitSemaphores = %p, VkImage image = %p, int* pNativeFenceFd = %p)",
Alexis Hetu2d77aea2019-06-17 13:43:50 -04002941 queue, waitSemaphoreCount, pWaitSemaphores, static_cast<void*>(image), pNativeFenceFd);
Hernan Liatis8a91a352019-04-29 17:14:06 -07002942
Hernan Liatisd61595f2019-05-10 16:30:07 -07002943 // This is a hack to deal with screen tearing for now.
2944 // Need to correctly implement threading using VkSemaphore
2945 // to get rid of it. b/132458423
2946 vkQueueWaitIdle(queue);
2947
Hernan Liatis628604e2019-05-07 15:30:18 -07002948 GrallocModule* grallocMod = GrallocModule::getInstance();
2949 void* nativeBuffer;
2950
2951 auto it = androidSwapchainMap.find(image);
2952
2953 if (it == androidSwapchainMap.end())
2954 ABORT("ANDROID: Swapchain image not found");
2955
2956 BackingMemory backmem = it->second;
2957
Chris Forbes4963b952019-05-29 14:37:57 -07002958 VkExtent3D extent = vk::Cast(image)->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
Hernan Liatis628604e2019-05-07 15:30:18 -07002959 grallocMod->lock(backmem.nativeHandle, GRALLOC_USAGE_SW_WRITE_OFTEN, 0, 0, extent.width, extent.height, &nativeBuffer);
2960
Hernan Liatis3c735072019-06-10 15:07:18 -07002961 char* buffer = static_cast<char*>(backmem.imageMemory->getOffsetPointer(0));
Hernan Liatis628604e2019-05-07 15:30:18 -07002962 int imageRowBytes = vk::Cast(image)->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
2963 int colorBytes = vk::Cast(image)->getFormat().bytes();
2964
2965 for(int i = 0; i < extent.height; i++)
2966 {
2967 memcpy((void*)((char*)nativeBuffer + (i * backmem.stride * colorBytes)), buffer + (i * imageRowBytes), imageRowBytes);
2968 }
2969
Hernan Liatis8a91a352019-04-29 17:14:06 -07002970 return VK_SUCCESS;
2971}
2972#endif // __ANDROID__
2973
Chris Forbes3d27f2e2018-09-26 09:24:39 -07002974}