Skip to content

Commit

Permalink
Merge pull request #77 from billhollings/master
Browse files Browse the repository at this point in the history
Fixes for issues #73 & #76.
  • Loading branch information
billhollings committed Mar 2, 2018
2 parents 2e45073 + 754cc10 commit 3f9e8bc
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 24 deletions.
19 changes: 16 additions & 3 deletions Docs/MoltenVK_Runtime_UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Table of Contents
- [About **MoltenVK**](#about_moltenvk)
- [Running the **MoltenVK** Demo Applications](#demos)
- [Installing **MoltenVK** in Your *Vulkan* Application](#install)
- [Build and Runtime Requirements](#requirements)
- [Install as Static Library Framework](#install_static_lib)
- [Install as Dynamic Library](#install_dynamic_lib)
- [Interacting with the **MoltenVK** Runtime](#interaction)
Expand Down Expand Up @@ -95,9 +96,21 @@ features by modifying *Xcode* build settings. All of this is explained in the
Installing **MoltenVK** in Your *Vulkan* Application
----------------------------------------------------

>***Note:*** **MoltenVK** can be run on *iOS 9* and *macOS 11.0* devices,
but it does reference advanced OS frameworks during building. *Xcode 9*
or above is required to build and link **MoltenVK** projects.
<a name="requirements"></a>
### Build and Runtime Requirements

At development time, **MoltenVK** references advanced OS frameworks during building.

- *Xcode 9* or above is required to build and link **MoltenVK** projects.

Once built, **MoltenVK** can be run on *iOS* or *macOS* devices that support *Metal*.

- **MoltenVK** requires at least *macOS 10.11* or *iOS 9*.
- Information on *macOS* devices that are compatible with *Metal* can be found in
[this article](http://www.idownloadblog.com/2015/06/22/how-to-find-mac-el-capitan-metal-compatible).
- Information on compatible *iOS* devices that are compatible with *Metal* can be found in
[this article](https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/HardwareGPUInformation/HardwareGPUInformation.html).


<a name="install_static_lib"></a>
### Install as Static Library Framework
Expand Down
5 changes: 5 additions & 0 deletions External/makeSPIRVTools
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
# macOS usage: ./makeSPIRVTools

# Build SPIRV-Tools

echo
echo MoltenVK building SPIRV-Tools
echo

ln -sfn ../../SPIRV-Headers SPIRV-Tools/external/SPIRV-Headers
rm -rf SPIRV-Tools/build
mkdir SPIRV-Tools/build
Expand Down
10 changes: 10 additions & 0 deletions External/makeVulkanSpec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
MVK_EXTS="VK_KHR_swapchain VK_KHR_surface VK_MVK_ios_surface VK_MVK_macos_surface VK_IMG_format_pvrtc VK_AMD_negative_viewport_height"

# Generate vulkan.hpp and consolidate all header files

echo
echo MoltenVK building vulkan.h
echo

cd Vulkan-Hpp
cmake .
make
Expand All @@ -20,6 +25,11 @@ cp Vulkan-Docs/src/vulkan/*.h vulkan
cd -

# Generate the Vulkan Spec document

echo
echo MoltenVK building Vulkan spec document
echo

cd Vulkan-Hpp/Vulkan-Docs/doc/specs/vulkan
make clean_generated
make EXTENSIONS="$MVK_EXTS" APITITLE="(with extensions supported by MoltenVK)" html
Expand Down
5 changes: 5 additions & 0 deletions External/makeglslang
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
# macOS usage: ./makeglslang

# Build glslang

echo
echo MoltenVK building glslang
echo

rm -rf glslang/build
mkdir glslang/build
cd glslang/build
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@
case VK_SHADER_STAGE_FRAGMENT_BIT: return &_fragmentPushConstants;
case VK_SHADER_STAGE_COMPUTE_BIT: return &_computePushConstants;
default:
MVKAssert(false, "Invalid shader stage: %lu", shaderStage);
MVKAssert(false, "Invalid shader stage: %u", shaderStage);
return VK_NULL_HANDLE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/Commands/MVKMTLBufferAllocation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
#pragma mark MVKMTLBufferAllocator

const MVKMTLBufferAllocation* MVKMTLBufferAllocator::acquireMTLBufferRegion(NSUInteger length) {
MVKAssert(length <= _maxAllocationLength, "This MVKMTLBufferAllocator has been configured to dispense MVKMTLBufferRegions no larger than %llu bytes.", _maxAllocationLength);
MVKAssert(length <= _maxAllocationLength, "This MVKMTLBufferAllocator has been configured to dispense MVKMTLBufferRegions no larger than %lu bytes.", (unsigned long)_maxAllocationLength);

// Convert max length to the next power-of-two exponent to use as a lookup
uint32_t p2Exp = mvkPowerOfTwoExponent(length);
Expand Down
10 changes: 5 additions & 5 deletions MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,11 @@
resetIOSurface();

if (ioSurface) {
if (IOSurfaceGetWidth(ioSurface) != _extent.width) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface width %d does not match VkImage width %d.", IOSurfaceGetWidth(ioSurface), _extent.width); }
if (IOSurfaceGetHeight(ioSurface) != _extent.height) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface height %d does not match VkImage height %d.", IOSurfaceGetHeight(ioSurface), _extent.height); }
if (IOSurfaceGetBytesPerElement(ioSurface) != mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat)) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface bytes per element %d does not match VkImage bytes per element %d.", IOSurfaceGetBytesPerElement(ioSurface), mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat)); }
if (IOSurfaceGetElementWidth(ioSurface) != mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).width) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface element width %d does not match VkImage element width %d.", IOSurfaceGetElementWidth(ioSurface), mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).width); }
if (IOSurfaceGetElementHeight(ioSurface) != mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).height) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface element height %d does not match VkImage element height %d.", IOSurfaceGetElementHeight(ioSurface), mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).height); }
if (IOSurfaceGetWidth(ioSurface) != _extent.width) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface width %zu does not match VkImage width %d.", IOSurfaceGetWidth(ioSurface), _extent.width); }
if (IOSurfaceGetHeight(ioSurface) != _extent.height) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface height %zu does not match VkImage height %d.", IOSurfaceGetHeight(ioSurface), _extent.height); }
if (IOSurfaceGetBytesPerElement(ioSurface) != mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat)) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface bytes per element %zu does not match VkImage bytes per element %d.", IOSurfaceGetBytesPerElement(ioSurface), mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat)); }
if (IOSurfaceGetElementWidth(ioSurface) != mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).width) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface element width %zu does not match VkImage element width %d.", IOSurfaceGetElementWidth(ioSurface), mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).width); }
if (IOSurfaceGetElementHeight(ioSurface) != mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).height) { return mvkNotifyErrorWithText(VK_ERROR_INITIALIZATION_FAILED, "vkUseIOSurfaceMVK() : IOSurface element height %zu does not match VkImage element height %d.", IOSurfaceGetElementHeight(ioSurface), mvkMTLPixelFormatBlockTexelSize(_mtlPixelFormat).height); }

_ioSurface = ioSurface;
CFRetain(_ioSurface);
Expand Down
4 changes: 2 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKSync.mm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
// MVKLogDebug("Waiting on semaphore %p for max timeout %llu. Elapsed time: %.6f ms.", this, timeout, mvkGetElapsedMilliseconds());
bool isDone = _blocker.wait(timeout, true);
// MVKLogDebug("Done waiting on semaphore %p. Elapsed time: %.6f ms.", this, mvkGetElapsedMilliseconds());
if ( !isDone && timeout > 0 ) { mvkNotifyErrorWithText(VK_TIMEOUT, "Vulkan semaphore timeout after %d nanoseconds.", timeout); }
if ( !isDone && timeout > 0 ) { mvkNotifyErrorWithText(VK_TIMEOUT, "Vulkan semaphore timeout after %llu nanoseconds.", timeout); }
return isDone;
}

Expand Down Expand Up @@ -176,7 +176,7 @@

bool MVKFenceSitter::wait(uint64_t timeout) {
bool isDone = _blocker.wait(timeout);
if ( !isDone && timeout > 0 ) { mvkNotifyErrorWithText(VK_TIMEOUT, "Vulkan fence timeout after %d nanoseconds.", timeout); }
if ( !isDone && timeout > 0 ) { mvkNotifyErrorWithText(VK_TIMEOUT, "Vulkan fence timeout after %llu nanoseconds.", timeout); }
return isDone;
}

Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ MVK_PUBLIC_SYMBOL MTLPixelFormat mvkMTLPixelFormatFromVkFormat(VkFormat vkFormat
errMsg += (fmtDescSubs.vkName) ? fmtDescSubs.vkName : to_string(fmtDescSubs.vk);
errMsg += " instead.";
}
mvkNotifyErrorWithText(VK_ERROR_FORMAT_NOT_SUPPORTED, errMsg.c_str());
mvkNotifyErrorWithText(VK_ERROR_FORMAT_NOT_SUPPORTED, "%s", errMsg.c_str());
}

return mtlPixFmt;
Expand Down
2 changes: 1 addition & 1 deletion MoltenVKPackaging.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\n# Package folder\nexport MVK_WKSPC_PATH=\"${PROJECT_DIR}\"\nexport MVK_PKG_LOCN=\"${MVK_WKSPC_PATH}/Package\"\nexport MVK_PKG_CONFIG_PATH=\"${MVK_PKG_LOCN}/${CONFIGURATION}\"\n\n# Copy the docs\ncp -a \"${MVK_WKSPC_PATH}/LICENSE\" \"${MVK_PKG_CONFIG_PATH}\"\ncp -pRLf \"${MVK_WKSPC_PATH}/Docs\" \"${MVK_PKG_CONFIG_PATH}\"\n\n";
shellScript = "set -e\n\n# Package folder\nexport MVK_WKSPC_PATH=\"${PROJECT_DIR}\"\nexport MVK_PKG_LOCN=\"${MVK_WKSPC_PATH}/Package\"\nexport MVK_PKG_CONFIG_PATH=\"${MVK_PKG_LOCN}/${CONFIGURATION}\"\n\n# Copy the docs. Allow silent fail if a symlinked doc is not built.\ncp -a \"${MVK_WKSPC_PATH}/LICENSE\" \"${MVK_PKG_CONFIG_PATH}\"\ncp -pRLf \"${MVK_WKSPC_PATH}/Docs\" \"${MVK_PKG_CONFIG_PATH}\" 2> /dev/null || true\n\n";
};
A9FEADD61F3517480010240E /* Package MoltenVK */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,21 @@ Installing **MoltenVK**
this `MoltenVK` repository, and then run the `External/makeAll` script to create necessary
components within the third-party libraries.

1. Ensure you have `python3` and `asciidoctor` installed:
1. Ensure you have `python3` installed:

brew install python3
sudo gem install asciidoctor

2. Recursively clone the `MoltenVK` repository:
2. **_Optional:_** If you want to generate a Vulkan specification document for inclusion
in the final **MoltenVK** distribution package, ensure you have `asciidoctor` installed
(you can skip this otherwise):

brew install asciidoctor

3. Recursively clone the `MoltenVK` repository:

git clone --recursive https://github.com/KhronosGroup/MoltenVK.git

3. Run the third-party build script:
4. Run the third-party build script:

cd MoltenVK/External
./makeAll
Expand Down Expand Up @@ -120,9 +125,7 @@ The updated versions will then be "locked in" the next time the `MoltenVK` repos

This procdure updates all of the Third-Party library submodules. To update only a single submodule,
or for more information about the various Third-Party libraries and submodules used by **MoltenVK**,
please refer to the following documents:

- [`Docs/ThirdPartyConfig.md`](Docs/ThirdPartyConfig.md)
please refer to the [`Docs/ThirdPartyConfig.md`](Docs/ThirdPartyConfig.md) document.



Expand All @@ -134,9 +137,19 @@ Building **MoltenVK**
instructions in the [*Third-Party Components*](#third-party) section above to retrieve
and install the required third-party components.

>***Note:*** At runtime, **MoltenVK** can run on *iOS 9* and *macOS 10.11* devices,
>but it does reference advanced OS frameworks during building. *Xcode 9*
>or above is required to build **MoltenVK**, and build and link **MoltenVK** projects.
At development time, **MoltenVK** references advanced OS frameworks during building.

- *Xcode 9* or above is required to build and link **MoltenVK** projects.

Once built, **MoltenVK** can be run on *iOS* or *macOS* devices that support *Metal*.

- **MoltenVK** requires at least *macOS 10.11* or *iOS 9*.
- Information on *macOS* devices that are compatible with *Metal* can be found in
[this article](http://www.idownloadblog.com/2015/06/22/how-to-find-mac-el-capitan-metal-compatible).
- Information on compatible *iOS* devices that are compatible with *Metal* can be found in
[this article](https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/HardwareGPUInformation/HardwareGPUInformation.html).



The `MoltenVKPackaging.xcodeproj` *Xcode* project contains targets and schemes to build
and package the entire **MoltenVK** runtime distribution package, or to build individual
Expand Down

0 comments on commit 3f9e8bc

Please sign in to comment.