blob: 706210388f98d63cf6c65e065964ab8e0e55ad1b [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"
Antonio Maiorano42fd1592020-04-27 11:30:40 -040019#include "VkConfig.hpp"
Alexis Hetuc8176632019-01-22 17:01:28 -050020#include "VkDescriptorPool.hpp"
21#include "VkDescriptorSetLayout.hpp"
Alexis Hetuf705cec2019-01-29 14:09:36 -050022#include "VkDescriptorUpdateTemplate.hpp"
Antonio Maiorano42fd1592020-04-27 11:30:40 -040023#include "VkDestroy.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040024#include "VkDevice.hpp"
Alexis Hetu38ff8302018-10-18 15:08:13 -040025#include "VkDeviceMemory.hpp"
Alexis Hetu1f23d8c2018-10-16 14:40:19 -040026#include "VkEvent.hpp"
27#include "VkFence.hpp"
Alexis Hetu8f631c82018-11-15 15:11:36 -050028#include "VkFramebuffer.hpp"
Antonio Maiorano42fd1592020-04-27 11:30:40 -040029#include "VkGetProcAddress.hpp"
Alexis Hetuf62f3752018-11-15 14:51:15 -050030#include "VkImage.hpp"
Alexis Hetu9fbaf692018-11-19 11:30:43 -050031#include "VkImageView.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040032#include "VkInstance.hpp"
33#include "VkPhysicalDevice.hpp"
Alexis Hetu000df8b2018-10-24 15:22:41 -040034#include "VkPipeline.hpp"
Alexis Hetu18a84252018-11-19 11:30:43 -050035#include "VkPipelineCache.hpp"
Alexis Hetu000df8b2018-10-24 15:22:41 -040036#include "VkPipelineLayout.hpp"
Alexis Hetu86f8bdb2019-01-22 12:07:24 -050037#include "VkQueryPool.hpp"
Alexis Hetu767b41b2018-09-26 11:25:46 -040038#include "VkQueue.hpp"
Ben Clayton2ed93ab2019-12-17 20:38:03 +000039#include "VkRenderPass.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"
Sean Rissere823bb02019-09-06 13:06:26 -040043#include "VkStringify.hpp"
Nicolas Capens50b10592018-10-26 10:34:20 -040044
Ben Clayton25e06e02020-02-07 11:19:08 +000045#include "System/Debug.hpp"
46
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -040047#if defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_MACOS_MVK)
Antonio Maiorano42fd1592020-04-27 11:30:40 -040048# include "WSI/MetalSurface.hpp"
Alexis Hetu0662a4a2019-07-08 15:06:40 -040049#endif
50
Ben Claytona9af8832019-08-14 13:09:43 +010051#ifdef VK_USE_PLATFORM_XCB_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +000052# include "WSI/XcbSurfaceKHR.hpp"
Ben Claytona9af8832019-08-14 13:09:43 +010053#endif
54
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080055#ifdef VK_USE_PLATFORM_XLIB_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +000056# include "WSI/XlibSurfaceKHR.hpp"
Hernan Liatisc6eb41b2019-02-22 11:12:59 -080057#endif
58
Nicolas Capensd3545372019-08-09 13:59:18 -040059#ifdef VK_USE_PLATFORM_WIN32_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +000060# include "WSI/Win32SurfaceKHR.hpp"
Nicolas Capensd3545372019-08-09 13:59:18 -040061#endif
62
Hernan Liatis8a91a352019-04-29 17:14:06 -070063#ifdef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +000064# include "commit.h"
65# include "System/GrallocAndroid.hpp"
66# include <android/log.h>
Jason Macnak1de497c2020-04-08 11:31:50 -070067# include <hardware/gralloc1.h>
Ben Clayton2ed93ab2019-12-17 20:38:03 +000068# include <sync/sync.h>
Hernan Liatis8a91a352019-04-29 17:14:06 -070069#endif
70
Hernan Liatisc7943e92019-02-25 19:29:54 -080071#include "WSI/VkSwapchainKHR.hpp"
72
Ben Clayton056d6922019-07-04 12:41:13 +010073#include "Reactor/Nucleus.hpp"
74
Ben Clayton377573c2020-04-03 20:36:40 +010075#include "marl/mutex.h"
Alexis Hétu50038d62019-09-24 15:37:24 +000076#include "marl/scheduler.h"
77#include "marl/thread.h"
Ben Clayton377573c2020-04-03 20:36:40 +010078#include "marl/tsa.h"
Alexis Hétu50038d62019-09-24 15:37:24 +000079
Ben Claytond6c61362019-08-14 18:16:01 +010080#include "System/CPUID.hpp"
81
Alexis Hetu000df8b2018-10-24 15:22:41 -040082#include <algorithm>
Chris Forbes3d27f2e2018-09-26 09:24:39 -070083#include <cstring>
Hernan Liatis628604e2019-05-07 15:30:18 -070084#include <map>
Ben Clayton2ed93ab2019-12-17 20:38:03 +000085#include <string>
Alexis Hetud73b8712018-09-21 15:14:43 -040086
Ben Clayton2ed93ab2019-12-17 20:38:03 +000087namespace {
Alexis Hetud6fae382019-04-05 13:19:46 -040088
Tim Van Patten9da287f2019-11-07 10:27:18 -070089// Enable commit_id.py and #include commit.h for other platforms.
90#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT)
91void logBuildVersionInformation()
92{
93 // TODO(b/144093703): Don't call __android_log_print() directly
94 __android_log_print(ANDROID_LOG_INFO, "SwiftShader", "SwiftShader Version: %s", SWIFTSHADER_VERSION_STRING);
95}
96#endif // __ANDROID__ && ENABLE_BUILD_VERSION_OUTPUT
97
Ben Clayton2ed93ab2019-12-17 20:38:03 +000098bool HasExtensionProperty(const char *extensionName, const VkExtensionProperties *extensionProperties, uint32_t extensionPropertiesCount)
Alexis Hetud6fae382019-04-05 13:19:46 -040099{
100 for(uint32_t j = 0; j < extensionPropertiesCount; ++j)
101 {
102 if(strcmp(extensionName, extensionProperties[j].extensionName) == 0)
103 {
104 return true;
105 }
106 }
107
108 return false;
109}
110
Ben Clayton056d6922019-07-04 12:41:13 +0100111// setReactorDefaultConfig() sets the default configuration for Vulkan's use of
112// Reactor.
113void setReactorDefaultConfig()
114{
115 auto cfg = rr::Config::Edit()
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000116 .set(rr::Optimization::Level::Default)
117 .clearOptimizationPasses()
118 .add(rr::Optimization::Pass::ScalarReplAggregates)
119 .add(rr::Optimization::Pass::SCCP)
120 .add(rr::Optimization::Pass::CFGSimplification)
121 .add(rr::Optimization::Pass::EarlyCSEPass)
122 .add(rr::Optimization::Pass::CFGSimplification)
123 .add(rr::Optimization::Pass::InstructionCombining);
Ben Clayton056d6922019-07-04 12:41:13 +0100124
125 rr::Nucleus::adjustDefaultConfig(cfg);
126}
127
Ben Claytond6c61362019-08-14 18:16:01 +0100128void setCPUDefaults()
129{
130 sw::CPUID::setEnableSSE4_1(true);
131 sw::CPUID::setEnableSSSE3(true);
132 sw::CPUID::setEnableSSE3(true);
133 sw::CPUID::setEnableSSE2(true);
134 sw::CPUID::setEnableSSE(true);
135}
136
Ben Clayton6fff5122019-10-03 16:41:21 +0100137std::shared_ptr<marl::Scheduler> getOrCreateScheduler()
Alexis Hétu50038d62019-09-24 15:37:24 +0000138{
Ben Clayton377573c2020-04-03 20:36:40 +0100139 struct Scheduler
Ben Clayton6fff5122019-10-03 16:41:21 +0100140 {
Ben Clayton377573c2020-04-03 20:36:40 +0100141 marl::mutex mutex;
142 std::weak_ptr<marl::Scheduler> weakptr GUARDED_BY(mutex);
143 };
144
145 static Scheduler scheduler;
146
147 marl::lock lock(scheduler.mutex);
148 auto sptr = scheduler.weakptr.lock();
149 if(!sptr)
150 {
Ben Claytone817aaa2020-06-02 19:58:22 +0100151 marl::Scheduler::Config cfg;
152 cfg.setWorkerThreadCount(std::min<size_t>(marl::Thread::numLogicalCPUs(), 16));
153 cfg.setWorkerThreadInitializer([](int) {
Ben Clayton6fff5122019-10-03 16:41:21 +0100154 sw::CPUID::setFlushToZero(true);
155 sw::CPUID::setDenormalsAreZero(true);
156 });
Ben Claytone817aaa2020-06-02 19:58:22 +0100157 sptr = std::make_shared<marl::Scheduler>(cfg);
Ben Clayton377573c2020-04-03 20:36:40 +0100158 scheduler.weakptr = sptr;
Ben Clayton6fff5122019-10-03 16:41:21 +0100159 }
Ben Clayton377573c2020-04-03 20:36:40 +0100160 return sptr;
Alexis Hétu50038d62019-09-24 15:37:24 +0000161}
162
Ben Clayton056d6922019-07-04 12:41:13 +0100163// initializeLibrary() is called by vkCreateInstance() to perform one-off global
164// initialization of the swiftshader driver.
165void initializeLibrary()
166{
167 static bool doOnce = [] {
Tim Van Patten9da287f2019-11-07 10:27:18 -0700168#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT)
169 logBuildVersionInformation();
170#endif // __ANDROID__ && ENABLE_BUILD_VERSION_OUTPUT
Ben Clayton056d6922019-07-04 12:41:13 +0100171 setReactorDefaultConfig();
Ben Claytond6c61362019-08-14 18:16:01 +0100172 setCPUDefaults();
Ben Clayton056d6922019-07-04 12:41:13 +0100173 return true;
174 }();
175 (void)doOnce;
176}
177
Alexis Hetu9f8337e2020-02-07 11:07:43 -0500178template<class T>
179void ValidateRenderPassPNextChain(VkDevice device, const T *pCreateInfo)
180{
181 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
182
183 while(extensionCreateInfo)
184 {
185 switch(extensionCreateInfo->sType)
186 {
187 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO:
188 {
189 const VkRenderPassInputAttachmentAspectCreateInfo *inputAttachmentAspectCreateInfo = reinterpret_cast<const VkRenderPassInputAttachmentAspectCreateInfo *>(extensionCreateInfo);
190
191 for(uint32_t i = 0; i < inputAttachmentAspectCreateInfo->aspectReferenceCount; i++)
192 {
193 const auto &aspectReference = inputAttachmentAspectCreateInfo->pAspectReferences[i];
194 ASSERT(aspectReference.subpass < pCreateInfo->subpassCount);
195 const auto &subpassDescription = pCreateInfo->pSubpasses[aspectReference.subpass];
196 ASSERT(aspectReference.inputAttachmentIndex < subpassDescription.inputAttachmentCount);
197 const auto &attachmentReference = subpassDescription.pInputAttachments[aspectReference.inputAttachmentIndex];
198 if(attachmentReference.attachment != VK_ATTACHMENT_UNUSED)
199 {
200 // If the pNext chain includes an instance of VkRenderPassInputAttachmentAspectCreateInfo, for any
201 // element of the pInputAttachments member of any element of pSubpasses where the attachment member
202 // is not VK_ATTACHMENT_UNUSED, the aspectMask member of the corresponding element of
203 // VkRenderPassInputAttachmentAspectCreateInfo::pAspectReferences must only include aspects that are
204 // present in images of the format specified by the element of pAttachments at attachment
205 vk::Format format(pCreateInfo->pAttachments[attachmentReference.attachment].format);
206 bool isDepth = format.isDepth();
207 bool isStencil = format.isStencil();
208 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) || (!isDepth && !isStencil));
209 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || isDepth);
210 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) || isStencil);
211 }
212 }
213 }
214 break;
215 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
216 {
217 const VkRenderPassMultiviewCreateInfo *multiviewCreateInfo = reinterpret_cast<const VkRenderPassMultiviewCreateInfo *>(extensionCreateInfo);
218 ASSERT((multiviewCreateInfo->subpassCount == 0) || (multiviewCreateInfo->subpassCount == pCreateInfo->subpassCount));
219 ASSERT((multiviewCreateInfo->dependencyCount == 0) || (multiviewCreateInfo->dependencyCount == pCreateInfo->dependencyCount));
220
221 bool zeroMask = (multiviewCreateInfo->pViewMasks[0] == 0);
222 for(uint32_t i = 1; i < multiviewCreateInfo->subpassCount; i++)
223 {
224 ASSERT((multiviewCreateInfo->pViewMasks[i] == 0) == zeroMask);
225 }
226
227 if(zeroMask)
228 {
229 ASSERT(multiviewCreateInfo->correlationMaskCount == 0);
230 }
231
232 for(uint32_t i = 0; i < multiviewCreateInfo->dependencyCount; i++)
233 {
234 const auto &dependency = pCreateInfo->pDependencies[i];
235 if(multiviewCreateInfo->pViewOffsets[i] != 0)
236 {
237 ASSERT(dependency.srcSubpass != dependency.dstSubpass);
238 ASSERT(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT);
239 }
240 if(zeroMask)
241 {
242 ASSERT(!(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT));
243 }
244 }
245
246 // If the pNext chain includes an instance of VkRenderPassMultiviewCreateInfo,
247 // each element of its pViewMask member must not include a bit at a position
248 // greater than the value of VkPhysicalDeviceLimits::maxFramebufferLayers
249 // pViewMask is a 32 bit value. If maxFramebufferLayers > 32, it's impossible
250 // for pViewMask to contain a bit at an illegal position
251 // Note: Verify pViewMask values instead if we hit this assert
252 ASSERT(vk::Cast(device)->getPhysicalDevice()->getProperties().limits.maxFramebufferLayers >= 32);
253 }
254 break;
255 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -0500256 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Alexis Hetu9f8337e2020-02-07 11:07:43 -0500257 break;
258 }
259
260 extensionCreateInfo = extensionCreateInfo->pNext;
261 }
262}
263
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000264} // namespace
Alexis Hetud6fae382019-04-05 13:19:46 -0400265
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000266extern "C" {
267VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
Alexis Hetud73b8712018-09-21 15:14:43 -0400268{
Ben Claytonfb280672019-04-25 11:16:15 +0100269 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500270
Alexis Hetu7d96f512019-06-13 18:23:56 -0400271 return vk::GetInstanceProcAddr(vk::Cast(instance), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400272}
273
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000274VK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
Hernan Liatisb2841fe2019-02-21 12:57:52 -0800275{
276 *pSupportedVersion = 3;
277 return VK_SUCCESS;
278}
279
David 'Digit' Turner6e445042020-04-17 16:27:56 +0200280#if VK_USE_PLATFORM_FUCHSIA
281
282// This symbol must be exported by a Fuchsia Vulkan ICD. The Vulkan loader will
283// call it, passing the address of a global function pointer that can later be
284// used at runtime to connect to Fuchsia FIDL services, as required by certain
285// extensions. See https://fxbug.dev/13095 for more details.
286//
287// NOTE: This entry point has not been upstreamed to Khronos yet, which reserves
288// all symbols starting with vk_icd. See https://fxbug.dev/13074 which
289// tracks upstreaming progress.
290VK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdInitializeConnectToServiceCallback(
291 PFN_vkConnectToService callback)
292{
293 TRACE("(callback = %p)", callback);
294 vk::icdFuchsiaServiceConnectCallback = callback;
295 return VK_SUCCESS;
296}
297
298#endif // VK_USE_PLATFORM_FUCHSIA
299
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000300static const VkExtensionProperties instanceExtensionProperties[] = {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800301 { VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION },
302 { VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION },
303 { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION },
304 { VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION },
305 { 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 -0700306#ifndef __ANDROID__
Hernan Liatis2bb08642019-02-08 14:08:21 -0800307 { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700308#endif
Ben Claytona9af8832019-08-14 13:09:43 +0100309#ifdef VK_USE_PLATFORM_XCB_KHR
310 { VK_KHR_XCB_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_SPEC_VERSION },
311#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800312#ifdef VK_USE_PLATFORM_XLIB_KHR
313 { VK_KHR_XLIB_SURFACE_EXTENSION_NAME, VK_KHR_XLIB_SURFACE_SPEC_VERSION },
314#endif
Alexis Hetu0662a4a2019-07-08 15:06:40 -0400315#ifdef VK_USE_PLATFORM_MACOS_MVK
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000316 { VK_MVK_MACOS_SURFACE_EXTENSION_NAME, VK_MVK_MACOS_SURFACE_SPEC_VERSION },
Alexis Hetu0662a4a2019-07-08 15:06:40 -0400317#endif
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -0400318#ifdef VK_USE_PLATFORM_METAL_EXT
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000319 { VK_EXT_METAL_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_SPEC_VERSION },
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -0400320#endif
Nicolas Capensd3545372019-08-09 13:59:18 -0400321#ifdef VK_USE_PLATFORM_WIN32_KHR
322 { VK_KHR_WIN32_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_SPEC_VERSION },
323#endif
Hernan Liatis2bb08642019-02-08 14:08:21 -0800324};
325
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000326static const VkExtensionProperties deviceExtensionProperties[] = {
Nicolas Capens657dd6c2018-11-16 17:41:37 -0500327 { VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION },
328 // Vulkan 1.1 promoted extensions
Hernan Liatis2bb08642019-02-08 14:08:21 -0800329 { VK_KHR_16BIT_STORAGE_EXTENSION_NAME, VK_KHR_16BIT_STORAGE_SPEC_VERSION },
330 { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION },
Alexis Hetu9f8337e2020-02-07 11:07:43 -0500331 { VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME, VK_KHR_CREATE_RENDERPASS_2_SPEC_VERSION },
Hernan Liatis2bb08642019-02-08 14:08:21 -0800332 { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION },
333 { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION },
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000334 { VK_KHR_DEVICE_GROUP_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_SPEC_VERSION },
Hernan Liatis2bb08642019-02-08 14:08:21 -0800335 { VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_SPEC_VERSION },
336 { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION },
337 { VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION },
338 { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION },
339 { VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_SPEC_VERSION },
340 { VK_KHR_MAINTENANCE2_EXTENSION_NAME, VK_KHR_MAINTENANCE2_SPEC_VERSION },
341 { VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_KHR_MAINTENANCE3_SPEC_VERSION },
342 { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION },
343 { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION },
344 { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION },
Alexis Hetuaabd0852020-02-10 14:27:29 -0500345 { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION },
Chris Forbes83cdd252019-08-26 09:29:27 -0700346 // Only 1.1 core version of this is supported. The extension has additional requirements
347 //{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION },
Hernan Liatis2bb08642019-02-08 14:08:21 -0800348 { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION },
Chris Forbes83cdd252019-08-26 09:29:27 -0700349 // Only 1.1 core version of this is supported. The extension has additional requirements
350 //{ VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION },
Chris Forbes6b4b8142019-09-26 13:33:11 -0700351 { VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME, VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION },
Alexis Hetu23f9c252019-10-17 13:58:25 -0400352 // The following extension is only used to add support for Bresenham lines
353 { VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME, VK_EXT_LINE_RASTERIZATION_SPEC_VERSION },
Alexis Hetu1ee36c92020-02-20 14:07:26 -0500354 // The following extension is used by ANGLE to emulate blitting the stencil buffer
355 { VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION },
Chris Forbes1d667d62019-04-05 08:25:18 -0700356#ifndef __ANDROID__
Chris Forbes92577e52019-09-02 17:43:38 +0100357 // We fully support the KHR_swapchain v70 additions, so just track the spec version.
Hernan Liatiscff8c002019-02-25 15:56:36 -0800358 { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION },
Hernan Liatis8a91a352019-04-29 17:14:06 -0700359#else
Chris Forbes92577e52019-09-02 17:43:38 +0100360 // We only support V7 of this extension. Missing functionality: in V8,
361 // it becomes possible to pass a VkNativeBufferANDROID structure to
362 // vkBindImageMemory2. Android's swapchain implementation does this in
363 // order to support passing VkBindImageMemorySwapchainInfoKHR
364 // (from KHR_swapchain v70) to vkBindImageMemory2.
365 { VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME, 7 },
Chris Forbes1d667d62019-04-05 08:25:18 -0700366#endif
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800367#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
368 { VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION },
369#endif
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +0100370#if SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +0200371 { VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION },
372#endif
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +0100373#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
David 'Digit' Turner359bc802019-08-14 17:46:07 +0200374 { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION },
375#endif
Jonah Ryan-Davisf9f999f2020-01-08 14:41:28 -0500376
377 { VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, VK_EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION },
378
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +0100379#if VK_USE_PLATFORM_FUCHSIA
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +0200380 { VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION },
David 'Digit' Turnere52e2db2019-09-09 17:58:46 +0200381 { VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME, VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION },
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +0200382#endif
Alexis Hetuf8f61032019-10-10 16:45:30 -0400383 { VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME, VK_EXT_PROVOKING_VERTEX_SPEC_VERSION },
Antonio Maioranod9ba4b72020-05-04 14:38:59 -0400384 { VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME, VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION },
Hernan Liatis2bb08642019-02-08 14:08:21 -0800385};
386
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000387VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
Alexis Hetud73b8712018-09-21 15:14:43 -0400388{
Ben Claytonfb280672019-04-25 11:16:15 +0100389 TRACE("(const VkInstanceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkInstance* pInstance = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000390 pCreateInfo, pAllocator, pInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -0400391
Ben Clayton056d6922019-07-04 12:41:13 +0100392 initializeLibrary();
393
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500394 if(pCreateInfo->flags != 0)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400395 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500396 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
397 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
398 }
399
400 if(pCreateInfo->enabledLayerCount != 0)
401 {
Nicolas Capensdd0e6002020-01-24 01:21:47 -0500402 UNIMPLEMENTED("b/148240133: pCreateInfo->enabledLayerCount != 0"); // FIXME(b/148240133)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400403 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400404
Alexis Hetud6fae382019-04-05 13:19:46 -0400405 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500406 for(uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400407 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500408 if(!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], instanceExtensionProperties, extensionPropertiesCount))
Hernan Liatis2bb08642019-02-08 14:08:21 -0800409 {
410 return VK_ERROR_EXTENSION_NOT_PRESENT;
411 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400412 }
413
414 if(pCreateInfo->pNext)
415 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000416 const VkBaseInStructure *createInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -0500417 switch(createInfo->sType)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400418 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000419 case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO:
420 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
421 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
422 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
423 // internal use by the loader, and do not have corresponding
424 // Vulkan structures in this Specification."
425 break;
426 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -0500427 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(createInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000428 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400429 }
430 }
431
432 *pInstance = VK_NULL_HANDLE;
433 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
434
435 VkResult result = vk::DispatchablePhysicalDevice::Create(pAllocator, pCreateInfo, &physicalDevice);
436 if(result != VK_SUCCESS)
437 {
438 return result;
439 }
440
Nicolas Capens0c736802019-05-27 12:53:31 -0400441 result = vk::DispatchableInstance::Create(pAllocator, pCreateInfo, pInstance, physicalDevice);
Alexis Hetu767b41b2018-09-26 11:25:46 -0400442 if(result != VK_SUCCESS)
443 {
444 vk::destroy(physicalDevice, pAllocator);
445 return result;
446 }
447
448 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -0400449}
450
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000451VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -0400452{
Ben Claytonfb280672019-04-25 11:16:15 +0100453 TRACE("(VkInstance instance = %p, const VkAllocationCallbacks* pAllocator = %p)", instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400454
Alexis Hetu767b41b2018-09-26 11:25:46 -0400455 vk::destroy(instance, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400456}
457
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000458VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
Alexis Hetud73b8712018-09-21 15:14:43 -0400459{
Ben Claytonfb280672019-04-25 11:16:15 +0100460 TRACE("(VkInstance instance = %p, uint32_t* pPhysicalDeviceCount = %p, VkPhysicalDevice* pPhysicalDevices = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000461 instance, pPhysicalDeviceCount, pPhysicalDevices);
Alexis Hetud73b8712018-09-21 15:14:43 -0400462
Chris Forbesdf84b942019-06-12 11:28:09 -0700463 return vk::Cast(instance)->getPhysicalDevices(pPhysicalDeviceCount, pPhysicalDevices);
Alexis Hetud73b8712018-09-21 15:14:43 -0400464}
465
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000466VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
Alexis Hetud73b8712018-09-21 15:14:43 -0400467{
Ben Claytonfb280672019-04-25 11:16:15 +0100468 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures* pFeatures = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000469 physicalDevice, pFeatures);
Alexis Hetud73b8712018-09-21 15:14:43 -0400470
Alexis Hetu767b41b2018-09-26 11:25:46 -0400471 *pFeatures = vk::Cast(physicalDevice)->getFeatures();
Alexis Hetud73b8712018-09-21 15:14:43 -0400472}
473
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000474VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400475{
Ben Claytonfb280672019-04-25 11:16:15 +0100476 TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties* pFormatProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000477 physicalDevice, (int)format, pFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400478
Alexis Hetu767b41b2018-09-26 11:25:46 -0400479 vk::Cast(physicalDevice)->getFormatProperties(format, pFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400480}
481
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000482VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400483{
Ben Claytonfb280672019-04-25 11:16:15 +0100484 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkImageType type = %d, VkImageTiling tiling = %d, VkImageUsageFlags usage = %d, VkImageCreateFlags flags = %d, VkImageFormatProperties* pImageFormatProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000485 physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400486
Nicolas Capens7e01e4e2019-05-18 08:19:07 -0400487 // "If the combination of parameters to vkGetPhysicalDeviceImageFormatProperties is not supported by the implementation
488 // for use in vkCreateImage, then all members of VkImageFormatProperties will be filled with zero."
489 memset(pImageFormatProperties, 0, sizeof(VkImageFormatProperties));
490
Chris Forbes57378332019-01-16 15:17:24 -0800491 VkFormatProperties properties;
492 vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
493
Chris Forbes1bc77312019-05-09 14:02:26 -0700494 VkFormatFeatureFlags features;
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500495 switch(tiling)
Chris Forbes57378332019-01-16 15:17:24 -0800496 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000497 case VK_IMAGE_TILING_LINEAR:
498 features = properties.linearTilingFeatures;
499 break;
Chris Forbes57378332019-01-16 15:17:24 -0800500
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000501 case VK_IMAGE_TILING_OPTIMAL:
502 features = properties.optimalTilingFeatures;
503 break;
Chris Forbes57378332019-01-16 15:17:24 -0800504
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000505 default:
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500506 UNSUPPORTED("VkImageTiling %d", int(tiling));
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000507 features = 0;
Chris Forbes1bc77312019-05-09 14:02:26 -0700508 }
509
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500510 if(features == 0)
Chris Forbes1bc77312019-05-09 14:02:26 -0700511 {
512 return VK_ERROR_FORMAT_NOT_SUPPORTED;
513 }
514
515 // Check for usage conflict with features
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500516 if((usage & VK_IMAGE_USAGE_SAMPLED_BIT) && !(features & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
Chris Forbes1bc77312019-05-09 14:02:26 -0700517 {
518 return VK_ERROR_FORMAT_NOT_SUPPORTED;
Chris Forbes57378332019-01-16 15:17:24 -0800519 }
520
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500521 if((usage & VK_IMAGE_USAGE_STORAGE_BIT) && !(features & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT))
Chris Forbes0559bc42019-05-11 10:47:11 -0700522 {
523 return VK_ERROR_FORMAT_NOT_SUPPORTED;
524 }
525
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500526 if((usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT) && !(features & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
Chris Forbes0559bc42019-05-11 10:47:11 -0700527 {
528 return VK_ERROR_FORMAT_NOT_SUPPORTED;
529 }
530
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500531 if((usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) && !(features & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
Chris Forbes0559bc42019-05-11 10:47:11 -0700532 {
533 return VK_ERROR_FORMAT_NOT_SUPPORTED;
534 }
535
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500536 if((usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) && !(features & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)))
Chris Forbes0559bc42019-05-11 10:47:11 -0700537 {
538 return VK_ERROR_FORMAT_NOT_SUPPORTED;
539 }
540
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500541 if((usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) && !(features & VK_FORMAT_FEATURE_TRANSFER_SRC_BIT))
Chris Forbes0559bc42019-05-11 10:47:11 -0700542 {
543 return VK_ERROR_FORMAT_NOT_SUPPORTED;
544 }
545
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500546 if((usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) && !(features & VK_FORMAT_FEATURE_TRANSFER_DST_BIT))
Chris Forbes0559bc42019-05-11 10:47:11 -0700547 {
548 return VK_ERROR_FORMAT_NOT_SUPPORTED;
549 }
550
551 auto allRecognizedUsageBits = VK_IMAGE_USAGE_SAMPLED_BIT |
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000552 VK_IMAGE_USAGE_STORAGE_BIT |
553 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
554 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
555 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
556 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
557 VK_IMAGE_USAGE_TRANSFER_DST_BIT |
558 VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
Chris Forbes0559bc42019-05-11 10:47:11 -0700559 ASSERT(!(usage & ~(allRecognizedUsageBits)));
560
Nicolas Capens7e01e4e2019-05-18 08:19:07 -0400561 // "Images created with tiling equal to VK_IMAGE_TILING_LINEAR have further restrictions on their limits and capabilities
562 // compared to images created with tiling equal to VK_IMAGE_TILING_OPTIMAL."
563 if(tiling == VK_IMAGE_TILING_LINEAR)
564 {
565 if(type != VK_IMAGE_TYPE_2D)
566 {
567 return VK_ERROR_FORMAT_NOT_SUPPORTED;
568 }
569
570 if(vk::Format(format).isDepth() || vk::Format(format).isStencil())
571 {
572 return VK_ERROR_FORMAT_NOT_SUPPORTED;
573 }
574 }
575
Hernan Liatisbd18d582019-05-29 15:38:58 -0700576 // "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 -0400577 // have further restrictions on their limits and capabilities compared to images created with other formats."
578 if(vk::Format(format).isYcbcrFormat())
579 {
580 if(type != VK_IMAGE_TYPE_2D)
581 {
582 return VK_ERROR_FORMAT_NOT_SUPPORTED;
583 }
584 }
585
Alexis Hetu767b41b2018-09-26 11:25:46 -0400586 vk::Cast(physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400587
588 return VK_SUCCESS;
589}
590
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000591VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400592{
Ben Claytonfb280672019-04-25 11:16:15 +0100593 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties* pProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000594 physicalDevice, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400595
Alexis Hetu767b41b2018-09-26 11:25:46 -0400596 *pProperties = vk::Cast(physicalDevice)->getProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400597}
598
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000599VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400600{
Ben Claytonfb280672019-04-25 11:16:15 +0100601 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties* pQueueFamilyProperties = %p))", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400602
Alexis Hetu767b41b2018-09-26 11:25:46 -0400603 if(!pQueueFamilyProperties)
604 {
605 *pQueueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
606 }
607 else
608 {
609 vk::Cast(physicalDevice)->getQueueFamilyProperties(*pQueueFamilyPropertyCount, pQueueFamilyProperties);
610 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400611}
612
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000613VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400614{
Ben Claytonfb280672019-04-25 11:16:15 +0100615 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400616
Alexis Hetu767b41b2018-09-26 11:25:46 -0400617 *pMemoryProperties = vk::Cast(physicalDevice)->getMemoryProperties();
Alexis Hetud73b8712018-09-21 15:14:43 -0400618}
619
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000620VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
Alexis Hetud73b8712018-09-21 15:14:43 -0400621{
Ben Claytonfb280672019-04-25 11:16:15 +0100622 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500623
Alexis Hetu7d96f512019-06-13 18:23:56 -0400624 return vk::GetInstanceProcAddr(vk::Cast(instance), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400625}
626
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000627VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName)
Alexis Hetud73b8712018-09-21 15:14:43 -0400628{
Ben Claytonfb280672019-04-25 11:16:15 +0100629 TRACE("(VkDevice device = %p, const char* pName = %p)", device, pName);
Nicolas Capensdc853642018-11-19 15:50:18 -0500630
Alexis Hetu7d96f512019-06-13 18:23:56 -0400631 return vk::GetDeviceProcAddr(vk::Cast(device), pName);
Alexis Hetud73b8712018-09-21 15:14:43 -0400632}
633
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000634VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
Alexis Hetud73b8712018-09-21 15:14:43 -0400635{
Ben Claytonfb280672019-04-25 11:16:15 +0100636 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkDeviceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDevice* pDevice = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000637 physicalDevice, pCreateInfo, pAllocator, pDevice);
Alexis Hetud73b8712018-09-21 15:14:43 -0400638
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500639 if(pCreateInfo->flags != 0)
640 {
641 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
642 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
643 }
644
645 if(pCreateInfo->enabledLayerCount != 0)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400646 {
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500647 // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500648 UNSUPPORTED("pCreateInfo->enabledLayerCount != 0");
Alexis Hetu767b41b2018-09-26 11:25:46 -0400649 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400650
Alexis Hetud6fae382019-04-05 13:19:46 -0400651 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500652 for(uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
Hernan Liatiscff8c002019-02-25 15:56:36 -0800653 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500654 if(!HasExtensionProperty(pCreateInfo->ppEnabledExtensionNames[i], deviceExtensionProperties, extensionPropertiesCount))
Hernan Liatiscff8c002019-02-25 15:56:36 -0800655 {
656 return VK_ERROR_EXTENSION_NOT_PRESENT;
657 }
658 }
659
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000660 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500661
Nicolas Capensa29aa772019-06-26 00:36:28 -0400662 const VkPhysicalDeviceFeatures *enabledFeatures = pCreateInfo->pEnabledFeatures;
663
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500664 while(extensionCreateInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400665 {
Alexis Hetuf8f61032019-10-10 16:45:30 -0400666 // Casting to a long since some structures, such as
667 // VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT
668 // are not enumerated in the official Vulkan header
669 switch((long)(extensionCreateInfo->sType))
Alexis Hetu767b41b2018-09-26 11:25:46 -0400670 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000671 case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
672 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
673 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
674 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
675 // internal use by the loader, and do not have corresponding
676 // Vulkan structures in this Specification."
677 break;
678 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500679 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000680 ASSERT(!pCreateInfo->pEnabledFeatures); // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500681
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000682 const VkPhysicalDeviceFeatures2 *physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2 *>(extensionCreateInfo);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500683
Nicolas Capensa29aa772019-06-26 00:36:28 -0400684 enabledFeatures = &physicalDeviceFeatures2->features;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500685 }
686 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000687 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500688 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000689 const VkPhysicalDeviceSamplerYcbcrConversionFeatures *samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures *>(extensionCreateInfo);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500690
Nicolas Capense2f5da42019-05-16 11:01:31 -0400691 // YCbCr conversion is supported.
692 // samplerYcbcrConversionFeatures->samplerYcbcrConversion can be VK_TRUE or VK_FALSE.
693 // 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 -0700694 // "To create a sampler Y'CbCr conversion, the samplerYcbcrConversion feature must be enabled."
Nicolas Capense2f5da42019-05-16 11:01:31 -0400695 (void)samplerYcbcrConversionFeatures->samplerYcbcrConversion;
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500696 }
697 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000698 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500699 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000700 const VkPhysicalDevice16BitStorageFeatures *storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures *>(extensionCreateInfo);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500701
Nicolas Capens8fff8c32020-01-22 03:07:14 -0500702 if(storage16BitFeatures->storageBuffer16BitAccess != VK_FALSE ||
703 storage16BitFeatures->uniformAndStorageBuffer16BitAccess != VK_FALSE ||
704 storage16BitFeatures->storagePushConstant16 != VK_FALSE ||
705 storage16BitFeatures->storageInputOutput16 != VK_FALSE)
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500706 {
707 return VK_ERROR_FEATURE_NOT_PRESENT;
708 }
709 }
710 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000711 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500712 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000713 const VkPhysicalDeviceVariablePointerFeatures *variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures *>(extensionCreateInfo);
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500714
Nicolas Capens8fff8c32020-01-22 03:07:14 -0500715 if(variablePointerFeatures->variablePointersStorageBuffer != VK_FALSE ||
716 variablePointerFeatures->variablePointers != VK_FALSE)
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500717 {
718 return VK_ERROR_FEATURE_NOT_PRESENT;
719 }
720 }
721 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000722 case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO:
Alexis Hetu5ebd2c02019-01-22 17:17:27 -0500723 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000724 const VkDeviceGroupDeviceCreateInfo *groupDeviceCreateInfo = reinterpret_cast<const VkDeviceGroupDeviceCreateInfo *>(extensionCreateInfo);
Alexis Hetu5ebd2c02019-01-22 17:17:27 -0500725
726 if((groupDeviceCreateInfo->physicalDeviceCount != 1) ||
727 (groupDeviceCreateInfo->pPhysicalDevices[0] != physicalDevice))
728 {
729 return VK_ERROR_FEATURE_NOT_PRESENT;
730 }
731 }
732 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000733 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
Chris Forbesaad8cfc2019-08-15 19:09:16 -0700734 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000735 const VkPhysicalDeviceMultiviewFeatures *multiviewFeatures = reinterpret_cast<const VkPhysicalDeviceMultiviewFeatures *>(extensionCreateInfo);
Chris Forbesaad8cfc2019-08-15 19:09:16 -0700736
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500737 if(multiviewFeatures->multiviewGeometryShader ||
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000738 multiviewFeatures->multiviewTessellationShader)
Chris Forbesaad8cfc2019-08-15 19:09:16 -0700739 {
740 return VK_ERROR_FEATURE_NOT_PRESENT;
741 }
742 }
743 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000744 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES:
Chris Forbesd3353022019-08-15 19:21:55 -0700745 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000746 const VkPhysicalDeviceShaderDrawParametersFeatures *shaderDrawParametersFeatures = reinterpret_cast<const VkPhysicalDeviceShaderDrawParametersFeatures *>(extensionCreateInfo);
Chris Forbesd3353022019-08-15 19:21:55 -0700747
Nicolas Capens81bc9d92019-12-16 15:05:57 -0500748 if(shaderDrawParametersFeatures->shaderDrawParameters)
Chris Forbesd3353022019-08-15 19:21:55 -0700749 {
750 return VK_ERROR_FEATURE_NOT_PRESENT;
751 }
752 }
753 break;
Alexis Hetuaabd0852020-02-10 14:27:29 -0500754 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR:
755 {
Ben Claytona0453d52020-02-11 18:05:41 +0000756 const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *shaderDrawParametersFeatures = reinterpret_cast<const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *>(extensionCreateInfo);
Alexis Hetuaabd0852020-02-10 14:27:29 -0500757
758 // Separate depth and stencil layouts is already supported
759 (void)(shaderDrawParametersFeatures->separateDepthStencilLayouts);
760 }
761 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000762 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT:
Alexis Hetu23f9c252019-10-17 13:58:25 -0400763 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000764 const VkPhysicalDeviceLineRasterizationFeaturesEXT *lineRasterizationFeatures = reinterpret_cast<const VkPhysicalDeviceLineRasterizationFeaturesEXT *>(extensionCreateInfo);
Nicolas Capens8fff8c32020-01-22 03:07:14 -0500765 if((lineRasterizationFeatures->smoothLines != VK_FALSE) ||
766 (lineRasterizationFeatures->stippledBresenhamLines != VK_FALSE) ||
767 (lineRasterizationFeatures->stippledRectangularLines != VK_FALSE) ||
768 (lineRasterizationFeatures->stippledSmoothLines != VK_FALSE))
Alexis Hetu23f9c252019-10-17 13:58:25 -0400769 {
770 return VK_ERROR_FEATURE_NOT_PRESENT;
771 }
772 }
773 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000774 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT:
Alexis Hetuf8f61032019-10-10 16:45:30 -0400775 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000776 const VkPhysicalDeviceProvokingVertexFeaturesEXT *provokingVertexFeatures = reinterpret_cast<const VkPhysicalDeviceProvokingVertexFeaturesEXT *>(extensionCreateInfo);
Alexis Hetuf8f61032019-10-10 16:45:30 -0400777
778 // Provoking vertex is supported.
779 // provokingVertexFeatures->provokingVertexLast can be VK_TRUE or VK_FALSE.
780 // No action needs to be taken on our end in either case; it's the apps responsibility to check
781 // that the provokingVertexLast feature is enabled before using the provoking vertex convention.
782 (void)provokingVertexFeatures->provokingVertexLast;
783 }
Alexis Hetub07147b2019-10-29 12:49:24 -0400784 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000785 default:
786 // "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]"
Sean Risserc1e60dc2020-02-19 12:52:24 -0500787 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000788 break;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400789 }
Nicolas Capensd689d1c2018-11-19 16:02:36 -0500790
791 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400792 }
793
794 ASSERT(pCreateInfo->queueCreateInfoCount > 0);
795
Nicolas Capensa29aa772019-06-26 00:36:28 -0400796 if(enabledFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400797 {
Nicolas Capensa29aa772019-06-26 00:36:28 -0400798 if(!vk::Cast(physicalDevice)->hasFeatures(*enabledFeatures))
Nicolas Capensd5f14892018-11-13 14:06:37 -0500799 {
800 return VK_ERROR_FEATURE_NOT_PRESENT;
801 }
Alexis Hetu767b41b2018-09-26 11:25:46 -0400802 }
803
804 uint32_t queueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
805
806 for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
807 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000808 const VkDeviceQueueCreateInfo &queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500809 if(queueCreateInfo.flags != 0)
Alexis Hetu767b41b2018-09-26 11:25:46 -0400810 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -0500811 UNSUPPORTED("pCreateInfo->pQueueCreateInfos[%d]->flags %d", i, queueCreateInfo.flags);
Alexis Hetu7b29abf2019-11-21 17:26:17 -0500812 }
813
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000814 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(queueCreateInfo.pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -0500815 while(extInfo)
816 {
Sean Risserc1e60dc2020-02-19 12:52:24 -0500817 LOG_TRAP("pCreateInfo->pQueueCreateInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -0500818 extInfo = extInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400819 }
820
821 ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000822 (void)queueFamilyPropertyCount; // Silence unused variable warning
Alexis Hetu767b41b2018-09-26 11:25:46 -0400823 }
824
Alexis Hétu50038d62019-09-24 15:37:24 +0000825 auto scheduler = getOrCreateScheduler();
Ben Claytond6c61362019-08-14 18:16:01 +0100826 return vk::DispatchableDevice::Create(pAllocator, pCreateInfo, pDevice, vk::Cast(physicalDevice), enabledFeatures, scheduler);
Alexis Hetud73b8712018-09-21 15:14:43 -0400827}
828
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000829VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -0400830{
Ben Claytonfb280672019-04-25 11:16:15 +0100831 TRACE("(VkDevice device = %p, const VkAllocationCallbacks* pAllocator = %p)", device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400832
Alexis Hetu767b41b2018-09-26 11:25:46 -0400833 vk::destroy(device, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -0400834}
835
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000836VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400837{
Ben Claytonfb280672019-04-25 11:16:15 +0100838 TRACE("(const char* pLayerName = %p, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)",
Alexis Hetud73b8712018-09-21 15:14:43 -0400839 pLayerName, pPropertyCount, pProperties);
840
Hernan Liatis2bb08642019-02-08 14:08:21 -0800841 uint32_t extensionPropertiesCount = sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700842
Alexis Hetud73b8712018-09-21 15:14:43 -0400843 if(!pProperties)
844 {
Chris Forbes59781502018-10-25 11:19:54 -0700845 *pPropertyCount = extensionPropertiesCount;
Alexis Hetud73b8712018-09-21 15:14:43 -0400846 return VK_SUCCESS;
847 }
848
Chris Forbesdf84b942019-06-12 11:28:09 -0700849 auto toCopy = std::min(*pPropertyCount, extensionPropertiesCount);
850 for(uint32_t i = 0; i < toCopy; i++)
Alexis Hetud73b8712018-09-21 15:14:43 -0400851 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800852 pProperties[i] = instanceExtensionProperties[i];
Alexis Hetud73b8712018-09-21 15:14:43 -0400853 }
854
Chris Forbesdf84b942019-06-12 11:28:09 -0700855 *pPropertyCount = toCopy;
856 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400857}
858
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000859VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400860{
Ben Claytonfb280672019-04-25 11:16:15 +0100861 TRACE("(VkPhysicalDevice physicalDevice = %p, const char* pLayerName, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400862
Hernan Liatis2bb08642019-02-08 14:08:21 -0800863 uint32_t extensionPropertiesCount = sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]);
Chris Forbes59781502018-10-25 11:19:54 -0700864
Alexis Hetu767b41b2018-09-26 11:25:46 -0400865 if(!pProperties)
866 {
Chris Forbes59781502018-10-25 11:19:54 -0700867 *pPropertyCount = extensionPropertiesCount;
Alexis Hetu767b41b2018-09-26 11:25:46 -0400868 return VK_SUCCESS;
869 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400870
Chris Forbesdf84b942019-06-12 11:28:09 -0700871 auto toCopy = std::min(*pPropertyCount, extensionPropertiesCount);
872 for(uint32_t i = 0; i < toCopy; i++)
Chris Forbes59781502018-10-25 11:19:54 -0700873 {
Hernan Liatis2bb08642019-02-08 14:08:21 -0800874 pProperties[i] = deviceExtensionProperties[i];
Chris Forbes59781502018-10-25 11:19:54 -0700875 }
876
Chris Forbesdf84b942019-06-12 11:28:09 -0700877 *pPropertyCount = toCopy;
878 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
Alexis Hetud73b8712018-09-21 15:14:43 -0400879}
880
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000881VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400882{
Ben Claytonfb280672019-04-25 11:16:15 +0100883 TRACE("(uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400884
Alexis Hetu767b41b2018-09-26 11:25:46 -0400885 if(!pProperties)
886 {
887 *pPropertyCount = 0;
888 return VK_SUCCESS;
889 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400890
891 return VK_SUCCESS;
892}
893
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000894VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -0400895{
Ben Claytonfb280672019-04-25 11:16:15 +0100896 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -0400897
Alexis Hetu767b41b2018-09-26 11:25:46 -0400898 if(!pProperties)
899 {
900 *pPropertyCount = 0;
901 return VK_SUCCESS;
902 }
Alexis Hetud73b8712018-09-21 15:14:43 -0400903
904 return VK_SUCCESS;
905}
906
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000907VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
Alexis Hetud73b8712018-09-21 15:14:43 -0400908{
Ben Claytonfb280672019-04-25 11:16:15 +0100909 TRACE("(VkDevice device = %p, uint32_t queueFamilyIndex = %d, uint32_t queueIndex = %d, VkQueue* pQueue = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000910 device, queueFamilyIndex, queueIndex, pQueue);
Alexis Hetud73b8712018-09-21 15:14:43 -0400911
Alexis Hetu767b41b2018-09-26 11:25:46 -0400912 *pQueue = vk::Cast(device)->getQueue(queueFamilyIndex, queueIndex);
Alexis Hetud73b8712018-09-21 15:14:43 -0400913}
914
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000915VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
Alexis Hetud73b8712018-09-21 15:14:43 -0400916{
Ben Claytonfb280672019-04-25 11:16:15 +0100917 TRACE("(VkQueue queue = %p, uint32_t submitCount = %d, const VkSubmitInfo* pSubmits = %p, VkFence fence = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000918 queue, submitCount, pSubmits, static_cast<void *>(fence));
Alexis Hetu072dc0d2018-10-31 11:41:25 -0400919
Alexis Hetu7d96f512019-06-13 18:23:56 -0400920 return vk::Cast(queue)->submit(submitCount, pSubmits, vk::Cast(fence));
Alexis Hetud73b8712018-09-21 15:14:43 -0400921}
922
Nicolas Capensde16f322019-02-12 00:32:31 -0500923VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
924{
Ben Claytonfb280672019-04-25 11:16:15 +0100925 TRACE("(VkQueue queue = %p)", queue);
Nicolas Capensde16f322019-02-12 00:32:31 -0500926
Alexis Hetue1f51b92019-04-23 15:34:34 -0400927 return vk::Cast(queue)->waitIdle();
Nicolas Capensde16f322019-02-12 00:32:31 -0500928}
929
930VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
931{
Ben Claytonfb280672019-04-25 11:16:15 +0100932 TRACE("(VkDevice device = %p)", device);
Nicolas Capensde16f322019-02-12 00:32:31 -0500933
Alexis Hetue1f51b92019-04-23 15:34:34 -0400934 return vk::Cast(device)->waitIdle();
Alexis Hetud73b8712018-09-21 15:14:43 -0400935}
936
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000937VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
Alexis Hetud73b8712018-09-21 15:14:43 -0400938{
Ben Claytonfb280672019-04-25 11:16:15 +0100939 TRACE("(VkDevice device = %p, const VkMemoryAllocateInfo* pAllocateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDeviceMemory* pMemory = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000940 device, pAllocateInfo, pAllocator, pMemory);
Alexis Hetud73b8712018-09-21 15:14:43 -0400941
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000942 const VkBaseInStructure *allocationInfo = reinterpret_cast<const VkBaseInStructure *>(pAllocateInfo->pNext);
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500943 while(allocationInfo)
Alexis Hetu38ff8302018-10-18 15:08:13 -0400944 {
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -0500945 switch(allocationInfo->sType)
946 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000947 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
948 // This can safely be ignored, as the Vulkan spec mentions:
949 // "If the pNext chain includes a VkMemoryDedicatedAllocateInfo structure, then that structure
950 // includes a handle of the sole buffer or image resource that the memory *can* be bound to."
951 break;
952 case VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO:
953 // This extension controls on which physical devices the memory gets allocated.
954 // SwiftShader only has a single physical device, so this extension does nothing in this case.
955 break;
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +0100956#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000957 case VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR:
David 'Digit' Turner359bc802019-08-14 17:46:07 +0200958 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000959 auto *importInfo = reinterpret_cast<const VkImportMemoryFdInfoKHR *>(allocationInfo);
960 if(importInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
961 {
962 UNSUPPORTED("importInfo->handleType %u", importInfo->handleType);
963 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
964 }
965 break;
David 'Digit' Turner359bc802019-08-14 17:46:07 +0200966 }
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800967#endif // SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000968 case VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO:
David 'Digit' Turner359bc802019-08-14 17:46:07 +0200969 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000970 auto *exportInfo = reinterpret_cast<const VkExportMemoryAllocateInfo *>(allocationInfo);
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800971 switch(exportInfo->handleTypes)
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000972 {
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800973#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
974 case VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT:
975 break;
976#endif
977#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
978 case VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID:
979 break;
980#endif
David 'Digit' Turnere52e2db2019-09-09 17:58:46 +0200981#if VK_USE_PLATFORM_FUCHSIA
982 case VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA:
983 break;
984#endif
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800985 default:
986 UNSUPPORTED("exportInfo->handleTypes %u", exportInfo->handleTypes);
987 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
Ben Clayton2ed93ab2019-12-17 20:38:03 +0000988 }
989 break;
David 'Digit' Turner359bc802019-08-14 17:46:07 +0200990 }
Chris Forbes9f1e03b2020-01-09 11:45:28 -0800991#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
992 case VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID:
993 // Ignore
994 break;
995#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
Jonah Ryan-Davisf9f999f2020-01-08 14:41:28 -0500996 case VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT:
997 {
998 auto *importInfo = reinterpret_cast<const VkImportMemoryHostPointerInfoEXT *>(allocationInfo);
999 if(importInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT && importInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT)
1000 {
1001 UNSUPPORTED("importInfo->handleType %u", importInfo->handleType);
1002 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1003 }
1004 break;
1005 }
David 'Digit' Turnere52e2db2019-09-09 17:58:46 +02001006#if VK_USE_PLATFORM_FUCHSIA
1007 case VK_STRUCTURE_TYPE_TEMP_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA:
1008 {
1009 auto *importInfo = reinterpret_cast<const VkImportMemoryZirconHandleInfoFUCHSIA *>(allocationInfo);
1010 if(importInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
1011 {
1012 UNSUPPORTED("importInfo->handleType %u", importInfo->handleType);
1013 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1014 }
1015 break;
1016 }
1017#endif // VK_USE_PLATFORM_FUCHSIA
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001018 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05001019 LOG_TRAP("pAllocateInfo->pNext sType = %s", vk::Stringify(allocationInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001020 break;
Alexis Hetu7ca9f4a2019-01-17 14:51:43 -05001021 }
1022
1023 allocationInfo = allocationInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -04001024 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001025
Alexis Hetu38ff8302018-10-18 15:08:13 -04001026 VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
1027 if(result != VK_SUCCESS)
1028 {
1029 return result;
1030 }
1031
1032 // Make sure the memory allocation is done now so that OOM errors can be checked now
1033 result = vk::Cast(*pMemory)->allocate();
1034 if(result != VK_SUCCESS)
1035 {
1036 vk::destroy(*pMemory, pAllocator);
1037 *pMemory = VK_NULL_HANDLE;
1038 }
1039
1040 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -04001041}
1042
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001043VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001044{
Ben Claytonfb280672019-04-25 11:16:15 +01001045 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001046 device, static_cast<void *>(memory), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001047
Alexis Hetu38ff8302018-10-18 15:08:13 -04001048 vk::destroy(memory, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001049}
1050
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001051#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001052VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR(VkDevice device, const VkMemoryGetFdInfoKHR *getFdInfo, int *pFd)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001053{
1054 TRACE("(VkDevice device = %p, const VkMemoryGetFdInfoKHR* getFdInfo = %p, int* pFd = %p",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001055 device, getFdInfo, pFd);
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001056
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001057 if(getFdInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001058 {
1059 UNSUPPORTED("pGetFdInfo->handleType %u", getFdInfo->handleType);
1060 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1061 }
1062 return vk::Cast(getFdInfo->memory)->exportFd(pFd);
1063}
1064
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001065VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR *pMemoryFdProperties)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001066{
1067 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, int fd = %d, VkMemoryFdPropertiesKHR* pMemoryFdProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001068 device, handleType, fd, pMemoryFdProperties);
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001069
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001070 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001071 {
1072 UNSUPPORTED("handleType %u", handleType);
1073 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1074 }
1075
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001076 if(fd < 0)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001077 {
1078 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1079 }
1080
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001081 const VkPhysicalDeviceMemoryProperties &memoryProperties =
1082 vk::Cast(device)->getPhysicalDevice()->getMemoryProperties();
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001083
1084 // All SwiftShader memory types support this!
1085 pMemoryFdProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
1086
1087 return VK_SUCCESS;
1088}
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001089#endif // SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
David 'Digit' Turnere52e2db2019-09-09 17:58:46 +02001090#if VK_USE_PLATFORM_FUCHSIA
1091VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA *pGetHandleInfo, zx_handle_t *pHandle)
1092{
1093 TRACE("(VkDevice device = %p, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetHandleInfo = %p, zx_handle_t* pHandle = %p",
1094 device, pGetHandleInfo, pHandle);
1095
1096 if(pGetHandleInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
1097 {
1098 UNSUPPORTED("pGetHandleInfo->handleType %u", pGetHandleInfo->handleType);
1099 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1100 }
1101 return vk::Cast(pGetHandleInfo->memory)->exportHandle(pHandle);
1102}
1103
1104VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t handle, VkMemoryZirconHandlePropertiesFUCHSIA *pMemoryZirconHandleProperties)
1105{
1106 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, zx_handle_t handle = %d, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties = %p)",
1107 device, handleType, handle, pMemoryZirconHandleProperties);
1108
1109 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
1110 {
1111 UNSUPPORTED("handleType %u", handleType);
1112 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1113 }
1114
1115 if(handle == ZX_HANDLE_INVALID)
1116 {
1117 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1118 }
1119
1120 const VkPhysicalDeviceMemoryProperties &memoryProperties =
1121 vk::Cast(device)->getPhysicalDevice()->getMemoryProperties();
1122
1123 // All SwiftShader memory types support this!
1124 pMemoryZirconHandleProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
1125
1126 return VK_SUCCESS;
1127}
1128#endif // VK_USE_PLATFORM_FUCHSIA
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001129
Jonah Ryan-Davisf9f999f2020-01-08 14:41:28 -05001130VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, const void *pHostPointer, VkMemoryHostPointerPropertiesEXT *pMemoryHostPointerProperties)
1131{
1132 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, const void *pHostPointer = %p, VkMemoryHostPointerPropertiesEXT *pMemoryHostPointerProperties = %p)",
1133 device, handleType, pHostPointer, pMemoryHostPointerProperties);
1134
1135 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT && handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT)
1136 {
1137 UNSUPPORTED("handleType %u", handleType);
1138 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1139 }
1140 pMemoryHostPointerProperties->memoryTypeBits = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1141
1142 return VK_SUCCESS;
1143}
1144
Chris Forbes9f1e03b2020-01-09 11:45:28 -08001145#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
1146VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID *pInfo, struct AHardwareBuffer **pBuffer)
1147{
1148 TRACE("(VkDevice device = %p, const VkMemoryGetAndroidHardwareBufferInfoANDROID *pInfo = %p, struct AHardwareBuffer **pBuffer = %p)",
1149 device, pInfo, pBuffer);
1150
1151 return vk::Cast(pInfo->memory)->exportAhb(pBuffer);
1152}
1153
1154VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(VkDevice device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
1155{
1156 TRACE("(VkDevice device = %p, const struct AHardwareBuffer *buffer = %p, VkAndroidHardwareBufferPropertiesANDROID *pProperties = %p)",
1157 device, buffer, pProperties);
1158
1159 return vk::DeviceMemory::getAhbProperties(buffer, pProperties);
1160}
1161#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
1162
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001163VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
Alexis Hetud73b8712018-09-21 15:14:43 -04001164{
Ben Claytonfb280672019-04-25 11:16:15 +01001165 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = %d, void** ppData = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001166 device, static_cast<void *>(memory), int(offset), int(size), flags, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001167
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001168 if(flags != 0)
1169 {
1170 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1171 UNSUPPORTED("flags %d", int(flags));
1172 }
1173
Alexis Hetu38ff8302018-10-18 15:08:13 -04001174 return vk::Cast(memory)->map(offset, size, ppData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001175}
1176
1177VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
1178{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001179 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p)", device, static_cast<void *>(memory));
Alexis Hetud73b8712018-09-21 15:14:43 -04001180
Alexis Hetu38ff8302018-10-18 15:08:13 -04001181 // Noop, memory will be released when the DeviceMemory object is released
Alexis Hetud73b8712018-09-21 15:14:43 -04001182}
1183
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001184VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
Alexis Hetud73b8712018-09-21 15:14:43 -04001185{
Ben Claytonfb280672019-04-25 11:16:15 +01001186 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001187 device, memoryRangeCount, pMemoryRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001188
Alexis Hetu38ff8302018-10-18 15:08:13 -04001189 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -04001190
1191 return VK_SUCCESS;
1192}
1193
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001194VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
Alexis Hetud73b8712018-09-21 15:14:43 -04001195{
Ben Claytonfb280672019-04-25 11:16:15 +01001196 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001197 device, memoryRangeCount, pMemoryRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04001198
Alexis Hetu38ff8302018-10-18 15:08:13 -04001199 // Noop, host and device memory are the same to SwiftShader
Alexis Hetud73b8712018-09-21 15:14:43 -04001200
1201 return VK_SUCCESS;
1202}
1203
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001204VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize *pCommittedMemoryInBytes)
Alexis Hetud73b8712018-09-21 15:14:43 -04001205{
Ben Claytonfb280672019-04-25 11:16:15 +01001206 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize* pCommittedMemoryInBytes = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001207 pDevice, static_cast<void *>(pMemory), pCommittedMemoryInBytes);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001208
1209 auto memory = vk::Cast(pMemory);
1210
1211#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001212 const auto &memoryProperties = vk::Cast(pDevice)->getPhysicalDevice()->getMemoryProperties();
Alexis Hetu38ff8302018-10-18 15:08:13 -04001213 uint32_t typeIndex = memory->getMemoryTypeIndex();
1214 ASSERT(typeIndex < memoryProperties.memoryTypeCount);
1215 ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
1216#endif
1217
1218 *pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
Alexis Hetud73b8712018-09-21 15:14:43 -04001219}
1220
1221VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
1222{
Ben Claytonfb280672019-04-25 11:16:15 +01001223 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001224 device, static_cast<void *>(buffer), static_cast<void *>(memory), int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -04001225
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001226 if(!vk::Cast(buffer)->canBindToMemory(vk::Cast(memory)))
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001227 {
1228 UNSUPPORTED("vkBindBufferMemory with invalid external memory");
1229 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1230 }
Alexis Hetu7d96f512019-06-13 18:23:56 -04001231 vk::Cast(buffer)->bind(vk::Cast(memory), memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -04001232 return VK_SUCCESS;
1233}
1234
1235VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
1236{
Ben Claytonfb280672019-04-25 11:16:15 +01001237 TRACE("(VkDevice device = %p, VkImage image = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001238 device, static_cast<void *>(image), static_cast<void *>(memory), int(memoryOffset));
Alexis Hetud73b8712018-09-21 15:14:43 -04001239
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001240 if(!vk::Cast(image)->canBindToMemory(vk::Cast(memory)))
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001241 {
1242 UNSUPPORTED("vkBindImageMemory with invalid external memory");
1243 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1244 }
Alexis Hetu7d96f512019-06-13 18:23:56 -04001245 vk::Cast(image)->bind(vk::Cast(memory), memoryOffset);
Alexis Hetud73b8712018-09-21 15:14:43 -04001246 return VK_SUCCESS;
1247}
1248
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001249VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04001250{
Ben Claytonfb280672019-04-25 11:16:15 +01001251 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001252 device, static_cast<void *>(buffer), pMemoryRequirements);
Alexis Hetud73b8712018-09-21 15:14:43 -04001253
Alexis Hetu38ff8302018-10-18 15:08:13 -04001254 *pMemoryRequirements = vk::Cast(buffer)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -04001255}
1256
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001257VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04001258{
Ben Claytonfb280672019-04-25 11:16:15 +01001259 TRACE("(VkDevice device = %p, VkImage image = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001260 device, static_cast<void *>(image), pMemoryRequirements);
Alexis Hetud73b8712018-09-21 15:14:43 -04001261
Alexis Hetua233cea2018-12-07 11:53:19 -05001262 *pMemoryRequirements = vk::Cast(image)->getMemoryRequirements();
Alexis Hetud73b8712018-09-21 15:14:43 -04001263}
1264
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001265VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *pSparseMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04001266{
Ben Claytonfb280672019-04-25 11:16:15 +01001267 TRACE("(VkDevice device = %p, VkImage image = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements* pSparseMemoryRequirements = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001268 device, static_cast<void *>(image), pSparseMemoryRequirementCount, pSparseMemoryRequirements);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04001269
Nicolas Capens5028a582018-11-13 15:03:35 -05001270 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
1271 // "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."
1272 *pSparseMemoryRequirementCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -04001273}
1274
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001275VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04001276{
Ben Claytonfb280672019-04-25 11:16:15 +01001277 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)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001278 physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
Chris Forbes2c25b142019-03-05 14:47:16 -08001279
1280 // We do not support sparse images.
1281 *pPropertyCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -04001282}
1283
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001284VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence)
Alexis Hetud73b8712018-09-21 15:14:43 -04001285{
1286 TRACE("()");
Nicolas Capens865f8892020-01-21 14:27:10 -05001287 UNSUPPORTED("vkQueueBindSparse");
Alexis Hetud73b8712018-09-21 15:14:43 -04001288 return VK_SUCCESS;
1289}
1290
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001291VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence)
Alexis Hetud73b8712018-09-21 15:14:43 -04001292{
Ben Claytonfb280672019-04-25 11:16:15 +01001293 TRACE("(VkDevice device = %p, const VkFenceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFence* pFence = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001294 device, pCreateInfo, pAllocator, pFence);
Alexis Hetud73b8712018-09-21 15:14:43 -04001295
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001296 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001297 while(nextInfo)
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001298 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001299 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001300 nextInfo = nextInfo->pNext;
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001301 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001302
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001303 return vk::Fence::Create(pAllocator, pCreateInfo, pFence);
Alexis Hetud73b8712018-09-21 15:14:43 -04001304}
1305
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001306VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001307{
Ben Claytonfb280672019-04-25 11:16:15 +01001308 TRACE("(VkDevice device = %p, VkFence fence = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001309 device, static_cast<void *>(fence), pAllocator);
Alexis Hetu767b41b2018-09-26 11:25:46 -04001310
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001311 vk::destroy(fence, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001312}
1313
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001314VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences)
Alexis Hetud73b8712018-09-21 15:14:43 -04001315{
Ben Claytonfb280672019-04-25 11:16:15 +01001316 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001317 device, fenceCount, pFences);
1318
1319 for(uint32_t i = 0; i < fenceCount; i++)
1320 {
1321 vk::Cast(pFences[i])->reset();
1322 }
1323
Alexis Hetud73b8712018-09-21 15:14:43 -04001324 return VK_SUCCESS;
1325}
1326
1327VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
1328{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001329 TRACE("(VkDevice device = %p, VkFence fence = %p)", device, static_cast<void *>(fence));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001330
1331 return vk::Cast(fence)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -04001332}
1333
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001334VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout)
Alexis Hetud73b8712018-09-21 15:14:43 -04001335{
Ben Claytonfb280672019-04-25 11:16:15 +01001336 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p, VkBool32 waitAll = %d, uint64_t timeout = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001337 device, int(fenceCount), pFences, int(waitAll), int(timeout));
Alexis Hetuc4bd9df2018-12-07 11:28:40 -05001338
Alexis Hetue1f51b92019-04-23 15:34:34 -04001339 return vk::Cast(device)->waitForFences(fenceCount, pFences, waitAll, timeout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001340}
1341
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001342VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
Alexis Hetud73b8712018-09-21 15:14:43 -04001343{
Ben Claytonfb280672019-04-25 11:16:15 +01001344 TRACE("(VkDevice device = %p, const VkSemaphoreCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSemaphore* pSemaphore = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001345 device, pCreateInfo, pAllocator, pSemaphore);
1346
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001347 if(pCreateInfo->flags != 0)
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001348 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001349 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1350 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001351 }
1352
David 'Digit' Turner43e33162019-11-22 14:18:49 +01001353 return vk::Semaphore::Create(pAllocator, pCreateInfo, pSemaphore, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001354}
1355
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001356VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001357{
Ben Claytonfb280672019-04-25 11:16:15 +01001358 TRACE("(VkDevice device = %p, VkSemaphore semaphore = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001359 device, static_cast<void *>(semaphore), pAllocator);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001360
1361 vk::destroy(semaphore, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001362}
1363
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001364#if SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001365VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *pGetFdInfo, int *pFd)
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001366{
1367 TRACE("(VkDevice device = %p, const VkSemaphoreGetFdInfoKHR* pGetFdInfo = %p, int* pFd = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001368 device, static_cast<const void *>(pGetFdInfo), static_cast<void *>(pFd));
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001369
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001370 if(pGetFdInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT)
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001371 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001372 UNSUPPORTED("pGetFdInfo->handleType %d", int(pGetFdInfo->handleType));
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001373 }
1374
1375 return vk::Cast(pGetFdInfo->semaphore)->exportFd(pFd);
1376}
1377
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001378VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR(VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreInfo)
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001379{
1380 TRACE("(VkDevice device = %p, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreInfo = %p",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001381 device, static_cast<const void *>(pImportSemaphoreInfo));
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001382
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001383 if(pImportSemaphoreInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT)
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001384 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001385 UNSUPPORTED("pImportSemaphoreInfo->handleType %d", int(pImportSemaphoreInfo->handleType));
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001386 }
1387 bool temporaryImport = (pImportSemaphoreInfo->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) != 0;
1388
1389 return vk::Cast(pImportSemaphoreInfo->semaphore)->importFd(pImportSemaphoreInfo->fd, temporaryImport);
1390}
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001391#endif // SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
David 'Digit' Turner7c4d0a02019-09-03 17:00:02 +02001392
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001393#if VK_USE_PLATFORM_FUCHSIA
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001394VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA(
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001395 VkDevice device,
1396 const VkImportSemaphoreZirconHandleInfoFUCHSIA *pImportSemaphoreZirconHandleInfo)
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001397{
1398 TRACE("(VkDevice device = %p, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo = %p)",
1399 device, pImportSemaphoreZirconHandleInfo);
1400
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001401 if(pImportSemaphoreZirconHandleInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA)
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001402 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001403 UNSUPPORTED("pImportSemaphoreZirconHandleInfo->handleType %d", int(pImportSemaphoreZirconHandleInfo->handleType));
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001404 }
1405 bool temporaryImport = (pImportSemaphoreZirconHandleInfo->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) != 0;
1406
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001407 return vk::Cast(pImportSemaphoreZirconHandleInfo->semaphore)->importHandle(pImportSemaphoreZirconHandleInfo->handle, temporaryImport);
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001408}
1409
1410VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA(
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001411 VkDevice device,
1412 const VkSemaphoreGetZirconHandleInfoFUCHSIA *pGetZirconHandleInfo,
1413 zx_handle_t *pZirconHandle)
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001414{
1415 TRACE("(VkDevice device = %p, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo = %p, zx_handle_t* pZirconHandle = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001416 device, static_cast<const void *>(pGetZirconHandleInfo), static_cast<void *>(pZirconHandle));
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001417
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001418 if(pGetZirconHandleInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_TEMP_ZIRCON_EVENT_BIT_FUCHSIA)
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001419 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001420 UNSUPPORTED("pGetZirconHandleInfo->handleType %d", int(pGetZirconHandleInfo->handleType));
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001421 }
1422
1423 return vk::Cast(pGetZirconHandleInfo->semaphore)->exportHandle(pZirconHandle);
1424}
David 'Digit' Turner3a7101b2019-11-22 11:55:53 +01001425#endif // VK_USE_PLATFORM_FUCHSIA
David 'Digit' Turnerfda994c2019-09-04 16:36:36 +02001426
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001427VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
Alexis Hetud73b8712018-09-21 15:14:43 -04001428{
Ben Claytonfb280672019-04-25 11:16:15 +01001429 TRACE("(VkDevice device = %p, const VkEventCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkEvent* pEvent = %p)",
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001430 device, pCreateInfo, pAllocator, pEvent);
1431
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001432 if(pCreateInfo->flags != 0)
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001433 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001434 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1435 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001436 }
1437
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001438 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001439 while(extInfo)
1440 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001441 // Vulkan 1.2: "pNext must be NULL"
Sean Risserc1e60dc2020-02-19 12:52:24 -05001442 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001443 extInfo = extInfo->pNext;
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001444 }
1445
1446 return vk::Event::Create(pAllocator, pCreateInfo, pEvent);
Alexis Hetud73b8712018-09-21 15:14:43 -04001447}
1448
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001449VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001450{
Ben Claytonfb280672019-04-25 11:16:15 +01001451 TRACE("(VkDevice device = %p, VkEvent event = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001452 device, static_cast<void *>(event), pAllocator);
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001453
1454 vk::destroy(event, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001455}
1456
1457VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
1458{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001459 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001460
1461 return vk::Cast(event)->getStatus();
Alexis Hetud73b8712018-09-21 15:14:43 -04001462}
1463
1464VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event)
1465{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001466 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001467
1468 vk::Cast(event)->signal();
1469
Alexis Hetud73b8712018-09-21 15:14:43 -04001470 return VK_SUCCESS;
1471}
1472
1473VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event)
1474{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001475 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
Alexis Hetu1f23d8c2018-10-16 14:40:19 -04001476
1477 vk::Cast(event)->reset();
1478
Alexis Hetud73b8712018-09-21 15:14:43 -04001479 return VK_SUCCESS;
1480}
1481
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001482VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool)
Alexis Hetud73b8712018-09-21 15:14:43 -04001483{
Ben Claytonfb280672019-04-25 11:16:15 +01001484 TRACE("(VkDevice device = %p, const VkQueryPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkQueryPool* pQueryPool = %p)",
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001485 device, pCreateInfo, pAllocator, pQueryPool);
1486
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001487 if(pCreateInfo->flags != 0)
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001488 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001489 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1490 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001491 }
1492
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001493 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001494 while(extInfo)
1495 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001496 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001497 extInfo = extInfo->pNext;
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001498 }
1499
1500 return vk::QueryPool::Create(pAllocator, pCreateInfo, pQueryPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04001501}
1502
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001503VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001504{
Ben Claytonfb280672019-04-25 11:16:15 +01001505 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001506 device, static_cast<void *>(queryPool), pAllocator);
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001507
1508 vk::destroy(queryPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001509}
1510
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001511VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *pData, VkDeviceSize stride, VkQueryResultFlags flags)
Alexis Hetud73b8712018-09-21 15:14:43 -04001512{
Ben Claytonfb280672019-04-25 11:16:15 +01001513 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)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001514 device, static_cast<void *>(queryPool), int(firstQuery), int(queryCount), int(dataSize), pData, int(stride), flags);
Alexis Hetu86f8bdb2019-01-22 12:07:24 -05001515
Alexis Hetuf0aa9d52019-04-01 17:06:47 -04001516 return vk::Cast(queryPool)->getResults(firstQuery, queryCount, dataSize, pData, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04001517}
1518
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001519VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
Alexis Hetud73b8712018-09-21 15:14:43 -04001520{
Ben Claytonfb280672019-04-25 11:16:15 +01001521 TRACE("(VkDevice device = %p, const VkBufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBuffer* pBuffer = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001522 device, pCreateInfo, pAllocator, pBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001523
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001524 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001525 while(nextInfo)
Alexis Hetu38ff8302018-10-18 15:08:13 -04001526 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001527 switch(nextInfo->sType)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001528 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001529 case VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO:
1530 // Do nothing. Should be handled by vk::Buffer::Create().
1531 break;
1532 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05001533 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001534 break;
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001535 }
1536 nextInfo = nextInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -04001537 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001538
Alexis Hetu38ff8302018-10-18 15:08:13 -04001539 return vk::Buffer::Create(pAllocator, pCreateInfo, pBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04001540}
1541
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001542VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001543{
Ben Claytonfb280672019-04-25 11:16:15 +01001544 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001545 device, static_cast<void *>(buffer), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001546
Alexis Hetu38ff8302018-10-18 15:08:13 -04001547 vk::destroy(buffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001548}
1549
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001550VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
Alexis Hetud73b8712018-09-21 15:14:43 -04001551{
Ben Claytonfb280672019-04-25 11:16:15 +01001552 TRACE("(VkDevice device = %p, const VkBufferViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBufferView* pView = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001553 device, pCreateInfo, pAllocator, pView);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001554
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001555 if(pCreateInfo->flags != 0)
Alexis Hetu38ff8302018-10-18 15:08:13 -04001556 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001557 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1558 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001559 }
1560
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001561 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001562 while(extInfo)
1563 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001564 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001565 extInfo = extInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -04001566 }
1567
1568 return vk::BufferView::Create(pAllocator, pCreateInfo, pView);
Alexis Hetud73b8712018-09-21 15:14:43 -04001569}
1570
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001571VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001572{
Ben Claytonfb280672019-04-25 11:16:15 +01001573 TRACE("(VkDevice device = %p, VkBufferView bufferView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001574 device, static_cast<void *>(bufferView), pAllocator);
Alexis Hetu38ff8302018-10-18 15:08:13 -04001575
1576 vk::destroy(bufferView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001577}
1578
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001579VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage)
Alexis Hetud73b8712018-09-21 15:14:43 -04001580{
Ben Claytonfb280672019-04-25 11:16:15 +01001581 TRACE("(VkDevice device = %p, const VkImageCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImage* pImage = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001582 device, pCreateInfo, pAllocator, pImage);
Alexis Hetud73b8712018-09-21 15:14:43 -04001583
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001584 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Hernan Liatis628604e2019-05-07 15:30:18 -07001585
1586#ifdef __ANDROID__
Alexis Hetu52445952019-10-31 17:51:07 -04001587 vk::BackingMemory backmem;
Hernan Liatis628604e2019-05-07 15:30:18 -07001588 bool swapchainImage = false;
1589#endif
1590
1591 while(extensionCreateInfo)
Alexis Hetuf62f3752018-11-15 14:51:15 -05001592 {
Hernan Liatis628604e2019-05-07 15:30:18 -07001593 switch((long)(extensionCreateInfo->sType))
1594 {
1595#ifdef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001596 case VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID:
1597 {
1598 const VkSwapchainImageCreateInfoANDROID *swapImageCreateInfo = reinterpret_cast<const VkSwapchainImageCreateInfoANDROID *>(extensionCreateInfo);
1599 backmem.androidUsage = swapImageCreateInfo->usage;
1600 }
1601 break;
1602 case VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID:
1603 {
1604 const VkNativeBufferANDROID *nativeBufferInfo = reinterpret_cast<const VkNativeBufferANDROID *>(extensionCreateInfo);
1605 backmem.nativeHandle = nativeBufferInfo->handle;
1606 backmem.stride = nativeBufferInfo->stride;
1607 swapchainImage = true;
1608 }
1609 break;
Hernan Liatis628604e2019-05-07 15:30:18 -07001610#endif
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001611 case VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO:
1612 // Do nothing. Should be handled by vk::Image::Create()
1613 break;
1614 case VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR:
1615 /* Do nothing. We don't actually need the swapchain handle yet; we'll do all the work in vkBindImageMemory2. */
1616 break;
1617 default:
1618 // "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]"
Sean Risserc1e60dc2020-02-19 12:52:24 -05001619 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001620 break;
Hernan Liatis628604e2019-05-07 15:30:18 -07001621 }
1622
1623 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetuf62f3752018-11-15 14:51:15 -05001624 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001625
Nicolas Capens0c736802019-05-27 12:53:31 -04001626 VkResult result = vk::Image::Create(pAllocator, pCreateInfo, pImage, vk::Cast(device));
Hernan Liatis628604e2019-05-07 15:30:18 -07001627
1628#ifdef __ANDROID__
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001629 if(swapchainImage)
Hernan Liatis628604e2019-05-07 15:30:18 -07001630 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -05001631 if(result != VK_SUCCESS)
Hernan Liatis628604e2019-05-07 15:30:18 -07001632 {
1633 return result;
1634 }
1635
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001636 vk::Image *image = vk::Cast(*pImage);
Alexis Hetu52445952019-10-31 17:51:07 -04001637 VkMemoryRequirements memRequirements = image->getMemoryRequirements();
Hernan Liatis628604e2019-05-07 15:30:18 -07001638
1639 VkMemoryAllocateInfo allocInfo = {};
1640 allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
1641 allocInfo.allocationSize = memRequirements.size;
1642 allocInfo.memoryTypeIndex = 0;
1643
Alexis Hetu82feec72019-06-19 12:42:38 -04001644 VkDeviceMemory devmem = { VK_NULL_HANDLE };
Alexis Hetu52445952019-10-31 17:51:07 -04001645 result = vkAllocateMemory(device, &allocInfo, pAllocator, &devmem);
Hernan Liatis628604e2019-05-07 15:30:18 -07001646 if(result != VK_SUCCESS)
1647 {
1648 return result;
1649 }
1650
Hernan Liatis3c735072019-06-10 15:07:18 -07001651 vkBindImageMemory(device, *pImage, devmem, 0);
Alexis Hetu52445952019-10-31 17:51:07 -04001652 backmem.externalMemory = true;
Hernan Liatis3c735072019-06-10 15:07:18 -07001653
Alexis Hetu52445952019-10-31 17:51:07 -04001654 image->setBackingMemory(backmem);
Hernan Liatis628604e2019-05-07 15:30:18 -07001655 }
1656#endif
1657
1658 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -04001659}
1660
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001661VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001662{
Ben Claytonfb280672019-04-25 11:16:15 +01001663 TRACE("(VkDevice device = %p, VkImage image = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001664 device, static_cast<void *>(image), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001665
Hernan Liatisf988cb52019-05-22 15:06:19 -07001666#ifdef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001667 vk::Image *img = vk::Cast(image);
Alexis Hetu52445952019-10-31 17:51:07 -04001668 if(img && img->hasExternalMemory())
Hernan Liatisf988cb52019-05-22 15:06:19 -07001669 {
Alexis Hetu52445952019-10-31 17:51:07 -04001670 vk::destroy(img->getExternalMemory(), pAllocator);
Hernan Liatisf988cb52019-05-22 15:06:19 -07001671 }
1672#endif
David 'Digit' Turner359bc802019-08-14 17:46:07 +02001673
1674 vk::destroy(image, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001675}
1676
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001677VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, VkSubresourceLayout *pLayout)
Alexis Hetud73b8712018-09-21 15:14:43 -04001678{
Ben Claytonfb280672019-04-25 11:16:15 +01001679 TRACE("(VkDevice device = %p, VkImage image = %p, const VkImageSubresource* pSubresource = %p, VkSubresourceLayout* pLayout = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001680 device, static_cast<void *>(image), pSubresource, pLayout);
Alexis Hetu6ab37b02019-01-24 17:02:45 -05001681
1682 vk::Cast(image)->getSubresourceLayout(pSubresource, pLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001683}
1684
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001685VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
Alexis Hetud73b8712018-09-21 15:14:43 -04001686{
Ben Claytonfb280672019-04-25 11:16:15 +01001687 TRACE("(VkDevice device = %p, const VkImageViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImageView* pView = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001688 device, pCreateInfo, pAllocator, pView);
Alexis Hetud73b8712018-09-21 15:14:43 -04001689
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001690 if(pCreateInfo->flags != 0)
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001691 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001692 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu60da1582019-04-05 16:34:38 -04001693 }
1694
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001695 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Nicolas Capens6b63c802019-05-16 11:10:34 -04001696 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
Alexis Hetu60da1582019-04-05 16:34:38 -04001697
1698 while(extensionCreateInfo)
1699 {
1700 switch(extensionCreateInfo->sType)
1701 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001702 case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR:
Alexis Hetu60da1582019-04-05 16:34:38 -04001703 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001704 const VkImageViewUsageCreateInfo *multiviewCreateInfo = reinterpret_cast<const VkImageViewUsageCreateInfo *>(extensionCreateInfo);
1705 ASSERT(!(~vk::Cast(pCreateInfo->image)->getUsage() & multiviewCreateInfo->usage));
Alexis Hetu60da1582019-04-05 16:34:38 -04001706 }
Alexis Hetu60da1582019-04-05 16:34:38 -04001707 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001708 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
1709 {
1710 const VkSamplerYcbcrConversionInfo *samplerYcbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo *>(extensionCreateInfo);
1711 ycbcrConversion = vk::Cast(samplerYcbcrConversionInfo->conversion);
1712
1713 if(ycbcrConversion)
1714 {
1715 ASSERT((pCreateInfo->components.r == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1716 (pCreateInfo->components.g == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1717 (pCreateInfo->components.b == VK_COMPONENT_SWIZZLE_IDENTITY) &&
1718 (pCreateInfo->components.a == VK_COMPONENT_SWIZZLE_IDENTITY));
1719 }
1720 }
1721 break;
1722 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05001723 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001724 break;
Alexis Hetu60da1582019-04-05 16:34:38 -04001725 }
1726
1727 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001728 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001729
Nicolas Capens6b63c802019-05-16 11:10:34 -04001730 return vk::ImageView::Create(pAllocator, pCreateInfo, pView, ycbcrConversion);
Alexis Hetud73b8712018-09-21 15:14:43 -04001731}
1732
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001733VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001734{
Ben Claytonfb280672019-04-25 11:16:15 +01001735 TRACE("(VkDevice device = %p, VkImageView imageView = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001736 device, static_cast<void *>(imageView), pAllocator);
Alexis Hetu9fbaf692018-11-19 11:30:43 -05001737
1738 vk::destroy(imageView, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001739}
1740
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001741VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkShaderModule *pShaderModule)
Alexis Hetud73b8712018-09-21 15:14:43 -04001742{
Ben Claytonfb280672019-04-25 11:16:15 +01001743 TRACE("(VkDevice device = %p, const VkShaderModuleCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkShaderModule* pShaderModule = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001744 device, pCreateInfo, pAllocator, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -04001745
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001746 if(pCreateInfo->flags != 0)
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001747 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001748 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1749 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001750 }
1751
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001752 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001753 while(nextInfo)
1754 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001755 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001756 nextInfo = nextInfo->pNext;
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001757 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001758
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001759 return vk::ShaderModule::Create(pAllocator, pCreateInfo, pShaderModule);
Alexis Hetud73b8712018-09-21 15:14:43 -04001760}
1761
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001762VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001763{
Ben Claytonfb280672019-04-25 11:16:15 +01001764 TRACE("(VkDevice device = %p, VkShaderModule shaderModule = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001765 device, static_cast<void *>(shaderModule), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001766
Alexis Hetu259ad3d2018-11-15 13:44:31 -05001767 vk::destroy(shaderModule, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001768}
1769
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001770VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineCache *pPipelineCache)
Alexis Hetud73b8712018-09-21 15:14:43 -04001771{
Ben Claytonfb280672019-04-25 11:16:15 +01001772 TRACE("(VkDevice device = %p, const VkPipelineCacheCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineCache* pPipelineCache = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001773 device, pCreateInfo, pAllocator, pPipelineCache);
Alexis Hetu18a84252018-11-19 11:30:43 -05001774
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001775 if(pCreateInfo->flags != 0)
Alexis Hetu18a84252018-11-19 11:30:43 -05001776 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001777 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1778 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001779 }
1780
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001781 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001782 while(extInfo)
1783 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001784 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001785 extInfo = extInfo->pNext;
Alexis Hetu18a84252018-11-19 11:30:43 -05001786 }
1787
1788 return vk::PipelineCache::Create(pAllocator, pCreateInfo, pPipelineCache);
Alexis Hetud73b8712018-09-21 15:14:43 -04001789}
1790
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001791VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001792{
Ben Claytonfb280672019-04-25 11:16:15 +01001793 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001794 device, static_cast<void *>(pipelineCache), pAllocator);
Alexis Hetu18a84252018-11-19 11:30:43 -05001795
1796 vk::destroy(pipelineCache, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001797}
1798
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001799VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t *pDataSize, void *pData)
Alexis Hetud73b8712018-09-21 15:14:43 -04001800{
Ben Claytonfb280672019-04-25 11:16:15 +01001801 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, size_t* pDataSize = %p, void* pData = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001802 device, static_cast<void *>(pipelineCache), pDataSize, pData);
Alexis Hetu1424ef62019-04-05 18:03:53 -04001803
1804 return vk::Cast(pipelineCache)->getData(pDataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04001805}
1806
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001807VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache *pSrcCaches)
Alexis Hetud73b8712018-09-21 15:14:43 -04001808{
Ben Claytonfb280672019-04-25 11:16:15 +01001809 TRACE("(VkDevice device = %p, VkPipelineCache dstCache = %p, uint32_t srcCacheCount = %d, const VkPipelineCache* pSrcCaches = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001810 device, static_cast<void *>(dstCache), int(srcCacheCount), pSrcCaches);
Alexis Hetu1424ef62019-04-05 18:03:53 -04001811
1812 return vk::Cast(dstCache)->merge(srcCacheCount, pSrcCaches);
Alexis Hetud73b8712018-09-21 15:14:43 -04001813}
1814
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001815VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
Alexis Hetud73b8712018-09-21 15:14:43 -04001816{
Ben Claytonfb280672019-04-25 11:16:15 +01001817 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkGraphicsPipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001818 device, static_cast<void *>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001819
Alexis Hetu000df8b2018-10-24 15:22:41 -04001820 VkResult errorResult = VK_SUCCESS;
1821 for(uint32_t i = 0; i < createInfoCount; i++)
1822 {
Nicolas Capensa29aa772019-06-26 00:36:28 -04001823 VkResult result = vk::GraphicsPipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i], vk::Cast(device));
1824
Ben Claytonf2be26a2019-03-08 12:02:05 +00001825 if(result == VK_SUCCESS)
1826 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001827 static_cast<vk::GraphicsPipeline *>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i], vk::Cast(pipelineCache));
Ben Claytonf2be26a2019-03-08 12:02:05 +00001828 }
1829 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001830 {
1831 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1832 // "When an application attempts to create many pipelines in a single command,
1833 // it is possible that some subset may fail creation. In that case, the
1834 // corresponding entries in the pPipelines output array will be filled with
1835 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1836 // out of memory errors), the vkCreate*Pipelines commands will return an
1837 // error code. The implementation will attempt to create all pipelines, and
1838 // only return VK_NULL_HANDLE values for those that actually failed."
1839 pPipelines[i] = VK_NULL_HANDLE;
1840 errorResult = result;
1841 }
1842 }
1843
1844 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001845}
1846
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001847VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
Alexis Hetud73b8712018-09-21 15:14:43 -04001848{
Ben Claytonfb280672019-04-25 11:16:15 +01001849 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkComputePipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001850 device, static_cast<void *>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
Alexis Hetud73b8712018-09-21 15:14:43 -04001851
Alexis Hetu000df8b2018-10-24 15:22:41 -04001852 VkResult errorResult = VK_SUCCESS;
1853 for(uint32_t i = 0; i < createInfoCount; i++)
1854 {
Nicolas Capensa29aa772019-06-26 00:36:28 -04001855 VkResult result = vk::ComputePipeline::Create(pAllocator, &pCreateInfos[i], &pPipelines[i], vk::Cast(device));
1856
Ben Claytonf2be26a2019-03-08 12:02:05 +00001857 if(result == VK_SUCCESS)
1858 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001859 static_cast<vk::ComputePipeline *>(vk::Cast(pPipelines[i]))->compileShaders(pAllocator, &pCreateInfos[i], vk::Cast(pipelineCache));
Ben Claytonf2be26a2019-03-08 12:02:05 +00001860 }
1861 else
Alexis Hetu000df8b2018-10-24 15:22:41 -04001862 {
1863 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
1864 // "When an application attempts to create many pipelines in a single command,
1865 // it is possible that some subset may fail creation. In that case, the
1866 // corresponding entries in the pPipelines output array will be filled with
1867 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
1868 // out of memory errors), the vkCreate*Pipelines commands will return an
1869 // error code. The implementation will attempt to create all pipelines, and
1870 // only return VK_NULL_HANDLE values for those that actually failed."
1871 pPipelines[i] = VK_NULL_HANDLE;
1872 errorResult = result;
1873 }
1874 }
1875
1876 return errorResult;
Alexis Hetud73b8712018-09-21 15:14:43 -04001877}
1878
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001879VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001880{
Ben Claytonfb280672019-04-25 11:16:15 +01001881 TRACE("(VkDevice device = %p, VkPipeline pipeline = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001882 device, static_cast<void *>(pipeline), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001883
Alexis Hetu000df8b2018-10-24 15:22:41 -04001884 vk::destroy(pipeline, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001885}
1886
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001887VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout)
Alexis Hetud73b8712018-09-21 15:14:43 -04001888{
Ben Claytonfb280672019-04-25 11:16:15 +01001889 TRACE("(VkDevice device = %p, const VkPipelineLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineLayout* pPipelineLayout = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001890 device, pCreateInfo, pAllocator, pPipelineLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001891
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001892 if(pCreateInfo->flags != 0)
Alexis Hetu000df8b2018-10-24 15:22:41 -04001893 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001894 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1895 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001896 }
1897
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001898 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001899 while(nextInfo)
1900 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05001901 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05001902 nextInfo = nextInfo->pNext;
Alexis Hetu000df8b2018-10-24 15:22:41 -04001903 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001904
Alexis Hetu000df8b2018-10-24 15:22:41 -04001905 return vk::PipelineLayout::Create(pAllocator, pCreateInfo, pPipelineLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04001906}
1907
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001908VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001909{
Ben Claytonfb280672019-04-25 11:16:15 +01001910 TRACE("(VkDevice device = %p, VkPipelineLayout pipelineLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001911 device, static_cast<void *>(pipelineLayout), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001912
Trevor David Black3ad285a2020-05-26 19:28:05 +00001913 vk::release(pipelineLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001914}
1915
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001916VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler)
Alexis Hetud73b8712018-09-21 15:14:43 -04001917{
Ben Claytonfb280672019-04-25 11:16:15 +01001918 TRACE("(VkDevice device = %p, const VkSamplerCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSampler* pSampler = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001919 device, pCreateInfo, pAllocator, pSampler);
Alexis Hetud73b8712018-09-21 15:14:43 -04001920
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001921 if(pCreateInfo->flags != 0)
Alexis Hetu5174c572018-11-19 11:30:43 -05001922 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05001923 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu5174c572018-11-19 11:30:43 -05001924 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001925
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001926 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Nicolas Capens6b63c802019-05-16 11:10:34 -04001927 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
Antonio Maioranod9ba4b72020-05-04 14:38:59 -04001928 VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision = VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE;
Nicolas Capens6b63c802019-05-16 11:10:34 -04001929
1930 while(extensionCreateInfo)
1931 {
Antonio Maioranod9ba4b72020-05-04 14:38:59 -04001932 switch(static_cast<long>(extensionCreateInfo->sType))
Nicolas Capens6b63c802019-05-16 11:10:34 -04001933 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001934 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
Nicolas Capens6b63c802019-05-16 11:10:34 -04001935 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001936 const VkSamplerYcbcrConversionInfo *samplerYcbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo *>(extensionCreateInfo);
Nicolas Capens6b63c802019-05-16 11:10:34 -04001937 ycbcrConversion = vk::Cast(samplerYcbcrConversionInfo->conversion);
1938 }
1939 break;
Antonio Maioranod9ba4b72020-05-04 14:38:59 -04001940 case VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE:
1941 {
1942 const VkSamplerFilteringPrecisionGOOGLE *filteringInfo =
1943 reinterpret_cast<const VkSamplerFilteringPrecisionGOOGLE *>(extensionCreateInfo);
1944 filteringPrecision = filteringInfo->samplerFilteringPrecisionMode;
1945 }
1946 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001947 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05001948 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001949 break;
Nicolas Capens6b63c802019-05-16 11:10:34 -04001950 }
1951
1952 extensionCreateInfo = extensionCreateInfo->pNext;
1953 }
1954
Antonio Maioranod9ba4b72020-05-04 14:38:59 -04001955 vk::SamplerState samplerState(pCreateInfo, ycbcrConversion, filteringPrecision);
Nicolas Capens73c4a0c2020-03-17 17:29:11 -04001956 uint32_t samplerID = vk::Cast(device)->indexSampler(samplerState);
1957
1958 VkResult result = vk::Sampler::Create(pAllocator, pCreateInfo, pSampler, samplerState, samplerID);
1959
1960 if(*pSampler == VK_NULL_HANDLE)
1961 {
1962 ASSERT(result != VK_SUCCESS);
1963 vk::Cast(device)->removeSampler(samplerState);
1964 }
1965
1966 return result;
Alexis Hetud73b8712018-09-21 15:14:43 -04001967}
1968
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001969VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04001970{
Ben Claytonfb280672019-04-25 11:16:15 +01001971 TRACE("(VkDevice device = %p, VkSampler sampler = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001972 device, static_cast<void *>(sampler), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04001973
Nicolas Capens73c4a0c2020-03-17 17:29:11 -04001974 if(sampler != VK_NULL_HANDLE)
1975 {
1976 vk::Cast(device)->removeSampler(*vk::Cast(sampler));
1977
1978 vk::destroy(sampler, pAllocator);
1979 }
Alexis Hetud73b8712018-09-21 15:14:43 -04001980}
1981
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001982VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout)
Alexis Hetud73b8712018-09-21 15:14:43 -04001983{
Ben Claytonfb280672019-04-25 11:16:15 +01001984 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorSetLayout* pSetLayout = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05001985 device, pCreateInfo, pAllocator, pSetLayout);
1986
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001987 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu1300ba12019-05-07 15:47:11 -04001988
1989 while(extensionCreateInfo)
Alexis Hetuc8176632019-01-22 17:01:28 -05001990 {
Alexis Hetu1300ba12019-05-07 15:47:11 -04001991 switch(extensionCreateInfo->sType)
1992 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001993 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT:
1994 ASSERT(!vk::Cast(device)->hasExtension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME));
1995 break;
1996 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05001997 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00001998 break;
Alexis Hetu1300ba12019-05-07 15:47:11 -04001999 }
2000
2001 extensionCreateInfo = extensionCreateInfo->pNext;
Alexis Hetuc8176632019-01-22 17:01:28 -05002002 }
2003
2004 return vk::DescriptorSetLayout::Create(pAllocator, pCreateInfo, pSetLayout);
Alexis Hetud73b8712018-09-21 15:14:43 -04002005}
2006
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002007VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04002008{
Ben Claytonfb280672019-04-25 11:16:15 +01002009 TRACE("(VkDevice device = %p, VkDescriptorSetLayout descriptorSetLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002010 device, static_cast<void *>(descriptorSetLayout), pAllocator);
Alexis Hetuc8176632019-01-22 17:01:28 -05002011
2012 vk::destroy(descriptorSetLayout, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002013}
2014
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002015VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool)
Alexis Hetud73b8712018-09-21 15:14:43 -04002016{
Ben Claytonfb280672019-04-25 11:16:15 +01002017 TRACE("(VkDevice device = %p, const VkDescriptorPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorPool* pDescriptorPool = %p)",
Alexis Hetuc8176632019-01-22 17:01:28 -05002018 device, pCreateInfo, pAllocator, pDescriptorPool);
2019
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002020 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002021 while(extInfo)
Alexis Hetuc8176632019-01-22 17:01:28 -05002022 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002023 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002024 extInfo = extInfo->pNext;
Alexis Hetuc8176632019-01-22 17:01:28 -05002025 }
2026
2027 return vk::DescriptorPool::Create(pAllocator, pCreateInfo, pDescriptorPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04002028}
2029
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002030VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04002031{
Ben Claytonfb280672019-04-25 11:16:15 +01002032 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002033 device, static_cast<void *>(descriptorPool), pAllocator);
Alexis Hetuc8176632019-01-22 17:01:28 -05002034
2035 vk::destroy(descriptorPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002036}
2037
2038VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
2039{
Ben Claytonfb280672019-04-25 11:16:15 +01002040 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, VkDescriptorPoolResetFlags flags = 0x%x)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002041 device, static_cast<void *>(descriptorPool), int(flags));
Alexis Hetuc8176632019-01-22 17:01:28 -05002042
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002043 if(flags != 0)
Alexis Hetuc8176632019-01-22 17:01:28 -05002044 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002045 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2046 UNSUPPORTED("flags %d", int(flags));
Alexis Hetuc8176632019-01-22 17:01:28 -05002047 }
2048
2049 return vk::Cast(descriptorPool)->reset();
Alexis Hetud73b8712018-09-21 15:14:43 -04002050}
2051
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002052VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets)
Alexis Hetud73b8712018-09-21 15:14:43 -04002053{
Ben Claytonfb280672019-04-25 11:16:15 +01002054 TRACE("(VkDevice device = %p, const VkDescriptorSetAllocateInfo* pAllocateInfo = %p, VkDescriptorSet* pDescriptorSets = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002055 device, pAllocateInfo, pDescriptorSets);
Alexis Hetuc8176632019-01-22 17:01:28 -05002056
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002057 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pAllocateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002058 while(extInfo)
Alexis Hetuc8176632019-01-22 17:01:28 -05002059 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002060 LOG_TRAP("pAllocateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002061 extInfo = extInfo->pNext;
Alexis Hetuc8176632019-01-22 17:01:28 -05002062 }
2063
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002064 return vk::Cast(pAllocateInfo->descriptorPool)->allocateSets(pAllocateInfo->descriptorSetCount, pAllocateInfo->pSetLayouts, pDescriptorSets);
Alexis Hetud73b8712018-09-21 15:14:43 -04002065}
2066
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002067VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets)
Alexis Hetud73b8712018-09-21 15:14:43 -04002068{
Ben Claytonfb280672019-04-25 11:16:15 +01002069 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002070 device, static_cast<void *>(descriptorPool), descriptorSetCount, pDescriptorSets);
Alexis Hetuc8176632019-01-22 17:01:28 -05002071
2072 vk::Cast(descriptorPool)->freeSets(descriptorSetCount, pDescriptorSets);
2073
Alexis Hetud73b8712018-09-21 15:14:43 -04002074 return VK_SUCCESS;
2075}
2076
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002077VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
Alexis Hetud73b8712018-09-21 15:14:43 -04002078{
Ben Claytonfb280672019-04-25 11:16:15 +01002079 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 -05002080 device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
2081
2082 vk::Cast(device)->updateDescriptorSets(descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
Alexis Hetud73b8712018-09-21 15:14:43 -04002083}
2084
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002085VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer)
Alexis Hetud73b8712018-09-21 15:14:43 -04002086{
Ben Claytonfb280672019-04-25 11:16:15 +01002087 TRACE("(VkDevice device = %p, const VkFramebufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFramebuffer* pFramebuffer = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002088 device, pCreateInfo, pAllocator, pFramebuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04002089
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002090 if(pCreateInfo->flags != 0)
Alexis Hetu8f631c82018-11-15 15:11:36 -05002091 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002092 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002093 }
2094
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002095 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002096 while(nextInfo)
2097 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002098 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002099 nextInfo = nextInfo->pNext;
Alexis Hetu8f631c82018-11-15 15:11:36 -05002100 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002101
Alexis Hetu8f631c82018-11-15 15:11:36 -05002102 return vk::Framebuffer::Create(pAllocator, pCreateInfo, pFramebuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04002103}
2104
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002105VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04002106{
Ben Claytonfb280672019-04-25 11:16:15 +01002107 TRACE("(VkDevice device = %p, VkFramebuffer framebuffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002108 device, static_cast<void *>(framebuffer), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002109
Alexis Hetu8f631c82018-11-15 15:11:36 -05002110 vk::destroy(framebuffer, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002111}
2112
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002113VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
Alexis Hetud73b8712018-09-21 15:14:43 -04002114{
Ben Claytonfb280672019-04-25 11:16:15 +01002115 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002116 device, pCreateInfo, pAllocator, pRenderPass);
Alexis Hetud73b8712018-09-21 15:14:43 -04002117
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002118 if(pCreateInfo->flags != 0)
Alexis Hetub16f9892018-11-15 15:18:41 -05002119 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002120 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2121 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetu67806a12019-04-05 14:12:27 -04002122 }
2123
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002124 ValidateRenderPassPNextChain(device, pCreateInfo);
Alexis Hetu67806a12019-04-05 14:12:27 -04002125
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002126 return vk::RenderPass::Create(pAllocator, pCreateInfo, pRenderPass);
2127}
2128
2129VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
2130{
2131 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
2132 device, pCreateInfo, pAllocator, pRenderPass);
2133
2134 if(pCreateInfo->flags != 0)
Alexis Hetu67806a12019-04-05 14:12:27 -04002135 {
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002136 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2137 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
Alexis Hetub16f9892018-11-15 15:18:41 -05002138 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002139
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002140 ValidateRenderPassPNextChain(device, pCreateInfo);
2141
Alexis Hetub16f9892018-11-15 15:18:41 -05002142 return vk::RenderPass::Create(pAllocator, pCreateInfo, pRenderPass);
Alexis Hetud73b8712018-09-21 15:14:43 -04002143}
2144
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002145VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04002146{
Ben Claytonfb280672019-04-25 11:16:15 +01002147 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002148 device, static_cast<void *>(renderPass), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002149
Alexis Hetub16f9892018-11-15 15:18:41 -05002150 vk::destroy(renderPass, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002151}
2152
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002153VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D *pGranularity)
Alexis Hetud73b8712018-09-21 15:14:43 -04002154{
Ben Claytonfb280672019-04-25 11:16:15 +01002155 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, VkExtent2D* pGranularity = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002156 device, static_cast<void *>(renderPass), pGranularity);
Hernan Liatisc7943e92019-02-25 19:29:54 -08002157
Alexis Hetu6d74ab82019-02-15 14:42:38 -05002158 vk::Cast(renderPass)->getRenderAreaGranularity(pGranularity);
Alexis Hetud73b8712018-09-21 15:14:43 -04002159}
2160
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002161VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
Alexis Hetud73b8712018-09-21 15:14:43 -04002162{
Ben Claytonfb280672019-04-25 11:16:15 +01002163 TRACE("(VkDevice device = %p, const VkCommandPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkCommandPool* pCommandPool = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002164 device, pCreateInfo, pAllocator, pCommandPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04002165
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002166 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002167 while(nextInfo)
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05002168 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002169 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002170 nextInfo = nextInfo->pNext;
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05002171 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002172
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05002173 return vk::CommandPool::Create(pAllocator, pCreateInfo, pCommandPool);
Alexis Hetud73b8712018-09-21 15:14:43 -04002174}
2175
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002176VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04002177{
Ben Claytonfb280672019-04-25 11:16:15 +01002178 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002179 device, static_cast<void *>(commandPool), pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002180
Alexis Hetu9c4ecae2018-11-20 16:26:10 -05002181 vk::destroy(commandPool, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04002182}
2183
2184VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
2185{
Ben Claytonfb280672019-04-25 11:16:15 +01002186 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolResetFlags flags = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002187 device, static_cast<void *>(commandPool), int(flags));
Alexis Hetucd610c92019-02-01 16:47:51 -05002188
2189 return vk::Cast(commandPool)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002190}
2191
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002192VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
Alexis Hetud73b8712018-09-21 15:14:43 -04002193{
Ben Claytonfb280672019-04-25 11:16:15 +01002194 TRACE("(VkDevice device = %p, const VkCommandBufferAllocateInfo* pAllocateInfo = %p, VkCommandBuffer* pCommandBuffers = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002195 device, pAllocateInfo, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002196
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002197 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pAllocateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002198 while(nextInfo)
Alexis Hetubffee5e2018-11-19 11:30:43 -05002199 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002200 LOG_TRAP("pAllocateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002201 nextInfo = nextInfo->pNext;
Alexis Hetubffee5e2018-11-19 11:30:43 -05002202 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002203
Ben Claytona4e06ca2019-12-03 12:38:14 +00002204 return vk::Cast(pAllocateInfo->commandPool)->allocateCommandBuffers(vk::Cast(device), pAllocateInfo->level, pAllocateInfo->commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002205}
2206
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002207VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
Alexis Hetud73b8712018-09-21 15:14:43 -04002208{
Ben Claytonfb280672019-04-25 11:16:15 +01002209 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002210 device, static_cast<void *>(commandPool), int(commandBufferCount), pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002211
Alexis Hetubffee5e2018-11-19 11:30:43 -05002212 vk::Cast(commandPool)->freeCommandBuffers(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002213}
2214
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002215VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
Alexis Hetud73b8712018-09-21 15:14:43 -04002216{
Ben Claytonfb280672019-04-25 11:16:15 +01002217 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCommandBufferBeginInfo* pBeginInfo = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002218 commandBuffer, pBeginInfo);
Alexis Hetud73b8712018-09-21 15:14:43 -04002219
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002220 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pBeginInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002221 while(nextInfo)
Alexis Hetua9999ce2018-10-17 08:00:43 -04002222 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002223 LOG_TRAP("pBeginInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002224 nextInfo = nextInfo->pNext;
Alexis Hetua9999ce2018-10-17 08:00:43 -04002225 }
Alexis Hetud73b8712018-09-21 15:14:43 -04002226
Alexis Hetua9999ce2018-10-17 08:00:43 -04002227 return vk::Cast(commandBuffer)->begin(pBeginInfo->flags, pBeginInfo->pInheritanceInfo);
Alexis Hetud73b8712018-09-21 15:14:43 -04002228}
2229
2230VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
2231{
Ben Claytonfb280672019-04-25 11:16:15 +01002232 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04002233
Alexis Hetua9999ce2018-10-17 08:00:43 -04002234 return vk::Cast(commandBuffer)->end();
Alexis Hetud73b8712018-09-21 15:14:43 -04002235}
2236
2237VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags)
2238{
Ben Claytonfb280672019-04-25 11:16:15 +01002239 TRACE("VkCommandBuffer commandBuffer = %p, VkCommandBufferResetFlags flags = %d", commandBuffer, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002240
2241 return vk::Cast(commandBuffer)->reset(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002242}
2243
2244VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
2245{
Ben Claytonfb280672019-04-25 11:16:15 +01002246 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineBindPoint pipelineBindPoint = %d, VkPipeline pipeline = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002247 commandBuffer, int(pipelineBindPoint), static_cast<void *>(pipeline));
Alexis Hetud73b8712018-09-21 15:14:43 -04002248
Alexis Hetu7d96f512019-06-13 18:23:56 -04002249 vk::Cast(commandBuffer)->bindPipeline(pipelineBindPoint, vk::Cast(pipeline));
Alexis Hetud73b8712018-09-21 15:14:43 -04002250}
2251
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002252VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports)
Alexis Hetud73b8712018-09-21 15:14:43 -04002253{
Ben Claytonfb280672019-04-25 11:16:15 +01002254 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstViewport = %d, uint32_t viewportCount = %d, const VkViewport* pViewports = %p)",
2255 commandBuffer, int(firstViewport), int(viewportCount), pViewports);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002256
2257 vk::Cast(commandBuffer)->setViewport(firstViewport, viewportCount, pViewports);
Alexis Hetud73b8712018-09-21 15:14:43 -04002258}
2259
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002260VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors)
Alexis Hetud73b8712018-09-21 15:14:43 -04002261{
Ben Claytonfb280672019-04-25 11:16:15 +01002262 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstScissor = %d, uint32_t scissorCount = %d, const VkRect2D* pScissors = %p)",
2263 commandBuffer, int(firstScissor), int(scissorCount), pScissors);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002264
2265 vk::Cast(commandBuffer)->setScissor(firstScissor, scissorCount, pScissors);
Alexis Hetud73b8712018-09-21 15:14:43 -04002266}
2267
2268VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
2269{
Ben Claytonfb280672019-04-25 11:16:15 +01002270 TRACE("(VkCommandBuffer commandBuffer = %p, float lineWidth = %f)", commandBuffer, lineWidth);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002271
2272 vk::Cast(commandBuffer)->setLineWidth(lineWidth);
Alexis Hetud73b8712018-09-21 15:14:43 -04002273}
2274
2275VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
2276{
Ben Claytonfb280672019-04-25 11:16:15 +01002277 TRACE("(VkCommandBuffer commandBuffer = %p, float depthBiasConstantFactor = %f, float depthBiasClamp = %f, float depthBiasSlopeFactor = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002278 commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
2279
2280 vk::Cast(commandBuffer)->setDepthBias(depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
Alexis Hetud73b8712018-09-21 15:14:43 -04002281}
2282
2283VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
2284{
Ben Claytonfb280672019-04-25 11:16:15 +01002285 TRACE("(VkCommandBuffer commandBuffer = %p, const float blendConstants[4] = {%f, %f, %f, %f})",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002286 commandBuffer, blendConstants[0], blendConstants[1], blendConstants[2], blendConstants[3]);
2287
2288 vk::Cast(commandBuffer)->setBlendConstants(blendConstants);
Alexis Hetud73b8712018-09-21 15:14:43 -04002289}
2290
2291VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
2292{
Ben Claytonfb280672019-04-25 11:16:15 +01002293 TRACE("(VkCommandBuffer commandBuffer = %p, float minDepthBounds = %f, float maxDepthBounds = %f)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002294 commandBuffer, minDepthBounds, maxDepthBounds);
2295
2296 vk::Cast(commandBuffer)->setDepthBounds(minDepthBounds, maxDepthBounds);
Alexis Hetud73b8712018-09-21 15:14:43 -04002297}
2298
2299VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
2300{
Ben Claytonfb280672019-04-25 11:16:15 +01002301 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t compareMask = %d)",
2302 commandBuffer, int(faceMask), int(compareMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002303
2304 vk::Cast(commandBuffer)->setStencilCompareMask(faceMask, compareMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002305}
2306
2307VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
2308{
Ben Claytonfb280672019-04-25 11:16:15 +01002309 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t writeMask = %d)",
2310 commandBuffer, int(faceMask), int(writeMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002311
2312 vk::Cast(commandBuffer)->setStencilWriteMask(faceMask, writeMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002313}
2314
2315VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
2316{
Ben Claytonfb280672019-04-25 11:16:15 +01002317 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t reference = %d)",
2318 commandBuffer, int(faceMask), int(reference));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002319
2320 vk::Cast(commandBuffer)->setStencilReference(faceMask, reference);
Alexis Hetud73b8712018-09-21 15:14:43 -04002321}
2322
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002323VKAPI_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)
Alexis Hetud73b8712018-09-21 15:14:43 -04002324{
Ben Claytonfb280672019-04-25 11:16:15 +01002325 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)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002326 commandBuffer, int(pipelineBindPoint), static_cast<void *>(layout), int(firstSet), int(descriptorSetCount), pDescriptorSets, int(dynamicOffsetCount), pDynamicOffsets);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002327
Alexis Hetu7d96f512019-06-13 18:23:56 -04002328 vk::Cast(commandBuffer)->bindDescriptorSets(pipelineBindPoint, vk::Cast(layout), firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04002329}
2330
2331VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
2332{
Ben Claytonfb280672019-04-25 11:16:15 +01002333 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkIndexType indexType = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002334 commandBuffer, static_cast<void *>(buffer), int(offset), int(indexType));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002335
Alexis Hetu7d96f512019-06-13 18:23:56 -04002336 vk::Cast(commandBuffer)->bindIndexBuffer(vk::Cast(buffer), offset, indexType);
Alexis Hetud73b8712018-09-21 15:14:43 -04002337}
2338
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002339VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
Alexis Hetud73b8712018-09-21 15:14:43 -04002340{
Ben Claytonfb280672019-04-25 11:16:15 +01002341 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = %p, const VkDeviceSize* pOffsets = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002342 commandBuffer, int(firstBinding), int(bindingCount), pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04002343
Alexis Hetua9999ce2018-10-17 08:00:43 -04002344 vk::Cast(commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets);
Alexis Hetud73b8712018-09-21 15:14:43 -04002345}
2346
2347VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
2348{
Ben Claytonfb280672019-04-25 11:16:15 +01002349 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t vertexCount = %d, uint32_t instanceCount = %d, uint32_t firstVertex = %d, uint32_t firstInstance = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002350 commandBuffer, int(vertexCount), int(instanceCount), int(firstVertex), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04002351
Alexis Hetua9999ce2018-10-17 08:00:43 -04002352 vk::Cast(commandBuffer)->draw(vertexCount, instanceCount, firstVertex, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04002353}
2354
2355VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
2356{
Ben Claytonfb280672019-04-25 11:16:15 +01002357 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t indexCount = %d, uint32_t instanceCount = %d, uint32_t firstIndex = %d, int32_t vertexOffset = %d, uint32_t firstInstance = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002358 commandBuffer, int(indexCount), int(instanceCount), int(firstIndex), int(vertexOffset), int(firstInstance));
Alexis Hetud73b8712018-09-21 15:14:43 -04002359
Alexis Hetua9999ce2018-10-17 08:00:43 -04002360 vk::Cast(commandBuffer)->drawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
Alexis Hetud73b8712018-09-21 15:14:43 -04002361}
2362
2363VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
2364{
Ben Claytonfb280672019-04-25 11:16:15 +01002365 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002366 commandBuffer, static_cast<void *>(buffer), int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04002367
Alexis Hetu7d96f512019-06-13 18:23:56 -04002368 vk::Cast(commandBuffer)->drawIndirect(vk::Cast(buffer), offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04002369}
2370
2371VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
2372{
Ben Claytonfb280672019-04-25 11:16:15 +01002373 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002374 commandBuffer, static_cast<void *>(buffer), int(offset), int(drawCount), int(stride));
Alexis Hetud73b8712018-09-21 15:14:43 -04002375
Alexis Hetu7d96f512019-06-13 18:23:56 -04002376 vk::Cast(commandBuffer)->drawIndexedIndirect(vk::Cast(buffer), offset, drawCount, stride);
Alexis Hetud73b8712018-09-21 15:14:43 -04002377}
2378
2379VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
2380{
Ben Claytonfb280672019-04-25 11:16:15 +01002381 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t groupCountX = %d, uint32_t groupCountY = %d, uint32_t groupCountZ = %d)",
2382 commandBuffer, int(groupCountX), int(groupCountY), int(groupCountZ));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002383
2384 vk::Cast(commandBuffer)->dispatch(groupCountX, groupCountY, groupCountZ);
Alexis Hetud73b8712018-09-21 15:14:43 -04002385}
2386
2387VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
2388{
Ben Claytonfb280672019-04-25 11:16:15 +01002389 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002390 commandBuffer, static_cast<void *>(buffer), int(offset));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002391
Alexis Hetu7d96f512019-06-13 18:23:56 -04002392 vk::Cast(commandBuffer)->dispatchIndirect(vk::Cast(buffer), offset);
Alexis Hetud73b8712018-09-21 15:14:43 -04002393}
2394
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002395VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions)
Alexis Hetud73b8712018-09-21 15:14:43 -04002396{
Ben Claytonfb280672019-04-25 11:16:15 +01002397 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferCopy* pRegions = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002398 commandBuffer, static_cast<void *>(srcBuffer), static_cast<void *>(dstBuffer), int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002399
Alexis Hetu7d96f512019-06-13 18:23:56 -04002400 vk::Cast(commandBuffer)->copyBuffer(vk::Cast(srcBuffer), vk::Cast(dstBuffer), regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002401}
2402
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002403VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions)
Alexis Hetud73b8712018-09-21 15:14:43 -04002404{
Ben Claytonfb280672019-04-25 11:16:15 +01002405 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageCopy* pRegions = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002406 commandBuffer, static_cast<void *>(srcImage), srcImageLayout, static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002407
Alexis Hetu7d96f512019-06-13 18:23:56 -04002408 vk::Cast(commandBuffer)->copyImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002409}
2410
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002411VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
Alexis Hetud73b8712018-09-21 15:14:43 -04002412{
Ben Claytonfb280672019-04-25 11:16:15 +01002413 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)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002414 commandBuffer, static_cast<void *>(srcImage), srcImageLayout, static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions, filter);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002415
Alexis Hetu7d96f512019-06-13 18:23:56 -04002416 vk::Cast(commandBuffer)->blitImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions, filter);
Alexis Hetud73b8712018-09-21 15:14:43 -04002417}
2418
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002419VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions)
Alexis Hetud73b8712018-09-21 15:14:43 -04002420{
Ben Claytonfb280672019-04-25 11:16:15 +01002421 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002422 commandBuffer, static_cast<void *>(srcBuffer), static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002423
Alexis Hetu7d96f512019-06-13 18:23:56 -04002424 vk::Cast(commandBuffer)->copyBufferToImage(vk::Cast(srcBuffer), vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002425}
2426
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002427VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions)
Alexis Hetud73b8712018-09-21 15:14:43 -04002428{
Ben Claytonfb280672019-04-25 11:16:15 +01002429 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002430 commandBuffer, static_cast<void *>(srcImage), int(srcImageLayout), static_cast<void *>(dstBuffer), int(regionCount), pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002431
Alexis Hetu7d96f512019-06-13 18:23:56 -04002432 vk::Cast(commandBuffer)->copyImageToBuffer(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstBuffer), regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002433}
2434
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002435VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData)
Alexis Hetud73b8712018-09-21 15:14:43 -04002436{
Ben Claytonfb280672019-04-25 11:16:15 +01002437 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize dataSize = %d, const void* pData = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002438 commandBuffer, static_cast<void *>(dstBuffer), int(dstOffset), int(dataSize), pData);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002439
Alexis Hetu7d96f512019-06-13 18:23:56 -04002440 vk::Cast(commandBuffer)->updateBuffer(vk::Cast(dstBuffer), dstOffset, dataSize, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04002441}
2442
2443VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
2444{
Ben Claytonfb280672019-04-25 11:16:15 +01002445 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize size = %d, uint32_t data = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002446 commandBuffer, static_cast<void *>(dstBuffer), int(dstOffset), int(size), data);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002447
Alexis Hetu7d96f512019-06-13 18:23:56 -04002448 vk::Cast(commandBuffer)->fillBuffer(vk::Cast(dstBuffer), dstOffset, size, data);
Alexis Hetud73b8712018-09-21 15:14:43 -04002449}
2450
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002451VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
Alexis Hetud73b8712018-09-21 15:14:43 -04002452{
Ben Claytonfb280672019-04-25 11:16:15 +01002453 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearColorValue* pColor = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002454 commandBuffer, static_cast<void *>(image), int(imageLayout), pColor, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002455
Alexis Hetu7d96f512019-06-13 18:23:56 -04002456 vk::Cast(commandBuffer)->clearColorImage(vk::Cast(image), imageLayout, pColor, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04002457}
2458
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002459VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
Alexis Hetud73b8712018-09-21 15:14:43 -04002460{
Ben Claytonfb280672019-04-25 11:16:15 +01002461 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearDepthStencilValue* pDepthStencil = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002462 commandBuffer, static_cast<void *>(image), int(imageLayout), pDepthStencil, int(rangeCount), pRanges);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002463
Alexis Hetu7d96f512019-06-13 18:23:56 -04002464 vk::Cast(commandBuffer)->clearDepthStencilImage(vk::Cast(image), imageLayout, pDepthStencil, rangeCount, pRanges);
Alexis Hetud73b8712018-09-21 15:14:43 -04002465}
2466
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002467VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment *pAttachments, uint32_t rectCount, const VkClearRect *pRects)
Alexis Hetud73b8712018-09-21 15:14:43 -04002468{
Ben Claytonfb280672019-04-25 11:16:15 +01002469 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t attachmentCount = %d, const VkClearAttachment* pAttachments = %p, uint32_t rectCount = %d, const VkClearRect* pRects = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002470 commandBuffer, int(attachmentCount), pAttachments, int(rectCount), pRects);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002471
2472 vk::Cast(commandBuffer)->clearAttachments(attachmentCount, pAttachments, rectCount, pRects);
Alexis Hetud73b8712018-09-21 15:14:43 -04002473}
2474
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002475VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions)
Alexis Hetud73b8712018-09-21 15:14:43 -04002476{
Ben Claytonfb280672019-04-25 11:16:15 +01002477 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageResolve* pRegions = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002478 commandBuffer, static_cast<void *>(srcImage), int(srcImageLayout), static_cast<void *>(dstImage), int(dstImageLayout), regionCount, pRegions);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002479
Alexis Hetu7d96f512019-06-13 18:23:56 -04002480 vk::Cast(commandBuffer)->resolveImage(vk::Cast(srcImage), srcImageLayout, vk::Cast(dstImage), dstImageLayout, regionCount, pRegions);
Alexis Hetud73b8712018-09-21 15:14:43 -04002481}
2482
2483VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
2484{
Ben Claytonfb280672019-04-25 11:16:15 +01002485 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002486 commandBuffer, static_cast<void *>(event), int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002487
Alexis Hetu7d96f512019-06-13 18:23:56 -04002488 vk::Cast(commandBuffer)->setEvent(vk::Cast(event), stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002489}
2490
2491VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
2492{
Ben Claytonfb280672019-04-25 11:16:15 +01002493 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002494 commandBuffer, static_cast<void *>(event), int(stageMask));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002495
Alexis Hetu7d96f512019-06-13 18:23:56 -04002496 vk::Cast(commandBuffer)->resetEvent(vk::Cast(event), stageMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002497}
2498
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002499VKAPI_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)
Alexis Hetud73b8712018-09-21 15:14:43 -04002500{
Ben Claytonfb280672019-04-25 11:16:15 +01002501 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)",
2502 commandBuffer, int(eventCount), pEvents, int(srcStageMask), int(dstStageMask), int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002503
2504 vk::Cast(commandBuffer)->waitEvents(eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002505}
2506
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002507VKAPI_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)
Alexis Hetud73b8712018-09-21 15:14:43 -04002508{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002509 TRACE(
2510 "(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlags srcStageMask = 0x%x, VkPipelineStageFlags dstStageMask = 0x%x, VkDependencyFlags dependencyFlags = %d, uint32_t memoryBarrierCount = %d, onst VkMemoryBarrier* pMemoryBarriers = %p,"
2511 " uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
2512 commandBuffer, int(srcStageMask), int(dstStageMask), dependencyFlags, int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002513
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002514 vk::Cast(commandBuffer)->pipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002515}
2516
2517VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
2518{
Ben Claytonfb280672019-04-25 11:16:15 +01002519 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d, VkQueryControlFlags flags = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002520 commandBuffer, static_cast<void *>(queryPool), query, int(flags));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002521
Alexis Hetu7d96f512019-06-13 18:23:56 -04002522 vk::Cast(commandBuffer)->beginQuery(vk::Cast(queryPool), query, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002523}
2524
2525VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
2526{
Ben Claytonfb280672019-04-25 11:16:15 +01002527 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002528 commandBuffer, static_cast<void *>(queryPool), int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002529
Alexis Hetu7d96f512019-06-13 18:23:56 -04002530 vk::Cast(commandBuffer)->endQuery(vk::Cast(queryPool), query);
Alexis Hetud73b8712018-09-21 15:14:43 -04002531}
2532
2533VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
2534{
Ben Claytonfb280672019-04-25 11:16:15 +01002535 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002536 commandBuffer, static_cast<void *>(queryPool), int(firstQuery), int(queryCount));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002537
Alexis Hetu7d96f512019-06-13 18:23:56 -04002538 vk::Cast(commandBuffer)->resetQueryPool(vk::Cast(queryPool), firstQuery, queryCount);
Alexis Hetud73b8712018-09-21 15:14:43 -04002539}
2540
2541VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
2542{
Ben Claytonfb280672019-04-25 11:16:15 +01002543 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlagBits pipelineStage = %d, VkQueryPool queryPool = %p, uint32_t query = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002544 commandBuffer, int(pipelineStage), static_cast<void *>(queryPool), int(query));
Alexis Hetua9999ce2018-10-17 08:00:43 -04002545
Alexis Hetu7d96f512019-06-13 18:23:56 -04002546 vk::Cast(commandBuffer)->writeTimestamp(pipelineStage, vk::Cast(queryPool), query);
Alexis Hetud73b8712018-09-21 15:14:43 -04002547}
2548
2549VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
2550{
Ben Claytonfb280672019-04-25 11:16:15 +01002551 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)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002552 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 -04002553
Alexis Hetu7d96f512019-06-13 18:23:56 -04002554 vk::Cast(commandBuffer)->copyQueryPoolResults(vk::Cast(queryPool), firstQuery, queryCount, vk::Cast(dstBuffer), dstOffset, stride, flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04002555}
2556
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002557VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *pValues)
Alexis Hetud73b8712018-09-21 15:14:43 -04002558{
Ben Claytonfb280672019-04-25 11:16:15 +01002559 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineLayout layout = %p, VkShaderStageFlags stageFlags = %d, uint32_t offset = %d, uint32_t size = %d, const void* pValues = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002560 commandBuffer, static_cast<void *>(layout), stageFlags, offset, size, pValues);
Alexis Hetua9999ce2018-10-17 08:00:43 -04002561
Alexis Hetu7d96f512019-06-13 18:23:56 -04002562 vk::Cast(commandBuffer)->pushConstants(vk::Cast(layout), stageFlags, offset, size, pValues);
Alexis Hetud73b8712018-09-21 15:14:43 -04002563}
2564
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002565VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents)
Alexis Hetud73b8712018-09-21 15:14:43 -04002566{
Ben Claytonfb280672019-04-25 11:16:15 +01002567 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderPassBeginInfo* pRenderPassBegin = %p, VkSubpassContents contents = %d)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04002568 commandBuffer, pRenderPassBegin, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002569
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002570 const VkBaseInStructure *renderPassBeginInfo = reinterpret_cast<const VkBaseInStructure *>(pRenderPassBegin->pNext);
Alexis Hetu026ceef2019-05-07 17:35:11 -04002571 while(renderPassBeginInfo)
Alexis Hetua9999ce2018-10-17 08:00:43 -04002572 {
Alexis Hetu026ceef2019-05-07 17:35:11 -04002573 switch(renderPassBeginInfo->sType)
2574 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002575 case VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO:
2576 // This extension controls which render area is used on which physical device,
2577 // in order to distribute rendering between multiple physical devices.
2578 // SwiftShader only has a single physical device, so this extension does nothing in this case.
2579 break;
2580 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05002581 LOG_TRAP("pRenderPassBegin->pNext sType = %s", vk::Stringify(renderPassBeginInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002582 break;
Alexis Hetu026ceef2019-05-07 17:35:11 -04002583 }
2584
2585 renderPassBeginInfo = renderPassBeginInfo->pNext;
Alexis Hetua9999ce2018-10-17 08:00:43 -04002586 }
2587
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002588 vk::Cast(commandBuffer)->beginRenderPass(vk::Cast(pRenderPassBegin->renderPass), vk::Cast(pRenderPassBegin->framebuffer), pRenderPassBegin->renderArea, pRenderPassBegin->clearValueCount, pRenderPassBegin->pClearValues, contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002589}
2590
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002591VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, const VkSubpassBeginInfoKHR *pSubpassBeginInfo)
2592{
2593 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderPassBeginInfo* pRenderPassBegin = %p, const VkSubpassBeginInfoKHR* pSubpassBeginInfo = %p)",
2594 commandBuffer, pRenderPassBegin, pSubpassBeginInfo);
2595
2596 vk::Cast(commandBuffer)->beginRenderPass(vk::Cast(pRenderPassBegin->renderPass), vk::Cast(pRenderPassBegin->framebuffer), pRenderPassBegin->renderArea, pRenderPassBegin->clearValueCount, pRenderPassBegin->pClearValues, pSubpassBeginInfo->contents);
2597}
2598
Alexis Hetud73b8712018-09-21 15:14:43 -04002599VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
2600{
Ben Claytonfb280672019-04-25 11:16:15 +01002601 TRACE("(VkCommandBuffer commandBuffer = %p, VkSubpassContents contents = %d)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002602 commandBuffer, contents);
2603
2604 vk::Cast(commandBuffer)->nextSubpass(contents);
Alexis Hetud73b8712018-09-21 15:14:43 -04002605}
2606
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002607VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const VkSubpassEndInfoKHR *pSubpassEndInfo)
2608{
2609 TRACE("(VkCommandBuffer commandBuffer = %p, const VkSubpassBeginInfoKHR* pSubpassBeginInfo = %p, const VkSubpassEndInfoKHR* pSubpassEndInfo = %p)",
2610 commandBuffer, pSubpassBeginInfo, pSubpassEndInfo);
2611
2612 vk::Cast(commandBuffer)->nextSubpass(pSubpassBeginInfo->contents);
2613}
2614
Alexis Hetud73b8712018-09-21 15:14:43 -04002615VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
2616{
Ben Claytonfb280672019-04-25 11:16:15 +01002617 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
Alexis Hetud73b8712018-09-21 15:14:43 -04002618
Alexis Hetua9999ce2018-10-17 08:00:43 -04002619 vk::Cast(commandBuffer)->endRenderPass();
Alexis Hetud73b8712018-09-21 15:14:43 -04002620}
2621
Alexis Hetu9f8337e2020-02-07 11:07:43 -05002622VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo)
2623{
2624 TRACE("(VkCommandBuffer commandBuffer = %p, const VkSubpassEndInfoKHR* pSubpassEndInfo = %p)", commandBuffer, pSubpassEndInfo);
2625
2626 vk::Cast(commandBuffer)->endRenderPass();
2627}
2628
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002629VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
Alexis Hetud73b8712018-09-21 15:14:43 -04002630{
Ben Claytonfb280672019-04-25 11:16:15 +01002631 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
Alexis Hetua9999ce2018-10-17 08:00:43 -04002632 commandBuffer, commandBufferCount, pCommandBuffers);
2633
2634 vk::Cast(commandBuffer)->executeCommands(commandBufferCount, pCommandBuffers);
Alexis Hetud73b8712018-09-21 15:14:43 -04002635}
2636
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002637VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t *pApiVersion)
Alexis Hetud73b8712018-09-21 15:14:43 -04002638{
Ben Claytonfb280672019-04-25 11:16:15 +01002639 TRACE("(uint32_t* pApiVersion = %p)", pApiVersion);
Nicolas Capensee841c52018-11-13 14:18:26 -05002640 *pApiVersion = vk::API_VERSION;
Alexis Hetud73b8712018-09-21 15:14:43 -04002641 return VK_SUCCESS;
2642}
2643
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002644VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo *pBindInfos)
Alexis Hetud73b8712018-09-21 15:14:43 -04002645{
Ben Claytonfb280672019-04-25 11:16:15 +01002646 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = %p)",
Alexis Hetu38ff8302018-10-18 15:08:13 -04002647 device, bindInfoCount, pBindInfos);
2648
2649 for(uint32_t i = 0; i < bindInfoCount; i++)
2650 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002651 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pBindInfos[i].pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002652 while(extInfo)
Alexis Hetu38ff8302018-10-18 15:08:13 -04002653 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002654 LOG_TRAP("pBindInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002655 extInfo = extInfo->pNext;
Alexis Hetu38ff8302018-10-18 15:08:13 -04002656 }
2657
Nicolas Capens81bc9d92019-12-16 15:05:57 -05002658 if(!vk::Cast(pBindInfos[i].buffer)->canBindToMemory(vk::Cast(pBindInfos[i].memory)))
David 'Digit' Turner359bc802019-08-14 17:46:07 +02002659 {
2660 UNSUPPORTED("vkBindBufferMemory2 with invalid external memory");
2661 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
2662 }
2663 }
2664
Nicolas Capens81bc9d92019-12-16 15:05:57 -05002665 for(uint32_t i = 0; i < bindInfoCount; i++)
David 'Digit' Turner359bc802019-08-14 17:46:07 +02002666 {
Alexis Hetu7d96f512019-06-13 18:23:56 -04002667 vk::Cast(pBindInfos[i].buffer)->bind(vk::Cast(pBindInfos[i].memory), pBindInfos[i].memoryOffset);
Alexis Hetu38ff8302018-10-18 15:08:13 -04002668 }
2669
Alexis Hetud73b8712018-09-21 15:14:43 -04002670 return VK_SUCCESS;
2671}
2672
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002673VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo *pBindInfos)
Alexis Hetud73b8712018-09-21 15:14:43 -04002674{
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002675 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindImageMemoryInfo* pBindInfos = %p)",
2676 device, bindInfoCount, pBindInfos);
Nicolas Capens71c012b2019-05-22 13:31:52 -04002677
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002678 for(uint32_t i = 0; i < bindInfoCount; i++)
2679 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -05002680 if(!vk::Cast(pBindInfos[i].image)->canBindToMemory(vk::Cast(pBindInfos[i].memory)))
David 'Digit' Turner359bc802019-08-14 17:46:07 +02002681 {
2682 UNSUPPORTED("vkBindImageMemory2 with invalid external memory");
2683 return VK_ERROR_OUT_OF_DEVICE_MEMORY;
2684 }
2685 }
2686
2687 for(uint32_t i = 0; i < bindInfoCount; i++)
2688 {
Chris Forbes92577e52019-09-02 17:43:38 +01002689 vk::DeviceMemory *memory = vk::Cast(pBindInfos[i].memory);
2690 VkDeviceSize offset = pBindInfos[i].memoryOffset;
2691
2692 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pBindInfos[i].pNext);
Nicolas Capens81bc9d92019-12-16 15:05:57 -05002693 while(extInfo)
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002694 {
Nicolas Capens81bc9d92019-12-16 15:05:57 -05002695 switch(extInfo->sType)
Chris Forbes92577e52019-09-02 17:43:38 +01002696 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002697 case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO:
2698 /* Do nothing */
2699 break;
Chris Forbes92577e52019-09-02 17:43:38 +01002700
2701#ifndef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002702 case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR:
Chris Forbes92577e52019-09-02 17:43:38 +01002703 {
2704 auto swapchainInfo = reinterpret_cast<VkBindImageMemorySwapchainInfoKHR const *>(extInfo);
2705 memory = vk::Cast(swapchainInfo->swapchain)->getImage(swapchainInfo->imageIndex).getImageMemory();
2706 offset = 0;
2707 }
2708 break;
2709#endif
2710
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002711 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05002712 LOG_TRAP("pBindInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002713 break;
Chris Forbes92577e52019-09-02 17:43:38 +01002714 }
2715 extInfo = extInfo->pNext;
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002716 }
2717
Chris Forbes92577e52019-09-02 17:43:38 +01002718 vk::Cast(pBindInfos[i].image)->bind(memory, offset);
Alexis Hetuf18f0c12019-05-07 14:34:15 -04002719 }
2720
Alexis Hetud73b8712018-09-21 15:14:43 -04002721 return VK_SUCCESS;
2722}
2723
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002724VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags *pPeerMemoryFeatures)
Alexis Hetud73b8712018-09-21 15:14:43 -04002725{
Ben Claytonfb280672019-04-25 11:16:15 +01002726 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 -04002727 device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
2728
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002729 ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
Nicolas Capens44bd43a2020-01-22 03:07:14 -05002730 UNSUPPORTED("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 -04002731}
2732
2733VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
2734{
Alexis Hetu026ceef2019-05-07 17:35:11 -04002735 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t deviceMask = %d", commandBuffer, deviceMask);
2736
2737 vk::Cast(commandBuffer)->setDeviceMask(deviceMask);
Alexis Hetud73b8712018-09-21 15:14:43 -04002738}
2739
2740VKAPI_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)
2741{
Chris Forbes4a4c2592019-05-13 08:53:36 -07002742 TRACE("(VkCommandBuffer commandBuffer = %p, baseGroupX = %u, baseGroupY = %u, baseGroupZ = %u, groupCountX = %u, groupCountY = %u, groupCountZ = %u)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002743 commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
Chris Forbes4a4c2592019-05-13 08:53:36 -07002744
2745 vk::Cast(commandBuffer)->dispatchBase(baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
Alexis Hetud73b8712018-09-21 15:14:43 -04002746}
2747
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002748VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04002749{
Ben Claytonfb280672019-04-25 11:16:15 +01002750 TRACE("VkInstance instance = %p, uint32_t* pPhysicalDeviceGroupCount = %p, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = %p",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002751 instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
2752
Chris Forbesdf84b942019-06-12 11:28:09 -07002753 return vk::Cast(instance)->getPhysicalDeviceGroups(pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002754}
2755
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002756VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04002757{
Ben Claytonfb280672019-04-25 11:16:15 +01002758 TRACE("(VkDevice device = %p, const VkImageMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002759 device, pInfo, pMemoryRequirements);
2760
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002761 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002762 while(extInfo)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002763 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002764 LOG_TRAP("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002765 extInfo = extInfo->pNext;
Alexis Hetu42761d22019-04-08 11:25:59 -04002766 }
2767
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002768 VkBaseOutStructure *extensionRequirements = reinterpret_cast<VkBaseOutStructure *>(pMemoryRequirements->pNext);
Alexis Hetu42761d22019-04-08 11:25:59 -04002769 while(extensionRequirements)
2770 {
2771 switch(extensionRequirements->sType)
2772 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002773 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
2774 {
2775 auto requirements = reinterpret_cast<VkMemoryDedicatedRequirements *>(extensionRequirements);
2776 vk::Cast(device)->getRequirements(requirements);
2777 }
Alexis Hetu42761d22019-04-08 11:25:59 -04002778 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002779 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05002780 LOG_TRAP("pMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002781 break;
Alexis Hetu42761d22019-04-08 11:25:59 -04002782 }
2783
2784 extensionRequirements = extensionRequirements->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002785 }
2786
2787 vkGetImageMemoryRequirements(device, pInfo->image, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04002788}
2789
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002790VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04002791{
Ben Claytonfb280672019-04-25 11:16:15 +01002792 TRACE("(VkDevice device = %p, const VkBufferMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002793 device, pInfo, pMemoryRequirements);
2794
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002795 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002796 while(extInfo)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002797 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002798 LOG_TRAP("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002799 extInfo = extInfo->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002800 }
2801
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002802 VkBaseOutStructure *extensionRequirements = reinterpret_cast<VkBaseOutStructure *>(pMemoryRequirements->pNext);
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002803 while(extensionRequirements)
2804 {
2805 switch(extensionRequirements->sType)
2806 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002807 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002808 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002809 auto requirements = reinterpret_cast<VkMemoryDedicatedRequirements *>(extensionRequirements);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002810 vk::Cast(device)->getRequirements(requirements);
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002811 }
2812 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002813 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05002814 LOG_TRAP("pMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002815 break;
Alexis Hetu1e6a9892019-03-15 12:12:00 -04002816 }
2817
2818 extensionRequirements = extensionRequirements->pNext;
2819 }
2820
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002821 vkGetBufferMemoryRequirements(device, pInfo->buffer, &(pMemoryRequirements->memoryRequirements));
Alexis Hetud73b8712018-09-21 15:14:43 -04002822}
2823
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002824VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements)
Alexis Hetud73b8712018-09-21 15:14:43 -04002825{
Ben Claytonfb280672019-04-25 11:16:15 +01002826 TRACE("(VkDevice device = %p, const VkImageSparseMemoryRequirementsInfo2* pInfo = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002827 device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
2828
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002829 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002830 while(extInfo)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002831 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002832 LOG_TRAP("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002833 extInfo = extInfo->pNext;
2834 }
2835
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002836 auto extensionRequirements = reinterpret_cast<VkBaseInStructure const *>(pSparseMemoryRequirements->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002837 while(extensionRequirements)
2838 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05002839 LOG_TRAP("pSparseMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05002840 extensionRequirements = extensionRequirements->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002841 }
2842
Alexis Hetu4100b732019-10-11 17:01:48 -04002843 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
2844 // "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."
2845 *pSparseMemoryRequirementCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -04002846}
2847
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002848VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures)
Alexis Hetud73b8712018-09-21 15:14:43 -04002849{
Ben Claytonfb280672019-04-25 11:16:15 +01002850 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures2* pFeatures = %p)", physicalDevice, pFeatures);
Alexis Hetud73b8712018-09-21 15:14:43 -04002851
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002852 VkBaseOutStructure *extensionFeatures = reinterpret_cast<VkBaseOutStructure *>(pFeatures->pNext);
Nicolas Capensae8d4642018-11-13 15:17:16 -05002853 while(extensionFeatures)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002854 {
Alexis Hetub07147b2019-10-29 12:49:24 -04002855 switch((long)(extensionFeatures->sType))
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002856 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002857 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002858 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002859 auto features = reinterpret_cast<VkPhysicalDeviceSamplerYcbcrConversionFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002860 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002861 }
2862 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002863 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002864 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002865 auto features = reinterpret_cast<VkPhysicalDevice16BitStorageFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002866 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002867 }
2868 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002869 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002870 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002871 auto features = reinterpret_cast<VkPhysicalDeviceVariablePointerFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002872 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002873 }
2874 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002875 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002876 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002877 auto features = reinterpret_cast<VkPhysicalDevice8BitStorageFeaturesKHR *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002878 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002879 }
2880 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002881 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002882 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002883 auto features = reinterpret_cast<VkPhysicalDeviceMultiviewFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002884 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002885 }
2886 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002887 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002888 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002889 auto features = reinterpret_cast<VkPhysicalDeviceProtectedMemoryFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002890 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002891 }
2892 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002893 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES:
Chris Forbes6408c552019-04-15 12:59:34 -07002894 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002895 auto features = reinterpret_cast<VkPhysicalDeviceShaderDrawParameterFeatures *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002896 vk::Cast(physicalDevice)->getFeatures(features);
Chris Forbes6408c552019-04-15 12:59:34 -07002897 }
2898 break;
Alexis Hetuaabd0852020-02-10 14:27:29 -05002899 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR:
2900 {
Ben Claytona0453d52020-02-11 18:05:41 +00002901 auto features = reinterpret_cast<VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *>(extensionFeatures);
Alexis Hetuaabd0852020-02-10 14:27:29 -05002902 vk::Cast(physicalDevice)->getFeatures(features);
2903 }
2904 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002905 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT:
Alexis Hetu23f9c252019-10-17 13:58:25 -04002906 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002907 auto features = reinterpret_cast<VkPhysicalDeviceLineRasterizationFeaturesEXT *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002908 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetu23f9c252019-10-17 13:58:25 -04002909 }
2910 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002911 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT:
Alexis Hetub07147b2019-10-29 12:49:24 -04002912 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002913 auto features = reinterpret_cast<VkPhysicalDeviceProvokingVertexFeaturesEXT *>(extensionFeatures);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002914 vk::Cast(physicalDevice)->getFeatures(features);
Alexis Hetub07147b2019-10-29 12:49:24 -04002915 }
Alexis Hetue1cda392019-10-29 14:29:02 -04002916 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002917 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT:
2918 ASSERT(!HasExtensionProperty(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME, deviceExtensionProperties,
2919 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2920 break;
2921 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT:
2922 ASSERT(!HasExtensionProperty(VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME, deviceExtensionProperties,
2923 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2924 break;
2925 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR:
2926 ASSERT(!HasExtensionProperty(VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, deviceExtensionProperties,
2927 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2928 break;
2929 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR:
2930 ASSERT(!HasExtensionProperty(VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME, deviceExtensionProperties,
2931 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2932 break;
2933 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05002934 LOG_TRAP("pFeatures->pNext sType = %s", vk::Stringify(extensionFeatures->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002935 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002936 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05002937
2938 extensionFeatures = extensionFeatures->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04002939 }
2940
2941 vkGetPhysicalDeviceFeatures(physicalDevice, &(pFeatures->features));
Alexis Hetud73b8712018-09-21 15:14:43 -04002942}
2943
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002944VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04002945{
Ben Claytonfb280672019-04-25 11:16:15 +01002946 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties2* pProperties = %p)", physicalDevice, pProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04002947
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002948 VkBaseOutStructure *extensionProperties = reinterpret_cast<VkBaseOutStructure *>(pProperties->pNext);
Nicolas Capensae8d4642018-11-13 15:17:16 -05002949 while(extensionProperties)
Alexis Hetu767b41b2018-09-26 11:25:46 -04002950 {
Alexis Hetuf8f61032019-10-10 16:45:30 -04002951 // Casting to a long since some structures, such as
2952 // VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID and
2953 // VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT
Hernan Liatis83a3eb42019-04-29 17:16:10 -07002954 // are not enumerated in the official Vulkan header
2955 switch((long)(extensionProperties->sType))
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002956 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002957 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002958 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002959 auto properties = reinterpret_cast<VkPhysicalDeviceIDProperties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002960 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002961 }
2962 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002963 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002964 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002965 auto properties = reinterpret_cast<VkPhysicalDeviceMaintenance3Properties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002966 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002967 }
2968 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002969 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002970 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002971 auto properties = reinterpret_cast<VkPhysicalDeviceMultiviewProperties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002972 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002973 }
2974 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002975 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002976 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002977 auto properties = reinterpret_cast<VkPhysicalDevicePointClippingProperties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002978 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002979 }
2980 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002981 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002982 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002983 auto properties = reinterpret_cast<VkPhysicalDeviceProtectedMemoryProperties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002984 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002985 }
2986 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002987 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002988 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002989 auto properties = reinterpret_cast<VkPhysicalDeviceSubgroupProperties *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05002990 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04002991 }
2992 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00002993 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT:
2994 // Explicitly ignored, since VK_EXT_sample_locations is not supported
2995 ASSERT(!HasExtensionProperty(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME, deviceExtensionProperties,
2996 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
2997 break;
2998 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT:
Jonah Ryan-Davisf9f999f2020-01-08 14:41:28 -05002999 {
3000 auto properties = reinterpret_cast<VkPhysicalDeviceExternalMemoryHostPropertiesEXT *>(extensionProperties);
3001 vk::Cast(physicalDevice)->getProperties(properties);
3002 }
3003 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003004 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR:
Nicolas Capens657dd6c2018-11-16 17:41:37 -05003005 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003006 auto properties = reinterpret_cast<VkPhysicalDeviceDriverPropertiesKHR *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05003007 vk::Cast(physicalDevice)->getProperties(properties);
Nicolas Capens657dd6c2018-11-16 17:41:37 -05003008 }
3009 break;
Hernan Liatis83a3eb42019-04-29 17:16:10 -07003010#ifdef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003011 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
Hernan Liatis83a3eb42019-04-29 17:16:10 -07003012 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003013 auto properties = reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05003014 vk::Cast(physicalDevice)->getProperties(properties);
Hernan Liatis83a3eb42019-04-29 17:16:10 -07003015 }
3016 break;
3017#endif
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003018 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT:
Alexis Hetu23f9c252019-10-17 13:58:25 -04003019 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003020 auto properties = reinterpret_cast<VkPhysicalDeviceLineRasterizationPropertiesEXT *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05003021 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetu23f9c252019-10-17 13:58:25 -04003022 }
3023 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003024 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT:
Alexis Hetuf8f61032019-10-10 16:45:30 -04003025 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003026 auto properties = reinterpret_cast<VkPhysicalDeviceProvokingVertexPropertiesEXT *>(extensionProperties);
Alexis Hetu131a1ba2019-11-21 16:39:06 -05003027 vk::Cast(physicalDevice)->getProperties(properties);
Alexis Hetuf8f61032019-10-10 16:45:30 -04003028 }
3029 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003030 default:
3031 // "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]"
Sean Risserc1e60dc2020-02-19 12:52:24 -05003032 LOG_TRAP("pProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003033 break;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003034 }
Nicolas Capensae8d4642018-11-13 15:17:16 -05003035
3036 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04003037 }
3038
3039 vkGetPhysicalDeviceProperties(physicalDevice, &(pProperties->properties));
Alexis Hetud73b8712018-09-21 15:14:43 -04003040}
3041
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003042VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 *pFormatProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003043{
Ben Claytonfb280672019-04-25 11:16:15 +01003044 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties2* pFormatProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003045 physicalDevice, format, pFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003046
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003047 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pFormatProperties->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003048 while(extInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -04003049 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003050 LOG_TRAP("pFormatProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003051 extInfo = extInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04003052 }
3053
3054 vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &(pFormatProperties->formatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04003055}
3056
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003057VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003058{
Ben Claytonfb280672019-04-25 11:16:15 +01003059 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo = %p, VkImageFormatProperties2* pImageFormatProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003060 physicalDevice, pImageFormatInfo, pImageFormatProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003061
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003062 const VkBaseInStructure *extensionFormatInfo = reinterpret_cast<const VkBaseInStructure *>(pImageFormatInfo->pNext);
Alexis Hetu00835732019-04-10 16:36:31 -04003063
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003064 const VkExternalMemoryHandleTypeFlagBits *handleType = nullptr;
Alexis Hetu00835732019-04-10 16:36:31 -04003065 while(extensionFormatInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -04003066 {
Alexis Hetu00835732019-04-10 16:36:31 -04003067 switch(extensionFormatInfo->sType)
3068 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003069 case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR:
3070 {
3071 // Explicitly ignored, since VK_KHR_image_format_list is not supported
3072 ASSERT(!HasExtensionProperty(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, deviceExtensionProperties,
3073 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
3074 }
Alexis Hetu00835732019-04-10 16:36:31 -04003075 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003076 case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT:
3077 {
3078 // Explicitly ignored, since VK_EXT_separate_stencil_usage is not supported
3079 ASSERT(!HasExtensionProperty(VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME, deviceExtensionProperties,
3080 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
3081 }
3082 break;
3083 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
3084 {
3085 const VkPhysicalDeviceExternalImageFormatInfo *imageFormatInfo = reinterpret_cast<const VkPhysicalDeviceExternalImageFormatInfo *>(extensionFormatInfo);
3086 handleType = &(imageFormatInfo->handleType);
3087 }
3088 break;
3089 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
3090 {
3091 // Explicitly ignored, since VK_EXT_image_drm_format_modifier is not supported
3092 ASSERT(!HasExtensionProperty(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME, deviceExtensionProperties,
3093 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
3094 }
3095 break;
3096 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05003097 LOG_TRAP("pImageFormatInfo->pNext sType = %s", vk::Stringify(extensionFormatInfo->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003098 break;
Alexis Hetu00835732019-04-10 16:36:31 -04003099 }
3100
3101 extensionFormatInfo = extensionFormatInfo->pNext;
3102 }
3103
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003104 VkBaseOutStructure *extensionProperties = reinterpret_cast<VkBaseOutStructure *>(pImageFormatProperties->pNext);
Alexis Hetu00835732019-04-10 16:36:31 -04003105
3106 while(extensionProperties)
3107 {
3108 switch(extensionProperties->sType)
3109 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003110 case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
3111 {
3112 auto properties = reinterpret_cast<VkExternalImageFormatProperties *>(extensionProperties);
3113 vk::Cast(physicalDevice)->getProperties(handleType, properties);
3114 }
Alexis Hetu00835732019-04-10 16:36:31 -04003115 break;
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003116 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
3117 {
3118 auto properties = reinterpret_cast<VkSamplerYcbcrConversionImageFormatProperties *>(extensionProperties);
3119 vk::Cast(physicalDevice)->getProperties(properties);
3120 }
3121 break;
3122 case VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD:
3123 {
3124 // Explicitly ignored, since VK_AMD_texture_gather_bias_lod is not supported
3125 ASSERT(!HasExtensionProperty(VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME, deviceExtensionProperties,
3126 sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0])));
3127 }
3128 break;
3129 default:
Sean Risserc1e60dc2020-02-19 12:52:24 -05003130 LOG_TRAP("pImageFormatProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003131 break;
Alexis Hetu00835732019-04-10 16:36:31 -04003132 }
3133
3134 extensionProperties = extensionProperties->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04003135 }
Alexis Hetud73b8712018-09-21 15:14:43 -04003136
Alexis Hetu767b41b2018-09-26 11:25:46 -04003137 return vkGetPhysicalDeviceImageFormatProperties(physicalDevice,
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003138 pImageFormatInfo->format,
3139 pImageFormatInfo->type,
3140 pImageFormatInfo->tiling,
3141 pImageFormatInfo->usage,
3142 pImageFormatInfo->flags,
3143 &(pImageFormatProperties->imageFormatProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04003144}
3145
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003146VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003147{
Ben Claytonfb280672019-04-25 11:16:15 +01003148 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties2* pQueueFamilyProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003149 physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003150
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003151 if(pQueueFamilyProperties)
Alexis Hetu767b41b2018-09-26 11:25:46 -04003152 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003153 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pQueueFamilyProperties->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003154 while(extInfo)
3155 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003156 LOG_TRAP("pQueueFamilyProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003157 extInfo = extInfo->pNext;
3158 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04003159 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04003160
Alexis Hetu4100b732019-10-11 17:01:48 -04003161 if(!pQueueFamilyProperties)
3162 {
3163 *pQueueFamilyPropertyCount = vk::Cast(physicalDevice)->getQueueFamilyPropertyCount();
3164 }
3165 else
3166 {
3167 vk::Cast(physicalDevice)->getQueueFamilyProperties(*pQueueFamilyPropertyCount, pQueueFamilyProperties);
3168 }
Alexis Hetud73b8712018-09-21 15:14:43 -04003169}
3170
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003171VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003172{
Ben Claytonfb280672019-04-25 11:16:15 +01003173 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties2* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003174
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003175 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pMemoryProperties->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003176 while(extInfo)
Alexis Hetu767b41b2018-09-26 11:25:46 -04003177 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003178 LOG_TRAP("pMemoryProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003179 extInfo = extInfo->pNext;
Alexis Hetu767b41b2018-09-26 11:25:46 -04003180 }
3181
3182 vkGetPhysicalDeviceMemoryProperties(physicalDevice, &(pMemoryProperties->memoryProperties));
Alexis Hetud73b8712018-09-21 15:14:43 -04003183}
3184
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003185VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo, uint32_t *pPropertyCount, VkSparseImageFormatProperties2 *pProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003186{
Ben Claytonfb280672019-04-25 11:16:15 +01003187 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo = %p, uint32_t* pPropertyCount = %p, VkSparseImageFormatProperties2* pProperties = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003188 physicalDevice, pFormatInfo, pPropertyCount, pProperties);
Alexis Hetu767b41b2018-09-26 11:25:46 -04003189
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003190 if(pProperties)
Alexis Hetu767b41b2018-09-26 11:25:46 -04003191 {
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003192 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pProperties->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003193 while(extInfo)
3194 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003195 LOG_TRAP("pProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003196 extInfo = extInfo->pNext;
3197 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04003198 }
Alexis Hetu767b41b2018-09-26 11:25:46 -04003199
Alexis Hetu4100b732019-10-11 17:01:48 -04003200 // We do not support sparse images.
3201 *pPropertyCount = 0;
Alexis Hetud73b8712018-09-21 15:14:43 -04003202}
3203
3204VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags)
3205{
Ben Claytonfb280672019-04-25 11:16:15 +01003206 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolTrimFlags flags = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003207 device, static_cast<void *>(commandPool), flags);
Nicolas Capensde16f322019-02-12 00:32:31 -05003208
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003209 if(flags != 0)
3210 {
3211 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
3212 UNSUPPORTED("flags %d", int(flags));
3213 }
3214
Alexis Hetucd610c92019-02-01 16:47:51 -05003215 vk::Cast(commandPool)->trim(flags);
Alexis Hetud73b8712018-09-21 15:14:43 -04003216}
3217
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003218VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue)
Alexis Hetud73b8712018-09-21 15:14:43 -04003219{
Ben Claytonfb280672019-04-25 11:16:15 +01003220 TRACE("(VkDevice device = %p, const VkDeviceQueueInfo2* pQueueInfo = %p, VkQueue* pQueue = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003221 device, pQueueInfo, pQueue);
3222
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003223 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pQueueInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003224 while(extInfo)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003225 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003226 LOG_TRAP("pQueueInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003227 extInfo = extInfo->pNext;
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003228 }
3229
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003230 if(pQueueInfo->flags != 0)
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003231 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003232 // The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
3233 // According to the Vulkan 1.2.132 spec, 4.3.1. Queue Family Properties:
3234 // "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
3235 // protected-capable queue. If the protected memory feature is not enabled,
3236 // the VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT bit of flags must not be set."
3237 UNSUPPORTED("VkPhysicalDeviceVulkan11Features::protectedMemory");
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003238 }
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003239
3240 vkGetDeviceQueue(device, pQueueInfo->queueFamilyIndex, pQueueInfo->queueIndex, pQueue);
Alexis Hetud73b8712018-09-21 15:14:43 -04003241}
3242
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003243VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSamplerYcbcrConversion *pYcbcrConversion)
Alexis Hetud73b8712018-09-21 15:14:43 -04003244{
Nicolas Capens6b63c802019-05-16 11:10:34 -04003245 TRACE("(VkDevice device = %p, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSamplerYcbcrConversion* pYcbcrConversion = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003246 device, pCreateInfo, pAllocator, pYcbcrConversion);
Nicolas Capens6b63c802019-05-16 11:10:34 -04003247
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003248 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003249 while(extInfo)
Nicolas Capens6b63c802019-05-16 11:10:34 -04003250 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003251 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003252 extInfo = extInfo->pNext;
Nicolas Capens6b63c802019-05-16 11:10:34 -04003253 }
3254
3255 return vk::SamplerYcbcrConversion::Create(pAllocator, pCreateInfo, pYcbcrConversion);
Alexis Hetud73b8712018-09-21 15:14:43 -04003256}
3257
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003258VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04003259{
Nicolas Capens6b63c802019-05-16 11:10:34 -04003260 TRACE("(VkDevice device = %p, VkSamplerYcbcrConversion ycbcrConversion = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003261 device, static_cast<void *>(ycbcrConversion), pAllocator);
Nicolas Capens6b63c802019-05-16 11:10:34 -04003262
3263 vk::destroy(ycbcrConversion, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04003264}
3265
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003266VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate)
Alexis Hetud73b8712018-09-21 15:14:43 -04003267{
Ben Claytonfb280672019-04-25 11:16:15 +01003268 TRACE("(VkDevice device = %p, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = %p)",
Alexis Hetuf705cec2019-01-29 14:09:36 -05003269 device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
3270
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003271 if(pCreateInfo->flags != 0)
Alexis Hetuf705cec2019-01-29 14:09:36 -05003272 {
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003273 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
3274 UNSUPPORTED("pCreateInfo->flags %d", int(pCreateInfo->flags));
3275 }
3276
3277 if(pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)
3278 {
3279 UNSUPPORTED("pCreateInfo->templateType %d", int(pCreateInfo->templateType));
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003280 }
3281
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003282 auto extInfo = reinterpret_cast<VkBaseInStructure const *>(pCreateInfo->pNext);
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003283 while(extInfo)
3284 {
Sean Risserc1e60dc2020-02-19 12:52:24 -05003285 LOG_TRAP("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
Alexis Hetu7b29abf2019-11-21 17:26:17 -05003286 extInfo = extInfo->pNext;
Alexis Hetuf705cec2019-01-29 14:09:36 -05003287 }
3288
3289 return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, pDescriptorUpdateTemplate);
Alexis Hetud73b8712018-09-21 15:14:43 -04003290}
3291
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003292VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks *pAllocator)
Alexis Hetud73b8712018-09-21 15:14:43 -04003293{
Ben Claytonfb280672019-04-25 11:16:15 +01003294 TRACE("(VkDevice device = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003295 device, static_cast<void *>(descriptorUpdateTemplate), pAllocator);
Alexis Hetuf705cec2019-01-29 14:09:36 -05003296
3297 vk::destroy(descriptorUpdateTemplate, pAllocator);
Alexis Hetud73b8712018-09-21 15:14:43 -04003298}
3299
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003300VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void *pData)
Alexis Hetud73b8712018-09-21 15:14:43 -04003301{
Ben Claytonfb280672019-04-25 11:16:15 +01003302 TRACE("(VkDevice device = %p, VkDescriptorSet descriptorSet = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const void* pData = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003303 device, static_cast<void *>(descriptorSet), static_cast<void *>(descriptorUpdateTemplate), pData);
Alexis Hetuf705cec2019-01-29 14:09:36 -05003304
Alexis Hetu6448bd62019-06-11 15:58:59 -04003305 vk::Cast(descriptorUpdateTemplate)->updateDescriptorSet(vk::Cast(device), descriptorSet, pData);
Alexis Hetud73b8712018-09-21 15:14:43 -04003306}
3307
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003308VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003309{
Ben Claytonfb280672019-04-25 11:16:15 +01003310 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo = %p, VkExternalBufferProperties* pExternalBufferProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003311 physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
3312
Alexis Hetu00835732019-04-10 16:36:31 -04003313 vk::Cast(physicalDevice)->getProperties(pExternalBufferInfo, pExternalBufferProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003314}
3315
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003316VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003317{
Ben Claytonfb280672019-04-25 11:16:15 +01003318 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo = %p, VkExternalFenceProperties* pExternalFenceProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003319 physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
3320
Alexis Hetu00835732019-04-10 16:36:31 -04003321 vk::Cast(physicalDevice)->getProperties(pExternalFenceInfo, pExternalFenceProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003322}
3323
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003324VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties)
Alexis Hetud73b8712018-09-21 15:14:43 -04003325{
Ben Claytonfb280672019-04-25 11:16:15 +01003326 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo = %p, VkExternalSemaphoreProperties* pExternalSemaphoreProperties = %p)",
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003327 physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
3328
Alexis Hetu00835732019-04-10 16:36:31 -04003329 vk::Cast(physicalDevice)->getProperties(pExternalSemaphoreInfo, pExternalSemaphoreProperties);
Alexis Hetud73b8712018-09-21 15:14:43 -04003330}
3331
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003332VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, VkDescriptorSetLayoutSupport *pSupport)
Alexis Hetud73b8712018-09-21 15:14:43 -04003333{
Ben Claytonfb280672019-04-25 11:16:15 +01003334 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, VkDescriptorSetLayoutSupport* pSupport = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003335 device, pCreateInfo, pSupport);
Alexis Hetu9e4d0402018-10-16 15:44:12 -04003336
3337 vk::Cast(device)->getDescriptorSetLayoutSupport(pCreateInfo, pSupport);
Alexis Hetud73b8712018-09-21 15:14:43 -04003338}
3339
Chris Forbesdeac5362019-11-25 08:18:34 -08003340VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, uint16_t lineStipplePattern)
3341{
3342 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t lineStippleFactor = %u, uint16_t lineStipplePattern = %u",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003343 commandBuffer, lineStippleFactor, lineStipplePattern);
Chris Forbesdeac5362019-11-25 08:18:34 -08003344
Nicolas Capens44bd43a2020-01-22 03:07:14 -05003345 UNSUPPORTED("VkPhysicalDeviceLineRasterizationFeaturesEXT::stippled*Lines");
Chris Forbesdeac5362019-11-25 08:18:34 -08003346}
3347
Ben Claytona9af8832019-08-14 13:09:43 +01003348#ifdef VK_USE_PLATFORM_XCB_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003349VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Ben Claytona9af8832019-08-14 13:09:43 +01003350{
3351 TRACE("(VkInstance instance = %p, VkXcbSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003352 instance, pCreateInfo, pAllocator, pSurface);
Ben Claytona9af8832019-08-14 13:09:43 +01003353
3354 return vk::XcbSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
3355}
3356
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003357VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id)
Ben Claytona9af8832019-08-14 13:09:43 +01003358{
3359 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, xcb_connection_t* connection = %p, xcb_visualid_t visual_id = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003360 physicalDevice, int(queueFamilyIndex), connection, int(visual_id));
Ben Claytona9af8832019-08-14 13:09:43 +01003361
3362 return VK_TRUE;
3363}
3364#endif
3365
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003366#ifdef VK_USE_PLATFORM_XLIB_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003367VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(VkInstance instance, const VkXlibSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003368{
Ben Claytonfb280672019-04-25 11:16:15 +01003369 TRACE("(VkInstance instance = %p, VkXlibSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003370 instance, pCreateInfo, pAllocator, pSurface);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003371
3372 return vk::XlibSurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
3373}
Hernan Liatisbd18d582019-05-29 15:38:58 -07003374
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003375VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display *dpy, VisualID visualID)
Hernan Liatisbd18d582019-05-29 15:38:58 -07003376{
3377 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, Display* dpy = %p, VisualID visualID = %lu)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003378 physicalDevice, int(queueFamilyIndex), dpy, visualID);
Hernan Liatisbd18d582019-05-29 15:38:58 -07003379
3380 return VK_TRUE;
3381}
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003382#endif
3383
Alexis Hetu0662a4a2019-07-08 15:06:40 -04003384#ifdef VK_USE_PLATFORM_MACOS_MVK
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003385VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Alexis Hetu0662a4a2019-07-08 15:06:40 -04003386{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003387 TRACE("(VkInstance instance = %p, VkMacOSSurfaceCreateInfoMVK* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
3388 instance, pCreateInfo, pAllocator, pSurface);
Alexis Hetu0662a4a2019-07-08 15:06:40 -04003389
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003390 return vk::MacOSSurfaceMVK::Create(pAllocator, pCreateInfo, pSurface);
Alexis Hetu0662a4a2019-07-08 15:06:40 -04003391}
3392#endif
3393
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -04003394#ifdef VK_USE_PLATFORM_METAL_EXT
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003395VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(VkInstance instance, const VkMetalSurfaceCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -04003396{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003397 TRACE("(VkInstance instance = %p, VkMetalSurfaceCreateInfoEXT* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
3398 instance, pCreateInfo, pAllocator, pSurface);
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -04003399
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003400 return vk::MetalSurfaceEXT::Create(pAllocator, pCreateInfo, pSurface);
Jonah Ryan-Davis215bc792019-10-31 17:23:49 -04003401}
3402#endif
3403
Nicolas Capensd3545372019-08-09 13:59:18 -04003404#ifdef VK_USE_PLATFORM_WIN32_KHR
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003405VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
Nicolas Capensd3545372019-08-09 13:59:18 -04003406{
3407 TRACE("(VkInstance instance = %p, VkWin32SurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003408 instance, pCreateInfo, pAllocator, pSurface);
Nicolas Capensd3545372019-08-09 13:59:18 -04003409
3410 return vk::Win32SurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
3411}
Sascha Willems883e8172019-10-22 20:08:12 +02003412
3413VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex)
3414{
3415 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003416 physicalDevice, queueFamilyIndex);
Sascha Willems883e8172019-10-22 20:08:12 +02003417 return VK_TRUE;
3418}
Nicolas Capensd3545372019-08-09 13:59:18 -04003419#endif
3420
Chris Forbes1d667d62019-04-05 08:25:18 -07003421#ifndef __ANDROID__
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003422VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator)
Chris Forbes1d667d62019-04-05 08:25:18 -07003423{
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003424 TRACE("(VkInstance instance = %p, VkSurfaceKHR surface = %p, const VkAllocationCallbacks* pAllocator = %p)",
3425 instance, static_cast<void *>(surface), pAllocator);
Chris Forbes1d667d62019-04-05 08:25:18 -07003426
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003427 vk::destroy(surface, pAllocator);
Chris Forbes1d667d62019-04-05 08:25:18 -07003428}
3429
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003430VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported)
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003431{
Ben Claytonfb280672019-04-25 11:16:15 +01003432 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, VkSurface surface = %p, VKBool32* pSupported = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003433 physicalDevice, int(queueFamilyIndex), static_cast<void *>(surface), pSupported);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003434
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003435 *pSupported = VK_TRUE;
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003436 return VK_SUCCESS;
3437}
3438
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003439VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003440{
Ben Claytonfb280672019-04-25 11:16:15 +01003441 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003442 physicalDevice, static_cast<void *>(surface), pSurfaceCapabilities);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003443
3444 vk::Cast(surface)->getSurfaceCapabilities(pSurfaceCapabilities);
3445 return VK_SUCCESS;
3446}
3447
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003448VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats)
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003449{
Ben Claytonfb280672019-04-25 11:16:15 +01003450 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p. uint32_t* pSurfaceFormatCount = %p, VkSurfaceFormatKHR* pSurfaceFormats = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003451 physicalDevice, static_cast<void *>(surface), pSurfaceFormatCount, pSurfaceFormats);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003452
3453 if(!pSurfaceFormats)
3454 {
3455 *pSurfaceFormatCount = vk::Cast(surface)->getSurfaceFormatsCount();
3456 return VK_SUCCESS;
3457 }
3458
3459 return vk::Cast(surface)->getSurfaceFormats(pSurfaceFormatCount, pSurfaceFormats);
3460}
3461
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003462VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003463{
Ben Claytonfb280672019-04-25 11:16:15 +01003464 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p uint32_t* pPresentModeCount = %p, VkPresentModeKHR* pPresentModes = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003465 physicalDevice, static_cast<void *>(surface), pPresentModeCount, pPresentModes);
Hernan Liatisc6eb41b2019-02-22 11:12:59 -08003466
3467 if(!pPresentModes)
3468 {
3469 *pPresentModeCount = vk::Cast(surface)->getPresentModeCount();
3470 return VK_SUCCESS;
3471 }
3472
3473 return vk::Cast(surface)->getPresentModes(pPresentModeCount, pPresentModes);
3474}
3475
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003476VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain)
Hernan Liatisc7943e92019-02-25 19:29:54 -08003477{
Ben Claytonfb280672019-04-25 11:16:15 +01003478 TRACE("(VkDevice device = %p, const VkSwapchainCreateInfoKHR* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSwapchainKHR* pSwapchain = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003479 device, pCreateInfo, pAllocator, pSwapchain);
Hernan Liatisc7943e92019-02-25 19:29:54 -08003480
Hernan Liatis43be7162019-03-08 17:57:41 -08003481 if(pCreateInfo->oldSwapchain)
3482 {
3483 vk::Cast(pCreateInfo->oldSwapchain)->retire();
3484 }
3485
Alexis Hetu63ae9242019-06-06 13:52:15 -04003486 if(vk::Cast(pCreateInfo->surface)->hasAssociatedSwapchain())
Hernan Liatis43be7162019-03-08 17:57:41 -08003487 {
3488 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
3489 }
3490
Hernan Liatisc7943e92019-02-25 19:29:54 -08003491 VkResult status = vk::SwapchainKHR::Create(pAllocator, pCreateInfo, pSwapchain);
3492
3493 if(status != VK_SUCCESS)
3494 {
3495 return status;
3496 }
3497
Alexis Hetu7d96f512019-06-13 18:23:56 -04003498 auto swapchain = vk::Cast(*pSwapchain);
3499 status = swapchain->createImages(device, pCreateInfo);
Hernan Liatisc7943e92019-02-25 19:29:54 -08003500
3501 if(status != VK_SUCCESS)
3502 {
3503 vk::destroy(*pSwapchain, pAllocator);
3504 return status;
3505 }
3506
Alexis Hetu7d96f512019-06-13 18:23:56 -04003507 vk::Cast(pCreateInfo->surface)->associateSwapchain(swapchain);
Hernan Liatis43be7162019-03-08 17:57:41 -08003508
Hernan Liatisc7943e92019-02-25 19:29:54 -08003509 return VK_SUCCESS;
3510}
3511
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003512VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator)
Hernan Liatisc7943e92019-02-25 19:29:54 -08003513{
Ben Claytonfb280672019-04-25 11:16:15 +01003514 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, const VkAllocationCallbacks* pAllocator = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003515 device, static_cast<void *>(swapchain), pAllocator);
Hernan Liatisc7943e92019-02-25 19:29:54 -08003516
3517 vk::destroy(swapchain, pAllocator);
3518}
3519
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003520VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages)
Hernan Liatisd00375a2019-02-26 11:19:27 -08003521{
Ben Claytonfb280672019-04-25 11:16:15 +01003522 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint32_t* pSwapchainImageCount = %p, VkImage* pSwapchainImages = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003523 device, static_cast<void *>(swapchain), pSwapchainImageCount, pSwapchainImages);
Hernan Liatisd00375a2019-02-26 11:19:27 -08003524
3525 if(!pSwapchainImages)
3526 {
3527 *pSwapchainImageCount = vk::Cast(swapchain)->getImageCount();
3528 return VK_SUCCESS;
3529 }
3530
3531 return vk::Cast(swapchain)->getImages(pSwapchainImageCount, pSwapchainImages);
3532}
3533
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003534VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex)
Hernan Liatis6b12a502019-03-01 15:06:13 -08003535{
Ben Claytonfb280672019-04-25 11:16:15 +01003536 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint64_t timeout = %d, VkSemaphore semaphore = %p, VkFence fence = %p, uint32_t* pImageIndex = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003537 device, static_cast<void *>(swapchain), int(timeout), static_cast<void *>(semaphore), static_cast<void *>(fence), pImageIndex);
Hernan Liatis6b12a502019-03-01 15:06:13 -08003538
Alexis Hetu7d96f512019-06-13 18:23:56 -04003539 return vk::Cast(swapchain)->getNextImage(timeout, vk::Cast(semaphore), vk::Cast(fence), pImageIndex);
Hernan Liatis6b12a502019-03-01 15:06:13 -08003540}
3541
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003542VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
Hernan Liatis6b12a502019-03-01 15:06:13 -08003543{
Ben Claytonfb280672019-04-25 11:16:15 +01003544 TRACE("(VkQueue queue = %p, const VkPresentInfoKHR* pPresentInfo = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003545 queue, pPresentInfo);
Hernan Liatis6b12a502019-03-01 15:06:13 -08003546
Antonio Maiorano26c6c4a2019-10-17 15:33:47 -04003547 return vk::Cast(queue)->present(pPresentInfo);
Hernan Liatis6b12a502019-03-01 15:06:13 -08003548}
Chris Forbesf993de32019-04-15 09:45:34 -07003549
Chris Forbes25c8e082019-09-02 16:20:09 +01003550VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, uint32_t *pImageIndex)
3551{
3552 TRACE("(VkDevice device = %p, const VkAcquireNextImageInfoKHR *pAcquireInfo = %p, uint32_t *pImageIndex = %p",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003553 device, pAcquireInfo, pImageIndex);
Chris Forbes25c8e082019-09-02 16:20:09 +01003554
3555 return vk::Cast(pAcquireInfo->swapchain)->getNextImage(pAcquireInfo->timeout, vk::Cast(pAcquireInfo->semaphore), vk::Cast(pAcquireInfo->fence), pImageIndex);
3556}
3557
Chris Forbesf993de32019-04-15 09:45:34 -07003558VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR *pDeviceGroupPresentCapabilities)
3559{
Ben Claytonfb280672019-04-25 11:16:15 +01003560 TRACE("(VkDevice device = %p, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003561 device, pDeviceGroupPresentCapabilities);
Chris Forbesf993de32019-04-15 09:45:34 -07003562
Nicolas Capens81bc9d92019-12-16 15:05:57 -05003563 for(int i = 0; i < VK_MAX_DEVICE_GROUP_SIZE; i++)
Chris Forbesf993de32019-04-15 09:45:34 -07003564 {
3565 // The only real physical device in the presentation group is device 0,
3566 // and it can present to itself.
3567 pDeviceGroupPresentCapabilities->presentMask[i] = (i == 0) ? 1 : 0;
3568 }
3569
3570 pDeviceGroupPresentCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
3571
3572 return VK_SUCCESS;
3573}
3574
3575VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *pModes)
3576{
Ben Claytonfb280672019-04-25 11:16:15 +01003577 TRACE("(VkDevice device = %p, VkSurfaceKHR surface = %p, VkDeviceGroupPresentModeFlagsKHR *pModes = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003578 device, static_cast<void *>(surface), pModes);
Chris Forbesf993de32019-04-15 09:45:34 -07003579
3580 *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
3581 return VK_SUCCESS;
3582}
3583
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003584VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pRectCount, VkRect2D *pRects)
Chris Forbesb52384b2019-08-28 12:01:29 -07003585{
3586 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, uint32_t* pRectCount = %p, VkRect2D* pRects = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003587 physicalDevice, static_cast<void *>(surface), pRectCount, pRects);
Chris Forbesb52384b2019-08-28 12:01:29 -07003588
3589 return vk::Cast(surface)->getPresentRectangles(pRectCount, pRects);
3590}
3591
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003592#endif // ! __ANDROID__
Hernan Liatis6b12a502019-03-01 15:06:13 -08003593
Hernan Liatis8a91a352019-04-29 17:14:06 -07003594#ifdef __ANDROID__
3595
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003596VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainUsage, uint64_t *grallocConsumerUsage, uint64_t *grallocProducerUsage)
Hernan Liatis8a91a352019-04-29 17:14:06 -07003597{
Hernan Liatis628604e2019-05-07 15:30:18 -07003598 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, VkSwapchainImageUsageFlagsANDROID swapchainUsage = %d, uint64_t* grallocConsumerUsage = %p, uin64_t* grallocProducerUsage = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003599 device, format, imageUsage, swapchainUsage, grallocConsumerUsage, grallocProducerUsage);
Hernan Liatis8a91a352019-04-29 17:14:06 -07003600
Hernan Liatis788ea9f2019-05-01 11:10:36 -07003601 *grallocConsumerUsage = 0;
3602 *grallocProducerUsage = GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
3603
Hernan Liatis8a91a352019-04-29 17:14:06 -07003604 return VK_SUCCESS;
3605}
3606
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003607VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int *grallocUsage)
Hernan Liatis8a91a352019-04-29 17:14:06 -07003608{
Hernan Liatis628604e2019-05-07 15:30:18 -07003609 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, int* grallocUsage = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003610 device, format, imageUsage, grallocUsage);
Hernan Liatis8a91a352019-04-29 17:14:06 -07003611
Hernan Liatis3429bb52019-05-29 18:42:11 -07003612 *grallocUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
3613
Hernan Liatis8a91a352019-04-29 17:14:06 -07003614 return VK_SUCCESS;
3615}
3616
3617VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence)
3618{
Hernan Liatis628604e2019-05-07 15:30:18 -07003619 TRACE("(VkDevice device = %p, VkImage image = %p, int nativeFenceFd = %d, VkSemaphore semaphore = %p, VkFence fence = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003620 device, static_cast<void *>(image), nativeFenceFd, static_cast<void *>(semaphore), static_cast<void *>(fence));
Hernan Liatis8a91a352019-04-29 17:14:06 -07003621
Hernan Liatisd5f462c2019-05-24 15:45:05 -07003622 if(nativeFenceFd >= 0)
3623 {
3624 sync_wait(nativeFenceFd, -1);
3625 close(nativeFenceFd);
3626 }
3627
3628 if(fence != VK_NULL_HANDLE)
3629 {
3630 vk::Cast(fence)->complete();
3631 }
3632
3633 if(semaphore != VK_NULL_HANDLE)
3634 {
3635 vk::Cast(semaphore)->signal();
3636 }
3637
Hernan Liatis8a91a352019-04-29 17:14:06 -07003638 return VK_SUCCESS;
3639}
3640
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003641VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore *pWaitSemaphores, VkImage image, int *pNativeFenceFd)
Hernan Liatis8a91a352019-04-29 17:14:06 -07003642{
Hernan Liatis628604e2019-05-07 15:30:18 -07003643 TRACE("(VkQueue queue = %p, uint32_t waitSemaphoreCount = %d, const VkSemaphore* pWaitSemaphores = %p, VkImage image = %p, int* pNativeFenceFd = %p)",
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003644 queue, waitSemaphoreCount, pWaitSemaphores, static_cast<void *>(image), pNativeFenceFd);
Hernan Liatis8a91a352019-04-29 17:14:06 -07003645
Hernan Liatisd61595f2019-05-10 16:30:07 -07003646 // This is a hack to deal with screen tearing for now.
3647 // Need to correctly implement threading using VkSemaphore
3648 // to get rid of it. b/132458423
3649 vkQueueWaitIdle(queue);
3650
Alexis Hetu52445952019-10-31 17:51:07 -04003651 *pNativeFenceFd = -1;
Hernan Liatis628604e2019-05-07 15:30:18 -07003652
Alexis Hetu52445952019-10-31 17:51:07 -04003653 return vk::Cast(image)->prepareForExternalUseANDROID();
Hernan Liatis8a91a352019-04-29 17:14:06 -07003654}
Ben Clayton2ed93ab2019-12-17 20:38:03 +00003655#endif // __ANDROID__
Chris Forbes3d27f2e2018-09-26 09:24:39 -07003656}