diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index fa1947624..76ad81c0a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -134,13 +134,13 @@ jobs:
- name: retrieve VulkanSDK
if: steps.VulkanSDK.outputs.cache-hit != 'true'
run: |
- wget https://sdk.lunarg.com/sdk/download/1.3.280.0/mac/vulkansdk-macos-1.3.280.0.dmg
- sudo hdiutil attach vulkansdk-macos-1.3.280.0.dmg
- sudo /Volumes/vulkansdk-macos-1.3.280.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.ios
- sudo hdiutil detach /Volumes/vulkansdk-macos-1.3.280.0
+ wget https://sdk.lunarg.com/sdk/download/1.3.290.0/mac/vulkansdk-macos-1.3.290.0.dmg
+ sudo hdiutil attach vulkansdk-macos-1.3.290.0.dmg
+ sudo /Volumes/vulkansdk-macos-1.3.290.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root ~/VulkanSDK --accept-licenses --default-answer --confirm-command install com.lunarg.vulkan.ios
+ sudo hdiutil detach /Volumes/vulkansdk-macos-1.3.290.0
- name: build_ios
run: |
- source ~/VulkanSDK/setup-env.sh
- cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0
+ source ~/VulkanSDK/iOS/setup-env.sh
+ cmake -H"." -B"build/ios" -DVKB_BUILD_TESTS=ON -DVKB_BUILD_SAMPLES=ON -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO
cmake --build "build/ios" --target vulkan_samples --config ${{ matrix.build_type }} -- -sdk iphoneos -allowProvisioningUpdates
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 8dc181c83..1de3d7b7e 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -23,6 +23,8 @@ project(vulkan_samples LANGUAGES C CXX)
if(IOS AND CMAKE_VERSION VERSION_LESS 3.20)
message(FATAL_ERROR "Configuring iOS apps requires a minimum CMake version of 3.20")
+elseif(APPLE AND NOT IOS AND CMAKE_VERSION VERSION_LESS 3.17)
+ message(FATAL_ERROR "Configuring Xcode for macOS requires a minimum CMake version of 3.17")
endif()
add_subdirectory(plugins)
@@ -83,8 +85,10 @@ endif()
# Create MSVC project
if(MSVC)
- #Set the working directory to the source of the project so developer dont have to
+ # Set VS startup project, working directory to project root, and command line arguments to default sample
+ set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+ set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "sample hello_triangle")
#Configure output paths
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
@@ -99,28 +103,40 @@ endif()
# Enable building from XCode for IOS
if(IOS)
set(CMAKE_MACOSX_BUNDLE YES)
- set(MACOSX_BUNDLE_GUI_IDENTIFIER com.khronos.vulkansamples)
+ if(NOT DEFINED MACOSX_BUNDLE_GUI_IDENTIFIER)
+ if(${CMAKE_OSX_SYSROOT} STREQUAL "iphoneos" AND DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
+ message(FATAL_ERROR "Building for iOS device with a specified development team requires setting MACOSX_BUNDLE_GUI_IDENTIFIER")
+ else()
+ set(MACOSX_BUNDLE_GUI_IDENTIFIER com.khronos.vulkansamples)
+ endif()
+ endif()
if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
- if(CMAKE_OSX_SYSROOT STREQUAL ios)
- message(FATAL_ERROR "BUILDING for iOS device requires setting the CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM,
- It is safe to build for iossimulator without code signing")
+ if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED)
+ if(${CMAKE_OSX_SYSROOT} STREQUAL "iphoneos")
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "YES")
+ else()
+ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
+ endif()
+ endif()
+ if(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED)
+ message(FATAL_ERROR "Building for iOS with code signing requires setting CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM; note it is safe to build for iOS Simulator without code signing")
else()
- message("Building for ios simulator without a code signing identity; this is allowed, turning off code signing")
- set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO")
+ message(STATUS "Building for iOS device or iOS Simulator without a code signing identity; turning off code signing")
set_target_properties(${PROJECT_NAME} PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY "NO"
)
endif ()
else()
+ message(STATUS "Building for iOS device or iOS Simulator with a code signing identity; turning on code signing")
set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "YES")
set_target_properties(${PROJECT_NAME} PROPERTIES
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "YES"
XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY "YES"
)
endif ()
- find_package(Vulkan COMPONENTS MoltenVK REQUIRED)
- if(${Vulkan_VERSION} VERSION_GREATER_EQUAL 1.3.278)
+ # No need to search for Vulkan package or MoltenVK library, Vulkan cache variables already defined on Apple platforms by global_options.cmake
+ if(Vulkan_LIBRARY AND ${Vulkan_VERSION} VERSION_GREATER_EQUAL 1.3.278)
target_sources(${PROJECT_NAME} PRIVATE
${Vulkan_Target_SDK}/iOS/share/vulkan
)
@@ -145,25 +161,35 @@ if(IOS)
MACOSX_PACKAGE_LOCATION Resources
)
set(FRAMEWORKS_TO_EMBED)
- list(APPEND FRAMEWORKS_TO_EMBED "${Vulkan_MoltenVK_LIBRARY};${Vulkan_LIBRARIES};")
- # trouble is can't turn this on/off if XCode decides to build debug and we're configured for release. Need to revist
- #if(("${VKB_DEBUG}" STREQUAL "ON") OR ("${VKB_VALIDATION_LAYERS}" STREQUAL "ON"))
- list(APPEND FRAMEWORKS_TO_EMBED "${Vulkan_Layer_VALIDATION}")
- #endif ()
+ if(Vulkan_MoltenVK_LIBRARY)
+ list(APPEND FRAMEWORKS_TO_EMBED "${Vulkan_MoltenVK_LIBRARY};")
+ else()
+ message(FATAL_ERROR "Can't find MoltenVK library. Please install the Vulkan SDK or MoltenVK project and set VULKAN_SDK.")
+ endif()
+ if(Vulkan_LIBRARY)
+ list(APPEND FRAMEWORKS_TO_EMBED "${Vulkan_LIBRARY};")
+ endif()
+ if(Vulkan_Layer_VALIDATION)
+ # trouble is can't turn this on/off if XCode decides to build debug and we're configured for release. Need to revist
+ # note the Vulkan validation layer must be present and enabled even in release mode for the shader_debugprintf sample
+ #if(("${VKB_DEBUG}" STREQUAL "ON") OR ("${VKB_VALIDATION_LAYERS}" STREQUAL "ON"))
+ list(APPEND FRAMEWORKS_TO_EMBED "${Vulkan_Layer_VALIDATION}")
+ #endif()
+ endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/ios/Info.plist
+ # These are already defined by the ios Info.plist file specified above
+ #MACOSX_BUNDLE_SHORT_VERSION_STRING 1.0.0
+ #MACOSX_BUNDLE_BUNDLE_VERSION 1.0.0
+ #MACOSX_BUNDLE_BUNDLE_NAME "vulkan samples"
)
set_target_properties(${PROJECT_NAME} PROPERTIES
- BUNDLE_IDENTIFIER com.khronos.vulkansamples
- XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.khronos.vulkansamples
+ XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER ${MACOSX_BUNDLE_GUI_IDENTIFIER}
XCODE_ATTRIBUTE_CLANG_ENABLE_MODULES "YES"
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Automatic" # already default value
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
- MACOSX_BUNDLE_SHORT_VERSION_STRING 1.0.0
- MACOSX_BUNDLE_BUNDLE_VERSION 1.0.0
- MACOSX_BUNDLE_BUNDLE_NAME "vulkan samples"
XCODE_EMBED_FRAMEWORKS "${FRAMEWORKS_TO_EMBED}"
XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY "YES"
XCODE_ATTRIBUTE_SKIP_INSTALL NO
@@ -171,4 +197,10 @@ if(IOS)
XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING NO
XCODE_SCHEME_ARGUMENTS "sample hello_triangle"
)
-endif ()
+elseif(APPLE)
+ # Set Xcode working directory to project root, and command line arguments to default sample
+ set_target_properties(${PROJECT_NAME} PROPERTIES
+ XCODE_SCHEME_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ XCODE_SCHEME_ARGUMENTS "sample hello_triangle"
+ )
+endif()
diff --git a/app/ios/Info.plist b/app/ios/Info.plist
index d97870192..542bd4d5b 100644
--- a/app/ios/Info.plist
+++ b/app/ios/Info.plist
@@ -28,11 +28,15 @@ limitations under the License.
CFBundleIconFile
CFBundleIdentifier
- com.khronos.vulkansamples
+ $(PRODUCT_BUNDLE_IDENTIFIER)
CFBundleInfoDictionaryVersion
6.0
CFBundleLongVersionString
+ CFBundleShortVersionString
+ 1.0.0
+ CFBundleVersion
+ 1.0.0
CFBundleName
vulkan samples
CFBundlePackageType
diff --git a/bldsys/cmake/global_options.cmake b/bldsys/cmake/global_options.cmake
index 467cd3d30..96c7addbf 100644
--- a/bldsys/cmake/global_options.cmake
+++ b/bldsys/cmake/global_options.cmake
@@ -34,9 +34,75 @@ endif()
if(APPLE)
cmake_minimum_required(VERSION 3.24)
set(VKB_ENABLE_PORTABILITY ON CACHE BOOL "Enable portability enumeration and subset features in the framework. This is required to be set when running on Apple platforms." FORCE)
-if(IOS)
- set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
-endif()
+
+ find_package(Vulkan QUIET OPTIONAL_COMPONENTS MoltenVK)
+ if(USE_MoltenVK OR (IOS AND (NOT Vulkan_MoltenVK_FOUND OR (${CMAKE_OSX_SYSROOT} STREQUAL "iphonesimulator" AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64"))))
+ # if using MoltenVK, or MoltenVK for iOS was not found, or using iOS Simulator on x86_64, look for MoltenVK in the Vulkan SDK and MoltenVK project locations
+ if(NOT Vulkan_MoltenVK_LIBRARY)
+ # since both are available in the Vulkan SDK and MoltenVK github project, make sure we look for MoltenVK framework on iOS and dylib on macOS
+ set(_saved_cmake_find_framework ${CMAKE_FIND_FRAMEWORK})
+ if(IOS)
+ set(CMAKE_FIND_FRAMEWORK ALWAYS)
+ else()
+ set(CMAKE_FIND_FRAMEWORK NEVER)
+ endif()
+ find_library(Vulkan_MoltenVK_LIBRARY NAMES MoltenVK HINTS "$ENV{VULKAN_SDK}/lib" "$ENV{VULKAN_SDK}/dynamic" "$ENV{VULKAN_SDK}/dylib/macOS")
+ set(CMAKE_FIND_FRAMEWORK ${_saved_cmake_find_framework})
+ unset(_saved_cmake_find_framework)
+ endif()
+
+ if(Vulkan_MoltenVK_LIBRARY)
+ get_filename_component(MoltenVK_LIBRARY_PATH ${Vulkan_MoltenVK_LIBRARY} DIRECTORY)
+
+ # For both iOS and macOS: set up global Vulkan Library defines so that MoltenVK is dynamically loaded versus the Vulkan loader
+ # on iOS we can control Vulkan library loading priority by selecting which libraries are embedded in the iOS application bundle
+ if(IOS)
+ add_compile_definitions(_HPP_VULKAN_LIBRARY="MoltenVK.framework/MoltenVK")
+ # unset FindVulkan.cmake cache variables so Vulkan loader, Validation Layer, and icd/layer json files are not embedded on iOS
+ unset(Vulkan_LIBRARY CACHE)
+ unset(Vulkan_Layer_VALIDATION CACHE)
+
+ # on macOS make sure that MoltenVK_LIBRARY_PATH points to the MoltenVK project installation and not to the Vulkan_LIBRARY location
+ # otherwise if DYLD_LIBRARY_PATH points to a common search path, Volk may dynamically load libvulkan.dylib versus libMoltenVK.dylib
+ elseif(NOT Vulkan_LIBRARY MATCHES "${MoltenVK_LIBRARY_PATH}")
+ add_compile_definitions(_HPP_VULKAN_LIBRARY="libMoltenVK.dylib")
+ add_compile_definitions(_GLFW_VULKAN_LIBRARY="libMoltenVK.dylib")
+ set(ENV{DYLD_LIBRARY_PATH} "${MoltenVK_LIBRARY_PATH}:$ENV{DYLD_LIBRARY_PATH}")
+ else()
+ message(FATAL_ERROR "Vulkan library found in MoltenVK search path. Please set VULKAN_SDK to the MoltenVK project install location.")
+ endif()
+ message(STATUS "Using MoltenVK: ${Vulkan_MoltenVK_LIBRARY}")
+ else()
+ message(FATAL_ERROR "Can't find MoltenVK library. Please install the Vulkan SDK or MoltenVK project and set VULKAN_SDK.")
+ endif()
+ elseif(IOS)
+ # if not using MoltenVK on iOS, set up global Vulkan Library define for iOS Vulkan loader
+ add_compile_definitions(_HPP_VULKAN_LIBRARY="vulkan.framework/vulkan")
+ endif()
+
+ if(CMAKE_GENERATOR MATCHES "Xcode")
+ set(CMAKE_XCODE_GENERATE_SCHEME ON)
+ set(CMAKE_XCODE_SCHEME_ENABLE_GPU_API_VALIDATION OFF)
+
+ if(NOT IOS)
+ # If the Vulkan library's or loader's environment variables are defined, make them available within Xcode schemes
+ if(DEFINED ENV{DYLD_LIBRARY_PATH})
+ set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}")
+ endif()
+ if(DEFINED ENV{VK_ADD_LAYER_PATH})
+ set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_ADD_LAYER_PATH=$ENV{VK_ADD_LAYER_PATH}")
+ endif()
+ if(DEFINED ENV{VK_ICD_FILENAMES})
+ set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_ICD_FILENAMES=$ENV{VK_ICD_FILENAMES}")
+ endif()
+ if(DEFINED ENV{VK_DRIVER_FILES})
+ set(CMAKE_XCODE_SCHEME_ENVIRONMENT "${CMAKE_XCODE_SCHEME_ENVIRONMENT};VK_DRIVER_FILES=$ENV{VK_DRIVER_FILES}")
+ endif()
+
+ # Suppress regeneration for Xcode since environment variables will be lost if not set in Xcode locations/custom paths
+ set(CMAKE_SUPPRESS_REGENERATION ON)
+ endif()
+ endif()
endif()
set(VKB_WARNINGS_AS_ERRORS ON CACHE BOOL "Enable Warnings as Errors")
diff --git a/bldsys/cmake/module/FindVulkan.cmake b/bldsys/cmake/module/FindVulkan.cmake
index 0c61808da..526301938 100644
--- a/bldsys/cmake/module/FindVulkan.cmake
+++ b/bldsys/cmake/module/FindVulkan.cmake
@@ -329,7 +329,7 @@ find_library(Vulkan_LIBRARY
HINTS
${_Vulkan_hint_library_search_paths}
)
-message(STATUS "vulkan_library ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}")
+#message(STATUS "vulkan_library ${Vulkan_LIBRARY} search paths ${_Vulkan_hint_library_search_paths}")
mark_as_advanced(Vulkan_LIBRARY)
find_library(Vulkan_Layer_API_DUMP
diff --git a/docs/build.adoc b/docs/build.adoc
index 4494cbd3e..b015af53c 100644
--- a/docs/build.adoc
+++ b/docs/build.adoc
@@ -165,7 +165,7 @@ It is also used by CI and is a basic version installed with Visual Studio 2022.
Go to the http://releases.llvm.org/download.html[LLVM downloads page] to get clang.
-=== Build with CMake
+=== Build with CMake and Visual Studio
____
Please make sure, when running any sample, that you either:
@@ -177,13 +177,13 @@ ____
`Step 1.` The following command will generate the VS project
----
-cmake -G"Visual Studio 15 2017 Win64" -S . -Bbuild/windows
+cmake -G "Visual Studio 15 2017 Win64" -S . -Bbuild/windows
----
(Prior to CMake v3.13)
----
-cmake -G"Visual Studio 15 2017 Win64" . -Bbuild/windows
+cmake -G "Visual Studio 15 2017 Win64" . -Bbuild/windows
----
(New in CMake v3.14.
@@ -200,6 +200,10 @@ Visual Studio 2022 must be installed)
cmake -G "Visual Studio 17 2022" -A x64 -S . -Bbuild/windows
----
+Open the *vulkan_samples.sln* VS project inside build/windows and build with Ctrl-Shift-B. To run Vulkan Samples, use Visual Studio's Debug Properties selection and set the Debugging Command Arguments to --help. Click the "Local Windows Debugger" button and you should see the help output in the terminal. For convenience, the default setting is to run the hello_triangle sample; just edit that to your desired sample to run.
+
+Alternatively, for command line builds use the steps below:
+
`Step 2.` Build the Visual Studio project
----
@@ -250,16 +254,30 @@ cmake --build build/linux --config Release --target vulkan_samples -j$(nproc)
=== Dependencies
* CMake v3.12+ (Apple Silicon requires at least 3.19.2)
-* XCode v12 for Apple Silicon
+* Xcode v12 for Apple Silicon
* Command Line Tools (CLT) for Xcode `xcode-select --install`
-* https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html[Vulkan SDK] `./install_vulkan.py`
+* https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg[Vulkan SDK] - Download and Install the Vulkan SDK with default options
* <>
* <<3d-models,3D models>>
-=== Build with CMake
+=== Set your environment variables
+
+----
+source /PATH/TO/VULKAN/SDK/setup-env.sh
+----
+
+=== Build with CMake and Xcode
`Step 1.` The following command will generate the project
+----
+cmake -G Xcode -Bbuild/mac-xcode -DCMAKE_BUILD_TYPE=Release
+----
+
+Open the *vulkan_samples* Xcode project inside build/mac-xcode and build with command-B. To run Vulkan Samples, use Xcode's edit-scheme selection and set the arguments to --help. Click the "Play" button and you should see the help output in the terminal. For convenience, the default setting is to run the hello_triangle sample; just edit that to your desired sample to run.
+
+Alternatively, for command line builds use the steps below:
+
----
cmake -Bbuild/mac -DCMAKE_BUILD_TYPE=Release
----
@@ -267,64 +285,65 @@ cmake -Bbuild/mac -DCMAKE_BUILD_TYPE=Release
`Step 2.` Build the project
----
-cmake --build build/mac --config Release --target vulkan_samples -j4
+cmake --build build/mac --config Release --target vulkan_samples -j$(sysctl -n hw.ncpu)
----
`Step 3.` Run the *Vulkan Samples* application to display the help message
----
-./build/mac/app/bin/Release//vulkan_samples --help
+./build/mac/app/bin/Release//vulkan_samples --help
----
== iOS
=== Dependencies
* CMake v3.28+ (Apple xcframeworks require at least 3.28)
-* XCode v12 for Apple Silicon
+* Xcode v12 for Apple Silicon
* Command Line Tools (CLT) for Xcode `xcode-select --install`
-* https://vulkan.lunarg.com/doc/sdk/latest/mac/getting_started.html[Vulkan SDK] `./install_vulkan.py`
+* https://sdk.lunarg.com/sdk/download/latest/mac/vulkan_sdk.dmg[Vulkan SDK] - Download and Install the Vulkan SDK making sure "Development libraries for iOS" is selected
* Vulkan at least version 1.3.278 to get the frameworks
* <>
* <<3d-models,3D models>>
-=== Set your environment variable
+=== Set your environment variables
-`Step 1.` edit ~/.bash_profile
-`Step 2.` add the environment variable
+NB: For iOS you must run the setup-env.sh located inside the Vulkan SDK's iOS directory
----
-export VULKAN_SDK=/PATH/TO/VULKAN/SDK
+source /PATH/TO/VULKAN/SDK/iOS/setup-env.sh
----
-`Step 3.` reload the bash_profile
+=== Build with CMake and Xcode
+
+`Step 1.` The following command will generate the project
----
-source ~/.bash_profile
+cmake -G Xcode -Bbuild/ios -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=YES -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_IOS_INSTALL_COMBINED=NO -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM="XXXX" -DMACOSX_BUNDLE_GUI_IDENTIFIER="com.YYYY.vulkansamples"
----
+NB: You MUST change the XXXX in the above to your TeamID (or Organizational Unit identifier in your Apple Development certificate) for code signing, and YYYY to your bundle identifier. iOS will NOT allow the application to run without code signing and bundle identifier setup.
-=== Build with CMake
-
-`Step 1.` The following command will generate the project
+Alternatively, you can build for the iOS Simulator without code signing or specifying a bundle identifier (a default bundle id will be used). However, depending on your host architecture, you MUST select either arm64 (Apple Silicon) or x86_64 in the command below
----
-cmake -Bbuild/mac -DCMAKE_BUILD_TYPE=Release -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=YES -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_IOS_INSTALL_COMBINED=NO -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM="XXXX"
+cmake -G Xcode -Bbuild/ios-sim -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=13.0 -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=YES -DCMAKE_OSX_ARCHITECTURES= -DCMAKE_IOS_INSTALL_COMBINED=NO
----
-NB: You MUST change the XXXX in the above to your TeamID for code signing. iOS will Not allow the application to run without code signing setup.
`Step 2.` Build the project
+It's recommended to open the *vulkan_samples* Xcode project that is generated inside build/ios or build/ios-sim and build with command-B.
+
+Alternatively, you can build with cmake as shown here
+
----
-cmake --build build/mac --config Release --target vulkan_samples -- -j 6 -sdk iphoneos -allowProvisioningUpdates
+cmake --build build/ios --config Release --target vulkan_samples -j$(sysctl -n hw.ncpu) -- -sdk iphoneos -allowProvisioningUpdates
----
-It's recommended to open the XCode project that is generated inside build/mac; building can be handled with command-B.
-
`Step 3.` Run the *Vulkan Samples* application
-To run Vulkan Samples, one must have an iOS device provisioned and working with XCode. Open the XCode project and ensure that can build/install to a device through XCode normally.
-Once the bundle is created from the build command in Step 2, use the edit-scheme selection in XCode and set the arguments to have --help
+To run Vulkan Samples, one must have an iOS physical or simulator device provisioned and working with Xcode. Open the Xcode project and ensure that can build/install to a device through Xcode normally.
+Once the bundle is created from the build command in Step 2, use the edit-scheme selection in Xcode and set the arguments to --help.
Click the "Play" button and you should see the help output in the terminal.
-For convenience, the default setting is to run the hello_triangle sample; just edit that to your desired sample to run
+For convenience, the default setting is to run the hello_triangle sample; just edit that to your desired sample to run.
== Android
diff --git a/framework/vulkan_sample.h b/framework/vulkan_sample.h
index f74398e9b..c902b5457 100644
--- a/framework/vulkan_sample.h
+++ b/framework/vulkan_sample.h
@@ -1008,8 +1008,8 @@ inline bool VulkanSample::prepare(const ApplicationOptions &options
LOGI("Initializing Vulkan sample");
// initialize C++-Bindings default dispatcher, first step
-#if TARGET_OS_IPHONE
- static vk::DynamicLoader dl("vulkan.framework/vulkan");
+#if defined(_HPP_VULKAN_LIBRARY)
+ static vk::DynamicLoader dl(_HPP_VULKAN_LIBRARY);
#else
static vk::DynamicLoader dl;
#endif
diff --git a/samples/api/hello_triangle/hello_triangle.cpp b/samples/api/hello_triangle/hello_triangle.cpp
index 33aec7d81..96a937199 100644
--- a/samples/api/hello_triangle/hello_triangle.cpp
+++ b/samples/api/hello_triangle/hello_triangle.cpp
@@ -200,7 +200,7 @@ void HelloTriangle::init_instance(Context &context,
bool portability_enumeration_available = false;
if (std::any_of(available_instance_extensions.begin(),
available_instance_extensions.end(),
- [](VkExtensionProperties extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0; }))
+ [](VkExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0; }))
{
active_instance_extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
portability_enumeration_available = true;
diff --git a/samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp b/samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp
index 5ef3b4cff..05e2433ab 100644
--- a/samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp
+++ b/samples/api/hpp_hello_triangle/hpp_hello_triangle.cpp
@@ -421,7 +421,11 @@ vk::ImageView HPPHelloTriangle::create_image_view(vk::Image image)
vk::Instance HPPHelloTriangle::create_instance(std::vector const &required_instance_extensions, std::vector const &required_validation_layers)
{
- static vk::DynamicLoader dl;
+#if defined(_HPP_VULKAN_LIBRARY)
+ static vk::DynamicLoader dl(_HPP_VULKAN_LIBRARY);
+#else
+ static vk::DynamicLoader dl;
+#endif
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = dl.getProcAddress("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
@@ -438,7 +442,7 @@ vk::Instance HPPHelloTriangle::create_instance(std::vector const &
bool portability_enumeration_available = false;
if (std::any_of(available_instance_extensions.begin(),
available_instance_extensions.end(),
- [](vk::ExtensionProperties extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0; }))
+ [](vk::ExtensionProperties const &extension) { return strcmp(extension.extensionName, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) == 0; }))
{
active_instance_extensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
portability_enumeration_available = true;
@@ -518,7 +522,7 @@ vk::Instance HPPHelloTriangle::create_instance(std::vector const &
// initialize function pointers for instance
VULKAN_HPP_DEFAULT_DISPATCHER.init(instance);
-#if defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR)
+#if defined(VK_USE_PLATFORM_DISPLAY_KHR) || defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(VK_USE_PLATFORM_METAL_EXT)
// we need some additional initializing for this platform!
if (volkInitialize())
{
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 8de63106c..c8571ff94 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -342,18 +342,18 @@ add_subdirectory(astc)
# ASTC apparently tries to build for x86_64 even on Mac arm64 architectures,
# but we can force it to build for the correct arch
# Upstream bug: https://github.com/ARM-software/astc-encoder/issues/458
-if(IOS AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "") )
- set(CMAKE_SYSTEM_PROCESSOR "arm64")
+if(IOS)
+ if(${CMAKE_OSX_SYSROOT} STREQUAL "iphonesimulator")
+ # handle iOS Simulator case, which should always match CMAKE_HOST_SYSTEM_PROCESSOR
+ set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
+ else()
+ set(CMAKE_SYSTEM_PROCESSOR arm64)
+ endif()
endif ()
if (APPLE AND (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64"))
set_target_properties(${ASTC_RAW_TARGET} PROPERTIES OSX_ARCHITECTURES "arm64")
endif()
-# if targeting iOS, that's always arm64 even when the host OS is x86-64
-if(IOS)
- set_target_properties(${ASTC_RAW_TARGET} PROPERTIES OSX_ARCHITECTURES "arm64")
-endif ()
-
# astc doesn't have separate directories for it's source code and public interface. Additionally, it includes it's
# own copy of STB. In order to avoid conflicts, we copy the only header we need to the build directory and alter the
# INTERFACE_INCLUDE_DIRECTORIES of the target