Skip to content

Commit

Permalink
Merge pull request #1726 from billhollings/vulkan-1_2
Browse files Browse the repository at this point in the history
Add support for Vulkan 1.2.
  • Loading branch information
billhollings authored Sep 28, 2022
2 parents 77b3cc0 + e8b32de commit c2e9f1d
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ distribution package, see the main [`README.md`](../README.md) document in the `
About **MoltenVK**
------------------

**MoltenVK** is a layered implementation of [*Vulkan 1.1*](https://www.khronos.org/vulkan)
**MoltenVK** is a layered implementation of [*Vulkan 1.2*](https://www.khronos.org/vulkan)
graphics and compute functionality, that is built on Apple's [*Metal*](https://developer.apple.com/metal)
graphics and compute framework on *macOS*, *iOS*, and *tvOS*. **MoltenVK** allows you to use *Vulkan*
graphics and compute functionality to develop modern, cross-platform, high-performance graphical games
Expand Down
7 changes: 5 additions & 2 deletions Docs/Whats_New.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ Copyright (c) 2015-2022 [The Brenwill Workshop Ltd.](http://www.brenwill.com)



MoltenVK 1.1.12
MoltenVK 1.2.0
--------------

Released TBD

- Add support for _Vulkan 1.2_.
- Add support for extensions:
- `VK_KHR_shader_float_controls`
- `VK_KHR_spirv_1_4`
Expand All @@ -31,8 +32,10 @@ Released TBD
- Fix occassional crash from retention of `MVKSwapchain` for future drawable presentations.
- Fix undefined reference to `vkGetBufferDeviceAddressEXT` when building with `MVK_HIDE_VULKAN_SYMBOLS=1`.
- Update `Makefile` to forward any build setting declared on the command line to Xcode.
- Add _**non-functional** Vulkan 1.3_ core function **_stubs_**, to avoid link errors with some external
libraries that assume _Vulkan 1.3_ linkages from the standard _Vulkan_ header files included with **MoltenVK**.
- Add `MVK_USE_CEREAL` build setting to avoid use of Cereal external library (for pipeline caching).
- `MoltenVKShaderConverter` tool automatically map bindings when converting _GLSL_.
- `MoltenVKShaderConverter` tool automatically maps bindings when converting _GLSL_.
- Update `VK_MVK_MOLTENVK_SPEC_VERSION` to version `36`.


Expand Down
5 changes: 3 additions & 2 deletions MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ typedef unsigned long MTLArgumentBuffersTier;
* - 401215 (version 4.12.15)
*/
#define MVK_VERSION_MAJOR 1
#define MVK_VERSION_MINOR 1
#define MVK_VERSION_PATCH 12
#define MVK_VERSION_MINOR 2
#define MVK_VERSION_PATCH 0

#define MVK_MAKE_VERSION(major, minor, patch) (((major) * 10000) + ((minor) * 100) + (patch))
#define MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH)
Expand Down Expand Up @@ -747,6 +747,7 @@ typedef struct {
* When reading this value, it will be one of the VK_API_VERSION_1_* values, including the latest
* VK_HEADER_VERSION component. When setting this value, it should be set to one of:
*
* VK_API_VERSION_1_2 (equivalent decimal number 4202496)
* VK_API_VERSION_1_1 (equivalent decimal number 4198400)
* VK_API_VERSION_1_0 (equivalent decimal number 4194304)
*
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {

/** Returns whether this binding has a variable descriptor count. */
inline bool hasVariableDescriptorCount() const {
return mvkIsAnyFlagEnabled(_flags, VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT);
return mvkIsAnyFlagEnabled(_flags, VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@
const VkDescriptorBindingFlags* MVKDescriptorSetLayout::getBindingFlags(const VkDescriptorSetLayoutCreateInfo* pCreateInfo) {
for (const auto* next = (VkBaseInStructure*)pCreateInfo->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT: {
auto* pDescSetLayoutBindingFlags = (VkDescriptorSetLayoutBindingFlagsCreateInfoEXT*)next;
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO: {
auto* pDescSetLayoutBindingFlags = (VkDescriptorSetLayoutBindingFlagsCreateInfo*)next;
return pDescSetLayoutBindingFlags->bindingCount ? pDescSetLayoutBindingFlags->pBindingFlags : nullptr;
}
default:
Expand Down Expand Up @@ -468,8 +468,8 @@
const uint32_t* MVKDescriptorPool::getVariableDecriptorCounts(const VkDescriptorSetAllocateInfo* pAllocateInfo) {
for (const auto* next = (VkBaseInStructure*)pAllocateInfo->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT: {
auto* pVarDescSetVarCounts = (VkDescriptorSetVariableDescriptorCountAllocateInfoEXT*)next;
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO: {
auto* pVarDescSetVarCounts = (VkDescriptorSetVariableDescriptorCountAllocateInfo*)next;
return pVarDescSetVarCounts->descriptorSetCount ? pVarDescSetVarCounts->pDescriptorCounts : nullptr;
}
default:
Expand Down Expand Up @@ -809,7 +809,7 @@
if (metalArgBuffSize) {
NSUInteger maxMTLBuffSize = _device->_pMetalFeatures->maxMTLBufferSize;
if (metalArgBuffSize > maxMTLBuffSize) {
setConfigurationResult(reportError(VK_ERROR_FRAGMENTATION_EXT, "vkCreateDescriptorPool(): The requested descriptor storage of %d MB is larger than the maximum descriptor storage of %d MB per VkDescriptorPool.", (uint32_t)(metalArgBuffSize / MEBI), (uint32_t)(maxMTLBuffSize / MEBI)));
setConfigurationResult(reportError(VK_ERROR_FRAGMENTATION, "vkCreateDescriptorPool(): The requested descriptor storage of %d MB is larger than the maximum descriptor storage of %d MB per VkDescriptorPool.", (uint32_t)(metalArgBuffSize / MEBI), (uint32_t)(maxMTLBuffSize / MEBI)));
metalArgBuffSize = maxMTLBuffSize;
}
_metalArgumentBuffer = [getMTLDevice() newBufferWithLength: metalArgBuffSize options: MTLResourceStorageModeShared]; // retained
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ class MVKDevice : public MVKDispatchableVulkanAPIObject {
void updateActivityPerformance(MVKPerformanceTracker& activity, uint64_t startTime, uint64_t endTime);
void getDescriptorVariableDescriptorCountLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayoutSupport* pSupport,
VkDescriptorSetVariableDescriptorCountLayoutSupportEXT* pVarDescSetCountSupport);
VkDescriptorSetVariableDescriptorCountLayoutSupport* pVarDescSetCountSupport);

MVKPhysicalDevice* _physicalDevice = nullptr;
MVKCommandResourceFactory* _commandResourceFactory = nullptr;
Expand Down
10 changes: 5 additions & 5 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3364,8 +3364,8 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope
// Check whether the layout has a variable-count descriptor, and if so, whether we can support it.
for (auto* next = (VkBaseOutStructure*)pSupport->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT: {
auto* pVarDescSetCountSupport = (VkDescriptorSetVariableDescriptorCountLayoutSupportEXT*)next;
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT: {
auto* pVarDescSetCountSupport = (VkDescriptorSetVariableDescriptorCountLayoutSupport*)next;
getDescriptorVariableDescriptorCountLayoutSupport(pCreateInfo, pSupport, pVarDescSetCountSupport);
break;
}
Expand All @@ -3378,16 +3378,16 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope
// Check whether the layout has a variable-count descriptor, and if so, whether we can support it.
void MVKDevice::getDescriptorVariableDescriptorCountLayoutSupport(const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
VkDescriptorSetLayoutSupport* pSupport,
VkDescriptorSetVariableDescriptorCountLayoutSupportEXT* pVarDescSetCountSupport) {
VkDescriptorSetVariableDescriptorCountLayoutSupport* pVarDescSetCountSupport) {
// Assume we don't need this, then set appropriately if we do.
pVarDescSetCountSupport->maxVariableDescriptorCount = 0;

// Look for a variable length descriptor and remember its index.
int32_t varBindingIdx = -1;
for (const auto* next = (VkBaseInStructure*)pCreateInfo->pNext; next; next = next->pNext) {
switch (next->sType) {
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT: {
auto* pDescSetLayoutBindingFlags = (VkDescriptorSetLayoutBindingFlagsCreateInfoEXT*)next;
case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO: {
auto* pDescSetLayoutBindingFlags = (VkDescriptorSetLayoutBindingFlagsCreateInfo*)next;
for (uint32_t bindIdx = 0; bindIdx < pDescSetLayoutBindingFlags->bindingCount; bindIdx++) {
if (mvkIsAnyFlagEnabled(pDescSetLayoutBindingFlags->pBindingFlags[bindIdx], VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT)) {
varBindingIdx = bindIdx;
Expand Down
5 changes: 3 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -402,18 +402,18 @@
#define ADD_INST_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_0, nullptr, nullptr, false)
#define ADD_DVC_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_0, nullptr, nullptr, true)

// Add a core function.
#define ADD_INST_1_1_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_1, nullptr, nullptr, false)
#define ADD_INST_1_3_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_3, nullptr, nullptr, false)
#define ADD_DVC_1_1_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_1, nullptr, nullptr, true)
#define ADD_DVC_1_2_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_2, nullptr, nullptr, true)
#define ADD_DVC_1_3_ENTRY_POINT(func) ADD_ENTRY_POINT(func, VK_API_VERSION_1_3, nullptr, nullptr, true)

// Adds both the 1.1 function and the promoted extension function.
// Add both the promoted core function and the extension function.
#define ADD_INST_1_1_PROMOTED_ENTRY_POINT(func, EXT) \
ADD_INST_1_1_ENTRY_POINT(func); \
ADD_ENTRY_POINT_MAP(func##KHR, func, 0, VK_##EXT##_EXTENSION_NAME, nullptr, false)

// Adds both the 1.1 function and the promoted extension function.
#define ADD_DVC_1_1_PROMOTED_ENTRY_POINT(func, EXT) \
ADD_DVC_1_1_ENTRY_POINT(func); \
ADD_ENTRY_POINT_MAP(func##KHR, func, 0, VK_##EXT##_EXTENSION_NAME, nullptr, true)
Expand All @@ -430,6 +430,7 @@
ADD_DVC_1_3_ENTRY_POINT(func); \
ADD_ENTRY_POINT_MAP(func##suffix, func, 0, VK_##EXT##_EXTENSION_NAME, nullptr, true)

// Add an extension function.
#define ADD_INST_EXT_ENTRY_POINT(func, EXT) ADD_ENTRY_POINT(func, 0, VK_##EXT##_EXTENSION_NAME, nullptr, false)
#define ADD_DVC_EXT_ENTRY_POINT(func, EXT) ADD_ENTRY_POINT(func, 0, VK_##EXT##_EXTENSION_NAME, nullptr, true)

Expand Down
4 changes: 2 additions & 2 deletions MoltenVK/MoltenVK/Utility/MVKEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
#endif

/** Macro to determine the Vulkan version supported by MoltenVK. */
#define MVK_VULKAN_API_VERSION VK_MAKE_VERSION(VK_VERSION_MAJOR(VK_API_VERSION_1_1), \
VK_VERSION_MINOR(VK_API_VERSION_1_1), \
#define MVK_VULKAN_API_VERSION VK_MAKE_VERSION(VK_VERSION_MAJOR(VK_API_VERSION_1_2), \
VK_VERSION_MINOR(VK_API_VERSION_1_2), \
VK_HEADER_VERSION)

/**
Expand Down
4 changes: 2 additions & 2 deletions MoltenVK/MoltenVK/Vulkan/vulkan.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@ MVK_PUBLIC_VULKAN_SYMBOL void vkResetQueryPool(

MVK_PUBLIC_VULKAN_SYMBOL VkResult vkSignalSemaphore(
VkDevice device,
const VkSemaphoreSignalInfoKHR* pSignalInfo) {
const VkSemaphoreSignalInfo* pSignalInfo) {

MVKTraceVulkanCallStart();
auto* mvkSem4 = (MVKTimelineSemaphore*)pSignalInfo->semaphore;
Expand All @@ -2465,7 +2465,7 @@ MVK_PUBLIC_VULKAN_SYMBOL VkResult vkSignalSemaphore(

MVK_PUBLIC_VULKAN_SYMBOL VkResult vkWaitSemaphores(
VkDevice device,
const VkSemaphoreWaitInfoKHR* pWaitInfo,
const VkSemaphoreWaitInfo* pWaitInfo,
uint64_t timeout) {

MVKTraceVulkanCallStart();
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ document in the `Docs` directory.
Introduction to MoltenVK
------------------------

**MoltenVK** is a layered implementation of [*Vulkan 1.1*](https://www.khronos.org/vulkan)
**MoltenVK** is a layered implementation of [*Vulkan 1.2*](https://www.khronos.org/vulkan)
graphics and compute functionality, that is built on Apple's [*Metal*](https://developer.apple.com/metal)
graphics and compute framework on *macOS*, *iOS*, and *tvOS*. **MoltenVK** allows you to use *Vulkan*
graphics and compute functionality to develop modern, cross-platform, high-performance graphical
Expand All @@ -88,7 +88,7 @@ channels, including *Apple's App Store*.
The **MoltenVK** runtime package contains two products:

- **MoltenVK** is a implementation of an almost-complete subset of the
[*Vulkan 1.1*](https://www.khronos.org/vulkan) graphics and compute API.
[*Vulkan 1.2*](https://www.khronos.org/vulkan) graphics and compute API.

- **MoltenVKShaderConverter** converts *SPIR-V* shader code to *Metal Shading Language (MSL)*
shader code, and converts *GLSL* shader source code to *SPIR-V* shader code and/or
Expand Down Expand Up @@ -305,11 +305,11 @@ the contents of that directory out of this **MoltenVK** repository into your own
**MoltenVK** and *Vulkan* Compliance
------------------------------------

**MoltenVK** is designed to be an implementation of a *Vulkan 1.1* subset that runs on *macOS*, *iOS*,
**MoltenVK** is designed to be an implementation of a *Vulkan 1.2* subset that runs on *macOS*, *iOS*,
and *tvOS* platforms by mapping *Vulkan* capability to native *Metal* capability.

The fundamental design and development goal of **MoltenVK** is to provide this capability in a way that
is both maximally compliant with the *Vulkan 1.1* specification, and maximally performant.
is both maximally compliant with the *Vulkan 1.2* specification, and maximally performant.

Such compliance and performance is inherently affected by the capability available through *Metal*, as the
native graphics driver on *macOS*, *iOS*, and *tvOS* platforms. *Vulkan* compliance may fall into one of
Expand Down Expand Up @@ -389,7 +389,7 @@ Property claims.
### *Vulkan* Validation

Despite running on top of *Metal*, **MoltenVK** operates as a *Vulkan* core layer. As such, as per the
error handling guidelines of the [*Vulkan* specification](https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#fundamentals-errors), **MoltenVK** should not perform *Vulkan* validation. When adding functionality
error handling guidelines of the [*Vulkan* specification](https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#fundamentals-errors), **MoltenVK** should not perform *Vulkan* validation. When adding functionality
to **MoltenVK**, avoid adding unnecessary validation code.

Validation and error generation **_is_** appropriate within **MoltenVK** in cases where **MoltenVK** deviates
Expand Down

0 comments on commit c2e9f1d

Please sign in to comment.