Path: blob/21.2-virgl/include/MoltenVK/vk_mvk_moltenvk.h
4558 views
/*1* vk_mvk_moltenvk.h2*3* Copyright (c) 2015-2021 The Brenwill Workshop Ltd. (http://www.brenwill.com)4*5* Licensed under the Apache License, Version 2.0 (the "License");6* you may not use this file except in compliance with the License.7* You may obtain a copy of the License at8*9* http://www.apache.org/licenses/LICENSE-2.010*11* Unless required by applicable law or agreed to in writing, software12* distributed under the License is distributed on an "AS IS" BASIS,13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14* See the License for the specific language governing permissions and15* limitations under the License.16*/171819/** Vulkan extension VK_MVK_moltenvk. */2021#ifndef __vk_mvk_moltenvk_h_22#define __vk_mvk_moltenvk_h_ 12324#ifdef __cplusplus25extern "C" {26#endif // __cplusplus2728#include "mvk_vulkan.h"2930#ifdef __OBJC__31#import <Metal/Metal.h>32#import <IOSurface/IOSurfaceRef.h>33#else34typedef unsigned long MTLLanguageVersion;35#endif363738/**39* The version number of MoltenVK is a single integer value, derived from the Major, Minor,40* and Patch version values, where each of the Major, Minor, and Patch components is allocated41* two decimal digits, in the format MjMnPt. This creates a version number that is both human42* readable and allows efficient computational comparisons to a single integer number.43*44* The following examples illustrate how the MoltenVK version number is built from its components:45* - 002000 (version 0.20.0)46* - 010000 (version 1.0.0)47* - 030104 (version 3.1.4)48* - 401215 (version 4.12.15)49*/50#define MVK_VERSION_MAJOR 151#define MVK_VERSION_MINOR 152#define MVK_VERSION_PATCH 25354#define MVK_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch))55#define MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH)5657#define VK_MVK_MOLTENVK_SPEC_VERSION 3058#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"5960/**61* MoltenVK configuration settings.62*63* To be active, some configuration settings must be set before a VkDevice is created.64* See the description of the individual configuration structure members for more information.65*66* There are three mechanisms for setting the values of the MoltenVK configuration parameters:67* - Runtime API via the vkGetMoltenVKConfigurationMVK()/vkSetMoltenVKConfigurationMVK() functions.68* - Application runtime environment variables.69* - Build settings at MoltenVK build time.70*71* To change the MoltenVK configuration settings at runtime using a programmatic API,72* use the vkGetMoltenVKConfigurationMVK() and vkSetMoltenVKConfigurationMVK() functions73* to retrieve, modify, and set a copy of the MVKConfiguration structure. To be active,74* some configuration settings must be set before a VkInstance or VkDevice is created.75* See the description of each member for more information.76*77* The initial value of each of the configuration settings can established at runtime78* by a corresponding environment variable, or if the environment variable is not set,79* by a corresponding build setting at the time MoltenVK is compiled. The environment80* variable and build setting for each configuration parameter share the same name.81*82* For example, the initial value of the shaderConversionFlipVertexY configuration setting83* is set by the MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y at runtime, or by the84* MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y build setting when MoltenVK is compiled.85*86* This structure may be extended as new features are added to MoltenVK. If you are linking to87* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION88* than your app was, the size of this structure in your app may be larger or smaller than the89* struct in MoltenVK. See the description of the vkGetMoltenVKConfigurationMVK() and90* vkSetMoltenVKConfigurationMVK() functions for information about how to handle this.91*92* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT93* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,94* SHOULD NOT BE CHANGED.95*/96typedef struct {9798/**99* If enabled, debugging capabilities will be enabled, including logging100* shader code during runtime shader conversion.101*102* The value of this parameter may be changed at any time during application runtime,103* and the changed value will immediately effect subsequent MoltenVK behaviour.104*105* The initial value or this parameter is set by the106* MVK_DEBUG107* runtime environment variable or MoltenVK compile-time build setting.108* If neither is set, the value of this parameter is false if MoltenVK was109* built in Release mode, and true if MoltenVK was built in Debug mode.110*/111VkBool32 debugMode;112113/**114* If enabled, MSL vertex shader code created during runtime shader conversion will115* flip the Y-axis of each vertex, as the Vulkan Y-axis is the inverse of OpenGL.116*117* An alternate way to reverse the Y-axis is to employ a negative Y-axis value on118* the viewport, in which case this parameter can be disabled.119*120* The value of this parameter may be changed at any time during application runtime,121* and the changed value will immediately effect subsequent MoltenVK behaviour.122* Specifically, this parameter can be enabled when compiling some pipelines,123* and disabled when compiling others. Existing pipelines are not automatically124* re-compiled when this parameter is changed.125*126* The initial value or this parameter is set by the127* MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y128* runtime environment variable or MoltenVK compile-time build setting.129* If neither is set, the value of this parameter defaults to true.130*/131VkBool32 shaderConversionFlipVertexY;132133/**134* If enabled, queue command submissions (vkQueueSubmit() & vkQueuePresentKHR()) will be135* processed on the thread that called the submission function. If disabled, processing136* will be dispatched to a GCD dispatch_queue whose priority is determined by137* VkDeviceQueueCreateInfo::pQueuePriorities during vkCreateDevice().138*139* The value of this parameter must be changed before creating a VkDevice,140* for the change to take effect.141*142* The initial value or this parameter is set by the143* MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS144* runtime environment variable or MoltenVK compile-time build setting.145* If neither is set, the value of this parameter defaults to true for macOS 10.14146* and above or iOS 12 and above, and false otherwise. The reason for this distinction147* is that this feature should be disabled when emulation is required to support VkEvents148* because native support for events (MTLEvent) is not available.149*/150VkBool32 synchronousQueueSubmits;151152/**153* If enabled, where possible, a Metal command buffer will be created and filled when each154* Vulkan command buffer is filled. For applications that parallelize the filling of Vulkan155* commmand buffers across multiple threads, this allows the Metal command buffers to also156* be filled on the same parallel thread. Because each command buffer is filled separately,157* this requires that each Vulkan command buffer requires a dedicated Metal command buffer.158*159* If disabled, a single Metal command buffer will be created and filled when the Vulkan160* command buffers are submitted to the Vulkan queue. This allows a single Metal command161* buffer to be used for all of the Vulkan command buffers in a queue submission. The162* Metal command buffer is filled on the thread that processes the command queue submission.163*164* Depending on the nature of your application, you may find performance is improved by filling165* the Metal command buffers on parallel threads, or you may find that performance is improved by166* consolidating all Vulkan command buffers onto a single Metal command buffer during queue submission.167*168* Prefilling of a Metal command buffer will not occur during the filling of secondary command169* buffers (VK_COMMAND_BUFFER_LEVEL_SECONDARY), or for primary command buffers that are intended170* to be submitted to multiple queues concurrently (VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT).171*172* When enabling this feature, be aware that one Metal command buffer is required for each Vulkan173* command buffer. Depending on the number of command buffers that you use, you may also need to174* change the value of the maxActiveMetalCommandBuffersPerQueue setting.175*176* If this feature is enabled, be aware that if you have recorded commands to a Vulkan command buffer,177* and then choose to reset that command buffer instead of submitting it, the corresponding prefilled178* Metal command buffer will still be submitted. This is because Metal command buffers do not support179* the concept of being reset after being filled. Depending on when and how often you do this,180* it may cause unexpected visual artifacts and unnecessary GPU load.181*182* This feature is incompatible with updating descriptors after binding. If any of the183* *UpdateAfterBind feature flags of VkPhysicalDeviceDescriptorIndexingFeaturesEXT or184* VkPhysicalDeviceInlineUniformBlockFeaturesEXT have been enabled, the value of this185* setting will be ignored and treated as if it is false.186*187* The value of this parameter may be changed at any time during application runtime,188* and the changed value will immediately effect subsequent MoltenVK behaviour.189* Specifically, this parameter can be enabled when filling some command buffers,190* and disabled when filling others.191*192* The initial value or this parameter is set by the193* MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS194* runtime environment variable or MoltenVK compile-time build setting.195* If neither is set, the value of this parameter defaults to false.196*/197VkBool32 prefillMetalCommandBuffers;198199/**200* The maximum number of Metal command buffers that can be concurrently active per Vulkan queue.201* The number of active Metal command buffers required depends on the prefillMetalCommandBuffers202* setting. If prefillMetalCommandBuffers is enabled, one Metal command buffer is required per203* Vulkan command buffer. If prefillMetalCommandBuffers is disabled, one Metal command buffer204* is required per command buffer queue submission, which may be significantly less than the205* number of Vulkan command buffers.206*207* The value of this parameter must be changed before creating a VkDevice,208* for the change to take effect.209*210* The initial value or this parameter is set by the211* MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE212* runtime environment variable or MoltenVK compile-time build setting.213* If neither is set, the value of this parameter defaults to 64.214*/215uint32_t maxActiveMetalCommandBuffersPerQueue;216217/**218* Metal allows only 8192 occlusion queries per MTLBuffer. If enabled, MoltenVK219* allocates a MTLBuffer for each query pool, allowing each query pool to support220* 8192 queries, which may slow performance or cause unexpected behaviour if the query221* pool is not established prior to a Metal renderpass, or if the query pool is changed222* within a renderpass. If disabled, one MTLBuffer will be shared by all query pools,223* which improves performance, but limits the total device queries to 8192.224*225* The value of this parameter may be changed at any time during application runtime,226* and the changed value will immediately effect subsequent MoltenVK behaviour.227* Specifically, this parameter can be enabled when creating some query pools,228* and disabled when creating others.229*230* The initial value or this parameter is set by the231* MVK_CONFIG_SUPPORT_LARGE_QUERY_POOLS232* runtime environment variable or MoltenVK compile-time build setting.233* If neither is set, the value of this parameter defaults to true.234*/235VkBool32 supportLargeQueryPools;236237/** Obsolete, ignored, and deprecated. All surface presentations are performed with a command buffer. */238VkBool32 presentWithCommandBuffer;239240/**241* If enabled, swapchain images will use simple Nearest sampling when magnifying the242* swapchain image to fit a physical display surface. If disabled, swapchain images will243* use Linear sampling when magnifying the swapchain image to fit a physical display surface.244* Enabling this setting avoids smearing effects when swapchain images are simple interger245* multiples of display pixels (eg- macOS Retina, and typical of graphics apps and games),246* but may cause aliasing effects when using non-integer display scaling.247*248* The value of this parameter may be changed before creating a VkSwapchain,249* for the change to take effect.250*251* The initial value or this parameter is set by the252* MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST253* runtime environment variable or MoltenVK compile-time build setting.254* If neither is set, the value of this parameter defaults to true.255*/256VkBool32 swapchainMagFilterUseNearest;257258/**259* The maximum amount of time, in nanoseconds, to wait for a Metal library, function, or260* pipeline state object to be compiled and created by the Metal compiler. An internal error261* within the Metal compiler can stall the thread for up to 30 seconds. Setting this value262* limits that delay to a specified amount of time, allowing shader compilations to fail fast.263*264* The value of this parameter may be changed at any time during application runtime,265* and the changed value will immediately effect subsequent MoltenVK behaviour.266*267* The initial value or this parameter is set by the268* MVK_CONFIG_METAL_COMPILE_TIMEOUT269* runtime environment variable or MoltenVK compile-time build setting.270* If neither is set, the value of this parameter defaults to infinite.271*/272uint64_t metalCompileTimeout;273274/**275* If enabled, performance statistics, as defined by the MVKPerformanceStatistics structure,276* are collected, and can be retrieved via the vkGetPerformanceStatisticsMVK() function.277*278* You can also use the performanceLoggingFrameCount or logActivityPerformanceInline279* parameters to automatically log the performance statistics collected by this parameter.280*281* The value of this parameter must be changed before creating a VkDevice,282* for the change to take effect.283*284* The initial value or this parameter is set by the285* MVK_CONFIG_PERFORMANCE_TRACKING286* runtime environment variable or MoltenVK compile-time build setting.287* If neither is set, the value of this parameter defaults to false.288*/289VkBool32 performanceTracking;290291/**292* If non-zero, performance statistics, frame-based statistics will be logged, on a293* repeating cycle, once per this many frames. The performanceTracking parameter must294* also be enabled. If this parameter is zero, or the performanceTracking parameter295* is disabled, no frame-based performance statistics will be logged.296*297* The value of this parameter may be changed at any time during application runtime,298* and the changed value will immediately effect subsequent MoltenVK behaviour.299*300* The initial value or this parameter is set by the301* MVK_CONFIG_PERFORMANCE_LOGGING_FRAME_COUNT302* runtime environment variable or MoltenVK compile-time build setting.303* If neither is set, the value of this parameter defaults to zero.304*/305uint32_t performanceLoggingFrameCount;306307/**308* If enabled, a MoltenVK logo watermark will be rendered on top of the scene.309* This can be enabled for publicity during demos.310*311* The value of this parameter may be changed at any time during application runtime,312* and the changed value will immediately effect subsequent MoltenVK behaviour.313*314* The initial value or this parameter is set by the315* MVK_CONFIG_DISPLAY_WATERMARK316* runtime environment variable or MoltenVK compile-time build setting.317* If neither is set, the value of this parameter defaults to false.318*/319VkBool32 displayWatermark;320321/**322* Metal does not distinguish functionality between queues, which would normally mean only323* a single general-purpose queue family with multiple queues is needed. However, Vulkan324* associates command buffers with a queue family, whereas Metal associates command buffers325* with a specific Metal queue. In order to allow a Metal command buffer to be prefilled326* before is is formally submitted to a Vulkan queue, each Vulkan queue family can support327* only a single Metal queue. As a result, in order to provide parallel queue operations,328* MoltenVK provides multiple queue families, each with a single queue.329*330* If this parameter is disabled, all queue families will be advertised as having general-purpose331* graphics + compute + transfer functionality, which is how the actual Metal queues behave.332*333* If this parameter is enabled, one queue family will be advertised as having general-purpose334* graphics + compute + transfer functionality, and the remaining queue families will be advertised335* as having specialized graphics OR compute OR transfer functionality, to make it easier for some336* apps to select a queue family with the appropriate requirements.337*338* The value of this parameter must be changed before creating a VkDevice, and before339* querying a VkPhysicalDevice for queue family properties, for the change to take effect.340*341* The initial value or this parameter is set by the342* MVK_CONFIG_SPECIALIZED_QUEUE_FAMILIES343* runtime environment variable or MoltenVK compile-time build setting.344* If neither is set, the value of this parameter defaults to false.345*/346VkBool32 specializedQueueFamilies;347348/**349* If enabled, when the app creates a VkDevice from a VkPhysicalDevice (GPU) that is neither350* headless nor low-power, and is different than the GPU used by the windowing system, the351* windowing system will be forced to switch to use the GPU selected by the Vulkan app.352* When the Vulkan app is ended, the windowing system will automatically switch back to353* using the previous GPU, depending on the usage requirements of other running apps.354*355* If disabled, the Vulkan app will render using its selected GPU, and if the windowing356* system uses a different GPU, the windowing system compositor will automatically copy357* framebuffer content from the app GPU to the windowing system GPU.358*359* The value of this parmeter has no effect on systems with a single GPU, or when the360* Vulkan app creates a VkDevice from a low-power or headless VkPhysicalDevice (GPU).361*362* Switching the windowing system GPU to match the Vulkan app GPU maximizes app performance,363* because it avoids the windowing system compositor from having to copy framebuffer content364* between GPUs on each rendered frame. However, doing so forces the entire system to365* potentially switch to using a GPU that may consume more power while the app is running.366*367* Some Vulkan apps may want to render using a high-power GPU, but leave it up to the368* system window compositor to determine how best to blend content with the windowing369* system, and as a result, may want to disable this parameter.370*371* The value of this parameter must be changed before creating a VkDevice,372* for the change to take effect.373*374* The initial value or this parameter is set by the375* MVK_CONFIG_SWITCH_SYSTEM_GPU376* runtime environment variable or MoltenVK compile-time build setting.377* If neither is set, the value of this parameter defaults to true.378*/379VkBool32 switchSystemGPU;380381/**382* If enabled, arbitrary VkImageView component swizzles are supported, as defined383* in VkImageViewCreateInfo::components when creating a VkImageView.384*385* If disabled, a very limited set of VkImageView component swizzles are supported386* via format substitutions.387*388* Metal does not natively support per-texture swizzling. If this parameter is enabled389* both when a VkImageView is created, and when any pipeline that uses that VkImageView390* is compiled, VkImageView swizzling is automatically performed in the converted Metal391* shader code during all texture sampling and reading operations, regardless of whether392* a swizzle is required for the VkImageView associated with the Metal texture.393* This may result in reduced performance.394*395* The value of this parameter may be changed at any time during application runtime,396* and the changed value will immediately effect subsequent MoltenVK behaviour.397* Specifically, this parameter can be enabled when creating VkImageViews that need it,398* and compiling pipelines that use those VkImageViews, and can be disabled when creating399* VkImageViews that don't need it, and compiling pipelines that use those VkImageViews.400*401* Existing pipelines are not automatically re-compiled when this parameter is changed.402*403* An error is logged and returned during VkImageView creation if that VkImageView404* requires full image view swizzling and this feature is not enabled. An error is405* also logged when a pipeline that was not compiled with full image view swizzling406* is presented with a VkImageView that is expecting it.407*408* An error is also retuned and logged when a VkPhysicalDeviceImageFormatInfo2KHR is passed409* in a call to vkGetPhysicalDeviceImageFormatProperties2KHR() to query for an VkImageView410* format that will require full swizzling to be enabled, and this feature is not enabled.411*412* If this parameter is disabled, the following limited set of VkImageView swizzles are413* supported by MoltenVK, via automatic format substitution:414*415* Texture format Swizzle416* -------------- -------417* VK_FORMAT_R8_UNORM ZERO, ANY, ANY, RED418* VK_FORMAT_A8_UNORM ALPHA, ANY, ANY, ZERO419* VK_FORMAT_R8G8B8A8_UNORM BLUE, GREEN, RED, ALPHA420* VK_FORMAT_R8G8B8A8_SRGB BLUE, GREEN, RED, ALPHA421* VK_FORMAT_B8G8R8A8_UNORM BLUE, GREEN, RED, ALPHA422* VK_FORMAT_B8G8R8A8_SRGB BLUE, GREEN, RED, ALPHA423* VK_FORMAT_D32_SFLOAT_S8_UINT RED, ANY, ANY, ANY (stencil only)424* VK_FORMAT_D24_UNORM_S8_UINT RED, ANY, ANY, ANY (stencil only)425*426* The initial value or this parameter is set by the427* MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE428* runtime environment variable or MoltenVK compile-time build setting.429* If neither is set, the value of this parameter defaults to false.430*/431VkBool32 fullImageViewSwizzle;432433/**434* The index of the queue family whose presentation submissions will435* be used as the default GPU Capture Scope during debugging in Xcode.436*437* The value of this parameter must be changed before creating a VkDevice,438* for the change to take effect.439*440* The initial value or this parameter is set by the441* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX442* runtime environment variable or MoltenVK compile-time build setting.443* If neither is set, the value of this parameter defaults to zero (the first queue family).444*/445uint32_t defaultGPUCaptureScopeQueueFamilyIndex;446447/**448* The index of the queue, within the queue family identified by the449* defaultGPUCaptureScopeQueueFamilyIndex parameter, whose presentation submissions450* will be used as the default GPU Capture Scope during debugging in Xcode.451*452* The value of this parameter must be changed before creating a VkDevice,453* for the change to take effect.454*455* The initial value or this parameter is set by the456* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX457* runtime environment variable or MoltenVK compile-time build setting.458* If neither is set, the value of this parameter defaults to zero (the first queue).459*/460uint32_t defaultGPUCaptureScopeQueueIndex;461462/**463* Corresponds to the fastMathEnabled property of MTLCompileOptions.464* Setting it may cause the Metal Compiler to optimize floating point operations465* in ways that may violate the IEEE 754 standard.466*467* Must be changed before creating a VkDevice, for the change to take effect.468*469* The initial value or this parameter is set by the470* MVK_CONFIG_FAST_MATH_ENABLED471* runtime environment variable or MoltenVK compile-time build setting.472* If neither is set, the value of this parameter defaults to true.473*/474VkBool32 fastMathEnabled;475476/**477* Controls the level of logging performned by MoltenVK using the following numeric values:478* 0: No logging.479* 1: Log errors only.480* 2: Log errors and informational messages.481*482* The value of this parameter may be changed at any time during application runtime,483* and the changed value will immediately effect subsequent MoltenVK behaviour.484*485* The initial value or this parameter is set by the486* MVK_CONFIG_LOG_LEVEL487* runtime environment variable or MoltenVK compile-time build setting.488* If neither is set, errors and informational messages are logged.489*/490uint32_t logLevel;491492/**493* Causes MoltenVK to log the name of each Vulkan call made by the application,494* along with the Mach thread ID, global system thread ID, and thread name.495* The logging format options can be controlled as follows:496* 0: No Vulkan call logging.497* 1: Log the name of each Vulkan call when the call is entered.498* 2: Log the name of each Vulkan call when the call is entered and exited. This499* effectively brackets any other logging activity within the scope of the Vulkan call.500* 3: Same as option 2, plus logs the time spent inside the Vulkan function.501* If none of these is set, no Vulkan call logging will occur.502*503* The value of this parameter may be changed at any time during application runtime,504* and the changed value will immediately effect subsequent MoltenVK behaviour.505*506* The initial value or this parameter is set by the507* MVK_CONFIG_TRACE_VULKAN_CALLS508* runtime environment variable or MoltenVK compile-time build setting.509* If neither is set, no Vulkan call logging will occur.510*/511uint32_t traceVulkanCalls;512513/**514* Force MoltenVK to use a low-power GPU, if one is availble on the device.515*516* The value of this parameter must be changed before creating a VkInstance,517* for the change to take effect.518*519* The initial value or this parameter is set by the520* MVK_CONFIG_FORCE_LOW_POWER_GPU521* runtime environment variable or MoltenVK compile-time build setting.522* If neither is set, this setting is disabled by default, allowing both523* low-power and high-power GPU's to be used.524*/525VkBool32 forceLowPowerGPU;526527/**528* Use MTLFence, if it is available on the device, for VkSemaphore synchronization behaviour.529*530* This parameter interacts with semaphoreUseMTLEvent. If both are enabled, semaphoreUseMTLFence531* takes priority and MTLFence will be used if it is available, otherwise MTLEvent will be used532* if it is available. If neither semaphoreUseMTLFence or semaphoreUseMTLEvent are enabled, or533* if neither MTLFence or MTLEvent are available, CPU-based synchoronization will be used.534*535* In the special case of VK_SEMAPHORE_TYPE_TIMELINE semaphores, MoltenVK will always536* use MTLSharedEvent if it is available on the platform, regardless of the values of537* MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS.538*539* The value of this parameter must be changed before creating a VkDevice,540* for the change to take effect.541*542* The initial value or this parameter is set by the543* MVK_ALLOW_METAL_FENCES544* runtime environment variable or MoltenVK compile-time build setting.545* If neither is set, this setting is enabled by default, and VkSemaphore will use MTLFence,546* if it is available.547*/548VkBool32 semaphoreUseMTLFence;549550/**551* Use MTLEvent, if it is available on the device, for VkSemaphore synchronization behaviour.552*553* This parameter interacts with semaphoreUseMTLFence. If both are enabled, semaphoreUseMTLFence554* takes priority and MTLFence will be used if it is available, otherwise MTLEvent will be used555* if it is available. If neither semaphoreUseMTLFence or semaphoreUseMTLEvent are enabled, or556* if neither MTLFence or MTLEvent are available, CPU-based synchoronization will be used.557*558* In the special case of VK_SEMAPHORE_TYPE_TIMELINE semaphores, MoltenVK will always559* use MTLSharedEvent if it is available on the platform, regardless of the values of560* MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS.561*562* The value of this parameter must be changed before creating a VkDevice,563* for the change to take effect.564*565* The initial value or this parameter is set by the566* MVK_ALLOW_METAL_EVENTS567* runtime environment variable or MoltenVK compile-time build setting.568* If neither is set, this setting is enabled by default, and VkSemaphore will use MTLEvent,569* if it is available, unless if MTLFence is available and semaphoreUseMTLFence is enabled.570*/571VkBool32 semaphoreUseMTLEvent;572573/**574* Controls whether Metal should run an automatic GPU capture without the user having to575* trigger it manually via the Xcode user interface, and controls the scope under which576* that GPU capture will occur. This is useful when trying to capture a one-shot GPU trace,577* such as when running a Vulkan CTS test case. For the automatic GPU capture to occur,578* the Xcode scheme under which the app is run must have the Metal GPU capture option579* enabled. MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE should not be set to manually trigger a580* GPU capture via the Xcode user interface.581*582* To automatically trigger a GPU capture, set this value as follows:583* 0: No automatic GPU capture.584* 1: Capture all GPU commands issued during the lifetime of the VkDevice.585* 2: Capture all GPU commands issued during the first rendered frame.586*587* The value of this parameter must be changed before creating a VkDevice,588* for the change to take effect.589*590* The initial value or this parameter is set by the591* MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE592* runtime environment variable or MoltenVK compile-time build setting.593* If neither is set, no automatic GPU capture will occur.594*/595uint32_t autoGPUCaptureScope;596597/**598* The path to a file where the automatic GPU capture should be saved, if autoGPUCaptureScope599* is enabled. In this case, the Xcode scheme need not have Metal GPU capture enabled, and in600* fact the app need not be run under Xcode's control at all. This is useful in case the app601* cannot be run under Xcode's control. A path starting with '~' can be used to place it in a602* user's home directory, as in the shell. This feature requires Metal 3.0 (macOS 10.15, iOS 13).603*604* If this parameter is NULL or an empty string, and autoGPUCaptureScope is enabled, automatic605* GPU capture will be handled by the Xcode user interface.606*607* The value of this parameter must be changed before creating a VkDevice,608* for the change to take effect.609*610* The initial value or this parameter is set by the611* MVK_CONFIG_AUTO_GPU_CAPTURE_OUTPUT_FILE612* runtime environment variable or MoltenVK compile-time build setting.613* If neither is set, automatic GPU capture will be handled by the Xcode user interface.614*/615char* autoGPUCaptureOutputFilepath;616617/**618* Controls whether MoltenVK should use a Metal 2D texture with a height of 1 for a619* Vulkan 1D image, or use a native Metal 1D texture. Metal imposes significant restrictions620* on native 1D textures, including not being renderable, clearable, or permitting mipmaps.621* Using a Metal 2D texture allows Vulkan 1D textures to support this additional functionality.622*623* The value of this parameter should only be changed before creating the VkInstance.624*625* The initial value or this parameter is set by the626* MVK_CONFIG_TEXTURE_1D_AS_2D627* runtime environment variable or MoltenVK compile-time build setting.628* If neither is set, this setting is enabled by default, and MoltenVK will629* use a Metal 2D texture for each Vulkan 1D image.630*/631VkBool32 texture1DAs2D;632633/**634* Controls whether MoltenVK should preallocate memory in each VkDescriptorPool635* ccording to the values of the VkDescriptorPoolSize parameters. Doing so may improve636* descriptor set allocation performance at a cost of preallocated application memory,637* and possible descreased performance when creating and reseting the VkDescriptorPool.638* If this setting is disabled, the descriptors required for a descriptor set will639* be dynamically allocated in application memory when the descriptor set itself is allocated.640*641* The value of this parameter may be changed at any time during application runtime,642* and the changed value will immediately effect behavior of VkDescriptorPools created643* after the setting is changed.644*645* The initial value or this parameter is set by the646* MVK_CONFIG_PREALLOCATE_DESCRIPTORS647* runtime environment variable or MoltenVK compile-time build setting.648* If neither is set, this setting is disabled by default, and MoltenVK will649* dynamically allocate descriptors when the containing descriptor set is allocated.650*/651VkBool32 preallocateDescriptors;652653/**654* Controls whether MoltenVK should use pools to manage memory used when adding commands655* to command buffers. If this setting is enabled, MoltenVK will use a pool to hold command656* resources for reuse during command execution. If this setting is disabled, command memory657* is allocated and destroyed each time a command is executed. This is a classic time-space658* trade off. When command pooling is active, the memory in the pool can be cleared via a659* call to the vkTrimCommandPoolKHR() command.660*661* The value of this parameter may be changed at any time during application runtime,662* and the changed value will immediately effect behavior of VkCommandPools created663* after the setting is changed.664*665* The initial value or this parameter is set by the666* MVK_CONFIG_USE_COMMAND_POOLING667* runtime environment variable or MoltenVK compile-time build setting.668* If neither is set, this setting is enabled by default, and MoltenVK will pool command memory.669*/670VkBool32 useCommandPooling;671672/**673* Controls whether MoltenVK should use MTLHeaps for allocating textures and buffers674* from device memory. If this setting is enabled, and placement MTLHeaps are675* available on the platform, MoltenVK will allocate a placement MTLHeap for each VkDeviceMemory676* instance, and allocate textures and buffers from that placement heap. If this environment677* variable is disabled, MoltenVK will allocate textures and buffers from general device memory.678*679* Apple recommends that MTLHeaps should only be used for specific requirements such as aliasing680* or hazard tracking, and MoltenVK testing has shown that allocating multiple textures of681* different types or usages from one MTLHeap can occassionally cause corruption issues under682* certain circumstances.683*684* The value of this parameter must be changed before creating a VkInstance,685* for the change to take effect.686*687* The initial value or this parameter is set by the688* MVK_CONFIG_USE_MTLHEAP689* runtime environment variable or MoltenVK compile-time build setting.690* If neither is set, this setting is disabled by default, and MoltenVK691* will allocate texures and buffers from general device memory.692*/693VkBool32 useMTLHeap;694695/**696* Controls whether MoltenVK should log the performance of individual activities as they happen.697* If this setting is enabled, activity performance will be logged when each activity happens.698* If this setting is disabled, activity performance will be logged when frame peformance is699* logged as determined by the performanceLoggingFrameCount value.700*701* The value of this parameter must be changed before creating a VkDevice,702* for the change to take effect.703*704* The initial value or this parameter is set by the705* MVK_CONFIG_PERFORMANCE_LOGGING_INLINE706* runtime environment variable or MoltenVK compile-time build setting.707* If neither is set, this setting is disabled by default, and activity708* performance will be logged only when frame activity is logged.709*/710VkBool32 logActivityPerformanceInline;711712} MVKConfiguration;713714/**715* Features provided by the current implementation of Metal on the current device. You can716* retrieve a copy of this structure using the vkGetPhysicalDeviceMetalFeaturesMVK() function.717*718* This structure may be extended as new features are added to MoltenVK. If you are linking to719* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION720* than your app was, the size of this structure in your app may be larger or smaller than the721* struct in MoltenVK. See the description of the vkGetPhysicalDeviceMetalFeaturesMVK() function722* for information about how to handle this.723*724* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT725* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,726* SHOULD NOT BE CHANGED.727*/728typedef struct {729uint32_t mslVersion; /**< The version of the Metal Shading Language available on this device. The format of the integer is MMmmpp, with two decimal digts each for Major, minor, and patch version values (eg. MSL 1.2 would appear as 010200). */730VkBool32 indirectDrawing; /**< If true, draw calls support parameters held in a GPU buffer. */731VkBool32 baseVertexInstanceDrawing; /**< If true, draw calls support specifiying the base vertex and instance. */732uint32_t dynamicMTLBufferSize; /**< If greater than zero, dynamic MTLBuffers for setting vertex, fragment, and compute bytes are supported, and their content must be below this value. */733VkBool32 shaderSpecialization; /**< If true, shader specialization (aka Metal function constants) is supported. */734VkBool32 ioSurfaces; /**< If true, VkImages can be underlaid by IOSurfaces via the vkUseIOSurfaceMVK() function, to support inter-process image transfers. */735VkBool32 texelBuffers; /**< If true, texel buffers are supported, allowing the contents of a buffer to be interpreted as an image via a VkBufferView. */736VkBool32 layeredRendering; /**< If true, layered rendering to multiple cube or texture array layers is supported. */737VkBool32 presentModeImmediate; /**< If true, immediate surface present mode (VK_PRESENT_MODE_IMMEDIATE_KHR), allowing a swapchain image to be presented immediately, without waiting for the vertical sync period of the display, is supported. */738VkBool32 stencilViews; /**< If true, stencil aspect views are supported through the MTLPixelFormatX24_Stencil8 and MTLPixelFormatX32_Stencil8 formats. */739VkBool32 multisampleArrayTextures; /**< If true, MTLTextureType2DMultisampleArray is supported. */740VkBool32 samplerClampToBorder; /**< If true, the border color set when creating a sampler will be respected. */741uint32_t maxTextureDimension; /**< The maximum size of each texture dimension (width, height, or depth). */742uint32_t maxPerStageBufferCount; /**< The total number of per-stage Metal buffers available for shader uniform content and attributes. */743uint32_t maxPerStageTextureCount; /**< The total number of per-stage Metal textures available for shader uniform content. */744uint32_t maxPerStageSamplerCount; /**< The total number of per-stage Metal samplers available for shader uniform content. */745VkDeviceSize maxMTLBufferSize; /**< The max size of a MTLBuffer (in bytes). */746VkDeviceSize mtlBufferAlignment; /**< The alignment used when allocating memory for MTLBuffers. Must be PoT. */747VkDeviceSize maxQueryBufferSize; /**< The maximum size of an occlusion query buffer (in bytes). */748VkDeviceSize mtlCopyBufferAlignment; /**< The alignment required during buffer copy operations (in bytes). */749VkSampleCountFlags supportedSampleCounts; /**< A bitmask identifying the sample counts supported by the device. */750uint32_t minSwapchainImageCount; /**< The minimum number of swapchain images that can be supported by a surface. */751uint32_t maxSwapchainImageCount; /**< The maximum number of swapchain images that can be supported by a surface. */752VkBool32 combinedStoreResolveAction; /**< If true, the device supports VK_ATTACHMENT_STORE_OP_STORE with a simultaneous resolve attachment. */753VkBool32 arrayOfTextures; /**< If true, arrays of textures is supported. */754VkBool32 arrayOfSamplers; /**< If true, arrays of texture samplers is supported. */755MTLLanguageVersion mslVersionEnum; /**< The version of the Metal Shading Language available on this device, as a Metal enumeration. */756VkBool32 depthSampleCompare; /**< If true, depth texture samplers support the comparison of the pixel value against a reference value. */757VkBool32 events; /**< If true, Metal synchronization events (MTLEvent) are supported. */758VkBool32 memoryBarriers; /**< If true, full memory barriers within Metal render passes are supported. */759VkBool32 multisampleLayeredRendering; /**< If true, layered rendering to multiple multi-sampled cube or texture array layers is supported. */760VkBool32 stencilFeedback; /**< If true, fragment shaders that write to [[stencil]] outputs are supported. */761VkBool32 textureBuffers; /**< If true, textures of type MTLTextureTypeBuffer are supported. */762VkBool32 postDepthCoverage; /**< If true, coverage masks in fragment shaders post-depth-test are supported. */763VkBool32 fences; /**< If true, Metal synchronization fences (MTLFence) are supported. */764VkBool32 rasterOrderGroups; /**< If true, Raster order groups in fragment shaders are supported. */765VkBool32 native3DCompressedTextures; /**< If true, 3D compressed images are supported natively, without manual decompression. */766VkBool32 nativeTextureSwizzle; /**< If true, component swizzle is supported natively, without manual swizzling in shaders. */767VkBool32 placementHeaps; /**< If true, MTLHeap objects support placement of resources. */768VkDeviceSize pushConstantSizeAlignment; /**< The alignment used internally when allocating memory for push constants. Must be PoT. */769uint32_t maxTextureLayers; /**< The maximum number of layers in an array texture. */770uint32_t maxSubgroupSize; /**< The maximum number of threads in a SIMD-group. */771VkDeviceSize vertexStrideAlignment; /**< The alignment used for the stride of vertex attribute bindings. */772VkBool32 indirectTessellationDrawing; /**< If true, tessellation draw calls support parameters held in a GPU buffer. */773VkBool32 nonUniformThreadgroups; /**< If true, the device supports arbitrary-sized grids in compute workloads. */774VkBool32 renderWithoutAttachments; /**< If true, we don't have to create a dummy attachment for a render pass if there isn't one. */775VkBool32 deferredStoreActions; /**< If true, render pass store actions can be specified after the render encoder is created. */776VkBool32 sharedLinearTextures; /**< If true, linear textures and texture buffers can be created from buffers in Shared storage. */777VkBool32 depthResolve; /**< If true, resolving depth textures with filters other than Sample0 is supported. */778VkBool32 stencilResolve; /**< If true, resolving stencil textures with filters other than Sample0 is supported. */779uint32_t maxPerStageDynamicMTLBufferCount; /**< The maximum number of inline buffers that can be set on a command buffer. */780uint32_t maxPerStageStorageTextureCount; /**< The total number of per-stage Metal textures with read-write access available for writing to from a shader. */781VkBool32 astcHDRTextures; /**< If true, ASTC HDR pixel formats are supported. */782VkBool32 renderLinearTextures; /**< If true, linear textures are renderable. */783VkBool32 pullModelInterpolation; /**< If true, explicit interpolation functions are supported. */784VkBool32 samplerMirrorClampToEdge; /**< If true, the mirrored clamp to edge address mode is supported in samplers. */785VkBool32 quadPermute; /**< If true, quadgroup permutation functions (vote, ballot, shuffle) are supported in shaders. */786VkBool32 simdPermute; /**< If true, SIMD-group permutation functions (vote, ballot, shuffle) are supported in shaders. */787VkBool32 simdReduction; /**< If true, SIMD-group reduction functions (arithmetic) are supported in shaders. */788uint32_t minSubgroupSize; /**< The minimum number of threads in a SIMD-group. */789VkBool32 textureBarriers; /**< If true, texture barriers are supported within Metal render passes. */790VkBool32 tileBasedDeferredRendering; /**< If true, this device uses tile-based deferred rendering. */791} MVKPhysicalDeviceMetalFeatures;792793/** MoltenVK performance of a particular type of activity. */794typedef struct {795uint32_t count; /**< The number of activities of this type. */796double latestDuration; /**< The latest (most recent) duration of the activity, in milliseconds. */797double averageDuration; /**< The average duration of the activity, in milliseconds. */798double minimumDuration; /**< The minimum duration of the activity, in milliseconds. */799double maximumDuration; /**< The maximum duration of the activity, in milliseconds. */800} MVKPerformanceTracker;801802/** MoltenVK performance of shader compilation activities. */803typedef struct {804MVKPerformanceTracker hashShaderCode; /** Create a hash from the incoming shader code. */805MVKPerformanceTracker spirvToMSL; /** Convert SPIR-V to MSL source code. */806MVKPerformanceTracker mslCompile; /** Compile MSL source code into a MTLLibrary. */807MVKPerformanceTracker mslLoad; /** Load pre-compiled MSL code into a MTLLibrary. */808MVKPerformanceTracker shaderLibraryFromCache; /** Retrieve a shader library from the cache, lazily creating it if needed. */809MVKPerformanceTracker functionRetrieval; /** Retrieve a MTLFunction from a MTLLibrary. */810MVKPerformanceTracker functionSpecialization; /** Specialize a retrieved MTLFunction. */811MVKPerformanceTracker pipelineCompile; /** Compile MTLFunctions into a pipeline. */812MVKPerformanceTracker glslToSPRIV; /** Convert GLSL to SPIR-V code. */813} MVKShaderCompilationPerformance;814815/** MoltenVK performance of pipeline cache activities. */816typedef struct {817MVKPerformanceTracker sizePipelineCache; /** Calculate the size of cache data required to write MSL to pipeline cache data stream. */818MVKPerformanceTracker writePipelineCache; /** Write MSL to pipeline cache data stream. */819MVKPerformanceTracker readPipelineCache; /** Read MSL from pipeline cache data stream. */820} MVKPipelineCachePerformance;821822/** MoltenVK performance of queue activities. */823typedef struct {824MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommandQueue or access an existing cached instance. */825MVKPerformanceTracker mtlCommandBufferCompletion; /** Completion of a MTLCommandBuffer on the GPU, from commit to completion callback. */826MVKPerformanceTracker nextCAMetalDrawable; /** Retrieve next CAMetalDrawable from CAMetalLayer during presentation. */827MVKPerformanceTracker frameInterval; /** Frame presentation interval (1000/FPS). */828} MVKQueuePerformance;829830/**831* MoltenVK performance. You can retrieve a copy of this structure using the vkGetPerformanceStatisticsMVK() function.832*833* This structure may be extended as new features are added to MoltenVK. If you are linking to834* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION835* than your app was, the size of this structure in your app may be larger or smaller than the836* struct in MoltenVK. See the description of the vkGetPerformanceStatisticsMVK() function for837* information about how to handle this.838*839* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT840* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,841* SHOULD NOT BE CHANGED.842*/843typedef struct {844MVKShaderCompilationPerformance shaderCompilation; /** Shader compilations activities. */845MVKPipelineCachePerformance pipelineCache; /** Pipeline cache activities. */846MVKQueuePerformance queue; /** Queue activities. */847} MVKPerformanceStatistics;848849850#pragma mark -851#pragma mark Function types852853typedef VkResult (VKAPI_PTR *PFN_vkGetMoltenVKConfigurationMVK)(VkInstance ignored, MVKConfiguration* pConfiguration, size_t* pConfigurationSize);854typedef VkResult (VKAPI_PTR *PFN_vkSetMoltenVKConfigurationMVK)(VkInstance ignored, MVKConfiguration* pConfiguration, size_t* pConfigurationSize);855typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceMetalFeaturesMVK)(VkPhysicalDevice physicalDevice, MVKPhysicalDeviceMetalFeatures* pMetalFeatures, size_t* pMetalFeaturesSize);856typedef VkResult (VKAPI_PTR *PFN_vkGetPerformanceStatisticsMVK)(VkDevice device, MVKPerformanceStatistics* pPerf, size_t* pPerfSize);857typedef void (VKAPI_PTR *PFN_vkGetVersionStringsMVK)(char* pMoltenVersionStringBuffer, uint32_t moltenVersionStringBufferLength, char* pVulkanVersionStringBuffer, uint32_t vulkanVersionStringBufferLength);858859#ifdef __OBJC__860typedef void (VKAPI_PTR *PFN_vkGetMTLDeviceMVK)(VkPhysicalDevice physicalDevice, id<MTLDevice>* pMTLDevice);861typedef VkResult (VKAPI_PTR *PFN_vkSetMTLTextureMVK)(VkImage image, id<MTLTexture> mtlTexture);862typedef void (VKAPI_PTR *PFN_vkGetMTLTextureMVK)(VkImage image, id<MTLTexture>* pMTLTexture);863typedef void (VKAPI_PTR *PFN_vkGetMTLBufferMVK)(VkBuffer buffer, id<MTLBuffer>* pMTLBuffer);864typedef VkResult (VKAPI_PTR *PFN_vkUseIOSurfaceMVK)(VkImage image, IOSurfaceRef ioSurface);865typedef void (VKAPI_PTR *PFN_vkGetIOSurfaceMVK)(VkImage image, IOSurfaceRef* pIOSurface);866#endif // __OBJC__867868869#pragma mark -870#pragma mark Function prototypes871872#ifndef VK_NO_PROTOTYPES873874/**875* Populates the pConfiguration structure with the current MoltenVK configuration settings.876*877* To change a specific configuration value, call vkGetMoltenVKConfigurationMVK() to retrieve878* the current configuration, make changes, and call vkSetMoltenVKConfigurationMVK() to879* update all of the values.880*881* The VkInstance object you provide here is ignored, and a VK_NULL_HANDLE value can be provided.882* This function can be called before the VkInstance has been created. It is safe to call this function883* with a VkInstance retrieved from a different layer in the Vulkan SDK Loader and Layers framework.884*885* To be active, some configuration settings must be set before a VkInstance or VkDevice886* is created. See the description of the MVKConfiguration members for more information.887*888* If you are linking to an implementation of MoltenVK that was compiled from a different889* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKConfiguration structure890* in your app may be larger or smaller than the same struct as expected by MoltenVK.891*892* When calling this function, set the value of *pConfigurationSize to sizeof(MVKConfiguration),893* to tell MoltenVK the limit of the size of your MVKConfiguration structure. Upon return from894* this function, the value of *pConfigurationSize will hold the actual number of bytes copied895* into your passed MVKConfiguration structure, which will be the smaller of what your app896* thinks is the size of MVKConfiguration, and what MoltenVK thinks it is. This represents the897* safe access area within the structure for both MoltenVK and your app.898*899* If the size that MoltenVK expects for MVKConfiguration is different than the value passed in900* *pConfigurationSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.901*902* Although it is not necessary, you can use this function to determine in advance the value903* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration904* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK905* expects MVKConfiguration to be.906*/907VKAPI_ATTR VkResult VKAPI_CALL vkGetMoltenVKConfigurationMVK(908VkInstance ignored,909MVKConfiguration* pConfiguration,910size_t* pConfigurationSize);911912/**913* Sets the MoltenVK configuration settings to those found in the pConfiguration structure.914*915* To change a specific configuration value, call vkGetMoltenVKConfigurationMVK()916* to retrieve the current configuration, make changes, and call917* vkSetMoltenVKConfigurationMVK() to update all of the values.918*919* The VkInstance object you provide here is ignored, and a VK_NULL_HANDLE value can be provided.920* This function can be called before the VkInstance has been created. It is safe to call this function921* with a VkInstance retrieved from a different layer in the Vulkan SDK Loader and Layers framework.922*923* To be active, some configuration settings must be set before a VkInstance or VkDevice924* is created. See the description of the MVKConfiguration members for more information.925*926* If you are linking to an implementation of MoltenVK that was compiled from a different927* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKConfiguration structure928* in your app may be larger or smaller than the same struct as expected by MoltenVK.929*930* When calling this function, set the value of *pConfigurationSize to sizeof(MVKConfiguration),931* to tell MoltenVK the limit of the size of your MVKConfiguration structure. Upon return from932* this function, the value of *pConfigurationSize will hold the actual number of bytes copied933* out of your passed MVKConfiguration structure, which will be the smaller of what your app934* thinks is the size of MVKConfiguration, and what MoltenVK thinks it is. This represents the935* safe access area within the structure for both MoltenVK and your app.936*937* If the size that MoltenVK expects for MVKConfiguration is different than the value passed in938* *pConfigurationSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.939*940* Although it is not necessary, you can use this function to determine in advance the value941* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration942* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK943* expects MVKConfiguration to be.944*/945VKAPI_ATTR VkResult VKAPI_CALL vkSetMoltenVKConfigurationMVK(946VkInstance ignored,947const MVKConfiguration* pConfiguration,948size_t* pConfigurationSize);949950/**951* Populates the pMetalFeatures structure with the Metal-specific features952* supported by the specified physical device.953*954* If you are linking to an implementation of MoltenVK that was compiled from a different955* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKPhysicalDeviceMetalFeatures956* structure in your app may be larger or smaller than the same struct as expected by MoltenVK.957*958* When calling this function, set the value of *pMetalFeaturesSize to sizeof(MVKPhysicalDeviceMetalFeatures),959* to tell MoltenVK the limit of the size of your MVKPhysicalDeviceMetalFeatures structure. Upon return from960* this function, the value of *pMetalFeaturesSize will hold the actual number of bytes copied into your961* passed MVKPhysicalDeviceMetalFeatures structure, which will be the smaller of what your app thinks is the962* size of MVKPhysicalDeviceMetalFeatures, and what MoltenVK thinks it is. This represents the safe access963* area within the structure for both MoltenVK and your app.964*965* If the size that MoltenVK expects for MVKPhysicalDeviceMetalFeatures is different than the value passed in966* *pMetalFeaturesSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.967*968* Although it is not necessary, you can use this function to determine in advance the value that MoltenVK969* expects the size of MVKPhysicalDeviceMetalFeatures to be by setting the value of pMetalFeatures to NULL.970* In that case, this function will set *pMetalFeaturesSize to the size that MoltenVK expects971* MVKPhysicalDeviceMetalFeatures to be.972*973* This function is not supported by the Vulkan SDK Loader and Layers framework.974* The VkPhysicalDevice object you provide here must have been retrieved directly from975* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan976* objects are often changed by layers, and passing them from one layer to another,977* or from a layer directly to MoltenVK, will result in undefined behaviour.978*/979VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceMetalFeaturesMVK(980VkPhysicalDevice physicalDevice,981MVKPhysicalDeviceMetalFeatures* pMetalFeatures,982size_t* pMetalFeaturesSize);983984/**985* Populates the pPerf structure with the current performance statistics for the device.986*987* If you are linking to an implementation of MoltenVK that was compiled from a different988* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKPerformanceStatistics989* structure in your app may be larger or smaller than the same struct as expected by MoltenVK.990*991* When calling this function, set the value of *pPerfSize to sizeof(MVKPerformanceStatistics),992* to tell MoltenVK the limit of the size of your MVKPerformanceStatistics structure. Upon return993* from this function, the value of *pPerfSize will hold the actual number of bytes copied into994* your passed MVKPerformanceStatistics structure, which will be the smaller of what your app995* thinks is the size of MVKPerformanceStatistics, and what MoltenVK thinks it is. This996* represents the safe access area within the structure for both MoltenVK and your app.997*998* If the size that MoltenVK expects for MVKPerformanceStatistics is different than the value passed999* in *pPerfSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.1000*1001* Although it is not necessary, you can use this function to determine in advance the value1002* that MoltenVK expects the size of MVKPerformanceStatistics to be by setting the value of1003* pPerf to NULL. In that case, this function will set *pPerfSize to the size that MoltenVK1004* expects MVKPerformanceStatistics to be.1005*1006* This function is not supported by the Vulkan SDK Loader and Layers framework.1007* The VkDevice object you provide here must have been retrieved directly from1008* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1009* objects are often changed by layers, and passing them from one layer to another,1010* or from a layer directly to MoltenVK, will result in undefined behaviour.1011*/1012VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceStatisticsMVK(1013VkDevice device,1014MVKPerformanceStatistics* pPerf,1015size_t* pPerfSize);10161017/**1018* Returns a human readable version of the MoltenVK and Vulkan versions.1019*1020* This function is provided as a convenience for reporting. Use the MVK_VERSION,1021* VK_API_VERSION_1_0, and VK_HEADER_VERSION macros for programmatically accessing1022* the corresponding version numbers.1023*/1024VKAPI_ATTR void VKAPI_CALL vkGetVersionStringsMVK(1025char* pMoltenVersionStringBuffer,1026uint32_t moltenVersionStringBufferLength,1027char* pVulkanVersionStringBuffer,1028uint32_t vulkanVersionStringBufferLength);10291030/**1031* Sets the number of threads in a workgroup for a compute kernel.1032*1033* This needs to be called if you are creating compute shader modules from MSL1034* source code or MSL compiled code. Workgroup size is determined automatically1035* if you're using SPIR-V.1036*1037* This function is not supported by the Vulkan SDK Loader and Layers framework.1038* The VkShaderModule object you provide here must have been retrieved directly from1039* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1040* objects are often changed by layers, and passing them from one layer to another,1041* or from a layer directly to MoltenVK, will result in undefined behaviour.1042*/1043VKAPI_ATTR void VKAPI_CALL vkSetWorkgroupSizeMVK(1044VkShaderModule shaderModule,1045uint32_t x,1046uint32_t y,1047uint32_t z);10481049#ifdef __OBJC__10501051/**1052* Returns, in the pMTLDevice pointer, the MTLDevice used by the VkPhysicalDevice.1053*1054* This function is not supported by the Vulkan SDK Loader and Layers framework.1055* The VkPhysicalDevice object you provide here must have been retrieved directly from1056* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1057* objects are often changed by layers, and passing them from one layer to another,1058* or from a layer directly to MoltenVK, will result in undefined behaviour.1059*/1060VKAPI_ATTR void VKAPI_CALL vkGetMTLDeviceMVK(1061VkPhysicalDevice physicalDevice,1062id<MTLDevice>* pMTLDevice);10631064/**1065* Sets the VkImage to use the specified MTLTexture.1066*1067* Any differences in the properties of mtlTexture and this image will modify the1068* properties of this image.1069*1070* If a MTLTexture has already been created for this image, it will be destroyed.1071*1072* Returns VK_SUCCESS.1073*1074* This function is not supported by the Vulkan SDK Loader and Layers framework.1075* The VkImage object you provide here must have been retrieved directly from1076* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1077* objects are often changed by layers, and passing them from one layer to another,1078* or from a layer directly to MoltenVK, will result in undefined behaviour.1079*/1080VKAPI_ATTR VkResult VKAPI_CALL vkSetMTLTextureMVK(1081VkImage image,1082id<MTLTexture> mtlTexture);10831084/**1085* Returns, in the pMTLTexture pointer, the MTLTexture currently underlaying the VkImage.1086*1087* This function is not supported by the Vulkan SDK Loader and Layers framework.1088* The VkImage object you provide here must have been retrieved directly from1089* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1090* objects are often changed by layers, and passing them from one layer to another,1091* or from a layer directly to MoltenVK, will result in undefined behaviour.1092*/1093VKAPI_ATTR void VKAPI_CALL vkGetMTLTextureMVK(1094VkImage image,1095id<MTLTexture>* pMTLTexture);10961097/**1098* Returns, in the pMTLBuffer pointer, the MTLBuffer currently underlaying the VkBuffer.1099*1100* This function is not supported by the Vulkan SDK Loader and Layers framework.1101* The VkBuffer object you provide here must have been retrieved directly from1102* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1103* objects are often changed by layers, and passing them from one layer to another,1104* or from a layer directly to MoltenVK, will result in undefined behaviour.1105*/1106VKAPI_ATTR void VKAPI_CALL vkGetMTLBufferMVK(1107VkBuffer buffer,1108id<MTLBuffer>* pMTLBuffer);11091110/**1111* Indicates that a VkImage should use an IOSurface to underlay the Metal texture.1112*1113* If ioSurface is not null, it will be used as the IOSurface, and any differences1114* in the properties of that IOSurface will modify the properties of this image.1115*1116* If ioSurface is null, this image will create and use an IOSurface1117* whose properties are compatible with the properties of this image.1118*1119* If a MTLTexture has already been created for this image, it will be destroyed.1120*1121* IOSurfaces are supported on the following platforms:1122* - macOS 10.11 and above1123* - iOS 11.0 and above1124*1125* To enable IOSurface support, ensure the Deployment Target build setting1126* (MACOSX_DEPLOYMENT_TARGET or IPHONEOS_DEPLOYMENT_TARGET) is set to at least1127* one of the values above when compiling MoltenVK, and any app that uses MoltenVK.1128*1129* Returns:1130* - VK_SUCCESS.1131* - VK_ERROR_FEATURE_NOT_PRESENT if IOSurfaces are not supported on the platform.1132* - VK_ERROR_INITIALIZATION_FAILED if ioSurface is specified and is not compatible with this VkImage.1133*1134* This function is not supported by the Vulkan SDK Loader and Layers framework.1135* The VkImage object you provide here must have been retrieved directly from1136* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1137* objects are often changed by layers, and passing them from one layer to another,1138* or from a layer directly to MoltenVK, will result in undefined behaviour.1139*/1140VKAPI_ATTR VkResult VKAPI_CALL vkUseIOSurfaceMVK(1141VkImage image,1142IOSurfaceRef ioSurface);11431144/**1145* Returns, in the pIOSurface pointer, the IOSurface currently underlaying the VkImage,1146* as set by the useIOSurfaceMVK() function, or returns null if the VkImage is not using1147* an IOSurface, or if the platform does not support IOSurfaces.1148*1149* This function is not supported by the Vulkan SDK Loader and Layers framework.1150* The VkImage object you provide here must have been retrieved directly from1151* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan1152* objects are often changed by layers, and passing them from one layer to another,1153* or from a layer directly to MoltenVK, will result in undefined behaviour.1154*/1155VKAPI_ATTR void VKAPI_CALL vkGetIOSurfaceMVK(1156VkImage image,1157IOSurfaceRef* pIOSurface);11581159#endif // __OBJC__116011611162#pragma mark -1163#pragma mark Shaders11641165/**1166* NOTE: Shader code should be submitted as SPIR-V. Although some simple direct MSL shaders may work,1167* direct loading of MSL source code or compiled MSL code is not officially supported at this time.1168* Future versions of MoltenVK may support direct MSL submission again.1169*1170* Enumerates the magic number values to set in the MVKMSLSPIRVHeader when1171* submitting a SPIR-V stream that contains either Metal Shading Language source1172* code or Metal Shading Language compiled binary code in place of SPIR-V code.1173*/1174typedef enum {1175kMVKMagicNumberSPIRVCode = 0x07230203, /**< SPIR-V stream contains standard SPIR-V code. */1176kMVKMagicNumberMSLSourceCode = 0x19960412, /**< SPIR-V stream contains Metal Shading Language source code. */1177kMVKMagicNumberMSLCompiledCode = 0x19981215, /**< SPIR-V stream contains Metal Shading Language compiled binary code. */1178} MVKMSLMagicNumber;11791180/**1181* NOTE: Shader code should be submitted as SPIR-V. Although some simple direct MSL shaders may work,1182* direct loading of MSL source code or compiled MSL code is not officially supported at this time.1183* Future versions of MoltenVK may support direct MSL submission again.1184*1185* Describes the header at the start of an SPIR-V stream, when it contains either1186* Metal Shading Language source code or Metal Shading Language compiled binary code.1187*1188* To submit MSL source code to the vkCreateShaderModule() function in place of SPIR-V1189* code, prepend a MVKMSLSPIRVHeader containing the kMVKMagicNumberMSLSourceCode magic1190* number to the MSL source code. The MSL source code must be null-terminated.1191*1192* To submit MSL compiled binary code to the vkCreateShaderModule() function in place of1193* SPIR-V code, prepend a MVKMSLSPIRVHeader containing the kMVKMagicNumberMSLCompiledCode1194* magic number to the MSL compiled binary code.1195*1196* In both cases, the pCode element of VkShaderModuleCreateInfo should pointer to the1197* location of the MVKMSLSPIRVHeader, and the MSL code should start at the byte immediately1198* after the MVKMSLSPIRVHeader.1199*1200* The codeSize element of VkShaderModuleCreateInfo should be set to the entire size of1201* the submitted code memory, including the additional sizeof(MVKMSLSPIRVHeader) bytes1202* taken up by the MVKMSLSPIRVHeader, and, in the case of MSL source code, including1203* the null-terminator byte.1204*/1205typedef uint32_t MVKMSLSPIRVHeader;120612071208#endif // VK_NO_PROTOTYPES120912101211#ifdef __cplusplus1212}1213#endif // __cplusplus12141215#endif121612171218