Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/include/MoltenVK/vk_mvk_moltenvk.h
4558 views
1
/*
2
* vk_mvk_moltenvk.h
3
*
4
* Copyright (c) 2015-2021 The Brenwill Workshop Ltd. (http://www.brenwill.com)
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
10
* http://www.apache.org/licenses/LICENSE-2.0
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
20
/** Vulkan extension VK_MVK_moltenvk. */
21
22
#ifndef __vk_mvk_moltenvk_h_
23
#define __vk_mvk_moltenvk_h_ 1
24
25
#ifdef __cplusplus
26
extern "C" {
27
#endif // __cplusplus
28
29
#include "mvk_vulkan.h"
30
31
#ifdef __OBJC__
32
#import <Metal/Metal.h>
33
#import <IOSurface/IOSurfaceRef.h>
34
#else
35
typedef unsigned long MTLLanguageVersion;
36
#endif
37
38
39
/**
40
* The version number of MoltenVK is a single integer value, derived from the Major, Minor,
41
* and Patch version values, where each of the Major, Minor, and Patch components is allocated
42
* two decimal digits, in the format MjMnPt. This creates a version number that is both human
43
* readable and allows efficient computational comparisons to a single integer number.
44
*
45
* The following examples illustrate how the MoltenVK version number is built from its components:
46
* - 002000 (version 0.20.0)
47
* - 010000 (version 1.0.0)
48
* - 030104 (version 3.1.4)
49
* - 401215 (version 4.12.15)
50
*/
51
#define MVK_VERSION_MAJOR 1
52
#define MVK_VERSION_MINOR 1
53
#define MVK_VERSION_PATCH 2
54
55
#define MVK_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch))
56
#define MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH)
57
58
#define VK_MVK_MOLTENVK_SPEC_VERSION 30
59
#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
60
61
/**
62
* MoltenVK configuration settings.
63
*
64
* To be active, some configuration settings must be set before a VkDevice is created.
65
* See the description of the individual configuration structure members for more information.
66
*
67
* There are three mechanisms for setting the values of the MoltenVK configuration parameters:
68
* - Runtime API via the vkGetMoltenVKConfigurationMVK()/vkSetMoltenVKConfigurationMVK() functions.
69
* - Application runtime environment variables.
70
* - Build settings at MoltenVK build time.
71
*
72
* To change the MoltenVK configuration settings at runtime using a programmatic API,
73
* use the vkGetMoltenVKConfigurationMVK() and vkSetMoltenVKConfigurationMVK() functions
74
* to retrieve, modify, and set a copy of the MVKConfiguration structure. To be active,
75
* some configuration settings must be set before a VkInstance or VkDevice is created.
76
* See the description of each member for more information.
77
*
78
* The initial value of each of the configuration settings can established at runtime
79
* by a corresponding environment variable, or if the environment variable is not set,
80
* by a corresponding build setting at the time MoltenVK is compiled. The environment
81
* variable and build setting for each configuration parameter share the same name.
82
*
83
* For example, the initial value of the shaderConversionFlipVertexY configuration setting
84
* is set by the MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y at runtime, or by the
85
* MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y build setting when MoltenVK is compiled.
86
*
87
* This structure may be extended as new features are added to MoltenVK. If you are linking to
88
* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION
89
* than your app was, the size of this structure in your app may be larger or smaller than the
90
* struct in MoltenVK. See the description of the vkGetMoltenVKConfigurationMVK() and
91
* vkSetMoltenVKConfigurationMVK() functions for information about how to handle this.
92
*
93
* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT
94
* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,
95
* SHOULD NOT BE CHANGED.
96
*/
97
typedef struct {
98
99
/**
100
* If enabled, debugging capabilities will be enabled, including logging
101
* shader code during runtime shader conversion.
102
*
103
* The value of this parameter may be changed at any time during application runtime,
104
* and the changed value will immediately effect subsequent MoltenVK behaviour.
105
*
106
* The initial value or this parameter is set by the
107
* MVK_DEBUG
108
* runtime environment variable or MoltenVK compile-time build setting.
109
* If neither is set, the value of this parameter is false if MoltenVK was
110
* built in Release mode, and true if MoltenVK was built in Debug mode.
111
*/
112
VkBool32 debugMode;
113
114
/**
115
* If enabled, MSL vertex shader code created during runtime shader conversion will
116
* flip the Y-axis of each vertex, as the Vulkan Y-axis is the inverse of OpenGL.
117
*
118
* An alternate way to reverse the Y-axis is to employ a negative Y-axis value on
119
* the viewport, in which case this parameter can be disabled.
120
*
121
* The value of this parameter may be changed at any time during application runtime,
122
* and the changed value will immediately effect subsequent MoltenVK behaviour.
123
* Specifically, this parameter can be enabled when compiling some pipelines,
124
* and disabled when compiling others. Existing pipelines are not automatically
125
* re-compiled when this parameter is changed.
126
*
127
* The initial value or this parameter is set by the
128
* MVK_CONFIG_SHADER_CONVERSION_FLIP_VERTEX_Y
129
* runtime environment variable or MoltenVK compile-time build setting.
130
* If neither is set, the value of this parameter defaults to true.
131
*/
132
VkBool32 shaderConversionFlipVertexY;
133
134
/**
135
* If enabled, queue command submissions (vkQueueSubmit() & vkQueuePresentKHR()) will be
136
* processed on the thread that called the submission function. If disabled, processing
137
* will be dispatched to a GCD dispatch_queue whose priority is determined by
138
* VkDeviceQueueCreateInfo::pQueuePriorities during vkCreateDevice().
139
*
140
* The value of this parameter must be changed before creating a VkDevice,
141
* for the change to take effect.
142
*
143
* The initial value or this parameter is set by the
144
* MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS
145
* runtime environment variable or MoltenVK compile-time build setting.
146
* If neither is set, the value of this parameter defaults to true for macOS 10.14
147
* and above or iOS 12 and above, and false otherwise. The reason for this distinction
148
* is that this feature should be disabled when emulation is required to support VkEvents
149
* because native support for events (MTLEvent) is not available.
150
*/
151
VkBool32 synchronousQueueSubmits;
152
153
/**
154
* If enabled, where possible, a Metal command buffer will be created and filled when each
155
* Vulkan command buffer is filled. For applications that parallelize the filling of Vulkan
156
* commmand buffers across multiple threads, this allows the Metal command buffers to also
157
* be filled on the same parallel thread. Because each command buffer is filled separately,
158
* this requires that each Vulkan command buffer requires a dedicated Metal command buffer.
159
*
160
* If disabled, a single Metal command buffer will be created and filled when the Vulkan
161
* command buffers are submitted to the Vulkan queue. This allows a single Metal command
162
* buffer to be used for all of the Vulkan command buffers in a queue submission. The
163
* Metal command buffer is filled on the thread that processes the command queue submission.
164
*
165
* Depending on the nature of your application, you may find performance is improved by filling
166
* the Metal command buffers on parallel threads, or you may find that performance is improved by
167
* consolidating all Vulkan command buffers onto a single Metal command buffer during queue submission.
168
*
169
* Prefilling of a Metal command buffer will not occur during the filling of secondary command
170
* buffers (VK_COMMAND_BUFFER_LEVEL_SECONDARY), or for primary command buffers that are intended
171
* to be submitted to multiple queues concurrently (VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT).
172
*
173
* When enabling this feature, be aware that one Metal command buffer is required for each Vulkan
174
* command buffer. Depending on the number of command buffers that you use, you may also need to
175
* change the value of the maxActiveMetalCommandBuffersPerQueue setting.
176
*
177
* If this feature is enabled, be aware that if you have recorded commands to a Vulkan command buffer,
178
* and then choose to reset that command buffer instead of submitting it, the corresponding prefilled
179
* Metal command buffer will still be submitted. This is because Metal command buffers do not support
180
* the concept of being reset after being filled. Depending on when and how often you do this,
181
* it may cause unexpected visual artifacts and unnecessary GPU load.
182
*
183
* This feature is incompatible with updating descriptors after binding. If any of the
184
* *UpdateAfterBind feature flags of VkPhysicalDeviceDescriptorIndexingFeaturesEXT or
185
* VkPhysicalDeviceInlineUniformBlockFeaturesEXT have been enabled, the value of this
186
* setting will be ignored and treated as if it is false.
187
*
188
* The value of this parameter may be changed at any time during application runtime,
189
* and the changed value will immediately effect subsequent MoltenVK behaviour.
190
* Specifically, this parameter can be enabled when filling some command buffers,
191
* and disabled when filling others.
192
*
193
* The initial value or this parameter is set by the
194
* MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS
195
* runtime environment variable or MoltenVK compile-time build setting.
196
* If neither is set, the value of this parameter defaults to false.
197
*/
198
VkBool32 prefillMetalCommandBuffers;
199
200
/**
201
* The maximum number of Metal command buffers that can be concurrently active per Vulkan queue.
202
* The number of active Metal command buffers required depends on the prefillMetalCommandBuffers
203
* setting. If prefillMetalCommandBuffers is enabled, one Metal command buffer is required per
204
* Vulkan command buffer. If prefillMetalCommandBuffers is disabled, one Metal command buffer
205
* is required per command buffer queue submission, which may be significantly less than the
206
* number of Vulkan command buffers.
207
*
208
* The value of this parameter must be changed before creating a VkDevice,
209
* for the change to take effect.
210
*
211
* The initial value or this parameter is set by the
212
* MVK_CONFIG_MAX_ACTIVE_METAL_COMMAND_BUFFERS_PER_QUEUE
213
* runtime environment variable or MoltenVK compile-time build setting.
214
* If neither is set, the value of this parameter defaults to 64.
215
*/
216
uint32_t maxActiveMetalCommandBuffersPerQueue;
217
218
/**
219
* Metal allows only 8192 occlusion queries per MTLBuffer. If enabled, MoltenVK
220
* allocates a MTLBuffer for each query pool, allowing each query pool to support
221
* 8192 queries, which may slow performance or cause unexpected behaviour if the query
222
* pool is not established prior to a Metal renderpass, or if the query pool is changed
223
* within a renderpass. If disabled, one MTLBuffer will be shared by all query pools,
224
* which improves performance, but limits the total device queries to 8192.
225
*
226
* The value of this parameter may be changed at any time during application runtime,
227
* and the changed value will immediately effect subsequent MoltenVK behaviour.
228
* Specifically, this parameter can be enabled when creating some query pools,
229
* and disabled when creating others.
230
*
231
* The initial value or this parameter is set by the
232
* MVK_CONFIG_SUPPORT_LARGE_QUERY_POOLS
233
* runtime environment variable or MoltenVK compile-time build setting.
234
* If neither is set, the value of this parameter defaults to true.
235
*/
236
VkBool32 supportLargeQueryPools;
237
238
/** Obsolete, ignored, and deprecated. All surface presentations are performed with a command buffer. */
239
VkBool32 presentWithCommandBuffer;
240
241
/**
242
* If enabled, swapchain images will use simple Nearest sampling when magnifying the
243
* swapchain image to fit a physical display surface. If disabled, swapchain images will
244
* use Linear sampling when magnifying the swapchain image to fit a physical display surface.
245
* Enabling this setting avoids smearing effects when swapchain images are simple interger
246
* multiples of display pixels (eg- macOS Retina, and typical of graphics apps and games),
247
* but may cause aliasing effects when using non-integer display scaling.
248
*
249
* The value of this parameter may be changed before creating a VkSwapchain,
250
* for the change to take effect.
251
*
252
* The initial value or this parameter is set by the
253
* MVK_CONFIG_SWAPCHAIN_MAG_FILTER_USE_NEAREST
254
* runtime environment variable or MoltenVK compile-time build setting.
255
* If neither is set, the value of this parameter defaults to true.
256
*/
257
VkBool32 swapchainMagFilterUseNearest;
258
259
/**
260
* The maximum amount of time, in nanoseconds, to wait for a Metal library, function, or
261
* pipeline state object to be compiled and created by the Metal compiler. An internal error
262
* within the Metal compiler can stall the thread for up to 30 seconds. Setting this value
263
* limits that delay to a specified amount of time, allowing shader compilations to fail fast.
264
*
265
* The value of this parameter may be changed at any time during application runtime,
266
* and the changed value will immediately effect subsequent MoltenVK behaviour.
267
*
268
* The initial value or this parameter is set by the
269
* MVK_CONFIG_METAL_COMPILE_TIMEOUT
270
* runtime environment variable or MoltenVK compile-time build setting.
271
* If neither is set, the value of this parameter defaults to infinite.
272
*/
273
uint64_t metalCompileTimeout;
274
275
/**
276
* If enabled, performance statistics, as defined by the MVKPerformanceStatistics structure,
277
* are collected, and can be retrieved via the vkGetPerformanceStatisticsMVK() function.
278
*
279
* You can also use the performanceLoggingFrameCount or logActivityPerformanceInline
280
* parameters to automatically log the performance statistics collected by this parameter.
281
*
282
* The value of this parameter must be changed before creating a VkDevice,
283
* for the change to take effect.
284
*
285
* The initial value or this parameter is set by the
286
* MVK_CONFIG_PERFORMANCE_TRACKING
287
* runtime environment variable or MoltenVK compile-time build setting.
288
* If neither is set, the value of this parameter defaults to false.
289
*/
290
VkBool32 performanceTracking;
291
292
/**
293
* If non-zero, performance statistics, frame-based statistics will be logged, on a
294
* repeating cycle, once per this many frames. The performanceTracking parameter must
295
* also be enabled. If this parameter is zero, or the performanceTracking parameter
296
* is disabled, no frame-based performance statistics will be logged.
297
*
298
* The value of this parameter may be changed at any time during application runtime,
299
* and the changed value will immediately effect subsequent MoltenVK behaviour.
300
*
301
* The initial value or this parameter is set by the
302
* MVK_CONFIG_PERFORMANCE_LOGGING_FRAME_COUNT
303
* runtime environment variable or MoltenVK compile-time build setting.
304
* If neither is set, the value of this parameter defaults to zero.
305
*/
306
uint32_t performanceLoggingFrameCount;
307
308
/**
309
* If enabled, a MoltenVK logo watermark will be rendered on top of the scene.
310
* This can be enabled for publicity during demos.
311
*
312
* The value of this parameter may be changed at any time during application runtime,
313
* and the changed value will immediately effect subsequent MoltenVK behaviour.
314
*
315
* The initial value or this parameter is set by the
316
* MVK_CONFIG_DISPLAY_WATERMARK
317
* runtime environment variable or MoltenVK compile-time build setting.
318
* If neither is set, the value of this parameter defaults to false.
319
*/
320
VkBool32 displayWatermark;
321
322
/**
323
* Metal does not distinguish functionality between queues, which would normally mean only
324
* a single general-purpose queue family with multiple queues is needed. However, Vulkan
325
* associates command buffers with a queue family, whereas Metal associates command buffers
326
* with a specific Metal queue. In order to allow a Metal command buffer to be prefilled
327
* before is is formally submitted to a Vulkan queue, each Vulkan queue family can support
328
* only a single Metal queue. As a result, in order to provide parallel queue operations,
329
* MoltenVK provides multiple queue families, each with a single queue.
330
*
331
* If this parameter is disabled, all queue families will be advertised as having general-purpose
332
* graphics + compute + transfer functionality, which is how the actual Metal queues behave.
333
*
334
* If this parameter is enabled, one queue family will be advertised as having general-purpose
335
* graphics + compute + transfer functionality, and the remaining queue families will be advertised
336
* as having specialized graphics OR compute OR transfer functionality, to make it easier for some
337
* apps to select a queue family with the appropriate requirements.
338
*
339
* The value of this parameter must be changed before creating a VkDevice, and before
340
* querying a VkPhysicalDevice for queue family properties, for the change to take effect.
341
*
342
* The initial value or this parameter is set by the
343
* MVK_CONFIG_SPECIALIZED_QUEUE_FAMILIES
344
* runtime environment variable or MoltenVK compile-time build setting.
345
* If neither is set, the value of this parameter defaults to false.
346
*/
347
VkBool32 specializedQueueFamilies;
348
349
/**
350
* If enabled, when the app creates a VkDevice from a VkPhysicalDevice (GPU) that is neither
351
* headless nor low-power, and is different than the GPU used by the windowing system, the
352
* windowing system will be forced to switch to use the GPU selected by the Vulkan app.
353
* When the Vulkan app is ended, the windowing system will automatically switch back to
354
* using the previous GPU, depending on the usage requirements of other running apps.
355
*
356
* If disabled, the Vulkan app will render using its selected GPU, and if the windowing
357
* system uses a different GPU, the windowing system compositor will automatically copy
358
* framebuffer content from the app GPU to the windowing system GPU.
359
*
360
* The value of this parmeter has no effect on systems with a single GPU, or when the
361
* Vulkan app creates a VkDevice from a low-power or headless VkPhysicalDevice (GPU).
362
*
363
* Switching the windowing system GPU to match the Vulkan app GPU maximizes app performance,
364
* because it avoids the windowing system compositor from having to copy framebuffer content
365
* between GPUs on each rendered frame. However, doing so forces the entire system to
366
* potentially switch to using a GPU that may consume more power while the app is running.
367
*
368
* Some Vulkan apps may want to render using a high-power GPU, but leave it up to the
369
* system window compositor to determine how best to blend content with the windowing
370
* system, and as a result, may want to disable this parameter.
371
*
372
* The value of this parameter must be changed before creating a VkDevice,
373
* for the change to take effect.
374
*
375
* The initial value or this parameter is set by the
376
* MVK_CONFIG_SWITCH_SYSTEM_GPU
377
* runtime environment variable or MoltenVK compile-time build setting.
378
* If neither is set, the value of this parameter defaults to true.
379
*/
380
VkBool32 switchSystemGPU;
381
382
/**
383
* If enabled, arbitrary VkImageView component swizzles are supported, as defined
384
* in VkImageViewCreateInfo::components when creating a VkImageView.
385
*
386
* If disabled, a very limited set of VkImageView component swizzles are supported
387
* via format substitutions.
388
*
389
* Metal does not natively support per-texture swizzling. If this parameter is enabled
390
* both when a VkImageView is created, and when any pipeline that uses that VkImageView
391
* is compiled, VkImageView swizzling is automatically performed in the converted Metal
392
* shader code during all texture sampling and reading operations, regardless of whether
393
* a swizzle is required for the VkImageView associated with the Metal texture.
394
* This may result in reduced performance.
395
*
396
* The value of this parameter may be changed at any time during application runtime,
397
* and the changed value will immediately effect subsequent MoltenVK behaviour.
398
* Specifically, this parameter can be enabled when creating VkImageViews that need it,
399
* and compiling pipelines that use those VkImageViews, and can be disabled when creating
400
* VkImageViews that don't need it, and compiling pipelines that use those VkImageViews.
401
*
402
* Existing pipelines are not automatically re-compiled when this parameter is changed.
403
*
404
* An error is logged and returned during VkImageView creation if that VkImageView
405
* requires full image view swizzling and this feature is not enabled. An error is
406
* also logged when a pipeline that was not compiled with full image view swizzling
407
* is presented with a VkImageView that is expecting it.
408
*
409
* An error is also retuned and logged when a VkPhysicalDeviceImageFormatInfo2KHR is passed
410
* in a call to vkGetPhysicalDeviceImageFormatProperties2KHR() to query for an VkImageView
411
* format that will require full swizzling to be enabled, and this feature is not enabled.
412
*
413
* If this parameter is disabled, the following limited set of VkImageView swizzles are
414
* supported by MoltenVK, via automatic format substitution:
415
*
416
* Texture format Swizzle
417
* -------------- -------
418
* VK_FORMAT_R8_UNORM ZERO, ANY, ANY, RED
419
* VK_FORMAT_A8_UNORM ALPHA, ANY, ANY, ZERO
420
* VK_FORMAT_R8G8B8A8_UNORM BLUE, GREEN, RED, ALPHA
421
* VK_FORMAT_R8G8B8A8_SRGB BLUE, GREEN, RED, ALPHA
422
* VK_FORMAT_B8G8R8A8_UNORM BLUE, GREEN, RED, ALPHA
423
* VK_FORMAT_B8G8R8A8_SRGB BLUE, GREEN, RED, ALPHA
424
* VK_FORMAT_D32_SFLOAT_S8_UINT RED, ANY, ANY, ANY (stencil only)
425
* VK_FORMAT_D24_UNORM_S8_UINT RED, ANY, ANY, ANY (stencil only)
426
*
427
* The initial value or this parameter is set by the
428
* MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE
429
* runtime environment variable or MoltenVK compile-time build setting.
430
* If neither is set, the value of this parameter defaults to false.
431
*/
432
VkBool32 fullImageViewSwizzle;
433
434
/**
435
* The index of the queue family whose presentation submissions will
436
* be used as the default GPU Capture Scope during debugging in Xcode.
437
*
438
* The value of this parameter must be changed before creating a VkDevice,
439
* for the change to take effect.
440
*
441
* The initial value or this parameter is set by the
442
* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_FAMILY_INDEX
443
* runtime environment variable or MoltenVK compile-time build setting.
444
* If neither is set, the value of this parameter defaults to zero (the first queue family).
445
*/
446
uint32_t defaultGPUCaptureScopeQueueFamilyIndex;
447
448
/**
449
* The index of the queue, within the queue family identified by the
450
* defaultGPUCaptureScopeQueueFamilyIndex parameter, whose presentation submissions
451
* will be used as the default GPU Capture Scope during debugging in Xcode.
452
*
453
* The value of this parameter must be changed before creating a VkDevice,
454
* for the change to take effect.
455
*
456
* The initial value or this parameter is set by the
457
* MVK_CONFIG_DEFAULT_GPU_CAPTURE_SCOPE_QUEUE_INDEX
458
* runtime environment variable or MoltenVK compile-time build setting.
459
* If neither is set, the value of this parameter defaults to zero (the first queue).
460
*/
461
uint32_t defaultGPUCaptureScopeQueueIndex;
462
463
/**
464
* Corresponds to the fastMathEnabled property of MTLCompileOptions.
465
* Setting it may cause the Metal Compiler to optimize floating point operations
466
* in ways that may violate the IEEE 754 standard.
467
*
468
* Must be changed before creating a VkDevice, for the change to take effect.
469
*
470
* The initial value or this parameter is set by the
471
* MVK_CONFIG_FAST_MATH_ENABLED
472
* runtime environment variable or MoltenVK compile-time build setting.
473
* If neither is set, the value of this parameter defaults to true.
474
*/
475
VkBool32 fastMathEnabled;
476
477
/**
478
* Controls the level of logging performned by MoltenVK using the following numeric values:
479
* 0: No logging.
480
* 1: Log errors only.
481
* 2: Log errors and informational messages.
482
*
483
* The value of this parameter may be changed at any time during application runtime,
484
* and the changed value will immediately effect subsequent MoltenVK behaviour.
485
*
486
* The initial value or this parameter is set by the
487
* MVK_CONFIG_LOG_LEVEL
488
* runtime environment variable or MoltenVK compile-time build setting.
489
* If neither is set, errors and informational messages are logged.
490
*/
491
uint32_t logLevel;
492
493
/**
494
* Causes MoltenVK to log the name of each Vulkan call made by the application,
495
* along with the Mach thread ID, global system thread ID, and thread name.
496
* The logging format options can be controlled as follows:
497
* 0: No Vulkan call logging.
498
* 1: Log the name of each Vulkan call when the call is entered.
499
* 2: Log the name of each Vulkan call when the call is entered and exited. This
500
* effectively brackets any other logging activity within the scope of the Vulkan call.
501
* 3: Same as option 2, plus logs the time spent inside the Vulkan function.
502
* If none of these is set, no Vulkan call logging will occur.
503
*
504
* The value of this parameter may be changed at any time during application runtime,
505
* and the changed value will immediately effect subsequent MoltenVK behaviour.
506
*
507
* The initial value or this parameter is set by the
508
* MVK_CONFIG_TRACE_VULKAN_CALLS
509
* runtime environment variable or MoltenVK compile-time build setting.
510
* If neither is set, no Vulkan call logging will occur.
511
*/
512
uint32_t traceVulkanCalls;
513
514
/**
515
* Force MoltenVK to use a low-power GPU, if one is availble on the device.
516
*
517
* The value of this parameter must be changed before creating a VkInstance,
518
* for the change to take effect.
519
*
520
* The initial value or this parameter is set by the
521
* MVK_CONFIG_FORCE_LOW_POWER_GPU
522
* runtime environment variable or MoltenVK compile-time build setting.
523
* If neither is set, this setting is disabled by default, allowing both
524
* low-power and high-power GPU's to be used.
525
*/
526
VkBool32 forceLowPowerGPU;
527
528
/**
529
* Use MTLFence, if it is available on the device, for VkSemaphore synchronization behaviour.
530
*
531
* This parameter interacts with semaphoreUseMTLEvent. If both are enabled, semaphoreUseMTLFence
532
* takes priority and MTLFence will be used if it is available, otherwise MTLEvent will be used
533
* if it is available. If neither semaphoreUseMTLFence or semaphoreUseMTLEvent are enabled, or
534
* if neither MTLFence or MTLEvent are available, CPU-based synchoronization will be used.
535
*
536
* In the special case of VK_SEMAPHORE_TYPE_TIMELINE semaphores, MoltenVK will always
537
* use MTLSharedEvent if it is available on the platform, regardless of the values of
538
* MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS.
539
*
540
* The value of this parameter must be changed before creating a VkDevice,
541
* for the change to take effect.
542
*
543
* The initial value or this parameter is set by the
544
* MVK_ALLOW_METAL_FENCES
545
* runtime environment variable or MoltenVK compile-time build setting.
546
* If neither is set, this setting is enabled by default, and VkSemaphore will use MTLFence,
547
* if it is available.
548
*/
549
VkBool32 semaphoreUseMTLFence;
550
551
/**
552
* Use MTLEvent, if it is available on the device, for VkSemaphore synchronization behaviour.
553
*
554
* This parameter interacts with semaphoreUseMTLFence. If both are enabled, semaphoreUseMTLFence
555
* takes priority and MTLFence will be used if it is available, otherwise MTLEvent will be used
556
* if it is available. If neither semaphoreUseMTLFence or semaphoreUseMTLEvent are enabled, or
557
* if neither MTLFence or MTLEvent are available, CPU-based synchoronization will be used.
558
*
559
* In the special case of VK_SEMAPHORE_TYPE_TIMELINE semaphores, MoltenVK will always
560
* use MTLSharedEvent if it is available on the platform, regardless of the values of
561
* MVK_ALLOW_METAL_FENCES or MVK_ALLOW_METAL_EVENTS.
562
*
563
* The value of this parameter must be changed before creating a VkDevice,
564
* for the change to take effect.
565
*
566
* The initial value or this parameter is set by the
567
* MVK_ALLOW_METAL_EVENTS
568
* runtime environment variable or MoltenVK compile-time build setting.
569
* If neither is set, this setting is enabled by default, and VkSemaphore will use MTLEvent,
570
* if it is available, unless if MTLFence is available and semaphoreUseMTLFence is enabled.
571
*/
572
VkBool32 semaphoreUseMTLEvent;
573
574
/**
575
* Controls whether Metal should run an automatic GPU capture without the user having to
576
* trigger it manually via the Xcode user interface, and controls the scope under which
577
* that GPU capture will occur. This is useful when trying to capture a one-shot GPU trace,
578
* such as when running a Vulkan CTS test case. For the automatic GPU capture to occur,
579
* the Xcode scheme under which the app is run must have the Metal GPU capture option
580
* enabled. MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE should not be set to manually trigger a
581
* GPU capture via the Xcode user interface.
582
*
583
* To automatically trigger a GPU capture, set this value as follows:
584
* 0: No automatic GPU capture.
585
* 1: Capture all GPU commands issued during the lifetime of the VkDevice.
586
* 2: Capture all GPU commands issued during the first rendered frame.
587
*
588
* The value of this parameter must be changed before creating a VkDevice,
589
* for the change to take effect.
590
*
591
* The initial value or this parameter is set by the
592
* MVK_CONFIG_AUTO_GPU_CAPTURE_SCOPE
593
* runtime environment variable or MoltenVK compile-time build setting.
594
* If neither is set, no automatic GPU capture will occur.
595
*/
596
uint32_t autoGPUCaptureScope;
597
598
/**
599
* The path to a file where the automatic GPU capture should be saved, if autoGPUCaptureScope
600
* is enabled. In this case, the Xcode scheme need not have Metal GPU capture enabled, and in
601
* fact the app need not be run under Xcode's control at all. This is useful in case the app
602
* cannot be run under Xcode's control. A path starting with '~' can be used to place it in a
603
* user's home directory, as in the shell. This feature requires Metal 3.0 (macOS 10.15, iOS 13).
604
*
605
* If this parameter is NULL or an empty string, and autoGPUCaptureScope is enabled, automatic
606
* GPU capture will be handled by the Xcode user interface.
607
*
608
* The value of this parameter must be changed before creating a VkDevice,
609
* for the change to take effect.
610
*
611
* The initial value or this parameter is set by the
612
* MVK_CONFIG_AUTO_GPU_CAPTURE_OUTPUT_FILE
613
* runtime environment variable or MoltenVK compile-time build setting.
614
* If neither is set, automatic GPU capture will be handled by the Xcode user interface.
615
*/
616
char* autoGPUCaptureOutputFilepath;
617
618
/**
619
* Controls whether MoltenVK should use a Metal 2D texture with a height of 1 for a
620
* Vulkan 1D image, or use a native Metal 1D texture. Metal imposes significant restrictions
621
* on native 1D textures, including not being renderable, clearable, or permitting mipmaps.
622
* Using a Metal 2D texture allows Vulkan 1D textures to support this additional functionality.
623
*
624
* The value of this parameter should only be changed before creating the VkInstance.
625
*
626
* The initial value or this parameter is set by the
627
* MVK_CONFIG_TEXTURE_1D_AS_2D
628
* runtime environment variable or MoltenVK compile-time build setting.
629
* If neither is set, this setting is enabled by default, and MoltenVK will
630
* use a Metal 2D texture for each Vulkan 1D image.
631
*/
632
VkBool32 texture1DAs2D;
633
634
/**
635
* Controls whether MoltenVK should preallocate memory in each VkDescriptorPool
636
* ccording to the values of the VkDescriptorPoolSize parameters. Doing so may improve
637
* descriptor set allocation performance at a cost of preallocated application memory,
638
* and possible descreased performance when creating and reseting the VkDescriptorPool.
639
* If this setting is disabled, the descriptors required for a descriptor set will
640
* be dynamically allocated in application memory when the descriptor set itself is allocated.
641
*
642
* The value of this parameter may be changed at any time during application runtime,
643
* and the changed value will immediately effect behavior of VkDescriptorPools created
644
* after the setting is changed.
645
*
646
* The initial value or this parameter is set by the
647
* MVK_CONFIG_PREALLOCATE_DESCRIPTORS
648
* runtime environment variable or MoltenVK compile-time build setting.
649
* If neither is set, this setting is disabled by default, and MoltenVK will
650
* dynamically allocate descriptors when the containing descriptor set is allocated.
651
*/
652
VkBool32 preallocateDescriptors;
653
654
/**
655
* Controls whether MoltenVK should use pools to manage memory used when adding commands
656
* to command buffers. If this setting is enabled, MoltenVK will use a pool to hold command
657
* resources for reuse during command execution. If this setting is disabled, command memory
658
* is allocated and destroyed each time a command is executed. This is a classic time-space
659
* trade off. When command pooling is active, the memory in the pool can be cleared via a
660
* call to the vkTrimCommandPoolKHR() command.
661
*
662
* The value of this parameter may be changed at any time during application runtime,
663
* and the changed value will immediately effect behavior of VkCommandPools created
664
* after the setting is changed.
665
*
666
* The initial value or this parameter is set by the
667
* MVK_CONFIG_USE_COMMAND_POOLING
668
* runtime environment variable or MoltenVK compile-time build setting.
669
* If neither is set, this setting is enabled by default, and MoltenVK will pool command memory.
670
*/
671
VkBool32 useCommandPooling;
672
673
/**
674
* Controls whether MoltenVK should use MTLHeaps for allocating textures and buffers
675
* from device memory. If this setting is enabled, and placement MTLHeaps are
676
* available on the platform, MoltenVK will allocate a placement MTLHeap for each VkDeviceMemory
677
* instance, and allocate textures and buffers from that placement heap. If this environment
678
* variable is disabled, MoltenVK will allocate textures and buffers from general device memory.
679
*
680
* Apple recommends that MTLHeaps should only be used for specific requirements such as aliasing
681
* or hazard tracking, and MoltenVK testing has shown that allocating multiple textures of
682
* different types or usages from one MTLHeap can occassionally cause corruption issues under
683
* certain circumstances.
684
*
685
* The value of this parameter must be changed before creating a VkInstance,
686
* for the change to take effect.
687
*
688
* The initial value or this parameter is set by the
689
* MVK_CONFIG_USE_MTLHEAP
690
* runtime environment variable or MoltenVK compile-time build setting.
691
* If neither is set, this setting is disabled by default, and MoltenVK
692
* will allocate texures and buffers from general device memory.
693
*/
694
VkBool32 useMTLHeap;
695
696
/**
697
* Controls whether MoltenVK should log the performance of individual activities as they happen.
698
* If this setting is enabled, activity performance will be logged when each activity happens.
699
* If this setting is disabled, activity performance will be logged when frame peformance is
700
* logged as determined by the performanceLoggingFrameCount value.
701
*
702
* The value of this parameter must be changed before creating a VkDevice,
703
* for the change to take effect.
704
*
705
* The initial value or this parameter is set by the
706
* MVK_CONFIG_PERFORMANCE_LOGGING_INLINE
707
* runtime environment variable or MoltenVK compile-time build setting.
708
* If neither is set, this setting is disabled by default, and activity
709
* performance will be logged only when frame activity is logged.
710
*/
711
VkBool32 logActivityPerformanceInline;
712
713
} MVKConfiguration;
714
715
/**
716
* Features provided by the current implementation of Metal on the current device. You can
717
* retrieve a copy of this structure using the vkGetPhysicalDeviceMetalFeaturesMVK() function.
718
*
719
* This structure may be extended as new features are added to MoltenVK. If you are linking to
720
* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION
721
* than your app was, the size of this structure in your app may be larger or smaller than the
722
* struct in MoltenVK. See the description of the vkGetPhysicalDeviceMetalFeaturesMVK() function
723
* for information about how to handle this.
724
*
725
* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT
726
* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,
727
* SHOULD NOT BE CHANGED.
728
*/
729
typedef struct {
730
uint32_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). */
731
VkBool32 indirectDrawing; /**< If true, draw calls support parameters held in a GPU buffer. */
732
VkBool32 baseVertexInstanceDrawing; /**< If true, draw calls support specifiying the base vertex and instance. */
733
uint32_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. */
734
VkBool32 shaderSpecialization; /**< If true, shader specialization (aka Metal function constants) is supported. */
735
VkBool32 ioSurfaces; /**< If true, VkImages can be underlaid by IOSurfaces via the vkUseIOSurfaceMVK() function, to support inter-process image transfers. */
736
VkBool32 texelBuffers; /**< If true, texel buffers are supported, allowing the contents of a buffer to be interpreted as an image via a VkBufferView. */
737
VkBool32 layeredRendering; /**< If true, layered rendering to multiple cube or texture array layers is supported. */
738
VkBool32 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. */
739
VkBool32 stencilViews; /**< If true, stencil aspect views are supported through the MTLPixelFormatX24_Stencil8 and MTLPixelFormatX32_Stencil8 formats. */
740
VkBool32 multisampleArrayTextures; /**< If true, MTLTextureType2DMultisampleArray is supported. */
741
VkBool32 samplerClampToBorder; /**< If true, the border color set when creating a sampler will be respected. */
742
uint32_t maxTextureDimension; /**< The maximum size of each texture dimension (width, height, or depth). */
743
uint32_t maxPerStageBufferCount; /**< The total number of per-stage Metal buffers available for shader uniform content and attributes. */
744
uint32_t maxPerStageTextureCount; /**< The total number of per-stage Metal textures available for shader uniform content. */
745
uint32_t maxPerStageSamplerCount; /**< The total number of per-stage Metal samplers available for shader uniform content. */
746
VkDeviceSize maxMTLBufferSize; /**< The max size of a MTLBuffer (in bytes). */
747
VkDeviceSize mtlBufferAlignment; /**< The alignment used when allocating memory for MTLBuffers. Must be PoT. */
748
VkDeviceSize maxQueryBufferSize; /**< The maximum size of an occlusion query buffer (in bytes). */
749
VkDeviceSize mtlCopyBufferAlignment; /**< The alignment required during buffer copy operations (in bytes). */
750
VkSampleCountFlags supportedSampleCounts; /**< A bitmask identifying the sample counts supported by the device. */
751
uint32_t minSwapchainImageCount; /**< The minimum number of swapchain images that can be supported by a surface. */
752
uint32_t maxSwapchainImageCount; /**< The maximum number of swapchain images that can be supported by a surface. */
753
VkBool32 combinedStoreResolveAction; /**< If true, the device supports VK_ATTACHMENT_STORE_OP_STORE with a simultaneous resolve attachment. */
754
VkBool32 arrayOfTextures; /**< If true, arrays of textures is supported. */
755
VkBool32 arrayOfSamplers; /**< If true, arrays of texture samplers is supported. */
756
MTLLanguageVersion mslVersionEnum; /**< The version of the Metal Shading Language available on this device, as a Metal enumeration. */
757
VkBool32 depthSampleCompare; /**< If true, depth texture samplers support the comparison of the pixel value against a reference value. */
758
VkBool32 events; /**< If true, Metal synchronization events (MTLEvent) are supported. */
759
VkBool32 memoryBarriers; /**< If true, full memory barriers within Metal render passes are supported. */
760
VkBool32 multisampleLayeredRendering; /**< If true, layered rendering to multiple multi-sampled cube or texture array layers is supported. */
761
VkBool32 stencilFeedback; /**< If true, fragment shaders that write to [[stencil]] outputs are supported. */
762
VkBool32 textureBuffers; /**< If true, textures of type MTLTextureTypeBuffer are supported. */
763
VkBool32 postDepthCoverage; /**< If true, coverage masks in fragment shaders post-depth-test are supported. */
764
VkBool32 fences; /**< If true, Metal synchronization fences (MTLFence) are supported. */
765
VkBool32 rasterOrderGroups; /**< If true, Raster order groups in fragment shaders are supported. */
766
VkBool32 native3DCompressedTextures; /**< If true, 3D compressed images are supported natively, without manual decompression. */
767
VkBool32 nativeTextureSwizzle; /**< If true, component swizzle is supported natively, without manual swizzling in shaders. */
768
VkBool32 placementHeaps; /**< If true, MTLHeap objects support placement of resources. */
769
VkDeviceSize pushConstantSizeAlignment; /**< The alignment used internally when allocating memory for push constants. Must be PoT. */
770
uint32_t maxTextureLayers; /**< The maximum number of layers in an array texture. */
771
uint32_t maxSubgroupSize; /**< The maximum number of threads in a SIMD-group. */
772
VkDeviceSize vertexStrideAlignment; /**< The alignment used for the stride of vertex attribute bindings. */
773
VkBool32 indirectTessellationDrawing; /**< If true, tessellation draw calls support parameters held in a GPU buffer. */
774
VkBool32 nonUniformThreadgroups; /**< If true, the device supports arbitrary-sized grids in compute workloads. */
775
VkBool32 renderWithoutAttachments; /**< If true, we don't have to create a dummy attachment for a render pass if there isn't one. */
776
VkBool32 deferredStoreActions; /**< If true, render pass store actions can be specified after the render encoder is created. */
777
VkBool32 sharedLinearTextures; /**< If true, linear textures and texture buffers can be created from buffers in Shared storage. */
778
VkBool32 depthResolve; /**< If true, resolving depth textures with filters other than Sample0 is supported. */
779
VkBool32 stencilResolve; /**< If true, resolving stencil textures with filters other than Sample0 is supported. */
780
uint32_t maxPerStageDynamicMTLBufferCount; /**< The maximum number of inline buffers that can be set on a command buffer. */
781
uint32_t maxPerStageStorageTextureCount; /**< The total number of per-stage Metal textures with read-write access available for writing to from a shader. */
782
VkBool32 astcHDRTextures; /**< If true, ASTC HDR pixel formats are supported. */
783
VkBool32 renderLinearTextures; /**< If true, linear textures are renderable. */
784
VkBool32 pullModelInterpolation; /**< If true, explicit interpolation functions are supported. */
785
VkBool32 samplerMirrorClampToEdge; /**< If true, the mirrored clamp to edge address mode is supported in samplers. */
786
VkBool32 quadPermute; /**< If true, quadgroup permutation functions (vote, ballot, shuffle) are supported in shaders. */
787
VkBool32 simdPermute; /**< If true, SIMD-group permutation functions (vote, ballot, shuffle) are supported in shaders. */
788
VkBool32 simdReduction; /**< If true, SIMD-group reduction functions (arithmetic) are supported in shaders. */
789
uint32_t minSubgroupSize; /**< The minimum number of threads in a SIMD-group. */
790
VkBool32 textureBarriers; /**< If true, texture barriers are supported within Metal render passes. */
791
VkBool32 tileBasedDeferredRendering; /**< If true, this device uses tile-based deferred rendering. */
792
} MVKPhysicalDeviceMetalFeatures;
793
794
/** MoltenVK performance of a particular type of activity. */
795
typedef struct {
796
uint32_t count; /**< The number of activities of this type. */
797
double latestDuration; /**< The latest (most recent) duration of the activity, in milliseconds. */
798
double averageDuration; /**< The average duration of the activity, in milliseconds. */
799
double minimumDuration; /**< The minimum duration of the activity, in milliseconds. */
800
double maximumDuration; /**< The maximum duration of the activity, in milliseconds. */
801
} MVKPerformanceTracker;
802
803
/** MoltenVK performance of shader compilation activities. */
804
typedef struct {
805
MVKPerformanceTracker hashShaderCode; /** Create a hash from the incoming shader code. */
806
MVKPerformanceTracker spirvToMSL; /** Convert SPIR-V to MSL source code. */
807
MVKPerformanceTracker mslCompile; /** Compile MSL source code into a MTLLibrary. */
808
MVKPerformanceTracker mslLoad; /** Load pre-compiled MSL code into a MTLLibrary. */
809
MVKPerformanceTracker shaderLibraryFromCache; /** Retrieve a shader library from the cache, lazily creating it if needed. */
810
MVKPerformanceTracker functionRetrieval; /** Retrieve a MTLFunction from a MTLLibrary. */
811
MVKPerformanceTracker functionSpecialization; /** Specialize a retrieved MTLFunction. */
812
MVKPerformanceTracker pipelineCompile; /** Compile MTLFunctions into a pipeline. */
813
MVKPerformanceTracker glslToSPRIV; /** Convert GLSL to SPIR-V code. */
814
} MVKShaderCompilationPerformance;
815
816
/** MoltenVK performance of pipeline cache activities. */
817
typedef struct {
818
MVKPerformanceTracker sizePipelineCache; /** Calculate the size of cache data required to write MSL to pipeline cache data stream. */
819
MVKPerformanceTracker writePipelineCache; /** Write MSL to pipeline cache data stream. */
820
MVKPerformanceTracker readPipelineCache; /** Read MSL from pipeline cache data stream. */
821
} MVKPipelineCachePerformance;
822
823
/** MoltenVK performance of queue activities. */
824
typedef struct {
825
MVKPerformanceTracker mtlQueueAccess; /** Create an MTLCommandQueue or access an existing cached instance. */
826
MVKPerformanceTracker mtlCommandBufferCompletion; /** Completion of a MTLCommandBuffer on the GPU, from commit to completion callback. */
827
MVKPerformanceTracker nextCAMetalDrawable; /** Retrieve next CAMetalDrawable from CAMetalLayer during presentation. */
828
MVKPerformanceTracker frameInterval; /** Frame presentation interval (1000/FPS). */
829
} MVKQueuePerformance;
830
831
/**
832
* MoltenVK performance. You can retrieve a copy of this structure using the vkGetPerformanceStatisticsMVK() function.
833
*
834
* This structure may be extended as new features are added to MoltenVK. If you are linking to
835
* an implementation of MoltenVK that was compiled from a different VK_MVK_MOLTENVK_SPEC_VERSION
836
* than your app was, the size of this structure in your app may be larger or smaller than the
837
* struct in MoltenVK. See the description of the vkGetPerformanceStatisticsMVK() function for
838
* information about how to handle this.
839
*
840
* TO SUPPORT DYNAMIC LINKING TO THIS STRUCTURE AS DESCRIBED ABOVE, THIS STRUCTURE SHOULD NOT
841
* BE CHANGED EXCEPT TO ADD ADDITIONAL MEMBERS ON THE END. EXISTING MEMBERS, AND THEIR ORDER,
842
* SHOULD NOT BE CHANGED.
843
*/
844
typedef struct {
845
MVKShaderCompilationPerformance shaderCompilation; /** Shader compilations activities. */
846
MVKPipelineCachePerformance pipelineCache; /** Pipeline cache activities. */
847
MVKQueuePerformance queue; /** Queue activities. */
848
} MVKPerformanceStatistics;
849
850
851
#pragma mark -
852
#pragma mark Function types
853
854
typedef VkResult (VKAPI_PTR *PFN_vkGetMoltenVKConfigurationMVK)(VkInstance ignored, MVKConfiguration* pConfiguration, size_t* pConfigurationSize);
855
typedef VkResult (VKAPI_PTR *PFN_vkSetMoltenVKConfigurationMVK)(VkInstance ignored, MVKConfiguration* pConfiguration, size_t* pConfigurationSize);
856
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceMetalFeaturesMVK)(VkPhysicalDevice physicalDevice, MVKPhysicalDeviceMetalFeatures* pMetalFeatures, size_t* pMetalFeaturesSize);
857
typedef VkResult (VKAPI_PTR *PFN_vkGetPerformanceStatisticsMVK)(VkDevice device, MVKPerformanceStatistics* pPerf, size_t* pPerfSize);
858
typedef void (VKAPI_PTR *PFN_vkGetVersionStringsMVK)(char* pMoltenVersionStringBuffer, uint32_t moltenVersionStringBufferLength, char* pVulkanVersionStringBuffer, uint32_t vulkanVersionStringBufferLength);
859
860
#ifdef __OBJC__
861
typedef void (VKAPI_PTR *PFN_vkGetMTLDeviceMVK)(VkPhysicalDevice physicalDevice, id<MTLDevice>* pMTLDevice);
862
typedef VkResult (VKAPI_PTR *PFN_vkSetMTLTextureMVK)(VkImage image, id<MTLTexture> mtlTexture);
863
typedef void (VKAPI_PTR *PFN_vkGetMTLTextureMVK)(VkImage image, id<MTLTexture>* pMTLTexture);
864
typedef void (VKAPI_PTR *PFN_vkGetMTLBufferMVK)(VkBuffer buffer, id<MTLBuffer>* pMTLBuffer);
865
typedef VkResult (VKAPI_PTR *PFN_vkUseIOSurfaceMVK)(VkImage image, IOSurfaceRef ioSurface);
866
typedef void (VKAPI_PTR *PFN_vkGetIOSurfaceMVK)(VkImage image, IOSurfaceRef* pIOSurface);
867
#endif // __OBJC__
868
869
870
#pragma mark -
871
#pragma mark Function prototypes
872
873
#ifndef VK_NO_PROTOTYPES
874
875
/**
876
* Populates the pConfiguration structure with the current MoltenVK configuration settings.
877
*
878
* To change a specific configuration value, call vkGetMoltenVKConfigurationMVK() to retrieve
879
* the current configuration, make changes, and call vkSetMoltenVKConfigurationMVK() to
880
* update all of the values.
881
*
882
* The VkInstance object you provide here is ignored, and a VK_NULL_HANDLE value can be provided.
883
* This function can be called before the VkInstance has been created. It is safe to call this function
884
* with a VkInstance retrieved from a different layer in the Vulkan SDK Loader and Layers framework.
885
*
886
* To be active, some configuration settings must be set before a VkInstance or VkDevice
887
* is created. See the description of the MVKConfiguration members for more information.
888
*
889
* If you are linking to an implementation of MoltenVK that was compiled from a different
890
* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKConfiguration structure
891
* in your app may be larger or smaller than the same struct as expected by MoltenVK.
892
*
893
* When calling this function, set the value of *pConfigurationSize to sizeof(MVKConfiguration),
894
* to tell MoltenVK the limit of the size of your MVKConfiguration structure. Upon return from
895
* this function, the value of *pConfigurationSize will hold the actual number of bytes copied
896
* into your passed MVKConfiguration structure, which will be the smaller of what your app
897
* thinks is the size of MVKConfiguration, and what MoltenVK thinks it is. This represents the
898
* safe access area within the structure for both MoltenVK and your app.
899
*
900
* If the size that MoltenVK expects for MVKConfiguration is different than the value passed in
901
* *pConfigurationSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.
902
*
903
* Although it is not necessary, you can use this function to determine in advance the value
904
* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration
905
* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK
906
* expects MVKConfiguration to be.
907
*/
908
VKAPI_ATTR VkResult VKAPI_CALL vkGetMoltenVKConfigurationMVK(
909
VkInstance ignored,
910
MVKConfiguration* pConfiguration,
911
size_t* pConfigurationSize);
912
913
/**
914
* Sets the MoltenVK configuration settings to those found in the pConfiguration structure.
915
*
916
* To change a specific configuration value, call vkGetMoltenVKConfigurationMVK()
917
* to retrieve the current configuration, make changes, and call
918
* vkSetMoltenVKConfigurationMVK() to update all of the values.
919
*
920
* The VkInstance object you provide here is ignored, and a VK_NULL_HANDLE value can be provided.
921
* This function can be called before the VkInstance has been created. It is safe to call this function
922
* with a VkInstance retrieved from a different layer in the Vulkan SDK Loader and Layers framework.
923
*
924
* To be active, some configuration settings must be set before a VkInstance or VkDevice
925
* is created. See the description of the MVKConfiguration members for more information.
926
*
927
* If you are linking to an implementation of MoltenVK that was compiled from a different
928
* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKConfiguration structure
929
* in your app may be larger or smaller than the same struct as expected by MoltenVK.
930
*
931
* When calling this function, set the value of *pConfigurationSize to sizeof(MVKConfiguration),
932
* to tell MoltenVK the limit of the size of your MVKConfiguration structure. Upon return from
933
* this function, the value of *pConfigurationSize will hold the actual number of bytes copied
934
* out of your passed MVKConfiguration structure, which will be the smaller of what your app
935
* thinks is the size of MVKConfiguration, and what MoltenVK thinks it is. This represents the
936
* safe access area within the structure for both MoltenVK and your app.
937
*
938
* If the size that MoltenVK expects for MVKConfiguration is different than the value passed in
939
* *pConfigurationSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.
940
*
941
* Although it is not necessary, you can use this function to determine in advance the value
942
* that MoltenVK expects the size of MVKConfiguration to be by setting the value of pConfiguration
943
* to NULL. In that case, this function will set *pConfigurationSize to the size that MoltenVK
944
* expects MVKConfiguration to be.
945
*/
946
VKAPI_ATTR VkResult VKAPI_CALL vkSetMoltenVKConfigurationMVK(
947
VkInstance ignored,
948
const MVKConfiguration* pConfiguration,
949
size_t* pConfigurationSize);
950
951
/**
952
* Populates the pMetalFeatures structure with the Metal-specific features
953
* supported by the specified physical device.
954
*
955
* If you are linking to an implementation of MoltenVK that was compiled from a different
956
* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKPhysicalDeviceMetalFeatures
957
* structure in your app may be larger or smaller than the same struct as expected by MoltenVK.
958
*
959
* When calling this function, set the value of *pMetalFeaturesSize to sizeof(MVKPhysicalDeviceMetalFeatures),
960
* to tell MoltenVK the limit of the size of your MVKPhysicalDeviceMetalFeatures structure. Upon return from
961
* this function, the value of *pMetalFeaturesSize will hold the actual number of bytes copied into your
962
* passed MVKPhysicalDeviceMetalFeatures structure, which will be the smaller of what your app thinks is the
963
* size of MVKPhysicalDeviceMetalFeatures, and what MoltenVK thinks it is. This represents the safe access
964
* area within the structure for both MoltenVK and your app.
965
*
966
* If the size that MoltenVK expects for MVKPhysicalDeviceMetalFeatures is different than the value passed in
967
* *pMetalFeaturesSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.
968
*
969
* Although it is not necessary, you can use this function to determine in advance the value that MoltenVK
970
* expects the size of MVKPhysicalDeviceMetalFeatures to be by setting the value of pMetalFeatures to NULL.
971
* In that case, this function will set *pMetalFeaturesSize to the size that MoltenVK expects
972
* MVKPhysicalDeviceMetalFeatures to be.
973
*
974
* This function is not supported by the Vulkan SDK Loader and Layers framework.
975
* The VkPhysicalDevice object you provide here must have been retrieved directly from
976
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
977
* objects are often changed by layers, and passing them from one layer to another,
978
* or from a layer directly to MoltenVK, will result in undefined behaviour.
979
*/
980
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceMetalFeaturesMVK(
981
VkPhysicalDevice physicalDevice,
982
MVKPhysicalDeviceMetalFeatures* pMetalFeatures,
983
size_t* pMetalFeaturesSize);
984
985
/**
986
* Populates the pPerf structure with the current performance statistics for the device.
987
*
988
* If you are linking to an implementation of MoltenVK that was compiled from a different
989
* VK_MVK_MOLTENVK_SPEC_VERSION than your app was, the size of the MVKPerformanceStatistics
990
* structure in your app may be larger or smaller than the same struct as expected by MoltenVK.
991
*
992
* When calling this function, set the value of *pPerfSize to sizeof(MVKPerformanceStatistics),
993
* to tell MoltenVK the limit of the size of your MVKPerformanceStatistics structure. Upon return
994
* from this function, the value of *pPerfSize will hold the actual number of bytes copied into
995
* your passed MVKPerformanceStatistics structure, which will be the smaller of what your app
996
* thinks is the size of MVKPerformanceStatistics, and what MoltenVK thinks it is. This
997
* represents the safe access area within the structure for both MoltenVK and your app.
998
*
999
* If the size that MoltenVK expects for MVKPerformanceStatistics is different than the value passed
1000
* in *pPerfSize, this function will return VK_INCOMPLETE, otherwise it will return VK_SUCCESS.
1001
*
1002
* Although it is not necessary, you can use this function to determine in advance the value
1003
* that MoltenVK expects the size of MVKPerformanceStatistics to be by setting the value of
1004
* pPerf to NULL. In that case, this function will set *pPerfSize to the size that MoltenVK
1005
* expects MVKPerformanceStatistics to be.
1006
*
1007
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1008
* The VkDevice object you provide here must have been retrieved directly from
1009
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1010
* objects are often changed by layers, and passing them from one layer to another,
1011
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1012
*/
1013
VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceStatisticsMVK(
1014
VkDevice device,
1015
MVKPerformanceStatistics* pPerf,
1016
size_t* pPerfSize);
1017
1018
/**
1019
* Returns a human readable version of the MoltenVK and Vulkan versions.
1020
*
1021
* This function is provided as a convenience for reporting. Use the MVK_VERSION,
1022
* VK_API_VERSION_1_0, and VK_HEADER_VERSION macros for programmatically accessing
1023
* the corresponding version numbers.
1024
*/
1025
VKAPI_ATTR void VKAPI_CALL vkGetVersionStringsMVK(
1026
char* pMoltenVersionStringBuffer,
1027
uint32_t moltenVersionStringBufferLength,
1028
char* pVulkanVersionStringBuffer,
1029
uint32_t vulkanVersionStringBufferLength);
1030
1031
/**
1032
* Sets the number of threads in a workgroup for a compute kernel.
1033
*
1034
* This needs to be called if you are creating compute shader modules from MSL
1035
* source code or MSL compiled code. Workgroup size is determined automatically
1036
* if you're using SPIR-V.
1037
*
1038
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1039
* The VkShaderModule object you provide here must have been retrieved directly from
1040
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1041
* objects are often changed by layers, and passing them from one layer to another,
1042
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1043
*/
1044
VKAPI_ATTR void VKAPI_CALL vkSetWorkgroupSizeMVK(
1045
VkShaderModule shaderModule,
1046
uint32_t x,
1047
uint32_t y,
1048
uint32_t z);
1049
1050
#ifdef __OBJC__
1051
1052
/**
1053
* Returns, in the pMTLDevice pointer, the MTLDevice used by the VkPhysicalDevice.
1054
*
1055
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1056
* The VkPhysicalDevice object you provide here must have been retrieved directly from
1057
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1058
* objects are often changed by layers, and passing them from one layer to another,
1059
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1060
*/
1061
VKAPI_ATTR void VKAPI_CALL vkGetMTLDeviceMVK(
1062
VkPhysicalDevice physicalDevice,
1063
id<MTLDevice>* pMTLDevice);
1064
1065
/**
1066
* Sets the VkImage to use the specified MTLTexture.
1067
*
1068
* Any differences in the properties of mtlTexture and this image will modify the
1069
* properties of this image.
1070
*
1071
* If a MTLTexture has already been created for this image, it will be destroyed.
1072
*
1073
* Returns VK_SUCCESS.
1074
*
1075
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1076
* The VkImage object you provide here must have been retrieved directly from
1077
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1078
* objects are often changed by layers, and passing them from one layer to another,
1079
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1080
*/
1081
VKAPI_ATTR VkResult VKAPI_CALL vkSetMTLTextureMVK(
1082
VkImage image,
1083
id<MTLTexture> mtlTexture);
1084
1085
/**
1086
* Returns, in the pMTLTexture pointer, the MTLTexture currently underlaying the VkImage.
1087
*
1088
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1089
* The VkImage object you provide here must have been retrieved directly from
1090
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1091
* objects are often changed by layers, and passing them from one layer to another,
1092
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1093
*/
1094
VKAPI_ATTR void VKAPI_CALL vkGetMTLTextureMVK(
1095
VkImage image,
1096
id<MTLTexture>* pMTLTexture);
1097
1098
/**
1099
* Returns, in the pMTLBuffer pointer, the MTLBuffer currently underlaying the VkBuffer.
1100
*
1101
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1102
* The VkBuffer object you provide here must have been retrieved directly from
1103
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1104
* objects are often changed by layers, and passing them from one layer to another,
1105
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1106
*/
1107
VKAPI_ATTR void VKAPI_CALL vkGetMTLBufferMVK(
1108
VkBuffer buffer,
1109
id<MTLBuffer>* pMTLBuffer);
1110
1111
/**
1112
* Indicates that a VkImage should use an IOSurface to underlay the Metal texture.
1113
*
1114
* If ioSurface is not null, it will be used as the IOSurface, and any differences
1115
* in the properties of that IOSurface will modify the properties of this image.
1116
*
1117
* If ioSurface is null, this image will create and use an IOSurface
1118
* whose properties are compatible with the properties of this image.
1119
*
1120
* If a MTLTexture has already been created for this image, it will be destroyed.
1121
*
1122
* IOSurfaces are supported on the following platforms:
1123
* - macOS 10.11 and above
1124
* - iOS 11.0 and above
1125
*
1126
* To enable IOSurface support, ensure the Deployment Target build setting
1127
* (MACOSX_DEPLOYMENT_TARGET or IPHONEOS_DEPLOYMENT_TARGET) is set to at least
1128
* one of the values above when compiling MoltenVK, and any app that uses MoltenVK.
1129
*
1130
* Returns:
1131
* - VK_SUCCESS.
1132
* - VK_ERROR_FEATURE_NOT_PRESENT if IOSurfaces are not supported on the platform.
1133
* - VK_ERROR_INITIALIZATION_FAILED if ioSurface is specified and is not compatible with this VkImage.
1134
*
1135
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1136
* The VkImage object you provide here must have been retrieved directly from
1137
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1138
* objects are often changed by layers, and passing them from one layer to another,
1139
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1140
*/
1141
VKAPI_ATTR VkResult VKAPI_CALL vkUseIOSurfaceMVK(
1142
VkImage image,
1143
IOSurfaceRef ioSurface);
1144
1145
/**
1146
* Returns, in the pIOSurface pointer, the IOSurface currently underlaying the VkImage,
1147
* as set by the useIOSurfaceMVK() function, or returns null if the VkImage is not using
1148
* an IOSurface, or if the platform does not support IOSurfaces.
1149
*
1150
* This function is not supported by the Vulkan SDK Loader and Layers framework.
1151
* The VkImage object you provide here must have been retrieved directly from
1152
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
1153
* objects are often changed by layers, and passing them from one layer to another,
1154
* or from a layer directly to MoltenVK, will result in undefined behaviour.
1155
*/
1156
VKAPI_ATTR void VKAPI_CALL vkGetIOSurfaceMVK(
1157
VkImage image,
1158
IOSurfaceRef* pIOSurface);
1159
1160
#endif // __OBJC__
1161
1162
1163
#pragma mark -
1164
#pragma mark Shaders
1165
1166
/**
1167
* NOTE: Shader code should be submitted as SPIR-V. Although some simple direct MSL shaders may work,
1168
* direct loading of MSL source code or compiled MSL code is not officially supported at this time.
1169
* Future versions of MoltenVK may support direct MSL submission again.
1170
*
1171
* Enumerates the magic number values to set in the MVKMSLSPIRVHeader when
1172
* submitting a SPIR-V stream that contains either Metal Shading Language source
1173
* code or Metal Shading Language compiled binary code in place of SPIR-V code.
1174
*/
1175
typedef enum {
1176
kMVKMagicNumberSPIRVCode = 0x07230203, /**< SPIR-V stream contains standard SPIR-V code. */
1177
kMVKMagicNumberMSLSourceCode = 0x19960412, /**< SPIR-V stream contains Metal Shading Language source code. */
1178
kMVKMagicNumberMSLCompiledCode = 0x19981215, /**< SPIR-V stream contains Metal Shading Language compiled binary code. */
1179
} MVKMSLMagicNumber;
1180
1181
/**
1182
* NOTE: Shader code should be submitted as SPIR-V. Although some simple direct MSL shaders may work,
1183
* direct loading of MSL source code or compiled MSL code is not officially supported at this time.
1184
* Future versions of MoltenVK may support direct MSL submission again.
1185
*
1186
* Describes the header at the start of an SPIR-V stream, when it contains either
1187
* Metal Shading Language source code or Metal Shading Language compiled binary code.
1188
*
1189
* To submit MSL source code to the vkCreateShaderModule() function in place of SPIR-V
1190
* code, prepend a MVKMSLSPIRVHeader containing the kMVKMagicNumberMSLSourceCode magic
1191
* number to the MSL source code. The MSL source code must be null-terminated.
1192
*
1193
* To submit MSL compiled binary code to the vkCreateShaderModule() function in place of
1194
* SPIR-V code, prepend a MVKMSLSPIRVHeader containing the kMVKMagicNumberMSLCompiledCode
1195
* magic number to the MSL compiled binary code.
1196
*
1197
* In both cases, the pCode element of VkShaderModuleCreateInfo should pointer to the
1198
* location of the MVKMSLSPIRVHeader, and the MSL code should start at the byte immediately
1199
* after the MVKMSLSPIRVHeader.
1200
*
1201
* The codeSize element of VkShaderModuleCreateInfo should be set to the entire size of
1202
* the submitted code memory, including the additional sizeof(MVKMSLSPIRVHeader) bytes
1203
* taken up by the MVKMSLSPIRVHeader, and, in the case of MSL source code, including
1204
* the null-terminator byte.
1205
*/
1206
typedef uint32_t MVKMSLSPIRVHeader;
1207
1208
1209
#endif // VK_NO_PROTOTYPES
1210
1211
1212
#ifdef __cplusplus
1213
}
1214
#endif // __cplusplus
1215
1216
#endif
1217
1218