60 Commits

Author SHA1 Message Date
Bill Hollings
4893f78b29 Identify each unsupported device feature flag that the app attempts to be enable.
- Make MVKDevice::enableFeatures() functions into templates to pass struct type.
- Add mvkGetAddressOfFirstMember() to retrieve the address of the first member of
  a struct, taking into consideration whether the struct has a Vulkan pNext member.
- Add mvk::getTypeName() and mvk::getOrdinalSuffix() string functions.
2023-05-15 15:14:30 -04:00
Bill Hollings
5092330273 Support BC compression on iOS/tvOS, where available.
- Add MVK_XCODE_14_3 macro to compile for iOS/tvOS 16.4 and above.
- Add support for BC compression on iOS/tvOS 16.4 and above where supported.
- Consolidate MVKPixelFormats::modifyMTLFormatCapabilities(mtlDev)
  and centralize querying MTLDevice format methods for all platforms.
2023-04-12 11:50:09 -04:00
Bill Hollings
cd8d0c30bb Add support for VK_EXT_external_memory_host extension.
- To expose host memory page size, add mvkGetHostMemoryPageSize() and
  MVKPhysicalDeviceMetalFeatures::hostMemoryPageSize.
- MVKPhysicalDevice::getProperties() sort EXT property structs alphabetically (unrelated).
- MVKExtensions.def fix alignment in OS versions (unrelated).
2023-03-19 22:53:36 -04:00
Bill Hollings
12592abbc9 Update copyright notices to year 2023. 2023-01-13 12:19:37 -05:00
Bill Hollings
682906976d Fix linking issues with dynamic Vulkan functions.
- Ensure Vulkan public symbols are not stripped from the library when
  statically linked to an app that calls all Vulkan functions dynamically.
- Per Vulkan 1.2 spec, support calling vkGetInstanceProcAddr() with a
  null instance, when vkGetInstanceProcAddr itself is the function name.
- Replace uses of strcmp() with mvkStringsAreEqual() to protect against
  null pointers, and provide a direct bool output (unrelated cleanup).
2023-01-10 07:22:05 -05:00
sean
83c0ca60fb
Add support for KHR_buffer_device_address 2022-06-16 17:32:25 +02:00
Bill Hollings
16408fd6ae Remove logged warning if MoltenVK does not support VkApplicationInfo::apiVersion value.
Update MoltenVK version to 1.1.8.
Minor spelling fixes in comments.
2022-02-09 13:36:08 -05:00
Nikita Fediuchin
4efb90b3c1 Update license year 2022-02-04 13:33:27 +02:00
Bill Hollings
52568efb27 Optionally hide additional static Vulkan linkage symbols.
Move the aliasing of promoted function pointers to the function pointer
lookup collection, because non-global function alias symbols are not
available in separately compiled object file.

Add public aliased Vulkan extension functions that were promoted to 1.1 to
the public symbols that are hidden when MVK_HIDE_VULKAN_SYMBOLS is enabled.

Add functions from the private VK_MVK_moltenvk extension that depend on
Vulkan object handles to the public symbols that are hidden when
MVK_HIDE_VULKAN_SYMBOLS is enabled, to discourage their use by apps that
are using the Vulkan Loader and Layers, because they are not supported by
the Vulkan Loader and Layers.

Update VK_MVK_MOLTENVK_SPEC_VERSION to version 33.
2021-12-18 14:00:37 -05:00
Nikita Fediuchin
6ac92fbacf Clean up MVKLogging
* Replaced ASL levels with MVKConfigLogLevel.
* Moved MVKLogging.h to Utility/ directory.
* Added MVKConfigLogLevel Warning and Debug levels.
2021-11-25 09:47:43 +02:00
Bill Hollings
5de7f5551c Support building MoltenVK with static Vulkan linkage symbols hidden.
Add build environment variable MVK_HIDE_VULKAN_SYMBOLS. to allow MoltenVK
to be built with static Vulkan API symbols hidden, to avoid library linking
conflicts when bound to a Vulkan Loader that also exports identical symbols.

The default value of MVK_HIDE_VULKAN_SYMBOLS is 0,
meaning Vulkan static symbols are exposed by default.

Add MVK_PUBLIC_VULKAN_SYMBOL directive to mark each Vulkan call symbols
for exporting or hiding.

Update the MoltenVK Xcode project to add the MVK_HIDE_VULKAN_SYMBOLS build
setting, and set the ENABLE_TESTABILITY build setting to NO, because it
conflicts with stripping symbols.

