1// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "VkBuffer.hpp"
16#include "VkBufferView.hpp"
17#include "VkCommandBuffer.hpp"
18#include "VkCommandPool.hpp"
19#include "VkConfig.hpp"
20#include "VkDebugUtilsMessenger.hpp"
21#include "VkDescriptorPool.hpp"
22#include "VkDescriptorSetLayout.hpp"
23#include "VkDescriptorUpdateTemplate.hpp"
24#include "VkDestroy.hpp"
25#include "VkDevice.hpp"
26#include "VkDeviceMemory.hpp"
27#include "VkEvent.hpp"
28#include "VkFence.hpp"
29#include "VkFramebuffer.hpp"
30#include "VkGetProcAddress.hpp"
31#include "VkImage.hpp"
32#include "VkImageView.hpp"
33#include "VkInstance.hpp"
34#include "VkPhysicalDevice.hpp"
35#include "VkPipeline.hpp"
36#include "VkPipelineCache.hpp"
37#include "VkPipelineLayout.hpp"
38#include "VkQueryPool.hpp"
39#include "VkQueue.hpp"
40#include "VkRenderPass.hpp"
41#include "VkSampler.hpp"
42#include "VkSemaphore.hpp"
43#include "VkShaderModule.hpp"
44#include "VkStringify.hpp"
45#include "VkStructConversion.hpp"
46#include "VkTimelineSemaphore.hpp"
47
48#include "Reactor/Nucleus.hpp"
49#include "System/CPUID.hpp"
50#include "System/Debug.hpp"
51#include "System/SwiftConfig.hpp"
52#include "WSI/HeadlessSurfaceKHR.hpp"
53#include "WSI/VkSwapchainKHR.hpp"
54
55#if defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_MACOS_MVK)
56# include "WSI/MetalSurface.hpp"
57#endif
58
59#ifdef VK_USE_PLATFORM_XCB_KHR
60# include "WSI/XcbSurfaceKHR.hpp"
61#endif
62
63#ifdef VK_USE_PLATFORM_WAYLAND_KHR
64# include "WSI/WaylandSurfaceKHR.hpp"
65#endif
66
67#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
68# include "WSI/DirectFBSurfaceEXT.hpp"
69#endif
70
71#ifdef VK_USE_PLATFORM_DISPLAY_KHR
72# include "WSI/DisplaySurfaceKHR.hpp"
73#endif
74
75#ifdef VK_USE_PLATFORM_WIN32_KHR
76# include "WSI/Win32SurfaceKHR.hpp"
77#endif
78
79#include "marl/mutex.h"
80#include "marl/scheduler.h"
81#include "marl/thread.h"
82#include "marl/tsa.h"
83
84#ifdef __ANDROID__
85# include "commit.h"
86# include "System/GrallocAndroid.hpp"
87# include <android/log.h>
88# include <hardware/gralloc1.h>
89# include <sync/sync.h>
90# ifdef SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
91# include "VkDeviceMemoryExternalAndroid.hpp"
92# endif
93#endif
94
95#include <algorithm>
96#include <cinttypes>
97#include <cstring>
98#include <functional>
99#include <map>
100#include <string>
101
102namespace {
103
104// Enable commit_id.py and #include commit.h for other platforms.
105#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT)
106void logBuildVersionInformation()
107{
108 // TODO(b/144093703): Don't call __android_log_print() directly
109 __android_log_print(ANDROID_LOG_INFO, "SwiftShader", "SwiftShader Version: %s", SWIFTSHADER_VERSION_STRING);
110}
111#endif // __ANDROID__ && ENABLE_BUILD_VERSION_OUTPUT
112
113std::shared_ptr<marl::Scheduler> getOrCreateScheduler()
114{
115 struct Scheduler
116 {
117 marl::mutex mutex;
118 std::weak_ptr<marl::Scheduler> weakptr GUARDED_BY(mutex);
119 };
120
121 static Scheduler scheduler; // TODO(b/208256248): Avoid exit-time destructor.
122
123 marl::lock lock(scheduler.mutex);
124 auto sptr = scheduler.weakptr.lock();
125 if(!sptr)
126 {
127 const sw::Configuration &config = sw::getConfiguration();
128 marl::Scheduler::Config cfg = sw::getSchedulerConfiguration(config);
129 sptr = std::make_shared<marl::Scheduler>(args&: cfg);
130 scheduler.weakptr = sptr;
131 }
132 return sptr;
133}
134
135// initializeLibrary() is called by vkCreateInstance() to perform one-off global
136// initialization of the swiftshader driver.
137void initializeLibrary()
138{
139 static bool doOnce = [] {
140#if defined(__ANDROID__) && defined(ENABLE_BUILD_VERSION_OUTPUT)
141 logBuildVersionInformation();
142#endif // __ANDROID__ && ENABLE_BUILD_VERSION_OUTPUT
143 return true;
144 }();
145 (void)doOnce;
146}
147
148template<class T>
149void ValidateRenderPassPNextChain(VkDevice device, const T *pCreateInfo)
150{
151 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
152
153 while(extensionCreateInfo)
154 {
155 switch(extensionCreateInfo->sType)
156 {
157 case VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO:
158 {
159 const VkRenderPassInputAttachmentAspectCreateInfo *inputAttachmentAspectCreateInfo = reinterpret_cast<const VkRenderPassInputAttachmentAspectCreateInfo *>(extensionCreateInfo);
160
161 for(uint32_t i = 0; i < inputAttachmentAspectCreateInfo->aspectReferenceCount; i++)
162 {
163 const auto &aspectReference = inputAttachmentAspectCreateInfo->pAspectReferences[i];
164 ASSERT(aspectReference.subpass < pCreateInfo->subpassCount);
165 const auto &subpassDescription = pCreateInfo->pSubpasses[aspectReference.subpass];
166 ASSERT(aspectReference.inputAttachmentIndex < subpassDescription.inputAttachmentCount);
167 const auto &attachmentReference = subpassDescription.pInputAttachments[aspectReference.inputAttachmentIndex];
168 if(attachmentReference.attachment != VK_ATTACHMENT_UNUSED)
169 {
170 // If the pNext chain includes an instance of VkRenderPassInputAttachmentAspectCreateInfo, for any
171 // element of the pInputAttachments member of any element of pSubpasses where the attachment member
172 // is not VK_ATTACHMENT_UNUSED, the aspectMask member of the corresponding element of
173 // VkRenderPassInputAttachmentAspectCreateInfo::pAspectReferences must only include aspects that are
174 // present in images of the format specified by the element of pAttachments at attachment
175 vk::Format format(pCreateInfo->pAttachments[attachmentReference.attachment].format);
176 bool isDepth = format.isDepth();
177 bool isStencil = format.isStencil();
178 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) || (!isDepth && !isStencil));
179 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) || isDepth);
180 ASSERT(!(aspectReference.aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) || isStencil);
181 }
182 }
183 }
184 break;
185 case VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO:
186 {
187 const VkRenderPassMultiviewCreateInfo *multiviewCreateInfo = reinterpret_cast<const VkRenderPassMultiviewCreateInfo *>(extensionCreateInfo);
188 ASSERT((multiviewCreateInfo->subpassCount == 0) || (multiviewCreateInfo->subpassCount == pCreateInfo->subpassCount));
189 ASSERT((multiviewCreateInfo->dependencyCount == 0) || (multiviewCreateInfo->dependencyCount == pCreateInfo->dependencyCount));
190
191 bool zeroMask = (multiviewCreateInfo->pViewMasks[0] == 0);
192 for(uint32_t i = 1; i < multiviewCreateInfo->subpassCount; i++)
193 {
194 ASSERT((multiviewCreateInfo->pViewMasks[i] == 0) == zeroMask);
195 }
196
197 if(zeroMask)
198 {
199 ASSERT(multiviewCreateInfo->correlationMaskCount == 0);
200 }
201
202 for(uint32_t i = 0; i < multiviewCreateInfo->dependencyCount; i++)
203 {
204 const auto &dependency = pCreateInfo->pDependencies[i];
205 if(multiviewCreateInfo->pViewOffsets[i] != 0)
206 {
207 ASSERT(dependency.srcSubpass != dependency.dstSubpass);
208 ASSERT(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT);
209 }
210 if(zeroMask)
211 {
212 ASSERT(!(dependency.dependencyFlags & VK_DEPENDENCY_VIEW_LOCAL_BIT));
213 }
214 }
215
216 // If the pNext chain includes an instance of VkRenderPassMultiviewCreateInfo,
217 // each element of its pViewMask member must not include a bit at a position
218 // greater than the value of VkPhysicalDeviceLimits::maxFramebufferLayers
219 // pViewMask is a 32 bit value. If maxFramebufferLayers > 32, it's impossible
220 // for pViewMask to contain a bit at an illegal position
221 // Note: Verify pViewMask values instead if we hit this assert
222 ASSERT(vk::Cast(device)->getPhysicalDevice()->getProperties().limits.maxFramebufferLayers >= 32);
223 }
224 break;
225 case VK_STRUCTURE_TYPE_MAX_ENUM:
226 // dEQP tests that this value is ignored.
227 break;
228 default:
229 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
230 break;
231 }
232
233 extensionCreateInfo = extensionCreateInfo->pNext;
234 }
235}
236
237} // namespace
238
239extern "C" {
240VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char *pName)
241{
242 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
243
244 return vk::GetInstanceProcAddr(instance: vk::Cast(object: instance), pName);
245}
246
247VK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
248{
249 *pSupportedVersion = 3;
250 return VK_SUCCESS;
251}
252
253#if VK_USE_PLATFORM_FUCHSIA
254
255// This symbol must be exported by a Fuchsia Vulkan ICD. The Vulkan loader will
256// call it, passing the address of a global function pointer that can later be
257// used at runtime to connect to Fuchsia FIDL services, as required by certain
258// extensions. See https://fxbug.dev/13095 for more details.
259//
260// NOTE: This entry point has not been upstreamed to Khronos yet, which reserves
261// all symbols starting with vk_icd. See https://fxbug.dev/13074 which
262// tracks upstreaming progress.
263VK_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vk_icdInitializeConnectToServiceCallback(
264 PFN_vkConnectToService callback)
265{
266 TRACE("(callback = %p)", callback);
267 vk::icdFuchsiaServiceConnectCallback = callback;
268 return VK_SUCCESS;
269}
270
271#endif // VK_USE_PLATFORM_FUCHSIA
272
273struct ExtensionProperties : public VkExtensionProperties
274{
275 std::function<bool()> isSupported = [] { return true; };
276};
277
278// TODO(b/208256248): Avoid exit-time destructor.
279static const ExtensionProperties instanceExtensionProperties[] = {
280 { { VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION } },
281 { { VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION } },
282 { { VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION } },
283 { { VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION } },
284 { { VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION } },
285 { { VK_EXT_DEBUG_UTILS_EXTENSION_NAME, VK_EXT_DEBUG_UTILS_SPEC_VERSION } },
286 { { VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, VK_EXT_HEADLESS_SURFACE_SPEC_VERSION } },
287#ifndef __ANDROID__
288 { { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_SPEC_VERSION } },
289 { { VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME, VK_EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION } },
290 { { VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION } },
291#endif
292#ifdef VK_USE_PLATFORM_XCB_KHR
293 { { VK_KHR_XCB_SURFACE_EXTENSION_NAME, VK_KHR_XCB_SURFACE_SPEC_VERSION }, .isSupported: [] { return vk::XcbSurfaceKHR::isSupported(); } },
294#endif
295#ifdef VK_USE_PLATFORM_WAYLAND_KHR
296 { { VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, VK_KHR_WAYLAND_SURFACE_SPEC_VERSION }, .isSupported: [] { return vk::WaylandSurfaceKHR::isSupported(); } },
297#endif
298#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
299 { { VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME, VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION } },
300#endif
301#ifdef VK_USE_PLATFORM_DISPLAY_KHR
302 { { VK_KHR_DISPLAY_EXTENSION_NAME, VK_KHR_DISPLAY_SPEC_VERSION } },
303#endif
304#ifdef VK_USE_PLATFORM_MACOS_MVK
305 { { VK_MVK_MACOS_SURFACE_EXTENSION_NAME, VK_MVK_MACOS_SURFACE_SPEC_VERSION } },
306#endif
307#ifdef VK_USE_PLATFORM_METAL_EXT
308 { { VK_EXT_METAL_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_SPEC_VERSION } },
309#endif
310#ifdef VK_USE_PLATFORM_WIN32_KHR
311 { { VK_KHR_WIN32_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_SPEC_VERSION } },
312#endif
313};
314
315// TODO(b/208256248): Avoid exit-time destructor.
316static const ExtensionProperties deviceExtensionProperties[] = {
317 { { VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME, VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION } },
318 // Vulkan 1.1 promoted extensions
319 { { VK_KHR_BIND_MEMORY_2_EXTENSION_NAME, VK_KHR_BIND_MEMORY_2_SPEC_VERSION } },
320 { { VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME, VK_KHR_CREATE_RENDERPASS_2_SPEC_VERSION } },
321 { { VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION } },
322 { { VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME, VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION } },
323 { { VK_KHR_DEVICE_GROUP_EXTENSION_NAME, VK_KHR_DEVICE_GROUP_SPEC_VERSION } },
324 { { VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME, VK_KHR_EXTERNAL_FENCE_SPEC_VERSION } },
325 { { VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION } },
326 { { VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION } },
327 { { VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION } },
328 { { VK_KHR_MAINTENANCE1_EXTENSION_NAME, VK_KHR_MAINTENANCE1_SPEC_VERSION } },
329 { { VK_KHR_MAINTENANCE2_EXTENSION_NAME, VK_KHR_MAINTENANCE2_SPEC_VERSION } },
330 { { VK_KHR_MAINTENANCE3_EXTENSION_NAME, VK_KHR_MAINTENANCE3_SPEC_VERSION } },
331 { { VK_KHR_MULTIVIEW_EXTENSION_NAME, VK_KHR_MULTIVIEW_SPEC_VERSION } },
332 { { VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME, VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION } },
333 { { VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME, VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION } },
334 { { VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME, VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION } },
335 // Only 1.1 core version of this is supported. The extension has additional requirements
336 //{{ VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION }},
337 { { VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME, VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION } },
338 // Only 1.1 core version of this is supported. The extension has additional requirements
339 //{{ VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME, VK_KHR_VARIABLE_POINTERS_SPEC_VERSION }},
340 { { VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME, VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION } },
341#ifndef __ANDROID__
342 // We fully support the KHR_swapchain v70 additions, so just track the spec version.
343 { { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_SWAPCHAIN_SPEC_VERSION } },
344#else
345 // We only support V7 of this extension. Missing functionality: in V8,
346 // it becomes possible to pass a VkNativeBufferANDROID structure to
347 // vkBindImageMemory2. Android's swapchain implementation does this in
348 // order to support passing VkBindImageMemorySwapchainInfoKHR
349 // (from KHR_swapchain v70) to vkBindImageMemory2.
350 { { VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME, 7 } },
351#endif
352#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
353 { { VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION } },
354#endif
355#if SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
356 { { VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION } },
357#endif
358#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
359 { { VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME, VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION } },
360#endif
361#if !defined(__APPLE__)
362 { { VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME, VK_EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION } },
363#endif
364#if VK_USE_PLATFORM_FUCHSIA
365 { { VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME, VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION } },
366 { { VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME, VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION } },
367#endif
368 { { VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME, VK_EXT_PROVOKING_VERTEX_SPEC_VERSION } },
369#if !defined(__ANDROID__)
370 { { VK_GOOGLE_SAMPLER_FILTERING_PRECISION_EXTENSION_NAME, VK_GOOGLE_SAMPLER_FILTERING_PRECISION_SPEC_VERSION } },
371#endif
372 { { VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME, VK_EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION } },
373#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
374 { { VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME, VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION } },
375#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
376 // Vulkan 1.2 promoted extensions
377 { { VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME, VK_EXT_HOST_QUERY_RESET_SPEC_VERSION } },
378 { { VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME, VK_EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION } },
379 { { VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME, VK_EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION } },
380 { { VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME, VK_KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION } },
381 { { VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME, VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION } },
382 { { VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME, VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION } },
383 { { VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME, VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION } },
384 { { VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME, VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION } },
385 { { VK_KHR_SPIRV_1_4_EXTENSION_NAME, VK_KHR_SPIRV_1_4_SPEC_VERSION } },
386 { { VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME, VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION } },
387 { { VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, VK_KHR_TIMELINE_SEMAPHORE_SPEC_VERSION } },
388 // Vulkan 1.3 promoted extensions
389 { { VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME, VK_EXT_EXTENDED_DYNAMIC_STATE_SPEC_VERSION } },
390 { { VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME, VK_EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION } },
391 { { VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME, VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_SPEC_VERSION } },
392 { { VK_EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME, VK_EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION } },
393 { { VK_EXT_PRIVATE_DATA_EXTENSION_NAME, VK_EXT_PRIVATE_DATA_SPEC_VERSION } },
394 { { VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME, VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION } },
395 { { VK_KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME, VK_KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION } },
396 { { VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME, VK_EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION } },
397 { { VK_EXT_TOOLING_INFO_EXTENSION_NAME, VK_EXT_TOOLING_INFO_SPEC_VERSION } },
398 { { VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME, VK_KHR_COPY_COMMANDS_2_SPEC_VERSION } },
399 { { VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, VK_KHR_DYNAMIC_RENDERING_SPEC_VERSION } },
400 { { VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME, VK_KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION } },
401 { { VK_KHR_MAINTENANCE_4_EXTENSION_NAME, VK_KHR_MAINTENANCE_4_SPEC_VERSION } },
402 { { VK_KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME, VK_KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION } },
403 { { VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME, VK_KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION } },
404 { { VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME, VK_KHR_SYNCHRONIZATION_2_SPEC_VERSION } },
405 { { VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_EXTENSION_NAME, VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_SPEC_VERSION } },
406 // Roadmap 2022 extension
407 { { VK_KHR_GLOBAL_PRIORITY_EXTENSION_NAME, VK_KHR_GLOBAL_PRIORITY_SPEC_VERSION } },
408 // Additional extension
409 { { VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION } },
410 { { VK_GOOGLE_DECORATE_STRING_EXTENSION_NAME, VK_GOOGLE_DECORATE_STRING_SPEC_VERSION } },
411 { { VK_GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME, VK_GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION } },
412 { { VK_GOOGLE_USER_TYPE_EXTENSION_NAME, VK_GOOGLE_USER_TYPE_SPEC_VERSION } },
413 { { VK_KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME, VK_KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION } },
414 { { VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION } },
415 { { VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME, VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION } },
416 { { VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME, VK_KHR_PIPELINE_LIBRARY_SPEC_VERSION } },
417#ifndef __ANDROID__
418 { { VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME, VK_EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION } },
419#endif
420 { { VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME, VK_EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION } },
421 { { VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_EXT_DESCRIPTOR_INDEXING_SPEC_VERSION } },
422 { { VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME, VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION } },
423 { { VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME, VK_EXT_CUSTOM_BORDER_COLOR_SPEC_VERSION } },
424 { { VK_EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME, VK_EXT_LOAD_STORE_OP_NONE_SPEC_VERSION } },
425 // The following extension is only used to add support for Bresenham lines
426 { { VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME, VK_EXT_LINE_RASTERIZATION_SPEC_VERSION } },
427 // The following extension is used by ANGLE to emulate blitting the stencil buffer
428 { { VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME, VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION } },
429 { { VK_EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME, VK_EXT_IMAGE_ROBUSTNESS_SPEC_VERSION } },
430 // Useful for D3D emulation
431 { { VK_EXT_4444_FORMATS_EXTENSION_NAME, VK_EXT_4444_FORMATS_SPEC_VERSION } },
432 // Used by ANGLE to support GL_KHR_blend_equation_advanced
433 { { VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME, VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION } },
434 // Used by ANGLE to implement triangle/etc list restarts as possible in OpenGL
435 { { VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME, VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_SPEC_VERSION } },
436 { { VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME, VK_EXT_PIPELINE_ROBUSTNESS_SPEC_VERSION } },
437 { { VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME, VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION } }
438};
439
440static uint32_t numSupportedExtensions(const ExtensionProperties *extensionProperties, uint32_t extensionPropertiesCount)
441{
442 uint32_t count = 0;
443
444 for(uint32_t i = 0; i < extensionPropertiesCount; i++)
445 {
446 if(extensionProperties[i].isSupported())
447 {
448 count++;
449 }
450 }
451
452 return count;
453}
454
455static uint32_t numInstanceSupportedExtensions()
456{
457 return numSupportedExtensions(extensionProperties: instanceExtensionProperties, extensionPropertiesCount: sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]));
458}
459
460static uint32_t numDeviceSupportedExtensions()
461{
462 return numSupportedExtensions(extensionProperties: deviceExtensionProperties, extensionPropertiesCount: sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]));
463}
464
465static bool hasExtension(const char *extensionName, const ExtensionProperties *extensionProperties, uint32_t extensionPropertiesCount)
466{
467 for(uint32_t i = 0; i < extensionPropertiesCount; i++)
468 {
469 if(strcmp(s1: extensionName, s2: extensionProperties[i].extensionName) == 0)
470 {
471 return extensionProperties[i].isSupported();
472 }
473 }
474
475 return false;
476}
477
478static bool hasInstanceExtension(const char *extensionName)
479{
480 return hasExtension(extensionName, extensionProperties: instanceExtensionProperties, extensionPropertiesCount: sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]));
481}
482
483static bool hasDeviceExtension(const char *extensionName)
484{
485 return hasExtension(extensionName, extensionProperties: deviceExtensionProperties, extensionPropertiesCount: sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]));
486}
487
488static void copyExtensions(VkExtensionProperties *pProperties, uint32_t toCopy, const ExtensionProperties *extensionProperties, uint32_t extensionPropertiesCount)
489{
490 for(uint32_t i = 0, j = 0; i < toCopy; i++, j++)
491 {
492 while((j < extensionPropertiesCount) && !extensionProperties[j].isSupported())
493 {
494 j++;
495 }
496 if(j < extensionPropertiesCount)
497 {
498 pProperties[i] = extensionProperties[j];
499 }
500 }
501}
502
503static void copyInstanceExtensions(VkExtensionProperties *pProperties, uint32_t toCopy)
504{
505 copyExtensions(pProperties, toCopy, extensionProperties: instanceExtensionProperties, extensionPropertiesCount: sizeof(instanceExtensionProperties) / sizeof(instanceExtensionProperties[0]));
506}
507
508static void copyDeviceExtensions(VkExtensionProperties *pProperties, uint32_t toCopy)
509{
510 copyExtensions(pProperties, toCopy, extensionProperties: deviceExtensionProperties, extensionPropertiesCount: sizeof(deviceExtensionProperties) / sizeof(deviceExtensionProperties[0]));
511}
512
513VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)
514{
515 TRACE("(const VkInstanceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkInstance* pInstance = %p)",
516 pCreateInfo, pAllocator, pInstance);
517
518 initializeLibrary();
519
520 if(pCreateInfo->flags != 0)
521 {
522 // Vulkan 1.3: "flags is reserved for future use." "flags must be 0"
523 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
524 }
525
526 if(pCreateInfo->enabledLayerCount != 0)
527 {
528 // Creating instances with unsupported layers should fail and SwiftShader doesn't support any layer
529 return VK_ERROR_LAYER_NOT_PRESENT;
530 }
531
532 for(uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
533 {
534 if(!hasInstanceExtension(extensionName: pCreateInfo->ppEnabledExtensionNames[i]))
535 {
536 return VK_ERROR_EXTENSION_NOT_PRESENT;
537 }
538 }
539
540 VkDebugUtilsMessengerEXT messenger = { VK_NULL_HANDLE };
541 if(pCreateInfo->pNext)
542 {
543 const VkBaseInStructure *createInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
544 switch(createInfo->sType)
545 {
546 case VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT:
547 {
548 const VkDebugUtilsMessengerCreateInfoEXT *debugUtilsMessengerCreateInfoEXT = reinterpret_cast<const VkDebugUtilsMessengerCreateInfoEXT *>(createInfo);
549 VkResult result = vk::DebugUtilsMessenger::Create(pAllocator, pCreateInfo: debugUtilsMessengerCreateInfoEXT, outObject: &messenger);
550 if(result != VK_SUCCESS)
551 {
552 return result;
553 }
554 }
555 break;
556 case VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO:
557 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
558 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
559 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
560 // internal use by the loader, and do not have corresponding
561 // Vulkan structures in this Specification."
562 break;
563 case VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG:
564 // TODO(b/229112690): This structure is only meant to be used by the Vulkan Loader
565 // and should not be forwarded to the driver.
566 break;
567 default:
568 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(createInfo->sType).c_str());
569 break;
570 }
571 }
572
573 *pInstance = VK_NULL_HANDLE;
574 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
575
576 VkResult result = vk::DispatchablePhysicalDevice::Create(pAllocator, pCreateInfo, outObject: &physicalDevice);
577 if(result != VK_SUCCESS)
578 {
579 vk::destroy(vkObject: messenger, pAllocator);
580 return result;
581 }
582
583 result = vk::DispatchableInstance::Create(pAllocator, pCreateInfo, outObject: pInstance, extendedInfo: physicalDevice, extendedInfo: vk::Cast(object: messenger));
584 if(result != VK_SUCCESS)
585 {
586 vk::destroy(vkObject: messenger, pAllocator);
587 vk::destroy(vkObject: physicalDevice, pAllocator);
588 return result;
589 }
590
591 return result;
592}
593
594VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
595{
596 TRACE("(VkInstance instance = %p, const VkAllocationCallbacks* pAllocator = %p)", instance, pAllocator);
597
598 vk::destroy(vkObject: instance, pAllocator);
599}
600
601VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
602{
603 TRACE("(VkInstance instance = %p, uint32_t* pPhysicalDeviceCount = %p, VkPhysicalDevice* pPhysicalDevices = %p)",
604 instance, pPhysicalDeviceCount, pPhysicalDevices);
605
606 return vk::Cast(object: instance)->getPhysicalDevices(pPhysicalDeviceCount, pPhysicalDevices);
607}
608
609VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
610{
611 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures* pFeatures = %p)",
612 physicalDevice, pFeatures);
613
614 *pFeatures = vk::Cast(object: physicalDevice)->getFeatures();
615}
616
617VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)
618{
619 TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties* pFormatProperties = %p)",
620 physicalDevice, (int)format, pFormatProperties);
621
622 vk::PhysicalDevice::GetFormatProperties(format, pFormatProperties);
623}
624
625VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties)
626{
627 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkImageType type = %d, VkImageTiling tiling = %d, VkImageUsageFlags usage = %d, VkImageCreateFlags flags = %d, VkImageFormatProperties* pImageFormatProperties = %p)",
628 physicalDevice, (int)format, (int)type, (int)tiling, usage, flags, pImageFormatProperties);
629
630 VkPhysicalDeviceImageFormatInfo2 info2 = {};
631 info2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2;
632 info2.pNext = nullptr;
633 info2.format = format;
634 info2.type = type;
635 info2.tiling = tiling;
636 info2.usage = usage;
637 info2.flags = flags;
638
639 VkImageFormatProperties2 properties2 = {};
640 properties2.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2;
641 properties2.pNext = nullptr;
642
643 VkResult result = vkGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo: &info2, pImageFormatProperties: &properties2);
644
645 *pImageFormatProperties = properties2.imageFormatProperties;
646
647 return result;
648}
649
650VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
651{
652 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties* pProperties = %p)",
653 physicalDevice, pProperties);
654
655 *pProperties = vk::Cast(object: physicalDevice)->getProperties();
656}
657
658VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties)
659{
660 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties* pQueueFamilyProperties = %p))", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
661
662 if(!pQueueFamilyProperties)
663 {
664 *pQueueFamilyPropertyCount = vk::Cast(object: physicalDevice)->getQueueFamilyPropertyCount();
665 }
666 else
667 {
668 vk::Cast(object: physicalDevice)->getQueueFamilyProperties(pQueueFamilyPropertyCount: *pQueueFamilyPropertyCount, pQueueFamilyProperties);
669 }
670}
671
672VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties)
673{
674 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
675
676 *pMemoryProperties = vk::PhysicalDevice::GetMemoryProperties();
677}
678
679VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
680{
681 TRACE("(VkInstance instance = %p, const char* pName = %p)", instance, pName);
682
683 return vk::GetInstanceProcAddr(instance: vk::Cast(object: instance), pName);
684}
685
686VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName)
687{
688 TRACE("(VkDevice device = %p, const char* pName = %p)", device, pName);
689
690 return vk::GetDeviceProcAddr(device: vk::Cast(object: device), pName);
691}
692
693VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
694{
695 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkDeviceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDevice* pDevice = %p)",
696 physicalDevice, pCreateInfo, pAllocator, pDevice);
697
698 if(pCreateInfo->flags != 0)
699 {
700 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
701 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
702 }
703
704 if(pCreateInfo->enabledLayerCount != 0)
705 {
706 // "The ppEnabledLayerNames and enabledLayerCount members of VkDeviceCreateInfo are deprecated and their values must be ignored by implementations."
707 UNSUPPORTED("pCreateInfo->enabledLayerCount != 0");
708 }
709
710 for(uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; ++i)
711 {
712 if(!hasDeviceExtension(extensionName: pCreateInfo->ppEnabledExtensionNames[i]))
713 {
714 return VK_ERROR_EXTENSION_NOT_PRESENT;
715 }
716 }
717
718 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
719
720 const VkPhysicalDeviceFeatures *enabledFeatures = pCreateInfo->pEnabledFeatures;
721
722 while(extensionCreateInfo)
723 {
724 switch(extensionCreateInfo->sType)
725 {
726 case VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO:
727 // According to the Vulkan spec, section 2.7.2. Implicit Valid Usage:
728 // "The values VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO and
729 // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO are reserved for
730 // internal use by the loader, and do not have corresponding
731 // Vulkan structures in this Specification."
732 break;
733 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2:
734 {
735 ASSERT(!pCreateInfo->pEnabledFeatures); // "If the pNext chain includes a VkPhysicalDeviceFeatures2 structure, then pEnabledFeatures must be NULL"
736
737 const VkPhysicalDeviceFeatures2 *physicalDeviceFeatures2 = reinterpret_cast<const VkPhysicalDeviceFeatures2 *>(extensionCreateInfo);
738
739 enabledFeatures = &physicalDeviceFeatures2->features;
740 }
741 break;
742 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES:
743 {
744 const VkPhysicalDeviceSamplerYcbcrConversionFeatures *samplerYcbcrConversionFeatures = reinterpret_cast<const VkPhysicalDeviceSamplerYcbcrConversionFeatures *>(extensionCreateInfo);
745
746 // YCbCr conversion is supported.
747 // samplerYcbcrConversionFeatures->samplerYcbcrConversion can be VK_TRUE or VK_FALSE.
748 // No action needs to be taken on our end in either case; it's the apps responsibility that
749 // "To create a sampler Y'CbCr conversion, the samplerYcbcrConversion feature must be enabled."
750 (void)samplerYcbcrConversionFeatures->samplerYcbcrConversion;
751 }
752 break;
753 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES:
754 {
755 const VkPhysicalDevice16BitStorageFeatures *storage16BitFeatures = reinterpret_cast<const VkPhysicalDevice16BitStorageFeatures *>(extensionCreateInfo);
756
757 if(storage16BitFeatures->storageBuffer16BitAccess != VK_FALSE ||
758 storage16BitFeatures->uniformAndStorageBuffer16BitAccess != VK_FALSE ||
759 storage16BitFeatures->storagePushConstant16 != VK_FALSE ||
760 storage16BitFeatures->storageInputOutput16 != VK_FALSE)
761 {
762 return VK_ERROR_FEATURE_NOT_PRESENT;
763 }
764 }
765 break;
766 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES:
767 {
768 const VkPhysicalDeviceVariablePointerFeatures *variablePointerFeatures = reinterpret_cast<const VkPhysicalDeviceVariablePointerFeatures *>(extensionCreateInfo);
769
770 if(variablePointerFeatures->variablePointersStorageBuffer != VK_FALSE ||
771 variablePointerFeatures->variablePointers != VK_FALSE)
772 {
773 return VK_ERROR_FEATURE_NOT_PRESENT;
774 }
775 }
776 break;
777 case VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO:
778 {
779 const VkDeviceGroupDeviceCreateInfo *groupDeviceCreateInfo = reinterpret_cast<const VkDeviceGroupDeviceCreateInfo *>(extensionCreateInfo);
780
781 if((groupDeviceCreateInfo->physicalDeviceCount != 1) ||
782 (groupDeviceCreateInfo->pPhysicalDevices[0] != physicalDevice))
783 {
784 return VK_ERROR_FEATURE_NOT_PRESENT;
785 }
786 }
787 break;
788 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES:
789 {
790 const VkPhysicalDeviceMultiviewFeatures *multiviewFeatures = reinterpret_cast<const VkPhysicalDeviceMultiviewFeatures *>(extensionCreateInfo);
791
792 if(multiviewFeatures->multiviewGeometryShader ||
793 multiviewFeatures->multiviewTessellationShader)
794 {
795 return VK_ERROR_FEATURE_NOT_PRESENT;
796 }
797 }
798 break;
799 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES:
800 {
801 const VkPhysicalDeviceShaderDrawParametersFeatures *shaderDrawParametersFeatures = reinterpret_cast<const VkPhysicalDeviceShaderDrawParametersFeatures *>(extensionCreateInfo);
802
803 if(shaderDrawParametersFeatures->shaderDrawParameters)
804 {
805 return VK_ERROR_FEATURE_NOT_PRESENT;
806 }
807 }
808 break;
809 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES:
810 {
811 const VkPhysicalDeviceDynamicRenderingFeatures *dynamicRenderingFeatures = reinterpret_cast<const VkPhysicalDeviceDynamicRenderingFeatures *>(extensionCreateInfo);
812
813 // Dynamic rendering is supported
814 (void)(dynamicRenderingFeatures->dynamicRendering);
815 }
816 break;
817 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES:
818 {
819 const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *shaderDrawParametersFeatures = reinterpret_cast<const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR *>(extensionCreateInfo);
820
821 // Separate depth and stencil layouts is already supported
822 (void)(shaderDrawParametersFeatures->separateDepthStencilLayouts);
823 }
824 break;
825 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT:
826 {
827 const auto *lineRasterizationFeatures = reinterpret_cast<const VkPhysicalDeviceLineRasterizationFeaturesEXT *>(extensionCreateInfo);
828 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: lineRasterizationFeatures);
829 if(!hasFeatures)
830 {
831 return VK_ERROR_FEATURE_NOT_PRESENT;
832 }
833 }
834 break;
835 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT:
836 {
837 const VkPhysicalDeviceProvokingVertexFeaturesEXT *provokingVertexFeatures = reinterpret_cast<const VkPhysicalDeviceProvokingVertexFeaturesEXT *>(extensionCreateInfo);
838 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: provokingVertexFeatures);
839 if(!hasFeatures)
840 {
841 return VK_ERROR_FEATURE_NOT_PRESENT;
842 }
843 }
844 break;
845 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES:
846 {
847 const VkPhysicalDeviceImageRobustnessFeatures *imageRobustnessFeatures = reinterpret_cast<const VkPhysicalDeviceImageRobustnessFeatures *>(extensionCreateInfo);
848
849 // We currently always provide robust image accesses. When the feature is disabled, results are
850 // undefined (for images with Dim != Buffer), so providing robustness is also acceptable.
851 // TODO(b/159329067): Only provide robustness when requested.
852 (void)imageRobustnessFeatures->robustImageAccess;
853 }
854 break;
855 // For unsupported structures, check that we don't expose the corresponding extension string:
856 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT:
857 ASSERT(!hasDeviceExtension(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME));
858 break;
859 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES:
860 {
861 const VkPhysicalDeviceImagelessFramebufferFeaturesKHR *imagelessFramebufferFeatures = reinterpret_cast<const VkPhysicalDeviceImagelessFramebufferFeaturesKHR *>(extensionCreateInfo);
862 // Always provide Imageless Framebuffers
863 (void)imagelessFramebufferFeatures->imagelessFramebuffer;
864 }
865 break;
866 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES:
867 {
868 const VkPhysicalDeviceScalarBlockLayoutFeatures *scalarBlockLayoutFeatures = reinterpret_cast<const VkPhysicalDeviceScalarBlockLayoutFeatures *>(extensionCreateInfo);
869
870 // VK_EXT_scalar_block_layout is supported, allowing C-like structure layout for SPIR-V blocks.
871 (void)scalarBlockLayoutFeatures->scalarBlockLayout;
872 }
873 break;
874#ifdef SWIFTSHADER_DEVICE_MEMORY_REPORT
875 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT:
876 {
877 const VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *deviceMemoryReportFeatures = reinterpret_cast<const VkPhysicalDeviceDeviceMemoryReportFeaturesEXT *>(extensionCreateInfo);
878 (void)deviceMemoryReportFeatures->deviceMemoryReport;
879 }
880 break;
881#endif // SWIFTSHADER_DEVICE_MEMORY_REPORT
882 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES:
883 {
884 const VkPhysicalDeviceHostQueryResetFeatures *hostQueryResetFeatures = reinterpret_cast<const VkPhysicalDeviceHostQueryResetFeatures *>(extensionCreateInfo);
885
886 // VK_EXT_host_query_reset is always enabled.
887 (void)hostQueryResetFeatures->hostQueryReset;
888 }
889 break;
890 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES:
891 {
892 const VkPhysicalDevicePipelineCreationCacheControlFeatures *pipelineCreationCacheControlFeatures = reinterpret_cast<const VkPhysicalDevicePipelineCreationCacheControlFeatures *>(extensionCreateInfo);
893
894 // VK_EXT_pipeline_creation_cache_control is always enabled.
895 (void)pipelineCreationCacheControlFeatures->pipelineCreationCacheControl;
896 }
897 break;
898 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES:
899 {
900 const auto *tsFeatures = reinterpret_cast<const VkPhysicalDeviceTimelineSemaphoreFeatures *>(extensionCreateInfo);
901
902 // VK_KHR_timeline_semaphores is always enabled
903 (void)tsFeatures->timelineSemaphore;
904 }
905 break;
906 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT:
907 {
908 const auto *customBorderColorFeatures = reinterpret_cast<const VkPhysicalDeviceCustomBorderColorFeaturesEXT *>(extensionCreateInfo);
909
910 // VK_EXT_custom_border_color is always enabled
911 (void)customBorderColorFeatures->customBorderColors;
912 (void)customBorderColorFeatures->customBorderColorWithoutFormat;
913 }
914 break;
915 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES:
916 {
917 const auto *vk11Features = reinterpret_cast<const VkPhysicalDeviceVulkan11Features *>(extensionCreateInfo);
918 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: vk11Features);
919 if(!hasFeatures)
920 {
921 return VK_ERROR_FEATURE_NOT_PRESENT;
922 }
923 }
924 break;
925 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES:
926 {
927 const auto *vk12Features = reinterpret_cast<const VkPhysicalDeviceVulkan12Features *>(extensionCreateInfo);
928 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: vk12Features);
929 if(!hasFeatures)
930 {
931 return VK_ERROR_FEATURE_NOT_PRESENT;
932 }
933 }
934 break;
935 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES:
936 {
937 const auto *vk13Features = reinterpret_cast<const VkPhysicalDeviceVulkan13Features *>(extensionCreateInfo);
938 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: vk13Features);
939 if(!hasFeatures)
940 {
941 return VK_ERROR_FEATURE_NOT_PRESENT;
942 }
943 }
944 break;
945 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT:
946 {
947 const auto *depthClipFeatures = reinterpret_cast<const VkPhysicalDeviceDepthClipEnableFeaturesEXT *>(extensionCreateInfo);
948 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: depthClipFeatures);
949 if(!hasFeatures)
950 {
951 return VK_ERROR_FEATURE_NOT_PRESENT;
952 }
953 }
954 break;
955 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT:
956 {
957 const auto *blendOpFeatures = reinterpret_cast<const VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT *>(extensionCreateInfo);
958 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: blendOpFeatures);
959 if(!hasFeatures)
960 {
961 return VK_ERROR_FEATURE_NOT_PRESENT;
962 }
963 }
964 break;
965 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT:
966 {
967 const auto *dynamicStateFeatures = reinterpret_cast<const VkPhysicalDeviceExtendedDynamicStateFeaturesEXT *>(extensionCreateInfo);
968 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: dynamicStateFeatures);
969 if(!hasFeatures)
970 {
971 return VK_ERROR_FEATURE_NOT_PRESENT;
972 }
973 }
974 break;
975 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES:
976 {
977 const auto *privateDataFeatures = reinterpret_cast<const VkPhysicalDevicePrivateDataFeatures *>(extensionCreateInfo);
978 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: privateDataFeatures);
979 if(!hasFeatures)
980 {
981 return VK_ERROR_FEATURE_NOT_PRESENT;
982 }
983 }
984 break;
985 case VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO:
986 {
987 const auto *privateDataCreateInfo = reinterpret_cast<const VkDevicePrivateDataCreateInfo *>(extensionCreateInfo);
988 (void)privateDataCreateInfo->privateDataSlotRequestCount;
989 }
990 break;
991 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES:
992 {
993 const auto *textureCompressionASTCHDRFeatures = reinterpret_cast<const VkPhysicalDeviceTextureCompressionASTCHDRFeatures *>(extensionCreateInfo);
994 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: textureCompressionASTCHDRFeatures);
995 if(!hasFeatures)
996 {
997 return VK_ERROR_FEATURE_NOT_PRESENT;
998 }
999 }
1000 break;
1001 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES:
1002 {
1003 const auto *shaderDemoteToHelperInvocationFeatures = reinterpret_cast<const VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures *>(extensionCreateInfo);
1004 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: shaderDemoteToHelperInvocationFeatures);
1005 if(!hasFeatures)
1006 {
1007 return VK_ERROR_FEATURE_NOT_PRESENT;
1008 }
1009 }
1010 break;
1011 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES:
1012 {
1013 const auto *shaderTerminateInvocationFeatures = reinterpret_cast<const VkPhysicalDeviceShaderTerminateInvocationFeatures *>(extensionCreateInfo);
1014 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: shaderTerminateInvocationFeatures);
1015 if(!hasFeatures)
1016 {
1017 return VK_ERROR_FEATURE_NOT_PRESENT;
1018 }
1019 }
1020 break;
1021 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES:
1022 {
1023 const auto *subgroupSizeControlFeatures = reinterpret_cast<const VkPhysicalDeviceSubgroupSizeControlFeatures *>(extensionCreateInfo);
1024 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: subgroupSizeControlFeatures);
1025 if(!hasFeatures)
1026 {
1027 return VK_ERROR_FEATURE_NOT_PRESENT;
1028 }
1029 }
1030 break;
1031 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES:
1032 {
1033 const auto *uniformBlockFeatures = reinterpret_cast<const VkPhysicalDeviceInlineUniformBlockFeatures *>(extensionCreateInfo);
1034 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: uniformBlockFeatures);
1035 if(!hasFeatures)
1036 {
1037 return VK_ERROR_FEATURE_NOT_PRESENT;
1038 }
1039 }
1040 break;
1041 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES:
1042 {
1043 const auto *integerDotProductFeatures = reinterpret_cast<const VkPhysicalDeviceShaderIntegerDotProductFeatures *>(extensionCreateInfo);
1044 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(features: integerDotProductFeatures);
1045 if(!hasFeatures)
1046 {
1047 return VK_ERROR_FEATURE_NOT_PRESENT;
1048 }
1049 }
1050 break;
1051 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES:
1052 {
1053 const auto *zeroInitializeWorkgroupMemoryFeatures = reinterpret_cast<const VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures *>(extensionCreateInfo);
1054 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: zeroInitializeWorkgroupMemoryFeatures);
1055 if(!hasFeatures)
1056 {
1057 return VK_ERROR_FEATURE_NOT_PRESENT;
1058 }
1059 }
1060 break;
1061 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT:
1062 {
1063 const auto *primitiveTopologyListRestartFeatures = reinterpret_cast<const VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT *>(extensionCreateInfo);
1064 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: primitiveTopologyListRestartFeatures);
1065 if(!hasFeatures)
1066 {
1067 return VK_ERROR_FEATURE_NOT_PRESENT;
1068 }
1069 }
1070 break;
1071 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES:
1072 {
1073 const auto *descriptorIndexingFeatures = reinterpret_cast<const VkPhysicalDeviceDescriptorIndexingFeatures *>(extensionCreateInfo);
1074 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: descriptorIndexingFeatures);
1075 if(!hasFeatures)
1076 {
1077 return VK_ERROR_FEATURE_NOT_PRESENT;
1078 }
1079 }
1080 break;
1081 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR:
1082 {
1083 const auto *globalPriorityQueryFeatures = reinterpret_cast<const VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR *>(extensionCreateInfo);
1084 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: globalPriorityQueryFeatures);
1085 if(!hasFeatures)
1086 {
1087 return VK_ERROR_FEATURE_NOT_PRESENT;
1088 }
1089 }
1090 break;
1091 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES:
1092 {
1093 const auto *protectedMemoryFeatures = reinterpret_cast<const VkPhysicalDeviceProtectedMemoryFeatures *>(extensionCreateInfo);
1094 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: protectedMemoryFeatures);
1095 if(!hasFeatures)
1096 {
1097 return VK_ERROR_FEATURE_NOT_PRESENT;
1098 }
1099 }
1100 break;
1101 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES:
1102 {
1103 const auto *bufferDeviceAddressFeatures = reinterpret_cast<const VkPhysicalDeviceBufferDeviceAddressFeatures *>(extensionCreateInfo);
1104 bool hasFeatures = vk::Cast(object: physicalDevice)->hasExtendedFeatures(requested: bufferDeviceAddressFeatures);
1105 if(!hasFeatures)
1106 {
1107 return VK_ERROR_FEATURE_NOT_PRESENT;
1108 }
1109 }
1110 break;
1111 // These structs are supported, but no behavior changes based on their feature flags
1112 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES:
1113 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES:
1114 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES:
1115 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES:
1116 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES:
1117 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT:
1118 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES:
1119 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES:
1120 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES:
1121 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT:
1122 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT:
1123 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT:
1124 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT:
1125 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_FEATURES_EXT:
1126 break;
1127 default:
1128 // "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]"
1129 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
1130 break;
1131 }
1132
1133 extensionCreateInfo = extensionCreateInfo->pNext;
1134 }
1135
1136 ASSERT(pCreateInfo->queueCreateInfoCount > 0);
1137
1138 if(enabledFeatures)
1139 {
1140 if(!vk::Cast(object: physicalDevice)->hasFeatures(requestedFeatures: *enabledFeatures))
1141 {
1142 return VK_ERROR_FEATURE_NOT_PRESENT;
1143 }
1144 }
1145
1146 uint32_t queueFamilyPropertyCount = vk::Cast(object: physicalDevice)->getQueueFamilyPropertyCount();
1147
1148 for(uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; i++)
1149 {
1150 const VkDeviceQueueCreateInfo &queueCreateInfo = pCreateInfo->pQueueCreateInfos[i];
1151 if(queueCreateInfo.flags != 0)
1152 {
1153 UNSUPPORTED("pCreateInfo->pQueueCreateInfos[%d]->flags 0x%08X", i, queueCreateInfo.flags);
1154 }
1155
1156 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(queueCreateInfo.pNext);
1157 while(extInfo)
1158 {
1159 switch(extInfo->sType)
1160 {
1161 case VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR:
1162 {
1163 const auto *globalPriorityCreateInfo = reinterpret_cast<const VkDeviceQueueGlobalPriorityCreateInfoKHR *>(extInfo);
1164 if(!(vk::Cast(object: physicalDevice)->validateQueueGlobalPriority(queueGlobalPriority: globalPriorityCreateInfo->globalPriority)))
1165 {
1166 return VK_ERROR_INITIALIZATION_FAILED;
1167 }
1168 }
1169 break;
1170 default:
1171 UNSUPPORTED("pCreateInfo->pQueueCreateInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
1172 break;
1173 }
1174
1175 extInfo = extInfo->pNext;
1176 }
1177
1178 ASSERT(queueCreateInfo.queueFamilyIndex < queueFamilyPropertyCount);
1179 (void)queueFamilyPropertyCount; // Silence unused variable warning
1180 }
1181
1182 auto scheduler = getOrCreateScheduler();
1183 return vk::DispatchableDevice::Create(pAllocator, pCreateInfo, outObject: pDevice, extendedInfo: vk::Cast(object: physicalDevice), extendedInfo: enabledFeatures, extendedInfo: scheduler);
1184}
1185
1186VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
1187{
1188 TRACE("(VkDevice device = %p, const VkAllocationCallbacks* pAllocator = %p)", device, pAllocator);
1189
1190 vk::destroy(vkObject: device, pAllocator);
1191}
1192
1193VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
1194{
1195 TRACE("(const char* pLayerName = %p, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)",
1196 pLayerName, pPropertyCount, pProperties);
1197
1198 uint32_t extensionPropertiesCount = numInstanceSupportedExtensions();
1199
1200 if(!pProperties)
1201 {
1202 *pPropertyCount = extensionPropertiesCount;
1203 return VK_SUCCESS;
1204 }
1205
1206 auto toCopy = std::min(a: *pPropertyCount, b: extensionPropertiesCount);
1207 copyInstanceExtensions(pProperties, toCopy);
1208
1209 *pPropertyCount = toCopy;
1210 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
1211}
1212
1213VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
1214{
1215 TRACE("(VkPhysicalDevice physicalDevice = %p, const char* pLayerName, uint32_t* pPropertyCount = %p, VkExtensionProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
1216
1217 uint32_t extensionPropertiesCount = numDeviceSupportedExtensions();
1218
1219 if(!pProperties)
1220 {
1221 *pPropertyCount = extensionPropertiesCount;
1222 return VK_SUCCESS;
1223 }
1224
1225 auto toCopy = std::min(a: *pPropertyCount, b: extensionPropertiesCount);
1226 copyDeviceExtensions(pProperties, toCopy);
1227
1228 *pPropertyCount = toCopy;
1229 return (toCopy < extensionPropertiesCount) ? VK_INCOMPLETE : VK_SUCCESS;
1230}
1231
1232VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(uint32_t *pPropertyCount, VkLayerProperties *pProperties)
1233{
1234 TRACE("(uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", pPropertyCount, pProperties);
1235
1236 if(!pProperties)
1237 {
1238 *pPropertyCount = 0;
1239 return VK_SUCCESS;
1240 }
1241
1242 return VK_SUCCESS;
1243}
1244
1245VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties)
1246{
1247 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkLayerProperties* pProperties = %p)", physicalDevice, pPropertyCount, pProperties);
1248
1249 if(!pProperties)
1250 {
1251 *pPropertyCount = 0;
1252 return VK_SUCCESS;
1253 }
1254
1255 return VK_SUCCESS;
1256}
1257
1258VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)
1259{
1260 TRACE("(VkDevice device = %p, uint32_t queueFamilyIndex = %d, uint32_t queueIndex = %d, VkQueue* pQueue = %p)",
1261 device, queueFamilyIndex, queueIndex, pQueue);
1262
1263 *pQueue = vk::Cast(object: device)->getQueue(queueFamilyIndex, queueIndex);
1264}
1265
1266VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
1267{
1268 TRACE("(VkQueue queue = %p, uint32_t submitCount = %d, const VkSubmitInfo* pSubmits = %p, VkFence fence = %p)",
1269 queue, submitCount, pSubmits, static_cast<void *>(fence));
1270
1271 return vk::Cast(object: queue)->submit(submitCount, pSubmits: vk::SubmitInfo::Allocate(submitCount, pSubmits), fence: vk::Cast(object: fence));
1272}
1273
1274VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit2(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2 *pSubmits, VkFence fence)
1275{
1276 TRACE("(VkQueue queue = %p, uint32_t submitCount = %d, const VkSubmitInfo2* pSubmits = %p, VkFence fence = %p)",
1277 queue, submitCount, pSubmits, static_cast<void *>(fence));
1278
1279 return vk::Cast(object: queue)->submit(submitCount, pSubmits: vk::SubmitInfo::Allocate(submitCount, pSubmits), fence: vk::Cast(object: fence));
1280}
1281
1282VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
1283{
1284 TRACE("(VkQueue queue = %p)", queue);
1285
1286 return vk::Cast(object: queue)->waitIdle();
1287}
1288
1289VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
1290{
1291 TRACE("(VkDevice device = %p)", device);
1292
1293 return vk::Cast(object: device)->waitIdle();
1294}
1295
1296VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
1297{
1298 TRACE("(VkDevice device = %p, const VkMemoryAllocateInfo* pAllocateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDeviceMemory* pMemory = %p)",
1299 device, pAllocateInfo, pAllocator, pMemory);
1300
1301 VkResult result = vk::DeviceMemory::Allocate(pAllocator, pAllocateInfo, pMemory, device: vk::Cast(object: device));
1302
1303 if(result != VK_SUCCESS)
1304 {
1305 vk::destroy(vkObject: *pMemory, pAllocator);
1306 *pMemory = VK_NULL_HANDLE;
1307 }
1308
1309 return result;
1310}
1311
1312VKAPI_ATTR void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
1313{
1314 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, const VkAllocationCallbacks* pAllocator = %p)",
1315 device, static_cast<void *>(memory), pAllocator);
1316
1317 vk::destroy(vkObject: memory, pAllocator);
1318}
1319
1320#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
1321VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR(VkDevice device, const VkMemoryGetFdInfoKHR *getFdInfo, int *pFd)
1322{
1323 TRACE("(VkDevice device = %p, const VkMemoryGetFdInfoKHR* getFdInfo = %p, int* pFd = %p",
1324 device, getFdInfo, pFd);
1325
1326 if(getFdInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
1327 {
1328 UNSUPPORTED("pGetFdInfo->handleType %u", getFdInfo->handleType);
1329 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1330 }
1331 return vk::Cast(object: getFdInfo->memory)->exportFd(pFd);
1332}
1333
1334VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR *pMemoryFdProperties)
1335{
1336 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, int fd = %d, VkMemoryFdPropertiesKHR* pMemoryFdProperties = %p)",
1337 device, handleType, fd, pMemoryFdProperties);
1338
1339 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
1340 {
1341 UNSUPPORTED("handleType %u", handleType);
1342 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1343 }
1344
1345 if(fd < 0)
1346 {
1347 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1348 }
1349
1350 const VkPhysicalDeviceMemoryProperties &memoryProperties =
1351 vk::PhysicalDevice::GetMemoryProperties();
1352
1353 // All SwiftShader memory types support this!
1354 pMemoryFdProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
1355
1356 return VK_SUCCESS;
1357}
1358#endif // SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
1359#if VK_USE_PLATFORM_FUCHSIA
1360VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA *pGetHandleInfo, zx_handle_t *pHandle)
1361{
1362 TRACE("(VkDevice device = %p, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetHandleInfo = %p, zx_handle_t* pHandle = %p",
1363 device, pGetHandleInfo, pHandle);
1364
1365 if(pGetHandleInfo->handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA)
1366 {
1367 UNSUPPORTED("pGetHandleInfo->handleType %u", pGetHandleInfo->handleType);
1368 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1369 }
1370 return vk::Cast(pGetHandleInfo->memory)->exportHandle(pHandle);
1371}
1372
1373VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t handle, VkMemoryZirconHandlePropertiesFUCHSIA *pMemoryZirconHandleProperties)
1374{
1375 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, zx_handle_t handle = %d, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties = %p)",
1376 device, handleType, handle, pMemoryZirconHandleProperties);
1377
1378 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA)
1379 {
1380 UNSUPPORTED("handleType %u", handleType);
1381 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1382 }
1383
1384 if(handle == ZX_HANDLE_INVALID)
1385 {
1386 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1387 }
1388
1389 const VkPhysicalDeviceMemoryProperties &memoryProperties =
1390 vk::PhysicalDevice::GetMemoryProperties();
1391
1392 // All SwiftShader memory types support this!
1393 pMemoryZirconHandleProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
1394
1395 return VK_SUCCESS;
1396}
1397#endif // VK_USE_PLATFORM_FUCHSIA
1398
1399VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, const void *pHostPointer, VkMemoryHostPointerPropertiesEXT *pMemoryHostPointerProperties)
1400{
1401 TRACE("(VkDevice device = %p, VkExternalMemoryHandleTypeFlagBits handleType = %x, const void *pHostPointer = %p, VkMemoryHostPointerPropertiesEXT *pMemoryHostPointerProperties = %p)",
1402 device, handleType, pHostPointer, pMemoryHostPointerProperties);
1403
1404 if(handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT && handleType != VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT)
1405 {
1406 UNSUPPORTED("handleType %u", handleType);
1407 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1408 }
1409 pMemoryHostPointerProperties->memoryTypeBits = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
1410
1411 return VK_SUCCESS;
1412}
1413
1414#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
1415VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID *pInfo, struct AHardwareBuffer **pBuffer)
1416{
1417 TRACE("(VkDevice device = %p, const VkMemoryGetAndroidHardwareBufferInfoANDROID *pInfo = %p, struct AHardwareBuffer **pBuffer = %p)",
1418 device, pInfo, pBuffer);
1419
1420 return vk::Cast(pInfo->memory)->exportAndroidHardwareBuffer(pBuffer);
1421}
1422
1423VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(VkDevice device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
1424{
1425 TRACE("(VkDevice device = %p, const struct AHardwareBuffer *buffer = %p, VkAndroidHardwareBufferPropertiesANDROID *pProperties = %p)",
1426 device, buffer, pProperties);
1427
1428 return vk::DeviceMemory::GetAndroidHardwareBufferProperties(device, buffer, pProperties);
1429}
1430#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
1431
1432VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
1433{
1434 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize offset = %d, VkDeviceSize size = %d, VkMemoryMapFlags flags = %d, void** ppData = %p)",
1435 device, static_cast<void *>(memory), int(offset), int(size), flags, ppData);
1436
1437 if(flags != 0)
1438 {
1439 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1440 UNSUPPORTED("flags 0x%08X", int(flags));
1441 }
1442
1443 return vk::Cast(object: memory)->map(offset, size, ppData);
1444}
1445
1446VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)
1447{
1448 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p)", device, static_cast<void *>(memory));
1449
1450 // Noop, memory will be released when the DeviceMemory object is released
1451}
1452
1453VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
1454{
1455 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
1456 device, memoryRangeCount, pMemoryRanges);
1457
1458 // Noop, host and device memory are the same to SwiftShader
1459
1460 return VK_SUCCESS;
1461}
1462
1463VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange *pMemoryRanges)
1464{
1465 TRACE("(VkDevice device = %p, uint32_t memoryRangeCount = %d, const VkMappedMemoryRange* pMemoryRanges = %p)",
1466 device, memoryRangeCount, pMemoryRanges);
1467
1468 // Noop, host and device memory are the same to SwiftShader
1469
1470 return VK_SUCCESS;
1471}
1472
1473VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDeviceMemory pMemory, VkDeviceSize *pCommittedMemoryInBytes)
1474{
1475 TRACE("(VkDevice device = %p, VkDeviceMemory memory = %p, VkDeviceSize* pCommittedMemoryInBytes = %p)",
1476 pDevice, static_cast<void *>(pMemory), pCommittedMemoryInBytes);
1477
1478 auto *memory = vk::Cast(object: pMemory);
1479
1480#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
1481 const auto &memoryProperties = vk::PhysicalDevice::GetMemoryProperties();
1482 uint32_t typeIndex = memory->getMemoryTypeIndex();
1483 ASSERT(typeIndex < memoryProperties.memoryTypeCount);
1484 ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
1485#endif
1486
1487 *pCommittedMemoryInBytes = memory->getCommittedMemoryInBytes();
1488}
1489
1490VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
1491{
1492 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
1493 device, static_cast<void *>(buffer), static_cast<void *>(memory), int(memoryOffset));
1494
1495 if(!vk::Cast(object: buffer)->canBindToMemory(pDeviceMemory: vk::Cast(object: memory)))
1496 {
1497 UNSUPPORTED("vkBindBufferMemory with invalid external memory");
1498 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1499 }
1500 vk::Cast(object: buffer)->bind(pDeviceMemory: vk::Cast(object: memory), pMemoryOffset: memoryOffset);
1501 return VK_SUCCESS;
1502}
1503
1504VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
1505{
1506 TRACE("(VkDevice device = %p, VkImage image = %p, VkDeviceMemory memory = %p, VkDeviceSize memoryOffset = %d)",
1507 device, static_cast<void *>(image), static_cast<void *>(memory), int(memoryOffset));
1508
1509 if(!vk::Cast(object: image)->canBindToMemory(pDeviceMemory: vk::Cast(object: memory)))
1510 {
1511 UNSUPPORTED("vkBindImageMemory with invalid external memory");
1512 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
1513 }
1514 vk::Cast(object: image)->bind(pDeviceMemory: vk::Cast(object: memory), pMemoryOffset: memoryOffset);
1515 return VK_SUCCESS;
1516}
1517
1518VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
1519{
1520 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
1521 device, static_cast<void *>(buffer), pMemoryRequirements);
1522
1523 *pMemoryRequirements = vk::Cast(object: buffer)->getMemoryRequirements();
1524}
1525
1526VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)
1527{
1528 TRACE("(VkDevice device = %p, VkImage image = %p, VkMemoryRequirements* pMemoryRequirements = %p)",
1529 device, static_cast<void *>(image), pMemoryRequirements);
1530
1531 *pMemoryRequirements = vk::Cast(object: image)->getMemoryRequirements();
1532}
1533
1534VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(VkDevice device, VkImage image, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements *pSparseMemoryRequirements)
1535{
1536 TRACE("(VkDevice device = %p, VkImage image = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements* pSparseMemoryRequirements = %p)",
1537 device, static_cast<void *>(image), pSparseMemoryRequirementCount, pSparseMemoryRequirements);
1538
1539 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
1540 // "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."
1541 *pSparseMemoryRequirementCount = 0;
1542}
1543
1544VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties)
1545{
1546 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)",
1547 physicalDevice, format, type, samples, usage, tiling, pPropertyCount, pProperties);
1548
1549 // We do not support sparse images.
1550 *pPropertyCount = 0;
1551}
1552
1553VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo *pBindInfo, VkFence fence)
1554{
1555 TRACE("()");
1556 UNSUPPORTED("vkQueueBindSparse");
1557 return VK_SUCCESS;
1558}
1559
1560VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence)
1561{
1562 TRACE("(VkDevice device = %p, const VkFenceCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFence* pFence = %p)",
1563 device, pCreateInfo, pAllocator, pFence);
1564
1565 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1566 while(nextInfo)
1567 {
1568 switch(nextInfo->sType)
1569 {
1570 case VK_STRUCTURE_TYPE_MAX_ENUM:
1571 // dEQP tests that this value is ignored.
1572 break;
1573 default:
1574 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
1575 break;
1576 }
1577 nextInfo = nextInfo->pNext;
1578 }
1579
1580 return vk::Fence::Create(pAllocator, pCreateInfo, outObject: pFence);
1581}
1582
1583VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator)
1584{
1585 TRACE("(VkDevice device = %p, VkFence fence = %p, const VkAllocationCallbacks* pAllocator = %p)",
1586 device, static_cast<void *>(fence), pAllocator);
1587
1588 vk::destroy(vkObject: fence, pAllocator);
1589}
1590
1591VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences)
1592{
1593 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p)",
1594 device, fenceCount, pFences);
1595
1596 for(uint32_t i = 0; i < fenceCount; i++)
1597 {
1598 vk::Cast(object: pFences[i])->reset();
1599 }
1600
1601 return VK_SUCCESS;
1602}
1603
1604VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(VkDevice device, VkFence fence)
1605{
1606 TRACE("(VkDevice device = %p, VkFence fence = %p)", device, static_cast<void *>(fence));
1607
1608 return vk::Cast(object: fence)->getStatus();
1609}
1610
1611VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout)
1612{
1613 TRACE("(VkDevice device = %p, uint32_t fenceCount = %d, const VkFence* pFences = %p, VkBool32 waitAll = %d, uint64_t timeout = %" PRIu64 ")",
1614 device, int(fenceCount), pFences, int(waitAll), timeout);
1615
1616 return vk::Cast(object: device)->waitForFences(fenceCount, pFences, waitAll, timeout);
1617}
1618
1619VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
1620{
1621 TRACE("(VkDevice device = %p, const VkSemaphoreCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSemaphore* pSemaphore = %p)",
1622 device, pCreateInfo, pAllocator, pSemaphore);
1623
1624 if(pCreateInfo->flags != 0)
1625 {
1626 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1627 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
1628 }
1629
1630 VkSemaphoreType type = VK_SEMAPHORE_TYPE_BINARY;
1631 for(const auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1632 nextInfo != nullptr; nextInfo = nextInfo->pNext)
1633 {
1634 switch(nextInfo->sType)
1635 {
1636 case VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO:
1637 // Let the semaphore constructor handle this
1638 break;
1639 case VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO:
1640 {
1641 const VkSemaphoreTypeCreateInfo *info = reinterpret_cast<const VkSemaphoreTypeCreateInfo *>(nextInfo);
1642 type = info->semaphoreType;
1643 }
1644 break;
1645 default:
1646 WARN("nextInfo->sType = %s", vk::Stringify(nextInfo->sType).c_str());
1647 break;
1648 }
1649 }
1650
1651 if(type == VK_SEMAPHORE_TYPE_BINARY)
1652 {
1653 return vk::BinarySemaphore::Create(pAllocator, pCreateInfo, outObject: pSemaphore, extendedInfo: pAllocator);
1654 }
1655 else
1656 {
1657 return vk::TimelineSemaphore::Create(pAllocator, pCreateInfo, outObject: pSemaphore, extendedInfo: pAllocator);
1658 }
1659}
1660
1661VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)
1662{
1663 TRACE("(VkDevice device = %p, VkSemaphore semaphore = %p, const VkAllocationCallbacks* pAllocator = %p)",
1664 device, static_cast<void *>(semaphore), pAllocator);
1665
1666 vk::destroy(vkObject: semaphore, pAllocator);
1667}
1668
1669#if SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
1670VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *pGetFdInfo, int *pFd)
1671{
1672 TRACE("(VkDevice device = %p, const VkSemaphoreGetFdInfoKHR* pGetFdInfo = %p, int* pFd = %p)",
1673 device, static_cast<const void *>(pGetFdInfo), static_cast<void *>(pFd));
1674
1675 if(pGetFdInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT)
1676 {
1677 UNSUPPORTED("pGetFdInfo->handleType %d", int(pGetFdInfo->handleType));
1678 }
1679
1680 auto *sem = vk::DynamicCast<vk::BinarySemaphore>(object: pGetFdInfo->semaphore);
1681 ASSERT(sem != nullptr);
1682 return sem->exportFd(pFd);
1683}
1684
1685VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR(VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreInfo)
1686{
1687 TRACE("(VkDevice device = %p, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreInfo = %p",
1688 device, static_cast<const void *>(pImportSemaphoreInfo));
1689
1690 if(pImportSemaphoreInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT)
1691 {
1692 UNSUPPORTED("pImportSemaphoreInfo->handleType %d", int(pImportSemaphoreInfo->handleType));
1693 }
1694 bool temporaryImport = (pImportSemaphoreInfo->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) != 0;
1695
1696 auto *sem = vk::DynamicCast<vk::BinarySemaphore>(object: pImportSemaphoreInfo->semaphore);
1697 ASSERT(sem != nullptr);
1698 return sem->importFd(fd: pImportSemaphoreInfo->fd, temporaryImport);
1699}
1700#endif // SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD
1701
1702#if VK_USE_PLATFORM_FUCHSIA
1703VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA(
1704 VkDevice device,
1705 const VkImportSemaphoreZirconHandleInfoFUCHSIA *pImportSemaphoreZirconHandleInfo)
1706{
1707 TRACE("(VkDevice device = %p, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo = %p)",
1708 device, pImportSemaphoreZirconHandleInfo);
1709
1710 if(pImportSemaphoreZirconHandleInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA)
1711 {
1712 UNSUPPORTED("pImportSemaphoreZirconHandleInfo->handleType %d", int(pImportSemaphoreZirconHandleInfo->handleType));
1713 }
1714 bool temporaryImport = (pImportSemaphoreZirconHandleInfo->flags & VK_SEMAPHORE_IMPORT_TEMPORARY_BIT) != 0;
1715 auto *sem = vk::DynamicCast<vk::BinarySemaphore>(pImportSemaphoreZirconHandleInfo->semaphore);
1716 ASSERT(sem != nullptr);
1717 return sem->importHandle(pImportSemaphoreZirconHandleInfo->zirconHandle, temporaryImport);
1718}
1719
1720VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA(
1721 VkDevice device,
1722 const VkSemaphoreGetZirconHandleInfoFUCHSIA *pGetZirconHandleInfo,
1723 zx_handle_t *pZirconHandle)
1724{
1725 TRACE("(VkDevice device = %p, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo = %p, zx_handle_t* pZirconHandle = %p)",
1726 device, static_cast<const void *>(pGetZirconHandleInfo), static_cast<void *>(pZirconHandle));
1727
1728 if(pGetZirconHandleInfo->handleType != VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA)
1729 {
1730 UNSUPPORTED("pGetZirconHandleInfo->handleType %d", int(pGetZirconHandleInfo->handleType));
1731 }
1732
1733 auto *sem = vk::DynamicCast<vk::BinarySemaphore>(pGetZirconHandleInfo->semaphore);
1734 ASSERT(sem != nullptr);
1735 return sem->exportHandle(pZirconHandle);
1736}
1737#endif // VK_USE_PLATFORM_FUCHSIA
1738
1739VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreCounterValue(VkDevice device, VkSemaphore semaphore, uint64_t *pValue)
1740{
1741 TRACE("(VkDevice device = %p, VkSemaphore semaphore = %p, uint64_t* pValue = %p)",
1742 device, static_cast<void *>(semaphore), pValue);
1743 *pValue = vk::DynamicCast<vk::TimelineSemaphore>(object: semaphore)->getCounterValue();
1744 return VK_SUCCESS;
1745}
1746
1747VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphore(VkDevice device, const VkSemaphoreSignalInfo *pSignalInfo)
1748{
1749 TRACE("(VkDevice device = %p, const VkSemaphoreSignalInfo *pSignalInfo = %p)",
1750 device, pSignalInfo);
1751 vk::DynamicCast<vk::TimelineSemaphore>(object: pSignalInfo->semaphore)->signal(value: pSignalInfo->value);
1752 return VK_SUCCESS;
1753}
1754
1755VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphores(VkDevice device, const VkSemaphoreWaitInfo *pWaitInfo, uint64_t timeout)
1756{
1757 TRACE("(VkDevice device = %p, const VkSemaphoreWaitInfo *pWaitInfo = %p, uint64_t timeout = %" PRIu64 ")",
1758 device, pWaitInfo, timeout);
1759 return vk::Cast(object: device)->waitForSemaphores(pWaitInfo, timeout);
1760}
1761
1762VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
1763{
1764 TRACE("(VkDevice device = %p, const VkEventCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkEvent* pEvent = %p)",
1765 device, pCreateInfo, pAllocator, pEvent);
1766
1767 // VK_EVENT_CREATE_DEVICE_ONLY_BIT_KHR is provided by VK_KHR_synchronization2
1768 if((pCreateInfo->flags != 0) && (pCreateInfo->flags != VK_EVENT_CREATE_DEVICE_ONLY_BIT_KHR))
1769 {
1770 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
1771 }
1772
1773 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1774 while(extInfo)
1775 {
1776 // Vulkan 1.2: "pNext must be NULL"
1777 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
1778 extInfo = extInfo->pNext;
1779 }
1780
1781 return vk::Event::Create(pAllocator, pCreateInfo, outObject: pEvent);
1782}
1783
1784VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator)
1785{
1786 TRACE("(VkDevice device = %p, VkEvent event = %p, const VkAllocationCallbacks* pAllocator = %p)",
1787 device, static_cast<void *>(event), pAllocator);
1788
1789 vk::destroy(vkObject: event, pAllocator);
1790}
1791
1792VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
1793{
1794 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
1795
1796 return vk::Cast(object: event)->getStatus();
1797}
1798
1799VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(VkDevice device, VkEvent event)
1800{
1801 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
1802
1803 vk::Cast(object: event)->signal();
1804
1805 return VK_SUCCESS;
1806}
1807
1808VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(VkDevice device, VkEvent event)
1809{
1810 TRACE("(VkDevice device = %p, VkEvent event = %p)", device, static_cast<void *>(event));
1811
1812 vk::Cast(object: event)->reset();
1813
1814 return VK_SUCCESS;
1815}
1816
1817VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool)
1818{
1819 TRACE("(VkDevice device = %p, const VkQueryPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkQueryPool* pQueryPool = %p)",
1820 device, pCreateInfo, pAllocator, pQueryPool);
1821
1822 if(pCreateInfo->flags != 0)
1823 {
1824 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1825 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
1826 }
1827
1828 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1829 while(extInfo)
1830 {
1831 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
1832 extInfo = extInfo->pNext;
1833 }
1834
1835 return vk::QueryPool::Create(pAllocator, pCreateInfo, outObject: pQueryPool);
1836}
1837
1838VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator)
1839{
1840 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
1841 device, static_cast<void *>(queryPool), pAllocator);
1842
1843 vk::destroy(vkObject: queryPool, pAllocator);
1844}
1845
1846VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *pData, VkDeviceSize stride, VkQueryResultFlags flags)
1847{
1848 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)",
1849 device, static_cast<void *>(queryPool), int(firstQuery), int(queryCount), int(dataSize), pData, int(stride), flags);
1850
1851 return vk::Cast(object: queryPool)->getResults(firstQuery, queryCount, dataSize, pData, stride, flags);
1852}
1853
1854VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
1855{
1856 TRACE("(VkDevice device = %p, const VkBufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBuffer* pBuffer = %p)",
1857 device, pCreateInfo, pAllocator, pBuffer);
1858
1859 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1860 while(nextInfo)
1861 {
1862 switch(nextInfo->sType)
1863 {
1864 case VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO:
1865 // Do nothing. Should be handled by vk::Buffer::Create().
1866 break;
1867 case VK_STRUCTURE_TYPE_MAX_ENUM:
1868 // dEQP tests that this value is ignored.
1869 break;
1870 default:
1871 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
1872 break;
1873 }
1874 nextInfo = nextInfo->pNext;
1875 }
1876
1877 return vk::Buffer::Create(pAllocator, pCreateInfo, outObject: pBuffer);
1878}
1879
1880VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
1881{
1882 TRACE("(VkDevice device = %p, VkBuffer buffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
1883 device, static_cast<void *>(buffer), pAllocator);
1884
1885 vk::destroy(vkObject: buffer, pAllocator);
1886}
1887
1888VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferDeviceAddress(VkDevice device, const VkBufferDeviceAddressInfo *pInfo)
1889{
1890 TRACE("(VkDevice device = %p, const VkBufferDeviceAddressInfo* pInfo = %p)",
1891 device, pInfo);
1892
1893 // This function must return VkBufferDeviceAddressCreateInfoEXT::deviceAddress if provided
1894 ASSERT(!vk::Cast(device)->hasExtension(VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
1895
1896 return vk::Cast(object: pInfo->buffer)->getOpaqueCaptureAddress();
1897}
1898
1899VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddress(VkDevice device, const VkBufferDeviceAddressInfo *pInfo)
1900{
1901 TRACE("(VkDevice device = %p, const VkBufferDeviceAddressInfo* pInfo = %p)",
1902 device, pInfo);
1903
1904 return vk::Cast(object: pInfo->buffer)->getOpaqueCaptureAddress();
1905}
1906
1907VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddress(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo *pInfo)
1908{
1909 TRACE("(VkDevice device = %p, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo = %p)",
1910 device, pInfo);
1911
1912 return vk::Cast(object: pInfo->memory)->getOpaqueCaptureAddress();
1913}
1914
1915VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
1916{
1917 TRACE("(VkDevice device = %p, const VkBufferViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkBufferView* pView = %p)",
1918 device, pCreateInfo, pAllocator, pView);
1919
1920 if(pCreateInfo->flags != 0)
1921 {
1922 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
1923 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
1924 }
1925
1926 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1927 while(extInfo)
1928 {
1929 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
1930 extInfo = extInfo->pNext;
1931 }
1932
1933 return vk::BufferView::Create(pAllocator, pCreateInfo, outObject: pView);
1934}
1935
1936VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)
1937{
1938 TRACE("(VkDevice device = %p, VkBufferView bufferView = %p, const VkAllocationCallbacks* pAllocator = %p)",
1939 device, static_cast<void *>(bufferView), pAllocator);
1940
1941 vk::destroy(vkObject: bufferView, pAllocator);
1942}
1943
1944VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage)
1945{
1946 TRACE("(VkDevice device = %p, const VkImageCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImage* pImage = %p)",
1947 device, pCreateInfo, pAllocator, pImage);
1948
1949 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
1950
1951#ifdef __ANDROID__
1952 vk::BackingMemory backmem;
1953 bool swapchainImage = false;
1954#endif
1955
1956 while(extensionCreateInfo)
1957 {
1958 // Casting to an int since some structures, such as VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID and
1959 // VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID, are not enumerated in the official Vulkan headers.
1960 switch((int)(extensionCreateInfo->sType))
1961 {
1962#ifdef __ANDROID__
1963 case VK_STRUCTURE_TYPE_SWAPCHAIN_IMAGE_CREATE_INFO_ANDROID:
1964 {
1965 const VkSwapchainImageCreateInfoANDROID *swapImageCreateInfo = reinterpret_cast<const VkSwapchainImageCreateInfoANDROID *>(extensionCreateInfo);
1966 backmem.androidUsage = swapImageCreateInfo->usage;
1967 }
1968 break;
1969 case VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID:
1970 {
1971 const VkNativeBufferANDROID *nativeBufferInfo = reinterpret_cast<const VkNativeBufferANDROID *>(extensionCreateInfo);
1972 backmem.nativeHandle = nativeBufferInfo->handle;
1973 backmem.stride = nativeBufferInfo->stride;
1974 swapchainImage = true;
1975 }
1976 break;
1977 case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
1978 break;
1979 case VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID:
1980 // Do nothing. Should be handled by vk::Image::Create()
1981 break;
1982#endif
1983 case VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO:
1984 // Do nothing. Should be handled by vk::Image::Create()
1985 break;
1986 case VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR:
1987 /* Do nothing. We don't actually need the swapchain handle yet; we'll do all the work in vkBindImageMemory2. */
1988 break;
1989 case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO:
1990 // Do nothing. This extension tells the driver which image formats will be used
1991 // by the application. Swiftshader is not impacted from lacking this information,
1992 // so we don't need to track the format list.
1993 break;
1994 case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO:
1995 {
1996 // SwiftShader does not use an image's usage info for non-debug purposes outside of
1997 // vkGetPhysicalDeviceImageFormatProperties2. This also applies to separate stencil usage.
1998 const VkImageStencilUsageCreateInfo *stencilUsageInfo = reinterpret_cast<const VkImageStencilUsageCreateInfo *>(extensionCreateInfo);
1999 (void)stencilUsageInfo->stencilUsage;
2000 }
2001 break;
2002 case VK_STRUCTURE_TYPE_MAX_ENUM:
2003 // dEQP tests that this value is ignored.
2004 break;
2005 default:
2006 // "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]"
2007 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
2008 break;
2009 }
2010
2011 extensionCreateInfo = extensionCreateInfo->pNext;
2012 }
2013
2014 VkResult result = vk::Image::Create(pAllocator, pCreateInfo, outObject: pImage, extendedInfo: vk::Cast(object: device));
2015
2016#ifdef __ANDROID__
2017 if(swapchainImage)
2018 {
2019 if(result != VK_SUCCESS)
2020 {
2021 return result;
2022 }
2023
2024 vk::Image *image = vk::Cast(*pImage);
2025 VkMemoryRequirements memRequirements = image->getMemoryRequirements();
2026
2027 VkMemoryAllocateInfo allocInfo = {};
2028 allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
2029 allocInfo.allocationSize = memRequirements.size;
2030 allocInfo.memoryTypeIndex = 0;
2031
2032 VkDeviceMemory devmem = { VK_NULL_HANDLE };
2033 result = vkAllocateMemory(device, &allocInfo, pAllocator, &devmem);
2034 if(result != VK_SUCCESS)
2035 {
2036 return result;
2037 }
2038
2039 vkBindImageMemory(device, *pImage, devmem, 0);
2040 backmem.externalMemory = true;
2041
2042 image->setBackingMemory(backmem);
2043 }
2044#endif
2045
2046 return result;
2047}
2048
2049VKAPI_ATTR void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)
2050{
2051 TRACE("(VkDevice device = %p, VkImage image = %p, const VkAllocationCallbacks* pAllocator = %p)",
2052 device, static_cast<void *>(image), pAllocator);
2053
2054#ifdef __ANDROID__
2055 vk::Image *img = vk::Cast(image);
2056 if(img && img->hasExternalMemory())
2057 {
2058 vk::destroy(img->getExternalMemory(), pAllocator);
2059 }
2060#endif
2061
2062 vk::destroy(vkObject: image, pAllocator);
2063}
2064
2065VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(VkDevice device, VkImage image, const VkImageSubresource *pSubresource, VkSubresourceLayout *pLayout)
2066{
2067 TRACE("(VkDevice device = %p, VkImage image = %p, const VkImageSubresource* pSubresource = %p, VkSubresourceLayout* pLayout = %p)",
2068 device, static_cast<void *>(image), pSubresource, pLayout);
2069
2070 vk::Cast(object: image)->getSubresourceLayout(pSubresource, pLayout);
2071}
2072
2073VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
2074{
2075 TRACE("(VkDevice device = %p, const VkImageViewCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkImageView* pView = %p)",
2076 device, pCreateInfo, pAllocator, pView);
2077
2078 if(pCreateInfo->flags != 0)
2079 {
2080 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2081 }
2082
2083 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2084 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
2085
2086 while(extensionCreateInfo)
2087 {
2088 switch(extensionCreateInfo->sType)
2089 {
2090 case VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO:
2091 {
2092 const VkImageViewUsageCreateInfo *multiviewCreateInfo = reinterpret_cast<const VkImageViewUsageCreateInfo *>(extensionCreateInfo);
2093 ASSERT(!(~vk::Cast(pCreateInfo->image)->getUsage() & multiviewCreateInfo->usage));
2094 }
2095 break;
2096 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
2097 {
2098 const VkSamplerYcbcrConversionInfo *samplerYcbcrConversionInfo = reinterpret_cast<const VkSamplerYcbcrConversionInfo *>(extensionCreateInfo);
2099 ycbcrConversion = vk::Cast(object: samplerYcbcrConversionInfo->conversion);
2100
2101 if(ycbcrConversion)
2102 {
2103 ASSERT((pCreateInfo->components.r == VK_COMPONENT_SWIZZLE_IDENTITY || pCreateInfo->components.r == VK_COMPONENT_SWIZZLE_R) &&
2104 (pCreateInfo->components.g == VK_COMPONENT_SWIZZLE_IDENTITY || pCreateInfo->components.g == VK_COMPONENT_SWIZZLE_G) &&
2105 (pCreateInfo->components.b == VK_COMPONENT_SWIZZLE_IDENTITY || pCreateInfo->components.b == VK_COMPONENT_SWIZZLE_B) &&
2106 (pCreateInfo->components.a == VK_COMPONENT_SWIZZLE_IDENTITY || pCreateInfo->components.a == VK_COMPONENT_SWIZZLE_A));
2107 }
2108 }
2109 break;
2110 case VK_STRUCTURE_TYPE_MAX_ENUM:
2111 // dEQP tests that this value is ignored.
2112 break;
2113 case VK_STRUCTURE_TYPE_IMAGE_VIEW_MIN_LOD_CREATE_INFO_EXT:
2114 // TODO(b/218318109): Part of the VK_EXT_image_view_min_lod extension, which we don't support.
2115 // Remove when https://gitlab.khronos.org/Tracker/vk-gl-cts/-/issues/3094#note_348979 has been fixed.
2116 break;
2117 default:
2118 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
2119 break;
2120 }
2121
2122 extensionCreateInfo = extensionCreateInfo->pNext;
2123 }
2124
2125 VkResult result = vk::ImageView::Create(pAllocator, pCreateInfo, outObject: pView, extendedInfo: ycbcrConversion);
2126 if(result == VK_SUCCESS)
2127 {
2128 vk::Cast(object: device)->registerImageView(imageView: vk::Cast(object: *pView));
2129 }
2130
2131 return result;
2132}
2133
2134VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
2135{
2136 TRACE("(VkDevice device = %p, VkImageView imageView = %p, const VkAllocationCallbacks* pAllocator = %p)",
2137 device, static_cast<void *>(imageView), pAllocator);
2138
2139 vk::Cast(object: device)->unregisterImageView(imageView: vk::Cast(object: imageView));
2140 vk::destroy(vkObject: imageView, pAllocator);
2141}
2142
2143VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(VkDevice device, const VkShaderModuleCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkShaderModule *pShaderModule)
2144{
2145 TRACE("(VkDevice device = %p, const VkShaderModuleCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkShaderModule* pShaderModule = %p)",
2146 device, pCreateInfo, pAllocator, pShaderModule);
2147
2148 if(pCreateInfo->flags != 0)
2149 {
2150 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2151 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2152 }
2153
2154 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2155 while(nextInfo)
2156 {
2157 switch(nextInfo->sType)
2158 {
2159 case VK_STRUCTURE_TYPE_MAX_ENUM:
2160 // dEQP tests that this value is ignored.
2161 break;
2162 default:
2163 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
2164 break;
2165 }
2166 nextInfo = nextInfo->pNext;
2167 }
2168
2169 return vk::ShaderModule::Create(pAllocator, pCreateInfo, outObject: pShaderModule);
2170}
2171
2172VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator)
2173{
2174 TRACE("(VkDevice device = %p, VkShaderModule shaderModule = %p, const VkAllocationCallbacks* pAllocator = %p)",
2175 device, static_cast<void *>(shaderModule), pAllocator);
2176
2177 vk::destroy(vkObject: shaderModule, pAllocator);
2178}
2179
2180VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device, const VkPipelineCacheCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineCache *pPipelineCache)
2181{
2182 TRACE("(VkDevice device = %p, const VkPipelineCacheCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineCache* pPipelineCache = %p)",
2183 device, pCreateInfo, pAllocator, pPipelineCache);
2184
2185 if(pCreateInfo->flags != 0 && pCreateInfo->flags != VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT)
2186 {
2187 // Flags must be 0 or VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT.
2188 // VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT: When set, the implementation may skip any
2189 // unnecessary processing needed to support simultaneous modification from multiple threads where allowed.
2190 // TODO(b/246369329): Optimize PipelineCache objects when VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT is used.
2191 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2192 }
2193
2194 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2195 while(extInfo)
2196 {
2197 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
2198 extInfo = extInfo->pNext;
2199 }
2200
2201 return vk::PipelineCache::Create(pAllocator, pCreateInfo, outObject: pPipelineCache);
2202}
2203
2204VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks *pAllocator)
2205{
2206 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, const VkAllocationCallbacks* pAllocator = %p)",
2207 device, static_cast<void *>(pipelineCache), pAllocator);
2208
2209 vk::destroy(vkObject: pipelineCache, pAllocator);
2210}
2211
2212VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(VkDevice device, VkPipelineCache pipelineCache, size_t *pDataSize, void *pData)
2213{
2214 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, size_t* pDataSize = %p, void* pData = %p)",
2215 device, static_cast<void *>(pipelineCache), pDataSize, pData);
2216
2217 return vk::Cast(object: pipelineCache)->getData(pDataSize, pData);
2218}
2219
2220VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache *pSrcCaches)
2221{
2222 TRACE("(VkDevice device = %p, VkPipelineCache dstCache = %p, uint32_t srcCacheCount = %d, const VkPipelineCache* pSrcCaches = %p)",
2223 device, static_cast<void *>(dstCache), int(srcCacheCount), pSrcCaches);
2224
2225 return vk::Cast(object: dstCache)->merge(srcCacheCount, pSrcCaches);
2226}
2227
2228VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
2229{
2230 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkGraphicsPipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
2231 device, static_cast<void *>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
2232
2233 memset(s: pPipelines, c: 0, n: sizeof(void *) * createInfoCount);
2234
2235 VkResult errorResult = VK_SUCCESS;
2236 for(uint32_t i = 0; i < createInfoCount; i++)
2237 {
2238 VkResult result = vk::GraphicsPipeline::Create(pAllocator, pCreateInfo: &pCreateInfos[i], outObject: &pPipelines[i], extendedInfo: vk::Cast(object: device));
2239
2240 if(result == VK_SUCCESS)
2241 {
2242 result = static_cast<vk::GraphicsPipeline *>(vk::Cast(object: pPipelines[i]))->compileShaders(pAllocator, pCreateInfo: &pCreateInfos[i], pipelineCache: vk::Cast(object: pipelineCache));
2243 if(result != VK_SUCCESS)
2244 {
2245 vk::destroy(vkObject: pPipelines[i], pAllocator);
2246 }
2247 }
2248
2249 if(result != VK_SUCCESS)
2250 {
2251 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
2252 // "When an application attempts to create many pipelines in a single command,
2253 // it is possible that some subset may fail creation. In that case, the
2254 // corresponding entries in the pPipelines output array will be filled with
2255 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
2256 // out of memory errors), the vkCreate*Pipelines commands will return an
2257 // error code. The implementation will attempt to create all pipelines, and
2258 // only return VK_NULL_HANDLE values for those that actually failed."
2259 pPipelines[i] = VK_NULL_HANDLE;
2260 errorResult = result;
2261
2262 // VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT specifies that control
2263 // will be returned to the application on failure of the corresponding pipeline
2264 // rather than continuing to create additional pipelines.
2265 if(pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)
2266 {
2267 return errorResult;
2268 }
2269 }
2270 }
2271
2272 return errorResult;
2273}
2274
2275VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
2276{
2277 TRACE("(VkDevice device = %p, VkPipelineCache pipelineCache = %p, uint32_t createInfoCount = %d, const VkComputePipelineCreateInfo* pCreateInfos = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipeline* pPipelines = %p)",
2278 device, static_cast<void *>(pipelineCache), int(createInfoCount), pCreateInfos, pAllocator, pPipelines);
2279
2280 memset(s: pPipelines, c: 0, n: sizeof(void *) * createInfoCount);
2281
2282 VkResult errorResult = VK_SUCCESS;
2283 for(uint32_t i = 0; i < createInfoCount; i++)
2284 {
2285 VkResult result = vk::ComputePipeline::Create(pAllocator, pCreateInfo: &pCreateInfos[i], outObject: &pPipelines[i], extendedInfo: vk::Cast(object: device));
2286
2287 if(result == VK_SUCCESS)
2288 {
2289 result = static_cast<vk::ComputePipeline *>(vk::Cast(object: pPipelines[i]))->compileShaders(pAllocator, pCreateInfo: &pCreateInfos[i], pipelineCache: vk::Cast(object: pipelineCache));
2290 if(result != VK_SUCCESS)
2291 {
2292 vk::destroy(vkObject: pPipelines[i], pAllocator);
2293 }
2294 }
2295
2296 if(result != VK_SUCCESS)
2297 {
2298 // According to the Vulkan spec, section 9.4. Multiple Pipeline Creation
2299 // "When an application attempts to create many pipelines in a single command,
2300 // it is possible that some subset may fail creation. In that case, the
2301 // corresponding entries in the pPipelines output array will be filled with
2302 // VK_NULL_HANDLE values. If any pipeline fails creation (for example, due to
2303 // out of memory errors), the vkCreate*Pipelines commands will return an
2304 // error code. The implementation will attempt to create all pipelines, and
2305 // only return VK_NULL_HANDLE values for those that actually failed."
2306 pPipelines[i] = VK_NULL_HANDLE;
2307 errorResult = result;
2308
2309 // VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT specifies that control
2310 // will be returned to the application on failure of the corresponding pipeline
2311 // rather than continuing to create additional pipelines.
2312 if(pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)
2313 {
2314 return errorResult;
2315 }
2316 }
2317 }
2318
2319 return errorResult;
2320}
2321
2322VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)
2323{
2324 TRACE("(VkDevice device = %p, VkPipeline pipeline = %p, const VkAllocationCallbacks* pAllocator = %p)",
2325 device, static_cast<void *>(pipeline), pAllocator);
2326
2327 vk::destroy(vkObject: pipeline, pAllocator);
2328}
2329
2330VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout)
2331{
2332 TRACE("(VkDevice device = %p, const VkPipelineLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPipelineLayout* pPipelineLayout = %p)",
2333 device, pCreateInfo, pAllocator, pPipelineLayout);
2334
2335 if(pCreateInfo->flags != 0 && pCreateInfo->flags != VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT)
2336 {
2337 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2338 }
2339
2340 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2341 while(nextInfo)
2342 {
2343 switch(nextInfo->sType)
2344 {
2345 case VK_STRUCTURE_TYPE_MAX_ENUM:
2346 // dEQP tests that this value is ignored.
2347 break;
2348 default:
2349 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
2350 break;
2351 }
2352 nextInfo = nextInfo->pNext;
2353 }
2354
2355 return vk::PipelineLayout::Create(pAllocator, pCreateInfo, outObject: pPipelineLayout);
2356}
2357
2358VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
2359{
2360 TRACE("(VkDevice device = %p, VkPipelineLayout pipelineLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
2361 device, static_cast<void *>(pipelineLayout), pAllocator);
2362
2363 vk::release(vkObject: pipelineLayout, pAllocator);
2364}
2365
2366VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler)
2367{
2368 TRACE("(VkDevice device = %p, const VkSamplerCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSampler* pSampler = %p)",
2369 device, pCreateInfo, pAllocator, pSampler);
2370
2371 if(pCreateInfo->flags != 0)
2372 {
2373 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2374 }
2375
2376 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2377 const vk::SamplerYcbcrConversion *ycbcrConversion = nullptr;
2378 VkSamplerFilteringPrecisionModeGOOGLE filteringPrecision = VK_SAMPLER_FILTERING_PRECISION_MODE_LOW_GOOGLE;
2379 VkClearColorValue borderColor = {};
2380
2381 while(extensionCreateInfo)
2382 {
2383 switch(static_cast<long>(extensionCreateInfo->sType))
2384 {
2385 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO:
2386 {
2387 const VkSamplerYcbcrConversionInfo *samplerYcbcrConversionInfo =
2388 reinterpret_cast<const VkSamplerYcbcrConversionInfo *>(extensionCreateInfo);
2389 ycbcrConversion = vk::Cast(object: samplerYcbcrConversionInfo->conversion);
2390 }
2391 break;
2392#if !defined(__ANDROID__)
2393 case VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE:
2394 {
2395 const VkSamplerFilteringPrecisionGOOGLE *filteringInfo =
2396 reinterpret_cast<const VkSamplerFilteringPrecisionGOOGLE *>(extensionCreateInfo);
2397 filteringPrecision = filteringInfo->samplerFilteringPrecisionMode;
2398 }
2399 break;
2400#endif
2401 case VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT:
2402 {
2403 const VkSamplerCustomBorderColorCreateInfoEXT *borderColorInfo =
2404 reinterpret_cast<const VkSamplerCustomBorderColorCreateInfoEXT *>(extensionCreateInfo);
2405
2406 borderColor = borderColorInfo->customBorderColor;
2407 }
2408 break;
2409 default:
2410 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
2411 break;
2412 }
2413
2414 extensionCreateInfo = extensionCreateInfo->pNext;
2415 }
2416
2417 vk::SamplerState samplerState(pCreateInfo, ycbcrConversion, filteringPrecision, borderColor);
2418 uint32_t samplerID = vk::Cast(object: device)->indexSampler(samplerState);
2419
2420 VkResult result = vk::Sampler::Create(pAllocator, pCreateInfo, outObject: pSampler, extendedInfo: samplerState, extendedInfo: samplerID);
2421
2422 if(*pSampler == VK_NULL_HANDLE)
2423 {
2424 ASSERT(result != VK_SUCCESS);
2425 vk::Cast(object: device)->removeSampler(samplerState);
2426 }
2427
2428 return result;
2429}
2430
2431VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)
2432{
2433 TRACE("(VkDevice device = %p, VkSampler sampler = %p, const VkAllocationCallbacks* pAllocator = %p)",
2434 device, static_cast<void *>(sampler), pAllocator);
2435
2436 if(sampler != VK_NULL_HANDLE)
2437 {
2438 vk::Cast(object: device)->removeSampler(samplerState: *vk::Cast(object: sampler));
2439
2440 vk::destroy(vkObject: sampler, pAllocator);
2441 }
2442}
2443
2444VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout)
2445{
2446 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorSetLayout* pSetLayout = %p)",
2447 device, pCreateInfo, pAllocator, pSetLayout);
2448
2449 const VkBaseInStructure *extensionCreateInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2450
2451 while(extensionCreateInfo)
2452 {
2453 switch(extensionCreateInfo->sType)
2454 {
2455 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT:
2456 ASSERT(!vk::Cast(device)->hasExtension(VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME));
2457 break;
2458 default:
2459 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
2460 break;
2461 }
2462
2463 extensionCreateInfo = extensionCreateInfo->pNext;
2464 }
2465
2466 return vk::DescriptorSetLayout::Create(pAllocator, pCreateInfo, outObject: pSetLayout);
2467}
2468
2469VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)
2470{
2471 TRACE("(VkDevice device = %p, VkDescriptorSetLayout descriptorSetLayout = %p, const VkAllocationCallbacks* pAllocator = %p)",
2472 device, static_cast<void *>(descriptorSetLayout), pAllocator);
2473
2474 vk::destroy(vkObject: descriptorSetLayout, pAllocator);
2475}
2476
2477VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool)
2478{
2479 TRACE("(VkDevice device = %p, const VkDescriptorPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorPool* pDescriptorPool = %p)",
2480 device, pCreateInfo, pAllocator, pDescriptorPool);
2481
2482 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2483 while(extInfo)
2484 {
2485 switch(extInfo->sType)
2486 {
2487 case VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO:
2488 break;
2489 default:
2490 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
2491 break;
2492 }
2493 extInfo = extInfo->pNext;
2494 }
2495
2496 return vk::DescriptorPool::Create(pAllocator, pCreateInfo, outObject: pDescriptorPool);
2497}
2498
2499VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)
2500{
2501 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
2502 device, static_cast<void *>(descriptorPool), pAllocator);
2503
2504 vk::destroy(vkObject: descriptorPool, pAllocator);
2505}
2506
2507VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags)
2508{
2509 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, VkDescriptorPoolResetFlags flags = 0x%08X)",
2510 device, static_cast<void *>(descriptorPool), int(flags));
2511
2512 if(flags != 0)
2513 {
2514 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2515 UNSUPPORTED("flags 0x%08X", int(flags));
2516 }
2517
2518 return vk::Cast(object: descriptorPool)->reset();
2519}
2520
2521VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets)
2522{
2523 TRACE("(VkDevice device = %p, const VkDescriptorSetAllocateInfo* pAllocateInfo = %p, VkDescriptorSet* pDescriptorSets = %p)",
2524 device, pAllocateInfo, pDescriptorSets);
2525
2526 const VkDescriptorSetVariableDescriptorCountAllocateInfo *variableDescriptorCountAllocateInfo = nullptr;
2527
2528 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pAllocateInfo->pNext);
2529 while(extInfo)
2530 {
2531 switch(extInfo->sType)
2532 {
2533 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO:
2534 variableDescriptorCountAllocateInfo = reinterpret_cast<const VkDescriptorSetVariableDescriptorCountAllocateInfo *>(extInfo);
2535 break;
2536 default:
2537 UNSUPPORTED("pAllocateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
2538 break;
2539 }
2540 extInfo = extInfo->pNext;
2541 }
2542
2543 return vk::Cast(object: pAllocateInfo->descriptorPool)->allocateSets(descriptorSetCount: pAllocateInfo->descriptorSetCount, pSetLayouts: pAllocateInfo->pSetLayouts, pDescriptorSets, variableDescriptorCountAllocateInfo);
2544}
2545
2546VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets)
2547{
2548 TRACE("(VkDevice device = %p, VkDescriptorPool descriptorPool = %p, uint32_t descriptorSetCount = %d, const VkDescriptorSet* pDescriptorSets = %p)",
2549 device, static_cast<void *>(descriptorPool), descriptorSetCount, pDescriptorSets);
2550
2551 vk::Cast(object: descriptorPool)->freeSets(descriptorSetCount, pDescriptorSets);
2552
2553 return VK_SUCCESS;
2554}
2555
2556VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
2557{
2558 TRACE("(VkDevice device = %p, uint32_t descriptorWriteCount = %d, const VkWriteDescriptorSet* pDescriptorWrites = %p, uint32_t descriptorCopyCount = %d, const VkCopyDescriptorSet* pDescriptorCopies = %p)",
2559 device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
2560
2561 vk::Cast(object: device)->updateDescriptorSets(descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
2562}
2563
2564VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFramebuffer *pFramebuffer)
2565{
2566 TRACE("(VkDevice device = %p, const VkFramebufferCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkFramebuffer* pFramebuffer = %p)",
2567 device, pCreateInfo, pAllocator, pFramebuffer);
2568
2569 return vk::Framebuffer::Create(pAllocator, pCreateInfo, outObject: pFramebuffer);
2570}
2571
2572VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator)
2573{
2574 TRACE("(VkDevice device = %p, VkFramebuffer framebuffer = %p, const VkAllocationCallbacks* pAllocator = %p)",
2575 device, static_cast<void *>(framebuffer), pAllocator);
2576
2577 vk::destroy(vkObject: framebuffer, pAllocator);
2578}
2579
2580VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
2581{
2582 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
2583 device, pCreateInfo, pAllocator, pRenderPass);
2584
2585 if(pCreateInfo->flags != 0)
2586 {
2587 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2588 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2589 }
2590
2591 ValidateRenderPassPNextChain(device, pCreateInfo);
2592
2593 return vk::RenderPass::Create(pAllocator, pCreateInfo, outObject: pRenderPass);
2594}
2595
2596VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass)
2597{
2598 TRACE("(VkDevice device = %p, const VkRenderPassCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkRenderPass* pRenderPass = %p)",
2599 device, pCreateInfo, pAllocator, pRenderPass);
2600
2601 if(pCreateInfo->flags != 0)
2602 {
2603 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
2604 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
2605 }
2606
2607 ValidateRenderPassPNextChain(device, pCreateInfo);
2608
2609 return vk::RenderPass::Create(pAllocator, pCreateInfo, outObject: pRenderPass);
2610}
2611
2612VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)
2613{
2614 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, const VkAllocationCallbacks* pAllocator = %p)",
2615 device, static_cast<void *>(renderPass), pAllocator);
2616
2617 vk::destroy(vkObject: renderPass, pAllocator);
2618}
2619
2620VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(VkDevice device, VkRenderPass renderPass, VkExtent2D *pGranularity)
2621{
2622 TRACE("(VkDevice device = %p, VkRenderPass renderPass = %p, VkExtent2D* pGranularity = %p)",
2623 device, static_cast<void *>(renderPass), pGranularity);
2624
2625 vk::Cast(object: renderPass)->getRenderAreaGranularity(pGranularity);
2626}
2627
2628VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
2629{
2630 TRACE("(VkDevice device = %p, const VkCommandPoolCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkCommandPool* pCommandPool = %p)",
2631 device, pCreateInfo, pAllocator, pCommandPool);
2632
2633 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
2634 while(nextInfo)
2635 {
2636 switch(nextInfo->sType)
2637 {
2638 case VK_STRUCTURE_TYPE_MAX_ENUM:
2639 // dEQP tests that this value is ignored.
2640 break;
2641 default:
2642 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
2643 break;
2644 }
2645 nextInfo = nextInfo->pNext;
2646 }
2647
2648 return vk::CommandPool::Create(pAllocator, pCreateInfo, outObject: pCommandPool);
2649}
2650
2651VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator)
2652{
2653 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, const VkAllocationCallbacks* pAllocator = %p)",
2654 device, static_cast<void *>(commandPool), pAllocator);
2655
2656 vk::destroy(vkObject: commandPool, pAllocator);
2657}
2658
2659VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
2660{
2661 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolResetFlags flags = %d)",
2662 device, static_cast<void *>(commandPool), int(flags));
2663
2664 return vk::Cast(object: commandPool)->reset(flags);
2665}
2666
2667VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
2668{
2669 TRACE("(VkDevice device = %p, const VkCommandBufferAllocateInfo* pAllocateInfo = %p, VkCommandBuffer* pCommandBuffers = %p)",
2670 device, pAllocateInfo, pCommandBuffers);
2671
2672 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pAllocateInfo->pNext);
2673 while(nextInfo)
2674 {
2675 switch(nextInfo->sType)
2676 {
2677 case VK_STRUCTURE_TYPE_MAX_ENUM:
2678 // dEQP tests that this value is ignored.
2679 break;
2680 default:
2681 UNSUPPORTED("pAllocateInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
2682 break;
2683 }
2684 nextInfo = nextInfo->pNext;
2685 }
2686
2687 return vk::Cast(object: pAllocateInfo->commandPool)->allocateCommandBuffers(device: vk::Cast(object: device), level: pAllocateInfo->level, commandBufferCount: pAllocateInfo->commandBufferCount, pCommandBuffers);
2688}
2689
2690VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
2691{
2692 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
2693 device, static_cast<void *>(commandPool), int(commandBufferCount), pCommandBuffers);
2694
2695 vk::Cast(object: commandPool)->freeCommandBuffers(commandBufferCount, pCommandBuffers);
2696}
2697
2698VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
2699{
2700 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCommandBufferBeginInfo* pBeginInfo = %p)",
2701 commandBuffer, pBeginInfo);
2702
2703 auto *nextInfo = reinterpret_cast<const VkBaseInStructure *>(pBeginInfo->pNext);
2704 while(nextInfo)
2705 {
2706 switch(nextInfo->sType)
2707 {
2708 case VK_STRUCTURE_TYPE_MAX_ENUM:
2709 // dEQP tests that this value is ignored.
2710 break;
2711 default:
2712 UNSUPPORTED("pBeginInfo->pNext sType = %s", vk::Stringify(nextInfo->sType).c_str());
2713 break;
2714 }
2715 nextInfo = nextInfo->pNext;
2716 }
2717
2718 return vk::Cast(object: commandBuffer)->begin(flags: pBeginInfo->flags, pInheritanceInfo: pBeginInfo->pInheritanceInfo);
2719}
2720
2721VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
2722{
2723 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
2724
2725 return vk::Cast(object: commandBuffer)->end();
2726}
2727
2728VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags)
2729{
2730 TRACE("(VkCommandBuffer commandBuffer = %p, VkCommandBufferResetFlags flags = %d)", commandBuffer, int(flags));
2731
2732 return vk::Cast(object: commandBuffer)->reset(flags);
2733}
2734
2735VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
2736{
2737 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineBindPoint pipelineBindPoint = %d, VkPipeline pipeline = %p)",
2738 commandBuffer, int(pipelineBindPoint), static_cast<void *>(pipeline));
2739
2740 vk::Cast(object: commandBuffer)->bindPipeline(pipelineBindPoint, pipeline: vk::Cast(object: pipeline));
2741}
2742
2743VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports)
2744{
2745 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstViewport = %d, uint32_t viewportCount = %d, const VkViewport* pViewports = %p)",
2746 commandBuffer, int(firstViewport), int(viewportCount), pViewports);
2747
2748 vk::Cast(object: commandBuffer)->setViewport(firstViewport, viewportCount, pViewports);
2749}
2750
2751VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors)
2752{
2753 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstScissor = %d, uint32_t scissorCount = %d, const VkRect2D* pScissors = %p)",
2754 commandBuffer, int(firstScissor), int(scissorCount), pScissors);
2755
2756 vk::Cast(object: commandBuffer)->setScissor(firstScissor, scissorCount, pScissors);
2757}
2758
2759VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth)
2760{
2761 TRACE("(VkCommandBuffer commandBuffer = %p, float lineWidth = %f)", commandBuffer, lineWidth);
2762
2763 vk::Cast(object: commandBuffer)->setLineWidth(lineWidth);
2764}
2765
2766VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor)
2767{
2768 TRACE("(VkCommandBuffer commandBuffer = %p, float depthBiasConstantFactor = %f, float depthBiasClamp = %f, float depthBiasSlopeFactor = %f)",
2769 commandBuffer, depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
2770
2771 vk::Cast(object: commandBuffer)->setDepthBias(depthBiasConstantFactor, depthBiasClamp, depthBiasSlopeFactor);
2772}
2773
2774VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
2775{
2776 TRACE("(VkCommandBuffer commandBuffer = %p, const float blendConstants[4] = {%f, %f, %f, %f})",
2777 commandBuffer, blendConstants[0], blendConstants[1], blendConstants[2], blendConstants[3]);
2778
2779 vk::Cast(object: commandBuffer)->setBlendConstants(blendConstants);
2780}
2781
2782VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds)
2783{
2784 TRACE("(VkCommandBuffer commandBuffer = %p, float minDepthBounds = %f, float maxDepthBounds = %f)",
2785 commandBuffer, minDepthBounds, maxDepthBounds);
2786
2787 vk::Cast(object: commandBuffer)->setDepthBounds(minDepthBounds, maxDepthBounds);
2788}
2789
2790VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
2791{
2792 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t compareMask = %d)",
2793 commandBuffer, int(faceMask), int(compareMask));
2794
2795 vk::Cast(object: commandBuffer)->setStencilCompareMask(faceMask, compareMask);
2796}
2797
2798VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
2799{
2800 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t writeMask = %d)",
2801 commandBuffer, int(faceMask), int(writeMask));
2802
2803 vk::Cast(object: commandBuffer)->setStencilWriteMask(faceMask, writeMask);
2804}
2805
2806VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
2807{
2808 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, uint32_t reference = %d)",
2809 commandBuffer, int(faceMask), int(reference));
2810
2811 vk::Cast(object: commandBuffer)->setStencilReference(faceMask, reference);
2812}
2813
2814VKAPI_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)
2815{
2816 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)",
2817 commandBuffer, int(pipelineBindPoint), static_cast<void *>(layout), int(firstSet), int(descriptorSetCount), pDescriptorSets, int(dynamicOffsetCount), pDynamicOffsets);
2818
2819 vk::Cast(object: commandBuffer)->bindDescriptorSets(pipelineBindPoint, layout: vk::Cast(object: layout), firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
2820}
2821
2822VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
2823{
2824 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkIndexType indexType = %d)",
2825 commandBuffer, static_cast<void *>(buffer), int(offset), int(indexType));
2826
2827 vk::Cast(object: commandBuffer)->bindIndexBuffer(buffer: vk::Cast(object: buffer), offset, indexType);
2828}
2829
2830VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
2831{
2832 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = %p, const VkDeviceSize* pOffsets = %p)",
2833 commandBuffer, int(firstBinding), int(bindingCount), pBuffers, pOffsets);
2834
2835 vk::Cast(object: commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets, pSizes: nullptr, pStrides: nullptr);
2836}
2837
2838VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers2(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, const VkDeviceSize *pStrides)
2839{
2840 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t firstBinding = %d, uint32_t bindingCount = %d, const VkBuffer* pBuffers = %p, const VkDeviceSize* pOffsets = %p, const VkDeviceSize *pSizes = %p, const VkDeviceSize *pStrides = %p)",
2841 commandBuffer, int(firstBinding), int(bindingCount), pBuffers, pOffsets, pSizes, pStrides);
2842
2843 vk::Cast(object: commandBuffer)->bindVertexBuffers(firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides);
2844}
2845
2846VKAPI_ATTR void VKAPI_CALL vkCmdSetCullMode(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode)
2847{
2848 TRACE("(VkCommandBuffer commandBuffer = %p, VkCullModeFlags cullMode = %d)",
2849 commandBuffer, int(cullMode));
2850
2851 vk::Cast(object: commandBuffer)->setCullMode(cullMode);
2852}
2853
2854VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBoundsTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthBoundsTestEnable)
2855{
2856 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 depthBoundsTestEnable = %d)",
2857 commandBuffer, int(depthBoundsTestEnable));
2858
2859 vk::Cast(object: commandBuffer)->setDepthBoundsTestEnable(depthBoundsTestEnable);
2860}
2861
2862VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthCompareOp(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp)
2863{
2864 TRACE("(VkCommandBuffer commandBuffer = %p, VkCompareOp depthCompareOp = %d)",
2865 commandBuffer, int(depthCompareOp));
2866
2867 vk::Cast(object: commandBuffer)->setDepthCompareOp(depthCompareOp);
2868}
2869
2870VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable)
2871{
2872 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 depthTestEnable = %d)",
2873 commandBuffer, int(depthTestEnable));
2874
2875 vk::Cast(object: commandBuffer)->setDepthTestEnable(depthTestEnable);
2876}
2877
2878VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthWriteEnable(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable)
2879{
2880 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 depthWriteEnable = %d)",
2881 commandBuffer, int(depthWriteEnable));
2882
2883 vk::Cast(object: commandBuffer)->setDepthWriteEnable(depthWriteEnable);
2884}
2885
2886VKAPI_ATTR void VKAPI_CALL vkCmdSetFrontFace(VkCommandBuffer commandBuffer, VkFrontFace frontFace)
2887{
2888 TRACE("(VkCommandBuffer commandBuffer = %p, VkFrontFace frontFace = %d)",
2889 commandBuffer, int(frontFace));
2890
2891 vk::Cast(object: commandBuffer)->setFrontFace(frontFace);
2892}
2893
2894VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveTopology(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology)
2895{
2896 TRACE("(VkCommandBuffer commandBuffer = %p, VkPrimitiveTopology primitiveTopology = %d)",
2897 commandBuffer, int(primitiveTopology));
2898
2899 vk::Cast(object: commandBuffer)->setPrimitiveTopology(primitiveTopology);
2900}
2901
2902VKAPI_ATTR void VKAPI_CALL vkCmdSetScissorWithCount(VkCommandBuffer commandBuffer, uint32_t scissorCount, const VkRect2D *pScissors)
2903{
2904 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t scissorCount = %d, const VkRect2D *pScissors = %p)",
2905 commandBuffer, scissorCount, pScissors);
2906
2907 vk::Cast(object: commandBuffer)->setScissorWithCount(scissorCount, pScissors);
2908}
2909
2910VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilOp(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp)
2911{
2912 TRACE("(VkCommandBuffer commandBuffer = %p, VkStencilFaceFlags faceMask = %d, VkStencilOp failOp = %d, VkStencilOp passOp = %d, VkStencilOp depthFailOp = %d, VkCompareOp compareOp = %d)",
2913 commandBuffer, int(faceMask), int(failOp), int(passOp), int(depthFailOp), int(compareOp));
2914
2915 vk::Cast(object: commandBuffer)->setStencilOp(faceMask, failOp, passOp, depthFailOp, compareOp);
2916}
2917
2918VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilTestEnable(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable)
2919{
2920 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 stencilTestEnable = %d)",
2921 commandBuffer, int(stencilTestEnable));
2922
2923 vk::Cast(object: commandBuffer)->setStencilTestEnable(stencilTestEnable);
2924}
2925
2926VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWithCount(VkCommandBuffer commandBuffer, uint32_t viewportCount, const VkViewport *pViewports)
2927{
2928 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t viewportCount = %d, const VkViewport *pViewports = %p)",
2929 commandBuffer, viewportCount, pViewports);
2930
2931 vk::Cast(object: commandBuffer)->setViewportWithCount(viewportCount, pViewports);
2932}
2933
2934VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizerDiscardEnable(VkCommandBuffer commandBuffer, VkBool32 rasterizerDiscardEnable)
2935{
2936 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 rasterizerDiscardEnable = %d)",
2937 commandBuffer, rasterizerDiscardEnable);
2938
2939 vk::Cast(object: commandBuffer)->setRasterizerDiscardEnable(rasterizerDiscardEnable);
2940}
2941
2942VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBiasEnable(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable)
2943{
2944 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 depthBiasEnable = %d)",
2945 commandBuffer, depthBiasEnable);
2946
2947 vk::Cast(object: commandBuffer)->setDepthBiasEnable(depthBiasEnable);
2948}
2949
2950VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveRestartEnable(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable)
2951{
2952 TRACE("(VkCommandBuffer commandBuffer = %p, VkBool32 primitiveRestartEnable = %d)",
2953 commandBuffer, primitiveRestartEnable);
2954
2955 vk::Cast(object: commandBuffer)->setPrimitiveRestartEnable(primitiveRestartEnable);
2956}
2957
2958VKAPI_ATTR void VKAPI_CALL vkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
2959{
2960 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t vertexCount = %d, uint32_t instanceCount = %d, uint32_t firstVertex = %d, uint32_t firstInstance = %d)",
2961 commandBuffer, int(vertexCount), int(instanceCount), int(firstVertex), int(firstInstance));
2962
2963 vk::Cast(object: commandBuffer)->draw(vertexCount, instanceCount, firstVertex, firstInstance);
2964}
2965
2966VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance)
2967{
2968 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t indexCount = %d, uint32_t instanceCount = %d, uint32_t firstIndex = %d, int32_t vertexOffset = %d, uint32_t firstInstance = %d)",
2969 commandBuffer, int(indexCount), int(instanceCount), int(firstIndex), int(vertexOffset), int(firstInstance));
2970
2971 vk::Cast(object: commandBuffer)->drawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
2972}
2973
2974VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
2975{
2976 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
2977 commandBuffer, static_cast<void *>(buffer), int(offset), int(drawCount), int(stride));
2978
2979 vk::Cast(object: commandBuffer)->drawIndirect(buffer: vk::Cast(object: buffer), offset, drawCount, stride);
2980}
2981
2982VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride)
2983{
2984 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, uint32_t drawCount = %d, uint32_t stride = %d)",
2985 commandBuffer, static_cast<void *>(buffer), int(offset), int(drawCount), int(stride));
2986
2987 vk::Cast(object: commandBuffer)->drawIndexedIndirect(buffer: vk::Cast(object: buffer), offset, drawCount, stride);
2988}
2989
2990VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride)
2991{
2992 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkBuffer countBuffer = %p, VkDeviceSize countBufferOffset = %d, uint32_t maxDrawCount = %d, uint32_t stride = %d",
2993 commandBuffer, static_cast<void *>(buffer), int(offset), static_cast<void *>(countBuffer), int(countBufferOffset), int(maxDrawCount), int(stride));
2994 UNSUPPORTED("VK_KHR_draw_indirect_count");
2995}
2996
2997VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride)
2998{
2999 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d, VkBuffer countBuffer = %p, VkDeviceSize countBufferOffset = %d, uint32_t maxDrawCount = %d, uint32_t stride = %d",
3000 commandBuffer, static_cast<void *>(buffer), int(offset), static_cast<void *>(countBuffer), int(countBufferOffset), int(maxDrawCount), int(stride));
3001 UNSUPPORTED("VK_KHR_draw_indirect_count");
3002}
3003
3004VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
3005{
3006 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t groupCountX = %d, uint32_t groupCountY = %d, uint32_t groupCountZ = %d)",
3007 commandBuffer, int(groupCountX), int(groupCountY), int(groupCountZ));
3008
3009 vk::Cast(object: commandBuffer)->dispatch(groupCountX, groupCountY, groupCountZ);
3010}
3011
3012VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset)
3013{
3014 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer buffer = %p, VkDeviceSize offset = %d)",
3015 commandBuffer, static_cast<void *>(buffer), int(offset));
3016
3017 vk::Cast(object: commandBuffer)->dispatchIndirect(buffer: vk::Cast(object: buffer), offset);
3018}
3019
3020VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions)
3021{
3022 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferCopy* pRegions = %p)",
3023 commandBuffer, static_cast<void *>(srcBuffer), static_cast<void *>(dstBuffer), int(regionCount), pRegions);
3024
3025 vk::Cast(object: commandBuffer)->copyBuffer(copyBufferInfo: vk::CopyBufferInfo(srcBuffer, dstBuffer, regionCount, pRegions));
3026}
3027
3028VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer2(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2 *pCopyBufferInfo)
3029{
3030 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCopyBufferInfo2* pCopyBufferInfo = %p)",
3031 commandBuffer, pCopyBufferInfo);
3032
3033 vk::Cast(object: commandBuffer)->copyBuffer(copyBufferInfo: *pCopyBufferInfo);
3034}
3035
3036VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy *pRegions)
3037{
3038 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageCopy* pRegions = %p)",
3039 commandBuffer, static_cast<void *>(srcImage), srcImageLayout, static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions);
3040
3041 vk::Cast(object: commandBuffer)->copyImage(copyImageInfo: vk::CopyImageInfo(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions));
3042}
3043
3044VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage2(VkCommandBuffer commandBuffer, const VkCopyImageInfo2 *pCopyImageInfo)
3045{
3046 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCopyImageInfo2* pCopyImageInfo = %p)",
3047 commandBuffer, pCopyImageInfo);
3048
3049 vk::Cast(object: commandBuffer)->copyImage(copyImageInfo: *pCopyImageInfo);
3050}
3051
3052VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
3053{
3054 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)",
3055 commandBuffer, static_cast<void *>(srcImage), srcImageLayout, static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions, filter);
3056
3057 vk::Cast(object: commandBuffer)->blitImage(blitImageInfo: vk::BlitImageInfo(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter));
3058}
3059
3060VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage2(VkCommandBuffer commandBuffer, const VkBlitImageInfo2 *pBlitImageInfo)
3061{
3062 TRACE("(VkCommandBuffer commandBuffer = %p, const VkBlitImageInfo2* pBlitImageInfo = %p)",
3063 commandBuffer, pBlitImageInfo);
3064
3065 vk::Cast(object: commandBuffer)->blitImage(blitImageInfo: *pBlitImageInfo);
3066}
3067
3068VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy *pRegions)
3069{
3070 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer srcBuffer = %p, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
3071 commandBuffer, static_cast<void *>(srcBuffer), static_cast<void *>(dstImage), dstImageLayout, int(regionCount), pRegions);
3072
3073 vk::Cast(object: commandBuffer)->copyBufferToImage(copyBufferToImageInfo: vk::CopyBufferToImageInfo(srcBuffer, dstImage, dstImageLayout, regionCount, pRegions));
3074}
3075
3076VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage2(VkCommandBuffer commandBuffer, const VkCopyBufferToImageInfo2 *pCopyBufferToImageInfo)
3077{
3078 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo = %p)",
3079 commandBuffer, pCopyBufferToImageInfo);
3080
3081 vk::Cast(object: commandBuffer)->copyBufferToImage(copyBufferToImageInfo: *pCopyBufferToImageInfo);
3082}
3083
3084VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy *pRegions)
3085{
3086 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkBuffer dstBuffer = %p, uint32_t regionCount = %d, const VkBufferImageCopy* pRegions = %p)",
3087 commandBuffer, static_cast<void *>(srcImage), int(srcImageLayout), static_cast<void *>(dstBuffer), int(regionCount), pRegions);
3088
3089 vk::Cast(object: commandBuffer)->copyImageToBuffer(copyImageToBufferInfo: vk::CopyImageToBufferInfo(srcImage, srcImageLayout, dstBuffer, regionCount, pRegions));
3090}
3091
3092VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, const VkCopyImageToBufferInfo2 *pCopyImageToBufferInfo)
3093{
3094 TRACE("(VkCommandBuffer commandBuffer = %p, const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo = %p)",
3095 commandBuffer, pCopyImageToBufferInfo);
3096
3097 vk::Cast(object: commandBuffer)->copyImageToBuffer(copyImageToBufferInfo: *pCopyImageToBufferInfo);
3098}
3099
3100VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void *pData)
3101{
3102 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize dataSize = %d, const void* pData = %p)",
3103 commandBuffer, static_cast<void *>(dstBuffer), int(dstOffset), int(dataSize), pData);
3104
3105 vk::Cast(object: commandBuffer)->updateBuffer(dstBuffer: vk::Cast(object: dstBuffer), dstOffset, dataSize, pData);
3106}
3107
3108VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
3109{
3110 TRACE("(VkCommandBuffer commandBuffer = %p, VkBuffer dstBuffer = %p, VkDeviceSize dstOffset = %d, VkDeviceSize size = %d, uint32_t data = %d)",
3111 commandBuffer, static_cast<void *>(dstBuffer), int(dstOffset), int(size), data);
3112
3113 vk::Cast(object: commandBuffer)->fillBuffer(dstBuffer: vk::Cast(object: dstBuffer), dstOffset, size, data);
3114}
3115
3116VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue *pColor, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
3117{
3118 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearColorValue* pColor = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
3119 commandBuffer, static_cast<void *>(image), int(imageLayout), pColor, int(rangeCount), pRanges);
3120
3121 vk::Cast(object: commandBuffer)->clearColorImage(image: vk::Cast(object: image), imageLayout, pColor, rangeCount, pRanges);
3122}
3123
3124VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue *pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange *pRanges)
3125{
3126 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage image = %p, VkImageLayout imageLayout = %d, const VkClearDepthStencilValue* pDepthStencil = %p, uint32_t rangeCount = %d, const VkImageSubresourceRange* pRanges = %p)",
3127 commandBuffer, static_cast<void *>(image), int(imageLayout), pDepthStencil, int(rangeCount), pRanges);
3128
3129 vk::Cast(object: commandBuffer)->clearDepthStencilImage(image: vk::Cast(object: image), imageLayout, pDepthStencil, rangeCount, pRanges);
3130}
3131
3132VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment *pAttachments, uint32_t rectCount, const VkClearRect *pRects)
3133{
3134 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t attachmentCount = %d, const VkClearAttachment* pAttachments = %p, uint32_t rectCount = %d, const VkClearRect* pRects = %p)",
3135 commandBuffer, int(attachmentCount), pAttachments, int(rectCount), pRects);
3136
3137 vk::Cast(object: commandBuffer)->clearAttachments(attachmentCount, pAttachments, rectCount, pRects);
3138}
3139
3140VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve *pRegions)
3141{
3142 TRACE("(VkCommandBuffer commandBuffer = %p, VkImage srcImage = %p, VkImageLayout srcImageLayout = %d, VkImage dstImage = %p, VkImageLayout dstImageLayout = %d, uint32_t regionCount = %d, const VkImageResolve* pRegions = %p)",
3143 commandBuffer, static_cast<void *>(srcImage), int(srcImageLayout), static_cast<void *>(dstImage), int(dstImageLayout), regionCount, pRegions);
3144
3145 vk::Cast(object: commandBuffer)->resolveImage(resolveImageInfo: vk::ResolveImageInfo(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions));
3146}
3147
3148VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2 *pResolveImageInfo)
3149{
3150 TRACE("(VkCommandBuffer commandBuffer = %p, const VkResolveImageInfo2* pResolveImageInfo = %p)",
3151 commandBuffer, pResolveImageInfo);
3152
3153 vk::Cast(object: commandBuffer)->resolveImage(resolveImageInfo: *pResolveImageInfo);
3154}
3155
3156VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
3157{
3158 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
3159 commandBuffer, static_cast<void *>(event), int(stageMask));
3160
3161 vk::Cast(object: commandBuffer)->setEvent(event: vk::Cast(object: event), pDependencyInfo: vk::DependencyInfo(stageMask, stageMask, VkDependencyFlags(0), 0, nullptr, 0, nullptr, 0, nullptr));
3162}
3163
3164VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent2(VkCommandBuffer commandBuffer, VkEvent event, const VkDependencyInfo *pDependencyInfo)
3165{
3166 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, const VkDependencyInfo* pDependencyInfo = %p)",
3167 commandBuffer, static_cast<void *>(event), pDependencyInfo);
3168
3169 vk::Cast(object: commandBuffer)->setEvent(event: vk::Cast(object: event), pDependencyInfo: *pDependencyInfo);
3170}
3171
3172VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
3173{
3174 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags stageMask = %d)",
3175 commandBuffer, static_cast<void *>(event), int(stageMask));
3176
3177 vk::Cast(object: commandBuffer)->resetEvent(event: vk::Cast(object: event), stageMask);
3178}
3179
3180VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent2(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2 stageMask)
3181{
3182 TRACE("(VkCommandBuffer commandBuffer = %p, VkEvent event = %p, VkPipelineStageFlags2 stageMask = %d)",
3183 commandBuffer, static_cast<void *>(event), int(stageMask));
3184
3185 vk::Cast(object: commandBuffer)->resetEvent(event: vk::Cast(object: event), stageMask);
3186}
3187
3188VKAPI_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)
3189{
3190 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t eventCount = %d, const VkEvent* pEvents = %p, VkPipelineStageFlags srcStageMask = 0x%08X, VkPipelineStageFlags dstStageMask = 0x%08X, uint32_t memoryBarrierCount = %d, const VkMemoryBarrier* pMemoryBarriers = %p, uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
3191 commandBuffer, int(eventCount), pEvents, int(srcStageMask), int(dstStageMask), int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
3192
3193 vk::Cast(object: commandBuffer)->waitEvents(eventCount, pEvents, pDependencyInfo: vk::DependencyInfo(srcStageMask, dstStageMask, VkDependencyFlags(0), memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers));
3194}
3195
3196VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents2(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent *pEvents, const VkDependencyInfo *pDependencyInfos)
3197{
3198 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t eventCount = %d, const VkEvent* pEvents = %p, const VkDependencyInfo* pDependencyInfos = %p)",
3199 commandBuffer, int(eventCount), pEvents, pDependencyInfos);
3200
3201 vk::Cast(object: commandBuffer)->waitEvents(eventCount, pEvents, pDependencyInfo: *pDependencyInfos);
3202}
3203
3204VKAPI_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)
3205{
3206 TRACE(
3207 "(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlags srcStageMask = 0x%08X, VkPipelineStageFlags dstStageMask = 0x%08X, VkDependencyFlags dependencyFlags = %d, uint32_t memoryBarrierCount = %d, onst VkMemoryBarrier* pMemoryBarriers = %p,"
3208 " uint32_t bufferMemoryBarrierCount = %d, const VkBufferMemoryBarrier* pBufferMemoryBarriers = %p, uint32_t imageMemoryBarrierCount = %d, const VkImageMemoryBarrier* pImageMemoryBarriers = %p)",
3209 commandBuffer, int(srcStageMask), int(dstStageMask), dependencyFlags, int(memoryBarrierCount), pMemoryBarriers, int(bufferMemoryBarrierCount), pBufferMemoryBarriers, int(imageMemoryBarrierCount), pImageMemoryBarriers);
3210
3211 vk::Cast(object: commandBuffer)->pipelineBarrier(pDependencyInfo: vk::DependencyInfo(srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers));
3212}
3213
3214VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier2(VkCommandBuffer commandBuffer, const VkDependencyInfo *pDependencyInfo)
3215{
3216 TRACE("(VkCommandBuffer commandBuffer = %p, const VkDependencyInfo* pDependencyInfo = %p)",
3217 commandBuffer, pDependencyInfo);
3218
3219 vk::Cast(object: commandBuffer)->pipelineBarrier(pDependencyInfo: *pDependencyInfo);
3220}
3221
3222VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags)
3223{
3224 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d, VkQueryControlFlags flags = %d)",
3225 commandBuffer, static_cast<void *>(queryPool), query, int(flags));
3226
3227 vk::Cast(object: commandBuffer)->beginQuery(queryPool: vk::Cast(object: queryPool), query, flags);
3228}
3229
3230VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query)
3231{
3232 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t query = %d)",
3233 commandBuffer, static_cast<void *>(queryPool), int(query));
3234
3235 vk::Cast(object: commandBuffer)->endQuery(queryPool: vk::Cast(object: queryPool), query);
3236}
3237
3238VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
3239{
3240 TRACE("(VkCommandBuffer commandBuffer = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
3241 commandBuffer, static_cast<void *>(queryPool), int(firstQuery), int(queryCount));
3242
3243 vk::Cast(object: commandBuffer)->resetQueryPool(queryPool: vk::Cast(object: queryPool), firstQuery, queryCount);
3244}
3245
3246VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query)
3247{
3248 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlagBits pipelineStage = %d, VkQueryPool queryPool = %p, uint32_t query = %d)",
3249 commandBuffer, int(pipelineStage), static_cast<void *>(queryPool), int(query));
3250
3251 vk::Cast(object: commandBuffer)->writeTimestamp(pipelineStage, queryPool: vk::Cast(object: queryPool), query);
3252}
3253
3254VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp2(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 stage, VkQueryPool queryPool, uint32_t query)
3255{
3256 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineStageFlags2 stage = %d, VkQueryPool queryPool = %p, uint32_t query = %d)",
3257 commandBuffer, int(stage), static_cast<void *>(queryPool), int(query));
3258
3259 vk::Cast(object: commandBuffer)->writeTimestamp(pipelineStage: stage, queryPool: vk::Cast(object: queryPool), query);
3260}
3261
3262VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags)
3263{
3264 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)",
3265 commandBuffer, static_cast<void *>(queryPool), int(firstQuery), int(queryCount), static_cast<void *>(dstBuffer), int(dstOffset), int(stride), int(flags));
3266
3267 vk::Cast(object: commandBuffer)->copyQueryPoolResults(queryPool: vk::Cast(object: queryPool), firstQuery, queryCount, dstBuffer: vk::Cast(object: dstBuffer), dstOffset, stride, flags);
3268}
3269
3270VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void *pValues)
3271{
3272 TRACE("(VkCommandBuffer commandBuffer = %p, VkPipelineLayout layout = %p, VkShaderStageFlags stageFlags = %d, uint32_t offset = %d, uint32_t size = %d, const void* pValues = %p)",
3273 commandBuffer, static_cast<void *>(layout), stageFlags, offset, size, pValues);
3274
3275 vk::Cast(object: commandBuffer)->pushConstants(layout: vk::Cast(object: layout), stageFlags, offset, size, pValues);
3276}
3277
3278VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, VkSubpassContents contents)
3279{
3280 VkSubpassBeginInfo subpassBeginInfo = { .sType: VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO, .pNext: nullptr, .contents: contents };
3281 vkCmdBeginRenderPass2(commandBuffer, pRenderPassBegin, pSubpassBeginInfo: &subpassBeginInfo);
3282}
3283
3284VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *pRenderPassBegin, const VkSubpassBeginInfoKHR *pSubpassBeginInfo)
3285{
3286 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderPassBeginInfo* pRenderPassBegin = %p, const VkSubpassBeginInfoKHR* pSubpassBeginInfo = %p)",
3287 commandBuffer, pRenderPassBegin, pSubpassBeginInfo);
3288
3289 const VkBaseInStructure *renderPassBeginInfo = reinterpret_cast<const VkBaseInStructure *>(pRenderPassBegin->pNext);
3290 const VkRenderPassAttachmentBeginInfo *attachmentBeginInfo = nullptr;
3291 while(renderPassBeginInfo)
3292 {
3293 switch(renderPassBeginInfo->sType)
3294 {
3295 case VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO:
3296 // This extension controls which render area is used on which physical device,
3297 // in order to distribute rendering between multiple physical devices.
3298 // SwiftShader only has a single physical device, so this extension does nothing in this case.
3299 break;
3300 case VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO:
3301 attachmentBeginInfo = reinterpret_cast<const VkRenderPassAttachmentBeginInfo *>(renderPassBeginInfo);
3302 break;
3303 case VK_STRUCTURE_TYPE_MAX_ENUM:
3304 // dEQP tests that this value is ignored.
3305 break;
3306 default:
3307 UNSUPPORTED("pRenderPassBegin->pNext sType = %s", vk::Stringify(renderPassBeginInfo->sType).c_str());
3308 break;
3309 }
3310
3311 renderPassBeginInfo = renderPassBeginInfo->pNext;
3312 }
3313
3314 vk::Cast(object: commandBuffer)->beginRenderPass(renderPass: vk::Cast(object: pRenderPassBegin->renderPass), framebuffer: vk::Cast(object: pRenderPassBegin->framebuffer), renderArea: pRenderPassBegin->renderArea, clearValueCount: pRenderPassBegin->clearValueCount, pClearValues: pRenderPassBegin->pClearValues, contents: pSubpassBeginInfo->contents, attachmentBeginInfo);
3315}
3316
3317VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
3318{
3319 TRACE("(VkCommandBuffer commandBuffer = %p, VkSubpassContents contents = %d)",
3320 commandBuffer, contents);
3321
3322 vk::Cast(object: commandBuffer)->nextSubpass(contents);
3323}
3324
3325VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR *pSubpassBeginInfo, const VkSubpassEndInfoKHR *pSubpassEndInfo)
3326{
3327 TRACE("(VkCommandBuffer commandBuffer = %p, const VkSubpassBeginInfoKHR* pSubpassBeginInfo = %p, const VkSubpassEndInfoKHR* pSubpassEndInfo = %p)",
3328 commandBuffer, pSubpassBeginInfo, pSubpassEndInfo);
3329
3330 vk::Cast(object: commandBuffer)->nextSubpass(contents: pSubpassBeginInfo->contents);
3331}
3332
3333VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
3334{
3335 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
3336
3337 vk::Cast(object: commandBuffer)->endRenderPass();
3338}
3339
3340VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR *pSubpassEndInfo)
3341{
3342 TRACE("(VkCommandBuffer commandBuffer = %p, const VkSubpassEndInfoKHR* pSubpassEndInfo = %p)", commandBuffer, pSubpassEndInfo);
3343
3344 vk::Cast(object: commandBuffer)->endRenderPass();
3345}
3346
3347VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
3348{
3349 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t commandBufferCount = %d, const VkCommandBuffer* pCommandBuffers = %p)",
3350 commandBuffer, commandBufferCount, pCommandBuffers);
3351
3352 vk::Cast(object: commandBuffer)->executeCommands(commandBufferCount, pCommandBuffers);
3353}
3354
3355VKAPI_ATTR void VKAPI_CALL vkCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo *pRenderingInfo)
3356{
3357 TRACE("(VkCommandBuffer commandBuffer = %p, const VkRenderingInfo* pRenderingInfo = %p)",
3358 commandBuffer, pRenderingInfo);
3359
3360 vk::Cast(object: commandBuffer)->beginRendering(pRenderingInfo);
3361}
3362
3363VKAPI_ATTR void VKAPI_CALL vkCmdEndRendering(VkCommandBuffer commandBuffer)
3364{
3365 TRACE("(VkCommandBuffer commandBuffer = %p)",
3366 commandBuffer);
3367
3368 vk::Cast(object: commandBuffer)->endRendering();
3369}
3370
3371VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion(uint32_t *pApiVersion)
3372{
3373 TRACE("(uint32_t* pApiVersion = %p)", pApiVersion);
3374 *pApiVersion = vk::API_VERSION;
3375 return VK_SUCCESS;
3376}
3377
3378VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo *pBindInfos)
3379{
3380 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindBufferMemoryInfo* pBindInfos = %p)",
3381 device, bindInfoCount, pBindInfos);
3382
3383 for(uint32_t i = 0; i < bindInfoCount; i++)
3384 {
3385 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pBindInfos[i].pNext);
3386 while(extInfo)
3387 {
3388 UNSUPPORTED("pBindInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
3389 extInfo = extInfo->pNext;
3390 }
3391
3392 if(!vk::Cast(object: pBindInfos[i].buffer)->canBindToMemory(pDeviceMemory: vk::Cast(object: pBindInfos[i].memory)))
3393 {
3394 UNSUPPORTED("vkBindBufferMemory2 with invalid external memory");
3395 return VK_ERROR_INVALID_EXTERNAL_HANDLE;
3396 }
3397 }
3398
3399 for(uint32_t i = 0; i < bindInfoCount; i++)
3400 {
3401 vk::Cast(object: pBindInfos[i].buffer)->bind(pDeviceMemory: vk::Cast(object: pBindInfos[i].memory), pMemoryOffset: pBindInfos[i].memoryOffset);
3402 }
3403
3404 return VK_SUCCESS;
3405}
3406
3407VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo *pBindInfos)
3408{
3409 TRACE("(VkDevice device = %p, uint32_t bindInfoCount = %d, const VkBindImageMemoryInfo* pBindInfos = %p)",
3410 device, bindInfoCount, pBindInfos);
3411
3412 for(uint32_t i = 0; i < bindInfoCount; i++)
3413 {
3414 if(!vk::Cast(object: pBindInfos[i].image)->canBindToMemory(pDeviceMemory: vk::Cast(object: pBindInfos[i].memory)))
3415 {
3416 UNSUPPORTED("vkBindImageMemory2 with invalid external memory");
3417 return VK_ERROR_OUT_OF_DEVICE_MEMORY;
3418 }
3419 }
3420
3421 for(uint32_t i = 0; i < bindInfoCount; i++)
3422 {
3423 vk::DeviceMemory *memory = vk::Cast(object: pBindInfos[i].memory);
3424 VkDeviceSize offset = pBindInfos[i].memoryOffset;
3425
3426 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pBindInfos[i].pNext);
3427 while(extInfo)
3428 {
3429 switch(extInfo->sType)
3430 {
3431 case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO:
3432 /* Do nothing */
3433 break;
3434
3435#ifndef __ANDROID__
3436 case VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR:
3437 {
3438 const auto *swapchainInfo = reinterpret_cast<const VkBindImageMemorySwapchainInfoKHR *>(extInfo);
3439 memory = vk::Cast(object: swapchainInfo->swapchain)->getImage(imageIndex: swapchainInfo->imageIndex).getImageMemory();
3440 offset = 0;
3441 }
3442 break;
3443#endif
3444
3445 default:
3446 UNSUPPORTED("pBindInfos[%d].pNext sType = %s", i, vk::Stringify(extInfo->sType).c_str());
3447 break;
3448 }
3449 extInfo = extInfo->pNext;
3450 }
3451
3452 vk::Cast(object: pBindInfos[i].image)->bind(pDeviceMemory: memory, pMemoryOffset: offset);
3453 }
3454
3455 return VK_SUCCESS;
3456}
3457
3458VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags *pPeerMemoryFeatures)
3459{
3460 TRACE("(VkDevice device = %p, uint32_t heapIndex = %d, uint32_t localDeviceIndex = %d, uint32_t remoteDeviceIndex = %d, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures = %p)",
3461 device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
3462
3463 ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
3464 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.
3465}
3466
3467VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
3468{
3469 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t deviceMask = %d", commandBuffer, deviceMask);
3470
3471 vk::Cast(object: commandBuffer)->setDeviceMask(deviceMask);
3472}
3473
3474VKAPI_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)
3475{
3476 TRACE("(VkCommandBuffer commandBuffer = %p, baseGroupX = %u, baseGroupY = %u, baseGroupZ = %u, groupCountX = %u, groupCountY = %u, groupCountZ = %u)",
3477 commandBuffer, baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
3478
3479 vk::Cast(object: commandBuffer)->dispatchBase(baseGroupX, baseGroupY, baseGroupZ, groupCountX, groupCountY, groupCountZ);
3480}
3481
3482VKAPI_ATTR void VKAPI_CALL vkResetQueryPool(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
3483{
3484 TRACE("(VkDevice device = %p, VkQueryPool queryPool = %p, uint32_t firstQuery = %d, uint32_t queryCount = %d)",
3485 device, static_cast<void *>(queryPool), firstQuery, queryCount);
3486 vk::Cast(object: queryPool)->reset(firstQuery, queryCount);
3487}
3488
3489VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups(VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties)
3490{
3491 TRACE("(VkInstance instance = %p, uint32_t* pPhysicalDeviceGroupCount = %p, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties = %p)",
3492 instance, pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
3493
3494 return vk::Cast(object: instance)->getPhysicalDeviceGroups(pPhysicalDeviceGroupCount, pPhysicalDeviceGroupProperties);
3495}
3496
3497VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const VkImageMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
3498{
3499 TRACE("(VkDevice device = %p, const VkImageMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
3500 device, pInfo, pMemoryRequirements);
3501
3502 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pInfo->pNext);
3503 while(extInfo)
3504 {
3505 UNSUPPORTED("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
3506 extInfo = extInfo->pNext;
3507 }
3508
3509 vk::Cast(object: pInfo->image)->getMemoryRequirements(pMemoryRequirements);
3510}
3511
3512VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2(VkDevice device, const VkBufferMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
3513{
3514 TRACE("(VkDevice device = %p, const VkBufferMemoryRequirementsInfo2* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
3515 device, pInfo, pMemoryRequirements);
3516
3517 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pInfo->pNext);
3518 while(extInfo)
3519 {
3520 UNSUPPORTED("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
3521 extInfo = extInfo->pNext;
3522 }
3523
3524 VkBaseOutStructure *extensionRequirements = reinterpret_cast<VkBaseOutStructure *>(pMemoryRequirements->pNext);
3525 while(extensionRequirements)
3526 {
3527 switch(extensionRequirements->sType)
3528 {
3529 case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
3530 {
3531 auto *requirements = reinterpret_cast<VkMemoryDedicatedRequirements *>(extensionRequirements);
3532 vk::Cast(object: device)->getRequirements(requirements);
3533 }
3534 break;
3535 default:
3536 UNSUPPORTED("pMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
3537 break;
3538 }
3539
3540 extensionRequirements = extensionRequirements->pNext;
3541 }
3542
3543 vkGetBufferMemoryRequirements(device, buffer: pInfo->buffer, pMemoryRequirements: &(pMemoryRequirements->memoryRequirements));
3544}
3545
3546VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2(VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements)
3547{
3548 TRACE("(VkDevice device = %p, const VkImageSparseMemoryRequirementsInfo2* pInfo = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = %p)",
3549 device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
3550
3551 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pInfo->pNext);
3552 while(extInfo)
3553 {
3554 UNSUPPORTED("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
3555 extInfo = extInfo->pNext;
3556 }
3557
3558 if(pSparseMemoryRequirements) // Valid to be NULL
3559 {
3560 const auto *extensionRequirements = reinterpret_cast<const VkBaseInStructure *>(pSparseMemoryRequirements->pNext);
3561 while(extensionRequirements)
3562 {
3563 UNSUPPORTED("pSparseMemoryRequirements->pNext sType = %s", vk::Stringify(extensionRequirements->sType).c_str());
3564 extensionRequirements = extensionRequirements->pNext;
3565 }
3566 }
3567
3568 // The 'sparseBinding' feature is not supported, so images can not be created with the VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT flag.
3569 // "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."
3570 *pSparseMemoryRequirementCount = 0;
3571}
3572
3573VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures)
3574{
3575 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceFeatures2* pFeatures = %p)", physicalDevice, pFeatures);
3576
3577 vk::Cast(object: physicalDevice)->getFeatures2(features: pFeatures);
3578}
3579
3580VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties)
3581{
3582 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceProperties2* pProperties = %p)", physicalDevice, pProperties);
3583
3584 VkBaseOutStructure *extensionProperties = reinterpret_cast<VkBaseOutStructure *>(pProperties->pNext);
3585 while(extensionProperties)
3586 {
3587 // Casting to an int since some structures, such as VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID,
3588 // are not enumerated in the official Vulkan headers.
3589 switch((int)(extensionProperties->sType))
3590 {
3591 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES:
3592 {
3593 auto *properties = reinterpret_cast<VkPhysicalDeviceIDProperties *>(extensionProperties);
3594 vk::Cast(object: physicalDevice)->getProperties(properties);
3595 }
3596 break;
3597 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES:
3598 {
3599 auto *properties = reinterpret_cast<VkPhysicalDeviceMaintenance3Properties *>(extensionProperties);
3600 vk::Cast(object: physicalDevice)->getProperties(properties);
3601 }
3602 break;
3603 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES:
3604 {
3605 auto *properties = reinterpret_cast<VkPhysicalDeviceMaintenance4Properties *>(extensionProperties);
3606 vk::Cast(object: physicalDevice)->getProperties(properties);
3607 }
3608 break;
3609 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES:
3610 {
3611 auto *properties = reinterpret_cast<VkPhysicalDeviceMultiviewProperties *>(extensionProperties);
3612 vk::Cast(object: physicalDevice)->getProperties(properties);
3613 }
3614 break;
3615 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES:
3616 {
3617 auto *properties = reinterpret_cast<VkPhysicalDevicePointClippingProperties *>(extensionProperties);
3618 vk::Cast(object: physicalDevice)->getProperties(properties);
3619 }
3620 break;
3621 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES:
3622 {
3623 auto *properties = reinterpret_cast<VkPhysicalDeviceProtectedMemoryProperties *>(extensionProperties);
3624 vk::Cast(object: physicalDevice)->getProperties(properties);
3625 }
3626 break;
3627 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES:
3628 {
3629 auto *properties = reinterpret_cast<VkPhysicalDeviceSubgroupProperties *>(extensionProperties);
3630 vk::Cast(object: physicalDevice)->getProperties(properties);
3631 }
3632 break;
3633 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT:
3634 {
3635 auto *properties = reinterpret_cast<VkPhysicalDeviceExternalMemoryHostPropertiesEXT *>(extensionProperties);
3636 vk::Cast(object: physicalDevice)->getProperties(properties);
3637 }
3638 break;
3639 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES:
3640 {
3641 auto *properties = reinterpret_cast<VkPhysicalDeviceDriverProperties *>(extensionProperties);
3642 vk::Cast(object: physicalDevice)->getProperties(properties);
3643 }
3644 break;
3645#ifdef __ANDROID__
3646 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENTATION_PROPERTIES_ANDROID:
3647 {
3648 auto *properties = reinterpret_cast<VkPhysicalDevicePresentationPropertiesANDROID *>(extensionProperties);
3649 vk::Cast(physicalDevice)->getProperties(properties);
3650 }
3651 break;
3652#endif
3653 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT:
3654 {
3655 auto *properties = reinterpret_cast<VkPhysicalDeviceLineRasterizationPropertiesEXT *>(extensionProperties);
3656 vk::Cast(object: physicalDevice)->getProperties(properties);
3657 }
3658 break;
3659 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT:
3660 {
3661 auto *properties = reinterpret_cast<VkPhysicalDeviceProvokingVertexPropertiesEXT *>(extensionProperties);
3662 vk::Cast(object: physicalDevice)->getProperties(properties);
3663 }
3664 break;
3665 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES:
3666 {
3667 auto *properties = reinterpret_cast<VkPhysicalDeviceFloatControlsProperties *>(extensionProperties);
3668 vk::Cast(object: physicalDevice)->getProperties(properties);
3669 }
3670 break;
3671 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES:
3672 {
3673 auto *properties = reinterpret_cast<VkPhysicalDeviceVulkan11Properties *>(extensionProperties);
3674 vk::Cast(object: physicalDevice)->getProperties(properties);
3675 }
3676 break;
3677 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES:
3678 {
3679 auto *properties = reinterpret_cast<VkPhysicalDeviceSamplerFilterMinmaxProperties *>(extensionProperties);
3680 vk::Cast(object: physicalDevice)->getProperties(properties);
3681 }
3682 break;
3683 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES:
3684 {
3685 auto *properties = reinterpret_cast<VkPhysicalDeviceTimelineSemaphoreProperties *>(extensionProperties);
3686 vk::Cast(object: physicalDevice)->getProperties(properties);
3687 }
3688 break;
3689 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES:
3690 {
3691 auto *properties = reinterpret_cast<VkPhysicalDeviceVulkan12Properties *>(extensionProperties);
3692 vk::Cast(object: physicalDevice)->getProperties(properties);
3693 }
3694 break;
3695 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES:
3696 {
3697 auto *properties = reinterpret_cast<VkPhysicalDeviceVulkan13Properties *>(extensionProperties);
3698 vk::Cast(object: physicalDevice)->getProperties(properties);
3699 }
3700 break;
3701 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES:
3702 {
3703 auto *properties = reinterpret_cast<VkPhysicalDeviceDescriptorIndexingProperties *>(extensionProperties);
3704 vk::Cast(object: physicalDevice)->getProperties(properties);
3705 }
3706 break;
3707 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES:
3708 {
3709 auto *properties = reinterpret_cast<VkPhysicalDeviceDepthStencilResolveProperties *>(extensionProperties);
3710 vk::Cast(object: physicalDevice)->getProperties(properties);
3711 }
3712 break;
3713 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT:
3714 {
3715 auto *properties = reinterpret_cast<VkPhysicalDeviceCustomBorderColorPropertiesEXT *>(extensionProperties);
3716 vk::Cast(object: physicalDevice)->getProperties(properties);
3717 }
3718 break;
3719 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT:
3720 {
3721 auto *properties = reinterpret_cast<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT *>(extensionProperties);
3722 vk::Cast(object: physicalDevice)->getProperties(properties);
3723 }
3724 break;
3725 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES:
3726 {
3727 auto *properties = reinterpret_cast<VkPhysicalDeviceSubgroupSizeControlProperties *>(extensionProperties);
3728 vk::Cast(object: physicalDevice)->getProperties(properties);
3729 }
3730 break;
3731 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES:
3732 {
3733 auto *properties = reinterpret_cast<VkPhysicalDeviceInlineUniformBlockProperties *>(extensionProperties);
3734 vk::Cast(object: physicalDevice)->getProperties(properties);
3735 }
3736 break;
3737 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES:
3738 {
3739 auto *properties = reinterpret_cast<VkPhysicalDeviceTexelBufferAlignmentProperties *>(extensionProperties);
3740 vk::Cast(object: physicalDevice)->getProperties(properties);
3741 }
3742 break;
3743 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES:
3744 {
3745 auto *properties = reinterpret_cast<VkPhysicalDeviceShaderIntegerDotProductProperties *>(extensionProperties);
3746 vk::Cast(object: physicalDevice)->getProperties(properties);
3747 }
3748 break;
3749 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT:
3750 {
3751 auto *properties = reinterpret_cast<VkPhysicalDevicePipelineRobustnessPropertiesEXT *>(extensionProperties);
3752 vk::Cast(object: physicalDevice)->getProperties(properties);
3753 }
3754 break;
3755 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT:
3756 {
3757 auto *properties = reinterpret_cast<VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT *>(extensionProperties);
3758 vk::Cast(object: physicalDevice)->getProperties(properties);
3759 }
3760 break;
3761 default:
3762 // "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]"
3763 UNSUPPORTED("pProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
3764 break;
3765 }
3766
3767 extensionProperties = extensionProperties->pNext;
3768 }
3769
3770 vkGetPhysicalDeviceProperties(physicalDevice, pProperties: &(pProperties->properties));
3771}
3772
3773VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2 *pFormatProperties)
3774{
3775 TRACE("(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties2* pFormatProperties = %p)",
3776 physicalDevice, format, pFormatProperties);
3777
3778 VkBaseOutStructure *extensionProperties = reinterpret_cast<VkBaseOutStructure *>(pFormatProperties->pNext);
3779 while(extensionProperties)
3780 {
3781 switch(extensionProperties->sType)
3782 {
3783 case VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3:
3784 {
3785 auto *properties3 = reinterpret_cast<VkFormatProperties3 *>(extensionProperties);
3786 vk::Cast(object: physicalDevice)->GetFormatProperties(format, pFormatProperties: properties3);
3787 }
3788 break;
3789 default:
3790 // "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]"
3791 UNSUPPORTED("pFormatProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
3792 break;
3793 }
3794
3795 extensionProperties = extensionProperties->pNext;
3796 }
3797
3798 vkGetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties: &(pFormatProperties->formatProperties));
3799}
3800
3801VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties)
3802{
3803 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo = %p, VkImageFormatProperties2* pImageFormatProperties = %p)",
3804 physicalDevice, pImageFormatInfo, pImageFormatProperties);
3805
3806 // "If the combination of parameters to vkGetPhysicalDeviceImageFormatProperties is not supported by the implementation
3807 // for use in vkCreateImage, then all members of VkImageFormatProperties will be filled with zero."
3808 memset(s: &pImageFormatProperties->imageFormatProperties, c: 0, n: sizeof(VkImageFormatProperties));
3809
3810 const VkBaseInStructure *extensionFormatInfo = reinterpret_cast<const VkBaseInStructure *>(pImageFormatInfo->pNext);
3811
3812 const VkExternalMemoryHandleTypeFlagBits *handleType = nullptr;
3813 VkImageUsageFlags stencilUsage = 0;
3814 while(extensionFormatInfo)
3815 {
3816 switch(extensionFormatInfo->sType)
3817 {
3818 case VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO:
3819 {
3820 // Per the Vulkan spec on VkImageFormatListcreateInfo:
3821 // "If the pNext chain of VkImageCreateInfo includes a
3822 // VkImageFormatListCreateInfo structure, then that
3823 // structure contains a list of all formats that can be
3824 // used when creating views of this image"
3825 // This limitation does not affect SwiftShader's behavior and
3826 // the Vulkan Validation Layers can detect Views created with a
3827 // format which is not included in that list.
3828 }
3829 break;
3830 case VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO:
3831 {
3832 const VkImageStencilUsageCreateInfo *stencilUsageInfo = reinterpret_cast<const VkImageStencilUsageCreateInfo *>(extensionFormatInfo);
3833 stencilUsage = stencilUsageInfo->stencilUsage;
3834 }
3835 break;
3836 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO:
3837 {
3838 const VkPhysicalDeviceExternalImageFormatInfo *imageFormatInfo = reinterpret_cast<const VkPhysicalDeviceExternalImageFormatInfo *>(extensionFormatInfo);
3839 handleType = &(imageFormatInfo->handleType);
3840 }
3841 break;
3842 case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT:
3843 {
3844 // Explicitly ignored, since VK_EXT_image_drm_format_modifier is not supported
3845 ASSERT(!hasDeviceExtension(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME));
3846 }
3847 break;
3848 default:
3849 UNSUPPORTED("pImageFormatInfo->pNext sType = %s", vk::Stringify(extensionFormatInfo->sType).c_str());
3850 break;
3851 }
3852
3853 extensionFormatInfo = extensionFormatInfo->pNext;
3854 }
3855
3856 VkBaseOutStructure *extensionProperties = reinterpret_cast<VkBaseOutStructure *>(pImageFormatProperties->pNext);
3857
3858#ifdef __ANDROID__
3859 bool hasAHBUsage = false;
3860#endif
3861
3862 while(extensionProperties)
3863 {
3864 switch(extensionProperties->sType)
3865 {
3866 case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES:
3867 {
3868 auto *properties = reinterpret_cast<VkExternalImageFormatProperties *>(extensionProperties);
3869 vk::Cast(object: physicalDevice)->getProperties(handleType, properties);
3870 }
3871 break;
3872 case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES:
3873 {
3874 auto *properties = reinterpret_cast<VkSamplerYcbcrConversionImageFormatProperties *>(extensionProperties);
3875 vk::Cast(object: physicalDevice)->getProperties(properties);
3876 }
3877 break;
3878 case VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD:
3879 {
3880 // Explicitly ignored, since VK_AMD_texture_gather_bias_lod is not supported
3881 ASSERT(!hasDeviceExtension(VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME));
3882 }
3883 break;
3884#ifdef __ANDROID__
3885 case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
3886 {
3887 auto *properties = reinterpret_cast<VkAndroidHardwareBufferUsageANDROID *>(extensionProperties);
3888 vk::Cast(physicalDevice)->getProperties(pImageFormatInfo, properties);
3889 hasAHBUsage = true;
3890 }
3891 break;
3892#endif
3893 default:
3894 UNSUPPORTED("pImageFormatProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
3895 break;
3896 }
3897
3898 extensionProperties = extensionProperties->pNext;
3899 }
3900
3901 vk::Format format = pImageFormatInfo->format;
3902 VkImageType type = pImageFormatInfo->type;
3903 VkImageTiling tiling = pImageFormatInfo->tiling;
3904 VkImageUsageFlags usage = pImageFormatInfo->usage;
3905 VkImageCreateFlags flags = pImageFormatInfo->flags;
3906
3907 if(!vk::Cast(object: physicalDevice)->isFormatSupported(format, type, tiling, usage, stencilUsage, flags))
3908 {
3909 return VK_ERROR_FORMAT_NOT_SUPPORTED;
3910 }
3911
3912 vk::Cast(object: physicalDevice)->getImageFormatProperties(format, type, tiling, usage, flags, pImageFormatProperties: &pImageFormatProperties->imageFormatProperties);
3913
3914#ifdef __ANDROID__
3915 if(hasAHBUsage)
3916 {
3917 // AHardwareBuffer_lock may only be called with a single layer.
3918 pImageFormatProperties->imageFormatProperties.maxArrayLayers = 1;
3919 pImageFormatProperties->imageFormatProperties.maxMipLevels = 1;
3920 }
3921#endif
3922
3923 return VK_SUCCESS;
3924}
3925
3926VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties2 *pQueueFamilyProperties)
3927{
3928 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pQueueFamilyPropertyCount = %p, VkQueueFamilyProperties2* pQueueFamilyProperties = %p)",
3929 physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
3930
3931 if(!pQueueFamilyProperties)
3932 {
3933 *pQueueFamilyPropertyCount = vk::Cast(object: physicalDevice)->getQueueFamilyPropertyCount();
3934 }
3935 else
3936 {
3937 vk::Cast(object: physicalDevice)->getQueueFamilyProperties(pQueueFamilyPropertyCount: *pQueueFamilyPropertyCount, pQueueFamilyProperties);
3938 }
3939}
3940
3941VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2 *pMemoryProperties)
3942{
3943 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties2* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
3944
3945 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pMemoryProperties->pNext);
3946 while(extInfo)
3947 {
3948 UNSUPPORTED("pMemoryProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
3949 extInfo = extInfo->pNext;
3950 }
3951
3952 vkGetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties: &(pMemoryProperties->memoryProperties));
3953}
3954
3955VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo, uint32_t *pPropertyCount, VkSparseImageFormatProperties2 *pProperties)
3956{
3957 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo = %p, uint32_t* pPropertyCount = %p, VkSparseImageFormatProperties2* pProperties = %p)",
3958 physicalDevice, pFormatInfo, pPropertyCount, pProperties);
3959
3960 if(pProperties)
3961 {
3962 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pProperties->pNext);
3963 while(extInfo)
3964 {
3965 UNSUPPORTED("pProperties->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
3966 extInfo = extInfo->pNext;
3967 }
3968 }
3969
3970 // We do not support sparse images.
3971 *pPropertyCount = 0;
3972}
3973
3974VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t *pToolCount, VkPhysicalDeviceToolProperties *pToolProperties)
3975{
3976 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pToolCount = %p, VkPhysicalDeviceToolProperties* pToolProperties = %p)",
3977 physicalDevice, pToolCount, pToolProperties);
3978
3979 if(!pToolProperties)
3980 {
3981 *pToolCount = 0;
3982 return VK_SUCCESS;
3983 }
3984
3985 return VK_SUCCESS;
3986}
3987
3988VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags)
3989{
3990 TRACE("(VkDevice device = %p, VkCommandPool commandPool = %p, VkCommandPoolTrimFlags flags = %d)",
3991 device, static_cast<void *>(commandPool), flags);
3992
3993 if(flags != 0)
3994 {
3995 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
3996 UNSUPPORTED("flags 0x%08X", int(flags));
3997 }
3998
3999 vk::Cast(object: commandPool)->trim(flags);
4000}
4001
4002VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueueInfo2 *pQueueInfo, VkQueue *pQueue)
4003{
4004 TRACE("(VkDevice device = %p, const VkDeviceQueueInfo2* pQueueInfo = %p, VkQueue* pQueue = %p)",
4005 device, pQueueInfo, pQueue);
4006
4007 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pQueueInfo->pNext);
4008 while(extInfo)
4009 {
4010 UNSUPPORTED("pQueueInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
4011 extInfo = extInfo->pNext;
4012 }
4013
4014 if(pQueueInfo->flags != 0)
4015 {
4016 // The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
4017 // According to the Vulkan 1.2.132 spec, 4.3.1. Queue Family Properties:
4018 // "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
4019 // protected-capable queue. If the protected memory feature is not enabled,
4020 // the VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT bit of flags must not be set."
4021 UNSUPPORTED("VkPhysicalDeviceVulkan11Features::protectedMemory");
4022 }
4023
4024 vkGetDeviceQueue(device, queueFamilyIndex: pQueueInfo->queueFamilyIndex, queueIndex: pQueueInfo->queueIndex, pQueue);
4025}
4026
4027VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion(VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSamplerYcbcrConversion *pYcbcrConversion)
4028{
4029 TRACE("(VkDevice device = %p, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSamplerYcbcrConversion* pYcbcrConversion = %p)",
4030 device, pCreateInfo, pAllocator, pYcbcrConversion);
4031
4032 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
4033 while(extInfo)
4034 {
4035 switch(extInfo->sType)
4036 {
4037#ifdef __ANDROID__
4038 case VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID:
4039 break;
4040#endif
4041 default:
4042 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
4043 break;
4044 }
4045 extInfo = extInfo->pNext;
4046 }
4047
4048 return vk::SamplerYcbcrConversion::Create(pAllocator, pCreateInfo, outObject: pYcbcrConversion);
4049}
4050
4051VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks *pAllocator)
4052{
4053 TRACE("(VkDevice device = %p, VkSamplerYcbcrConversion ycbcrConversion = %p, const VkAllocationCallbacks* pAllocator = %p)",
4054 device, static_cast<void *>(ycbcrConversion), pAllocator);
4055
4056 vk::destroy(vkObject: ycbcrConversion, pAllocator);
4057}
4058
4059VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorUpdateTemplate *pDescriptorUpdateTemplate)
4060{
4061 TRACE("(VkDevice device = %p, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate = %p)",
4062 device, pCreateInfo, pAllocator, pDescriptorUpdateTemplate);
4063
4064 if(pCreateInfo->flags != 0)
4065 {
4066 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
4067 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
4068 }
4069
4070 if(pCreateInfo->templateType != VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET)
4071 {
4072 UNSUPPORTED("pCreateInfo->templateType %d", int(pCreateInfo->templateType));
4073 }
4074
4075 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pCreateInfo->pNext);
4076 while(extInfo)
4077 {
4078 UNSUPPORTED("pCreateInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
4079 extInfo = extInfo->pNext;
4080 }
4081
4082 return vk::DescriptorUpdateTemplate::Create(pAllocator, pCreateInfo, outObject: pDescriptorUpdateTemplate);
4083}
4084
4085VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks *pAllocator)
4086{
4087 TRACE("(VkDevice device = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const VkAllocationCallbacks* pAllocator = %p)",
4088 device, static_cast<void *>(descriptorUpdateTemplate), pAllocator);
4089
4090 vk::destroy(vkObject: descriptorUpdateTemplate, pAllocator);
4091}
4092
4093VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void *pData)
4094{
4095 TRACE("(VkDevice device = %p, VkDescriptorSet descriptorSet = %p, VkDescriptorUpdateTemplate descriptorUpdateTemplate = %p, const void* pData = %p)",
4096 device, static_cast<void *>(descriptorSet), static_cast<void *>(descriptorUpdateTemplate), pData);
4097
4098 vk::Cast(object: descriptorUpdateTemplate)->updateDescriptorSet(device: vk::Cast(object: device), descriptorSet, pData);
4099}
4100
4101VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties)
4102{
4103 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo = %p, VkExternalBufferProperties* pExternalBufferProperties = %p)",
4104 physicalDevice, pExternalBufferInfo, pExternalBufferProperties);
4105
4106 vk::Cast(object: physicalDevice)->getProperties(pExternalBufferInfo, pExternalBufferProperties);
4107}
4108
4109VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties)
4110{
4111 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo = %p, VkExternalFenceProperties* pExternalFenceProperties = %p)",
4112 physicalDevice, pExternalFenceInfo, pExternalFenceProperties);
4113
4114 vk::Cast(object: physicalDevice)->getProperties(pExternalFenceInfo, pExternalFenceProperties);
4115}
4116
4117VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo *pExternalSemaphoreInfo, VkExternalSemaphoreProperties *pExternalSemaphoreProperties)
4118{
4119 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo = %p, VkExternalSemaphoreProperties* pExternalSemaphoreProperties = %p)",
4120 physicalDevice, pExternalSemaphoreInfo, pExternalSemaphoreProperties);
4121
4122 vk::Cast(object: physicalDevice)->getProperties(pExternalSemaphoreInfo, pExternalSemaphoreProperties);
4123}
4124
4125VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, VkDescriptorSetLayoutSupport *pSupport)
4126{
4127 TRACE("(VkDevice device = %p, const VkDescriptorSetLayoutCreateInfo* pCreateInfo = %p, VkDescriptorSetLayoutSupport* pSupport = %p)",
4128 device, pCreateInfo, pSupport);
4129
4130 VkBaseOutStructure *layoutSupport = reinterpret_cast<VkBaseOutStructure *>(pSupport->pNext);
4131 while(layoutSupport)
4132 {
4133 switch(layoutSupport->sType)
4134 {
4135 case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT:
4136 break;
4137 default:
4138 UNSUPPORTED("pSupport->pNext sType = %s", vk::Stringify(layoutSupport->sType).c_str());
4139 break;
4140 }
4141
4142 layoutSupport = layoutSupport->pNext;
4143 }
4144
4145 vk::Cast(object: device)->getDescriptorSetLayoutSupport(pCreateInfo, pSupport);
4146}
4147
4148VKAPI_ATTR VkResult VKAPI_CALL vkCreatePrivateDataSlot(VkDevice device, const VkPrivateDataSlotCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPrivateDataSlot *pPrivateDataSlot)
4149{
4150 TRACE("(VkDevice device = %p, const VkPrivateDataSlotCreateInfo* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkPrivateDataSlot* pPrivateDataSlot = %p)",
4151 device, pCreateInfo, pAllocator, pPrivateDataSlot);
4152
4153 return vk::PrivateData::Create(pAllocator, pCreateInfo, outObject: pPrivateDataSlot);
4154}
4155
4156VKAPI_ATTR void VKAPI_CALL vkDestroyPrivateDataSlot(VkDevice device, VkPrivateDataSlot privateDataSlot, const VkAllocationCallbacks *pAllocator)
4157{
4158 TRACE("(VkDevice device = %p, VkPrivateDataSlot privateDataSlot = %p, const VkAllocationCallbacks* pAllocator = %p)",
4159 device, static_cast<void *>(privateDataSlot), pAllocator);
4160
4161 vk::Cast(object: device)->removePrivateDataSlot(privateDataSlot: vk::Cast(object: privateDataSlot));
4162 vk::destroy(vkObject: privateDataSlot, pAllocator);
4163}
4164
4165VKAPI_ATTR VkResult VKAPI_CALL vkSetPrivateData(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t data)
4166{
4167 TRACE("(VkDevice device = %p, VkObjectType objectType = %d, uint64_t objectHandle = %" PRIu64 ", VkPrivateDataSlot privateDataSlot = %p, uint64_t data = %" PRIu64 ")",
4168 device, objectType, objectHandle, static_cast<void *>(privateDataSlot), data);
4169
4170 return vk::Cast(object: device)->setPrivateData(objectType, objectHandle, privateDataSlot: vk::Cast(object: privateDataSlot), data);
4171}
4172
4173VKAPI_ATTR void VKAPI_CALL vkGetPrivateData(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t *pData)
4174{
4175 TRACE("(VkDevice device = %p, VkObjectType objectType = %d, uint64_t objectHandle = %" PRIu64 ", VkPrivateDataSlot privateDataSlot = %p, uint64_t data = %p)",
4176 device, objectType, objectHandle, static_cast<void *>(privateDataSlot), pData);
4177
4178 vk::Cast(object: device)->getPrivateData(objectType, objectHandle, privateDataSlot: vk::Cast(object: privateDataSlot), data: pData);
4179}
4180
4181VKAPI_ATTR void VKAPI_CALL vkGetDeviceBufferMemoryRequirements(VkDevice device, const VkDeviceBufferMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
4182{
4183 TRACE("(VkDevice device = %p, const VkDeviceBufferMemoryRequirements* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
4184 device, pInfo, pMemoryRequirements);
4185
4186 pMemoryRequirements->memoryRequirements =
4187 vk::Buffer::GetMemoryRequirements(size: pInfo->pCreateInfo->size, usage: pInfo->pCreateInfo->usage);
4188}
4189
4190VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
4191{
4192 TRACE("(VkDevice device = %p, const VkDeviceImageMemoryRequirements* pInfo = %p, VkMemoryRequirements2* pMemoryRequirements = %p)",
4193 device, pInfo, pMemoryRequirements);
4194
4195 const auto *extInfo = reinterpret_cast<const VkBaseInStructure *>(pInfo->pNext);
4196 while(extInfo)
4197 {
4198 UNSUPPORTED("pInfo->pNext sType = %s", vk::Stringify(extInfo->sType).c_str());
4199 extInfo = extInfo->pNext;
4200 }
4201
4202 // Create a temporary image object to obtain the memory requirements.
4203 // TODO(b/221299948): Reduce overhead by using a lightweight local proxy.
4204 pMemoryRequirements->memoryRequirements = {};
4205 const VkAllocationCallbacks *pAllocator = nullptr;
4206 VkImage image = { VK_NULL_HANDLE };
4207 VkResult result = vk::Image::Create(pAllocator, pCreateInfo: pInfo->pCreateInfo, outObject: &image, extendedInfo: vk::Cast(object: device));
4208 if(result == VK_SUCCESS)
4209 {
4210 vk::Cast(object: image)->getMemoryRequirements(pMemoryRequirements);
4211 }
4212 vk::destroy(vkObject: image, pAllocator);
4213}
4214
4215VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirements(VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, uint32_t *pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements)
4216{
4217 TRACE("(VkDevice device = %p, const VkDeviceImageMemoryRequirements* pInfo = %p, uint32_t* pSparseMemoryRequirementCount = %p, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements = %p)",
4218 device, pInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
4219
4220 *pSparseMemoryRequirementCount = 0;
4221}
4222
4223VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, uint16_t lineStipplePattern)
4224{
4225 TRACE("(VkCommandBuffer commandBuffer = %p, uint32_t lineStippleFactor = %u, uint16_t lineStipplePattern = %u)",
4226 commandBuffer, lineStippleFactor, lineStipplePattern);
4227
4228 static constexpr uint16_t solidLine = 0xFFFFu;
4229 if(lineStipplePattern != solidLine)
4230 {
4231 // VkPhysicalDeviceLineRasterizationFeaturesEXT::stippled*Lines are all set to VK_FALSE and,
4232 // according to the Vulkan spec for VkPipelineRasterizationLineStateCreateInfoEXT:
4233 // "If stippledLineEnable is VK_FALSE, the values of lineStippleFactor and lineStipplePattern are ignored."
4234 WARN("vkCmdSetLineStippleEXT: line stipple pattern ignored : 0x%04X", lineStipplePattern);
4235 }
4236}
4237
4238VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo)
4239{
4240 TRACE("(VkCommandBuffer commandBuffer = %p, const VkDebugUtilsLabelEXT* pLabelInfo = %p)",
4241 commandBuffer, pLabelInfo);
4242
4243 vk::Cast(object: commandBuffer)->beginDebugUtilsLabel(pLabelInfo);
4244}
4245
4246VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer)
4247{
4248 TRACE("(VkCommandBuffer commandBuffer = %p)", commandBuffer);
4249
4250 vk::Cast(object: commandBuffer)->endDebugUtilsLabel();
4251}
4252
4253VKAPI_ATTR void VKAPI_CALL vkCmdInsertDebugUtilsLabelEXT(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT *pLabelInfo)
4254{
4255 TRACE("(VkCommandBuffer commandBuffer = %p, const VkDebugUtilsLabelEXT* pLabelInfo = %p)",
4256 commandBuffer, pLabelInfo);
4257
4258 vk::Cast(object: commandBuffer)->insertDebugUtilsLabel(pLabelInfo);
4259}
4260
4261VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDebugUtilsMessengerEXT *pMessenger)
4262{
4263 TRACE("(VkInstance instance = %p, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkDebugUtilsMessengerEXT* pMessenger = %p)",
4264 instance, pCreateInfo, pAllocator, pMessenger);
4265
4266 if(pCreateInfo->flags != 0)
4267 {
4268 // Vulkan 1.2: "flags is reserved for future use." "flags must be 0"
4269 UNSUPPORTED("pCreateInfo->flags 0x%08X", int(pCreateInfo->flags));
4270 }
4271
4272 return vk::DebugUtilsMessenger::Create(pAllocator, pCreateInfo, outObject: pMessenger);
4273}
4274
4275VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT(VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks *pAllocator)
4276{
4277 TRACE("(VkInstance instance = %p, VkDebugUtilsMessengerEXT messenger = %p, const VkAllocationCallbacks* pAllocator = %p)",
4278 instance, static_cast<void *>(messenger), pAllocator);
4279
4280 vk::destroy(vkObject: messenger, pAllocator);
4281}
4282
4283VKAPI_ATTR void VKAPI_CALL vkQueueBeginDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo)
4284{
4285 TRACE("(VkQueue queue = %p, const VkDebugUtilsLabelEXT* pLabelInfo = %p)",
4286 queue, pLabelInfo);
4287
4288 vk::Cast(object: queue)->beginDebugUtilsLabel(pLabelInfo);
4289}
4290
4291VKAPI_ATTR void VKAPI_CALL vkQueueEndDebugUtilsLabelEXT(VkQueue queue)
4292{
4293 TRACE("(VkQueue queue = %p)", queue);
4294
4295 vk::Cast(object: queue)->endDebugUtilsLabel();
4296}
4297
4298VKAPI_ATTR void VKAPI_CALL vkQueueInsertDebugUtilsLabelEXT(VkQueue queue, const VkDebugUtilsLabelEXT *pLabelInfo)
4299{
4300 TRACE("(VkQueue queue = %p, const VkDebugUtilsLabelEXT* pLabelInfo = %p)",
4301 queue, pLabelInfo);
4302
4303 vk::Cast(object: queue)->insertDebugUtilsLabel(pLabelInfo);
4304}
4305
4306VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo)
4307{
4308 TRACE("(VkDevice device = %p, const VkDebugUtilsObjectNameInfoEXT* pNameInfo = %p)",
4309 device, pNameInfo);
4310
4311 return vk::Cast(object: device)->setDebugUtilsObjectName(pNameInfo);
4312}
4313
4314VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo)
4315{
4316 TRACE("(VkDevice device = %p, const VkDebugUtilsObjectTagInfoEXT* pTagInfo = %p)",
4317 device, pTagInfo);
4318
4319 return vk::Cast(object: device)->setDebugUtilsObjectTag(pTagInfo);
4320}
4321
4322VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData)
4323{
4324 TRACE("(VkInstance instance = %p, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity = %d, VkDebugUtilsMessageTypeFlagsEXT messageTypes = %d, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData = %p)",
4325 instance, messageSeverity, messageTypes, pCallbackData);
4326
4327 vk::Cast(object: instance)->submitDebugUtilsMessage(messageSeverity, messageTypes, pCallbackData);
4328}
4329
4330#ifdef VK_USE_PLATFORM_XCB_KHR
4331VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(VkInstance instance, const VkXcbSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4332{
4333 TRACE("(VkInstance instance = %p, VkXcbSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4334 instance, pCreateInfo, pAllocator, pSurface);
4335
4336 // VUID-VkXcbSurfaceCreateInfoKHR-connection-01310 : connection must point to a valid X11 xcb_connection_t
4337 ASSERT(pCreateInfo->connection);
4338
4339 return vk::XcbSurfaceKHR::Create(pAllocator, pCreateInfo, outObject: pSurface);
4340}
4341
4342VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t *connection, xcb_visualid_t visual_id)
4343{
4344 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, xcb_connection_t* connection = %p, xcb_visualid_t visual_id = %d)",
4345 physicalDevice, int(queueFamilyIndex), connection, int(visual_id));
4346
4347 return VK_TRUE;
4348}
4349#endif
4350
4351#ifdef VK_USE_PLATFORM_WAYLAND_KHR
4352VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4353{
4354 TRACE("(VkInstance instance = %p, VkWaylandSurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4355 instance, pCreateInfo, pAllocator, pSurface);
4356
4357 return vk::WaylandSurfaceKHR::Create(pAllocator, pCreateInfo, outObject: pSurface);
4358}
4359
4360VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display *display)
4361{
4362 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, struct wl_display* display = %p)",
4363 physicalDevice, int(queueFamilyIndex), display);
4364
4365 return VK_TRUE;
4366}
4367#endif
4368
4369#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
4370VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4371{
4372 TRACE("(VkInstance instance = %p, VkDirectFBSurfaceCreateInfoEXT* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4373 instance, pCreateInfo, pAllocator, pSurface);
4374
4375 return vk::DirectFBSurfaceEXT::Create(pAllocator, pCreateInfo, pSurface);
4376}
4377
4378VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB *dfb)
4379{
4380 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, IDirectFB* dfb = %p)",
4381 physicalDevice, int(queueFamilyIndex), dfb);
4382
4383 return VK_TRUE;
4384}
4385#endif
4386
4387#ifdef VK_USE_PLATFORM_DISPLAY_KHR
4388VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDisplayModeKHR *pMode)
4389{
4390 TRACE("(VkPhysicalDevice physicalDevice = %p, VkDisplayKHR display = %p, VkDisplayModeCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkDisplayModeKHR* pModei = %p)",
4391 physicalDevice, static_cast<void *>(display), pCreateInfo, pAllocator, pMode);
4392
4393 return VK_SUCCESS;
4394}
4395
4396VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4397{
4398 TRACE("(VkInstance instance = %p, VkDisplaySurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4399 instance, pCreateInfo, pAllocator, pSurface);
4400
4401 return vk::DisplaySurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
4402}
4403
4404VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties)
4405{
4406 TRACE("(VkPhysicalDevice physicalDevice = %p, VkDisplayKHR display = %p, uint32_t* pPropertyCount = %p, VkDisplayModePropertiesKHR* pProperties = %p)",
4407 physicalDevice, static_cast<void *>(display), pPropertyCount, pProperties);
4408
4409 return vk::DisplaySurfaceKHR::GetDisplayModeProperties(pPropertyCount, pProperties);
4410}
4411
4412VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR *pCapabilities)
4413{
4414 TRACE("(VkPhysicalDevice physicalDevice = %p, VkDisplayModeKHR mode = %p, uint32_t planeIndex = %d, VkDisplayPlaneCapabilitiesKHR* pCapabilities = %p)",
4415 physicalDevice, static_cast<void *>(mode), planeIndex, pCapabilities);
4416
4417 return vk::DisplaySurfaceKHR::GetDisplayPlaneCapabilities(pCapabilities);
4418}
4419
4420VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t *pDisplayCount, VkDisplayKHR *pDisplays)
4421{
4422 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t planeIndex = %d, uint32_t* pDisplayCount = %p, VkDisplayKHR* pDisplays = %p)",
4423 physicalDevice, planeIndex, pDisplayCount, pDisplays);
4424
4425 return vk::DisplaySurfaceKHR::GetDisplayPlaneSupportedDisplays(pDisplayCount, pDisplays);
4426}
4427
4428VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties)
4429{
4430 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkDisplayPlanePropertiesKHR* pProperties = %p)",
4431 physicalDevice, pPropertyCount, pProperties);
4432
4433 return vk::DisplaySurfaceKHR::GetPhysicalDeviceDisplayPlaneProperties(pPropertyCount, pProperties);
4434}
4435
4436VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties)
4437{
4438 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t* pPropertyCount = %p, VkDisplayPropertiesKHR* pProperties = %p)",
4439 physicalDevice, pPropertyCount, pProperties);
4440
4441 return vk::DisplaySurfaceKHR::GetPhysicalDeviceDisplayProperties(pPropertyCount, pProperties);
4442}
4443#endif
4444
4445#ifdef VK_USE_PLATFORM_MACOS_MVK
4446VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4447{
4448 TRACE("(VkInstance instance = %p, VkMacOSSurfaceCreateInfoMVK* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4449 instance, pCreateInfo, pAllocator, pSurface);
4450
4451 return vk::MacOSSurfaceMVK::Create(pAllocator, pCreateInfo, pSurface);
4452}
4453#endif
4454
4455#ifdef VK_USE_PLATFORM_METAL_EXT
4456VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT(VkInstance instance, const VkMetalSurfaceCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4457{
4458 TRACE("(VkInstance instance = %p, VkMetalSurfaceCreateInfoEXT* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4459 instance, pCreateInfo, pAllocator, pSurface);
4460
4461 return vk::MetalSurfaceEXT::Create(pAllocator, pCreateInfo, pSurface);
4462}
4463#endif
4464
4465#ifdef VK_USE_PLATFORM_WIN32_KHR
4466VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4467{
4468 TRACE("(VkInstance instance = %p, VkWin32SurfaceCreateInfoKHR* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4469 instance, pCreateInfo, pAllocator, pSurface);
4470
4471 return vk::Win32SurfaceKHR::Create(pAllocator, pCreateInfo, pSurface);
4472}
4473
4474VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex)
4475{
4476 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d)",
4477 physicalDevice, queueFamilyIndex);
4478 return VK_TRUE;
4479}
4480#endif
4481
4482VKAPI_ATTR VkResult VKAPI_CALL vkCreateHeadlessSurfaceEXT(VkInstance instance, const VkHeadlessSurfaceCreateInfoEXT *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
4483{
4484 TRACE("(VkInstance instance = %p, VkHeadlessSurfaceCreateInfoEXT* pCreateInfo = %p, VkAllocationCallbacks* pAllocator = %p, VkSurface* pSurface = %p)",
4485 instance, pCreateInfo, pAllocator, pSurface);
4486
4487 return vk::HeadlessSurfaceKHR::Create(pAllocator, pCreateInfo, outObject: pSurface);
4488}
4489
4490#ifndef __ANDROID__
4491VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator)
4492{
4493 TRACE("(VkInstance instance = %p, VkSurfaceKHR surface = %p, const VkAllocationCallbacks* pAllocator = %p)",
4494 instance, static_cast<void *>(surface), pAllocator);
4495
4496 vk::destroy(vkObject: surface, pAllocator);
4497}
4498
4499VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported)
4500{
4501 TRACE("(VkPhysicalDevice physicalDevice = %p, uint32_t queueFamilyIndex = %d, VkSurface surface = %p, VKBool32* pSupported = %p)",
4502 physicalDevice, int(queueFamilyIndex), static_cast<void *>(surface), pSupported);
4503
4504 *pSupported = VK_TRUE;
4505 return VK_SUCCESS;
4506}
4507
4508VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
4509{
4510 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities = %p)",
4511 physicalDevice, static_cast<void *>(surface), pSurfaceCapabilities);
4512
4513 return vk::Cast(object: surface)->getSurfaceCapabilities(pSurfaceInfoPNext: nullptr, pSurfaceCapabilities, pSurfaceCapabilitiesPNext: nullptr);
4514}
4515
4516VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, VkSurfaceCapabilities2KHR *pSurfaceCapabilities)
4517{
4518 TRACE("(VkPhysicalDevice physicalDevice = %p, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo = %p, VkSurfaceCapabilities2KHR *pSurfaceCapabilities = %p)",
4519 physicalDevice, pSurfaceInfo, pSurfaceCapabilities);
4520
4521 return vk::Cast(object: pSurfaceInfo->surface)->getSurfaceCapabilities(pSurfaceInfoPNext: pSurfaceInfo->pNext, pSurfaceCapabilities: &pSurfaceCapabilities->surfaceCapabilities, pSurfaceCapabilitiesPNext: pSurfaceCapabilities->pNext);
4522}
4523
4524VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats)
4525{
4526 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p. uint32_t* pSurfaceFormatCount = %p, VkSurfaceFormatKHR* pSurfaceFormats = %p)",
4527 physicalDevice, static_cast<void *>(surface), pSurfaceFormatCount, pSurfaceFormats);
4528
4529 if(!pSurfaceFormats)
4530 {
4531 *pSurfaceFormatCount = vk::Cast(object: surface)->getSurfaceFormatsCount(pSurfaceInfoPNext: nullptr);
4532 return VK_SUCCESS;
4533 }
4534
4535 std::vector<VkSurfaceFormat2KHR> formats(*pSurfaceFormatCount);
4536
4537 VkResult result = vk::Cast(object: surface)->getSurfaceFormats(pSurfaceInfoPNext: nullptr, pSurfaceFormatCount, pSurfaceFormats: formats.data());
4538
4539 if(result == VK_SUCCESS || result == VK_INCOMPLETE)
4540 {
4541 // The value returned in pSurfaceFormatCount is either capped at the original value,
4542 // or is smaller because there aren't that many formats.
4543 ASSERT(*pSurfaceFormatCount <= formats.size());
4544
4545 for(size_t i = 0; i < *pSurfaceFormatCount; ++i)
4546 {
4547 pSurfaceFormats[i] = formats[i].surfaceFormat;
4548 }
4549 }
4550
4551 return result;
4552}
4553
4554VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, uint32_t *pSurfaceFormatCount, VkSurfaceFormat2KHR *pSurfaceFormats)
4555{
4556 TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo = %p. uint32_t* pSurfaceFormatCount = %p, VkSurfaceFormat2KHR* pSurfaceFormats = %p)",
4557 physicalDevice, pSurfaceInfo, pSurfaceFormatCount, pSurfaceFormats);
4558
4559 if(!pSurfaceFormats)
4560 {
4561 *pSurfaceFormatCount = vk::Cast(object: pSurfaceInfo->surface)->getSurfaceFormatsCount(pSurfaceInfoPNext: pSurfaceInfo->pNext);
4562 return VK_SUCCESS;
4563 }
4564
4565 return vk::Cast(object: pSurfaceInfo->surface)->getSurfaceFormats(pSurfaceInfoPNext: pSurfaceInfo->pNext, pSurfaceFormatCount, pSurfaceFormats);
4566}
4567
4568VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
4569{
4570 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p uint32_t* pPresentModeCount = %p, VkPresentModeKHR* pPresentModes = %p)",
4571 physicalDevice, static_cast<void *>(surface), pPresentModeCount, pPresentModes);
4572
4573 if(!pPresentModes)
4574 {
4575 *pPresentModeCount = vk::Cast(object: surface)->getPresentModeCount();
4576 return VK_SUCCESS;
4577 }
4578
4579 return vk::Cast(object: surface)->getPresentModes(pPresentModeCount, pPresentModes);
4580}
4581
4582VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain)
4583{
4584 TRACE("(VkDevice device = %p, const VkSwapchainCreateInfoKHR* pCreateInfo = %p, const VkAllocationCallbacks* pAllocator = %p, VkSwapchainKHR* pSwapchain = %p)",
4585 device, pCreateInfo, pAllocator, pSwapchain);
4586
4587 if(pCreateInfo->oldSwapchain)
4588 {
4589 vk::Cast(object: pCreateInfo->oldSwapchain)->retire();
4590 }
4591
4592 if(vk::Cast(object: pCreateInfo->surface)->hasAssociatedSwapchain())
4593 {
4594 return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;
4595 }
4596
4597 VkResult status = vk::SwapchainKHR::Create(pAllocator, pCreateInfo, outObject: pSwapchain);
4598
4599 if(status != VK_SUCCESS)
4600 {
4601 return status;
4602 }
4603
4604 auto *swapchain = vk::Cast(object: *pSwapchain);
4605 status = swapchain->createImages(device, pCreateInfo);
4606
4607 if(status != VK_SUCCESS)
4608 {
4609 vk::destroy(vkObject: *pSwapchain, pAllocator);
4610 return status;
4611 }
4612
4613 vk::Cast(object: pCreateInfo->surface)->associateSwapchain(swapchain);
4614
4615 return VK_SUCCESS;
4616}
4617
4618VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator)
4619{
4620 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, const VkAllocationCallbacks* pAllocator = %p)",
4621 device, static_cast<void *>(swapchain), pAllocator);
4622
4623 vk::destroy(vkObject: swapchain, pAllocator);
4624}
4625
4626VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages)
4627{
4628 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint32_t* pSwapchainImageCount = %p, VkImage* pSwapchainImages = %p)",
4629 device, static_cast<void *>(swapchain), pSwapchainImageCount, pSwapchainImages);
4630
4631 if(!pSwapchainImages)
4632 {
4633 *pSwapchainImageCount = vk::Cast(object: swapchain)->getImageCount();
4634 return VK_SUCCESS;
4635 }
4636
4637 return vk::Cast(object: swapchain)->getImages(pSwapchainImageCount, pSwapchainImages);
4638}
4639
4640VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex)
4641{
4642 TRACE("(VkDevice device = %p, VkSwapchainKHR swapchain = %p, uint64_t timeout = %" PRIu64 ", VkSemaphore semaphore = %p, VkFence fence = %p, uint32_t* pImageIndex = %p)",
4643 device, static_cast<void *>(swapchain), timeout, static_cast<void *>(semaphore), static_cast<void *>(fence), pImageIndex);
4644
4645 return vk::Cast(object: swapchain)->getNextImage(timeout, semaphore: vk::DynamicCast<vk::BinarySemaphore>(object: semaphore), fence: vk::Cast(object: fence), pImageIndex);
4646}
4647
4648VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
4649{
4650 TRACE("(VkQueue queue = %p, const VkPresentInfoKHR* pPresentInfo = %p)",
4651 queue, pPresentInfo);
4652
4653 return vk::Cast(object: queue)->present(presentInfo: pPresentInfo);
4654}
4655
4656VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, uint32_t *pImageIndex)
4657{
4658 TRACE("(VkDevice device = %p, const VkAcquireNextImageInfoKHR *pAcquireInfo = %p, uint32_t *pImageIndex = %p",
4659 device, pAcquireInfo, pImageIndex);
4660
4661 return vk::Cast(object: pAcquireInfo->swapchain)->getNextImage(timeout: pAcquireInfo->timeout, semaphore: vk::DynamicCast<vk::BinarySemaphore>(object: pAcquireInfo->semaphore), fence: vk::Cast(object: pAcquireInfo->fence), pImageIndex);
4662}
4663
4664VKAPI_ATTR VkResult VKAPI_CALL vkReleaseSwapchainImagesEXT(VkDevice device, const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo)
4665{
4666 TRACE("(VkDevice device = %p, const VkReleaseSwapchainImagesInfoEXT *pReleaseInfo = %p",
4667 device, pReleaseInfo);
4668
4669 return vk::Cast(object: pReleaseInfo->swapchain)->releaseImages(imageIndexCount: pReleaseInfo->imageIndexCount, pImageIndices: pReleaseInfo->pImageIndices);
4670}
4671
4672VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR *pDeviceGroupPresentCapabilities)
4673{
4674 TRACE("(VkDevice device = %p, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities = %p)",
4675 device, pDeviceGroupPresentCapabilities);
4676
4677 for(unsigned int i = 0; i < VK_MAX_DEVICE_GROUP_SIZE; i++)
4678 {
4679 // The only real physical device in the presentation group is device 0,
4680 // and it can present to itself.
4681 pDeviceGroupPresentCapabilities->presentMask[i] = (i == 0) ? 1 : 0;
4682 }
4683
4684 pDeviceGroupPresentCapabilities->modes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
4685
4686 return VK_SUCCESS;
4687}
4688
4689VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *pModes)
4690{
4691 TRACE("(VkDevice device = %p, VkSurfaceKHR surface = %p, VkDeviceGroupPresentModeFlagsKHR *pModes = %p)",
4692 device, static_cast<void *>(surface), pModes);
4693
4694 *pModes = VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR;
4695 return VK_SUCCESS;
4696}
4697
4698VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pRectCount, VkRect2D *pRects)
4699{
4700 TRACE("(VkPhysicalDevice physicalDevice = %p, VkSurfaceKHR surface = %p, uint32_t* pRectCount = %p, VkRect2D* pRects = %p)",
4701 physicalDevice, static_cast<void *>(surface), pRectCount, pRects);
4702
4703 return vk::Cast(object: surface)->getPresentRectangles(pRectCount, pRects);
4704}
4705
4706#endif // ! __ANDROID__
4707
4708#ifdef __ANDROID__
4709
4710VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsage2ANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, VkSwapchainImageUsageFlagsANDROID swapchainUsage, uint64_t *grallocConsumerUsage, uint64_t *grallocProducerUsage)
4711{
4712 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, VkSwapchainImageUsageFlagsANDROID swapchainUsage = %d, uint64_t* grallocConsumerUsage = %p, uin64_t* grallocProducerUsage = %p)",
4713 device, format, imageUsage, swapchainUsage, grallocConsumerUsage, grallocProducerUsage);
4714
4715 *grallocConsumerUsage = 0;
4716 *grallocProducerUsage = GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
4717
4718 return VK_SUCCESS;
4719}
4720
4721VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainGrallocUsageANDROID(VkDevice device, VkFormat format, VkImageUsageFlags imageUsage, int *grallocUsage)
4722{
4723 TRACE("(VkDevice device = %p, VkFormat format = %d, VkImageUsageFlags imageUsage = %d, int* grallocUsage = %p)",
4724 device, format, imageUsage, grallocUsage);
4725
4726 *grallocUsage = GRALLOC_USAGE_SW_WRITE_OFTEN;
4727
4728 return VK_SUCCESS;
4729}
4730
4731VKAPI_ATTR VkResult VKAPI_CALL vkAcquireImageANDROID(VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence)
4732{
4733 TRACE("(VkDevice device = %p, VkImage image = %p, int nativeFenceFd = %d, VkSemaphore semaphore = %p, VkFence fence = %p)",
4734 device, static_cast<void *>(image), nativeFenceFd, static_cast<void *>(semaphore), static_cast<void *>(fence));
4735
4736 if(nativeFenceFd >= 0)
4737 {
4738 sync_wait(nativeFenceFd, -1);
4739 close(nativeFenceFd);
4740 }
4741
4742 if(fence != VK_NULL_HANDLE)
4743 {
4744 vk::Cast(fence)->complete();
4745 }
4746
4747 if(semaphore != VK_NULL_HANDLE)
4748 {
4749 vk::DynamicCast<vk::BinarySemaphore>(semaphore)->signal();
4750 }
4751
4752 return VK_SUCCESS;
4753}
4754
4755VKAPI_ATTR VkResult VKAPI_CALL vkQueueSignalReleaseImageANDROID(VkQueue queue, uint32_t waitSemaphoreCount, const VkSemaphore *pWaitSemaphores, VkImage image, int *pNativeFenceFd)
4756{
4757 TRACE("(VkQueue queue = %p, uint32_t waitSemaphoreCount = %d, const VkSemaphore* pWaitSemaphores = %p, VkImage image = %p, int* pNativeFenceFd = %p)",
4758 queue, waitSemaphoreCount, pWaitSemaphores, static_cast<void *>(image), pNativeFenceFd);
4759
4760 // This is a hack to deal with screen tearing for now.
4761 // Need to correctly implement threading using VkSemaphore
4762 // to get rid of it. b/132458423
4763 vkQueueWaitIdle(queue);
4764
4765 *pNativeFenceFd = -1;
4766
4767 return vk::Cast(image)->prepareForExternalUseANDROID();
4768}
4769#endif // __ANDROID__
4770}
4771

Provided by KDAB

Privacy Policy
Learn more about Flutter for embedded and desktop on industrialflutter.com

source code of flutter_engine/third_party/swiftshader/src/Vulkan/libVulkan.cpp