Update MoltenVK version to 1.1.7.
2021-11-17 18:22:33 -05:00
Nikita Fediuchin
c8813898cf Add MVKLogWarning, apiVersion warning
* Added MVKLogWarning logger, and updated header comments.
* Added greater _appInfo.apiVersion  than MoltenVK version warning.
2021-10-04 12:03:36 +03:00
Bill Hollings
6b502bcb60 Upgrade projects to Xcode 13 SDK APIs.
Add MVK_XCODE_13 code macro.
Support MTLLanguageVersion2_4 enum value.
MoltenVKPackaging project add DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING
build setting to suppress build warnings about using manual build orders.
2021-06-14 16:24:32 -04:00
Bill Hollings
cfc2556c31 Fix use of VkFlags in MVKConfiguration enumerated values.
MVKConfigLogLevel, MVKConfigTraceVulkanCalls, and MVKConfigAutoGPUCaptureScope
do not need to be VkFlags, since they aren't bitwise flags.

MVK_SET_FROM_ENV_OR_BUILD_INT32 supports setting enumerated values.
2021-03-10 09:26:59 -05:00
Bill Hollings
8e610a43a8 Support configuring supported Vulkan API version.
Add MVKConfiguration::apiVersionToAdvertise and MVK_CONFIG_API_VERSION_TO_ADVERTISE
env var to configure MoltenVK to advertise a particular Vulkan version.

Advertise MVKConfiguration::apiVersionToAdvertise in:
  vkEnumerateInstanceVersion()
  vkGetPhysicalDeviceProperties()
  vkEnumerateInstanceLayerProperties()
  vkEnumerateDeviceLayerProperties()

Add MVKConfiguration::advertiseExtensions and MVK_CONFIG_ADVERTISE_EXTENSIONS
env var to configure MoltenVK to not advertise support for any Vulkan  extensions.
Refactor population of MVKConfiguration from environment variables to better
support validating and baking config values set by app.
Update MoltenVK version to 1.1.3.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 31.
2021-02-24 16:32:14 -05:00
Bill Hollings
4675481a06 Redefine derivations of MVK_APPLE_SILICON, MVK_MACOS_APPLE_SILICON, and MVK_XCODE_12.
Derive MVK_APPLE_SILICON from target CPU.
Derive MVK_MACOS_APPLE_SILICON from target CPU and macOS platform.
Derive MVK_XCODE_12 from macOS and iOS SDK versions.
Test for simulator on non-Apple GPU using MVK_OS_SIMULATOR && !MVK_APPLE_SILICON.
2021-02-20 09:33:32 -05:00
Bill Hollings
e1b3585413 Add MVK_APPLE_SILICON macro definition.
Use MVK_APPLE_SILICON instead of
MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON or
MVK_MACOS_APPLE_SILICON || MVK_IOS_OR_TVOS.
2021-01-21 16:53:17 -05:00
Bill Hollings
015031c955 Update copyright notices to year 2021 and Xcode build settings check to Xcode 12.3. 2021-01-21 13:37:07 -05:00
Bill Hollings
7f62362db3 Fixes from review for Mac Catalyst on macOS 11.0+.
MVKPixelFormats revert testing for stencil feedback and add Mac Catalyst test.
Revert mvkOSVersionIsAtLeast(mac, ios) to remove test for Mac Catalyst version.
MVKRenderPass revert testing for MTLStorageModeMemoryless for iOS.
2020-12-02 16:22:38 -05:00
Bill Hollings
1ec58c9a92 Support building for Mac Catalyst on macOS 11.0+.
Define MVK_MACCAT build macro and use it to conditionally compile code to align
with build features and capabilities of Mac Catalyst platform on macOS 11.0+.
Treat Mac Catalyst as minor variation of macOS 11.0.
Update documentation.

Currently only support Mac Catalyst on macOS 11.0+, to avoid complexities of
deselecting iOS features and capabilities for Mac Catalyst on previous macOS versions.

Mac Catalyst (and Simulators) require use of XCFrameworks.
Currently unable to generate a dylib for Mac Catalyst.
2020-12-01 19:26:15 -05:00
Chip Davis
d73017f4db MVKDevice: Set properties for Apple Silicon GPUs on macOS. 2020-10-28 19:35:24 -05:00
Chip Davis
2c40e39699 Fix aliases on ARM64.
The semicolon is the comment character in ARM64 assembly. Just put the
alias symbol definition on another line.
2020-09-10 20:21:02 -05:00
Chip Davis
78963db6cc Export core names of Vulkan 1.1 calls promoted from extensions.
The functions are now defined under their core names. To avoid code
bloat, I've defined the suffixed names as aliases of the core names.
Both symbols will be globally defined with the same value, and in the
dylib both will be exported.

Fix the default API version when none is given. Zero is the same as
`VK_API_VERSION_1_0`. Prior to this, we were overwriting it with zero if
no app info were given, or if it were zero in the app info. It wasn't
important before, but now that we gate API availability on maximum
Vulkan version, we need to make sure it's a valid version.
2020-09-08 13:22:17 -05:00
Bill Hollings
72c4ba1118 Remove unneeded MVK_IOS_SIMULATOR and MVK_TVOS_SIMULATOR macros. 2020-07-17 22:18:08 -04:00
Bill Hollings
40d3485cec Remove unneeded switch default for MTLLanguageVersion.
Minor doc fixes from PR review.
2020-06-24 17:04:30 -04:00
Bill Hollings
7910f43867 MVKPixelFormats reduce some MTLPixelFormat capabilities for simulators.
Add MVK_IOS_SIMULATOR and MVK_TVOS_SIMULATOR macros.
MVKPixelFormats add disableMTLPixelFormatCapabilities().
MVKPixelFormats add disableAllMTLPixelFormatCapabilities().
2020-06-22 23:52:51 -04:00
Bill Hollings
72517a2474 Cleanup tvOS build warnings.
Use platform macros to conditionally build outstanding tvOS code.
Log validation error message when tvOS code doesn't support expected functionality.
2020-06-22 21:55:51 -04:00
Bill Hollings
37e8e3182c Redefine MoltenVK platform macros in terms of newer Apple target conditionals. 2020-06-22 21:37:30 -04:00
Aman Gupta
b8fb92a9e3 oops forgot this return 2020-06-18 16:36:45 -07:00
Aman Gupta
bdff52283d remove !MVK_TVOS usage 2020-06-17 17:14:31 -07:00
Aman Gupta
e847fb38e9 fix some missing return warnings 2020-06-17 14:46:06 -07:00
Aman Gupta
7392e23db2 unncessary change in the diff 2020-06-17 10:30:41 -07:00
Aman Gupta
a0e357fab5 Merge remote-tracking branch 'upstream/master' into tvos 2020-06-17 10:05:40 -07:00
Aman Gupta
9694169da6 split out MVK_IOS_OR_TVOS 2020-06-15 16:36:05 -07:00
Aman Gupta
b250212c6f add MVK_TVOS and start conditionalizing build failures 2020-06-15 16:21:13 -07:00
Bill Hollings
dd98fbd26f Remove use of @available() directive as it can cause issues in some build environments.
Generally replace use of @available() with respondsToSelector:.
Add mvkMakeOSVersion() and mvkOSVersionIsAtLeast(macos,ios) to help testing OS versions.
Set maxDrawIndexedIndexValue to kMVKUndefinedLargeUInt32 instead of uint32_t max.
2020-06-11 12:43:38 -04:00
Chip Davis
9260f5bfd5 MVKDevice: Support capturing GPU traces to a file.
Use MVK_CONFIG_AUTO_GPU_CAPTURE_OUTPUT_FILE to set the destination file.
This is useful for capturing traces where the program in question cannot
be run under Xcode's control; the captured trace can then be inspected
later with Xcode.

This new feature requires Metal 3.0 (macOS 10.15, iOS 13).
2020-04-22 18:38:08 -05:00
Bill Hollings
eb99488f04 Reinstate VulkanSamples API-Samples demo apps.
MVKShaderConverterTool add support to output SPIR-V as header (.h) files.
Add MVKShaderConverterTool Xcode target.
Add MVKShaderConverterTool Package Xcode scheme.
fetchDependencies builds MVKShaderConverterTool and runs
it on shader files in VulkanSamples API-Samples directory.
2020-04-11 16:19:03 -04:00
Bill Hollings
98fadbf68b Fix memory estimates for iOS 13+.
Fix os_proc_available_memory() not being called.
2020-04-02 18:54:22 -04:00
Bill Hollings
5728f50f0f Add mvkOSVersionIsAtLeast() to simplify and standardizing testing OS version. 2020-03-28 20:11:21 -04:00
Bill Hollings
8ec682938b Update copyright to 2020. 2020-01-07 16:47:29 -05:00
Bill Hollings
9b13006018 Support linear filtering when using vkCmdBlitImage().
Fixes linear filtering when using vkCmdBlitImage(), useful for mipmap generation.
Move MVKCmdBlitImage sampler definition to shader as a constexpr sampler,
and ensure mip_filter and filter are set correctly.
Add MVKRPSKeyBlitImg::srcFilter.
Include MVKCommonEnvironment.h in MVKLogging.h.
Update MoltenVK version to 1.0.39.
2019-11-12 16:47:33 -05:00
Bill Hollings
c6ea99e4db Support Metal 3.0.
Merge Metal-3.0 branch into master branch.
Update What's New document with merged features.
2019-10-16 18:26:58 -04:00
Bill Hollings
5c87700732 Reduce memory usage by adjusting default memory allocs for many MVKVectorInline uses.
MVKRenderPass use emplace_back() instead of push_back()
when populating _subpasses  & _attachments vectors.
Add mvkLogSizeOf(T) development debugging function.
2019-10-10 16:46:17 -04:00
Bill Hollings
5c7904c3a7 Add request for feedback from people who reject MoltenVK to README.md document.
Update MoltenVK version to 1.0.38.
2019-09-25 15:41:40 -05:00
Chip Davis
92f0bec6e2 MVKDevice: Report a second heap for non-UMA devices.
This is the heap representing system memory. The memory type
corresponding to `MTLStorageModeShared` is reported as belonging to this
heap.

I've tried to correct the reported size of the heaps as well while I'm
at it. UMA GPUs and the system heap for NUMA GPUs use the system memory
size as the heap size, and the amount of available memory as the budget.
iOS 13 uses the new `os_proc_available_memory()` API for this purpose.
NUMA GPUs additionally use the memory used by the process as a crude
measure of system heap usage.
2019-08-09 11:53:39 -05:00
Bill Hollings
d1a6b5a40d Remove exposure to leakable instances of NSString, NSArray & NSDictionary.
Reduce creation of autoreleased instances of NSString, NSArray & NSDictionary.
Ensure remaining are covered by deliberate autorelease pools.
2019-07-15 18:59:52 -04:00
Bill Hollings
173d8cc5f3 Add support for the VK_EXT_debug_report extension.
Add MVKDebugReportCallback class.
Add MVKVulkanAPIObject class as base class of classes exposed in Vulkan API.
Remove MVKRefCountedDeviceObject class and move ref-counting to MVKVulkanAPIObject.
Rename MVKDispatchableObject class to MVKDispatchableVulkanAPIObject.
Introduce multiple inheritance mixin classes into class hierarchy.
Add MVKBaseObject::getVulkanAPIObject() function to find Vulkan API object
controlling any subobject that needs to report something.
MVKCommandResourceFactory functions pass in calling object for reporting.
Add MVKBaseObject::reportMessage() & reportError() functions.
Replace mvkNotifyErrorWithText() static function with reportError()
instance function to allow access to debug reporting.
Redefine MVKLog*() functions to call reportError() instance method.
Delete MVKLogging.cpp.
Remove MVKLogging.h from MoltenVKShaderConverter project.
Add mvk_datatypes.hpp to redirect errors in mvk_datatypes.h functions to debug
reporting. Use mvk_datatypes.hpp internally for all references to these functions.
Convert several static methods to instance methods.
Refactor platform defines in MVKSurface.h.
Explicitly count MVKExtensionList extension count to avoid relying on struct size.
Remove MVKCommandBuffer::recordResult() and use setConfigurationResult().
Change log indication of error in logs from [***MoltenVK ERROR***] to [mvk-error],
for consistency with other log level indications.
Update MoltenVK version to 1.0.35.
2019-05-01 22:27:03 -04:00
Bill Hollings
ebce19b0b7 Add MoltenVKShaderConverter tool option to log shader conversion performance.
Move MVKOSExtension.h/mm to from MoltenVK to Common
and move MTLDevice functions to MVKDevice.
2019-04-11 14:26:35 -04:00
Bill Hollings
0984b11bc0 Set MSL version for shader compiling from Metal feature set.
Add MVKPhysicalDeviceMetalFeatures::mslVersionEnum and set from Metal feature sets.
Derive MVKPhysicalDeviceMetalFeatures:: mslVersion from mslVersionEnum.
MVKDevice::getMTLCompileOptions() sets MTLCompileOptions::languageVersion
from MVKPhysicalDeviceMetalFeatures::mslVersionEnum.
MVKAssert logs error even when assertions disabled.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 18.
2019-02-25 18:11:47 -05:00