macOS/iOS fixes plus other generic fixes for clang and validation warnings (#1117)
* Fix clang Objective-C++ flags for macOS command line builds * Fix getAssetPath() and getShaderBasePath() for macOS command line builds * Protect debugUtilsMessageCallback() from failing when pMessageIdName is NULL * Fix a few clang function override and mismatched type warnings * Fix validation layer warnings on exit for computeraytracing example * Fix regression in text visibility toggle for textOverlay example * Support VK_USE_PLATFORM_METAL_EXT vs. deprecated VK_USE_PLATFORM_MACOS_MVK / DVK_USE_PLATFORM_IOS_MVK * Check dynamic state features before enabling capabilities in dynamicstate example * Fix vkCmdDraw() vertexCount argument (PARTICLE_COUNT) in particlesystem example * Update examples list and restore benchmarking script (to top level) * Fix validation warning in descriptorindexing example * Fix device max recursion depth validation warnings in ray tracing examples * Fix OpenMP build settings for texture3d example on all platforms * Update and simplify build instructions for macOS * Update CI script with correct library path for libomp on macOS x86_64 * Update CI scipt to install libomp prior to macOS builds * Trying one more time to get the CI script working for macOS libomp * Fix vertexCount argument using calculated size in particlesystem example * Fix combined image descriptor offset calculation in descriptorbuffer example * macOS: Support non-system level Vulkan SDK installs, with fallback to MoltenVK library
This commit is contained in:
parent
4a0c8b8f23
commit
bdfd4709ff
29 changed files with 320 additions and 88 deletions
|
|
@ -8,11 +8,18 @@
|
|||
|
||||
#include "vulkanexamplebase.h"
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) && defined(VK_EXAMPLE_XCODE_GENERATED))
|
||||
#if defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
#if (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <QuartzCore/CAMetalLayer.h>
|
||||
#include <CoreVideo/CVDisplayLink.h>
|
||||
#endif
|
||||
#else // !defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
// SRS - Metal layer is defined externally when using iOS/macOS displayLink-driven examples project
|
||||
extern CAMetalLayer* layer;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::vector<const char*> VulkanExampleBase::args;
|
||||
|
||||
|
|
@ -50,6 +57,8 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
instanceExtensions.push_back(VK_MVK_IOS_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(VK_USE_PLATFORM_MACOS_MVK)
|
||||
instanceExtensions.push_back(VK_MVK_MACOS_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
instanceExtensions.push_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(VK_USE_PLATFORM_HEADLESS_EXT)
|
||||
instanceExtensions.push_back(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME);
|
||||
#elif defined(VK_USE_PLATFORM_SCREEN_QNX)
|
||||
|
|
@ -71,7 +80,7 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
}
|
||||
}
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
// SRS - When running on iOS/macOS with MoltenVK, enable VK_KHR_get_physical_device_properties2 if not already enabled by the example (required by VK_KHR_portability_subset)
|
||||
if (std::find(enabledInstanceExtensions.begin(), enabledInstanceExtensions.end(), VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == enabledInstanceExtensions.end())
|
||||
{
|
||||
|
|
@ -106,7 +115,7 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
}
|
||||
|
||||
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) && defined(VK_KHR_portability_enumeration)
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && defined(VK_KHR_portability_enumeration)
|
||||
// SRS - When running on iOS/macOS with MoltenVK and VK_KHR_portability_enumeration is defined and supported by the instance, enable the extension and the flag
|
||||
if (std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME) != supportedInstanceExtensions.end())
|
||||
{
|
||||
|
|
@ -262,7 +271,7 @@ void VulkanExampleBase::nextFrame()
|
|||
render();
|
||||
frameCounter++;
|
||||
auto tEnd = std::chrono::high_resolution_clock::now();
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || (defined(VK_USE_PLATFORM_MACOS_MVK) && !defined(VK_EXAMPLE_XCODE_GENERATED)))
|
||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && !defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
// SRS - Calculate tDiff as time between frames vs. rendering time for iOS/macOS displayLink-driven examples project
|
||||
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tPrevEnd).count();
|
||||
#else
|
||||
|
|
@ -306,7 +315,7 @@ void VulkanExampleBase::renderLoop()
|
|||
{
|
||||
// SRS - for non-apple plaforms, handle benchmarking here within VulkanExampleBase::renderLoop()
|
||||
// - for macOS, handle benchmarking within NSApp rendering loop via displayLinkOutputCb()
|
||||
#if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
#if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
if (benchmark.active) {
|
||||
#if defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
while (!configured)
|
||||
|
|
@ -659,7 +668,7 @@ void VulkanExampleBase::renderLoop()
|
|||
}
|
||||
updateOverlay();
|
||||
}
|
||||
#elif (defined(VK_USE_PLATFORM_MACOS_MVK) && defined(VK_EXAMPLE_XCODE_GENERATED))
|
||||
#elif (defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT)) && defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
[NSApp run];
|
||||
#elif defined(VK_USE_PLATFORM_SCREEN_QNX)
|
||||
while (!quit) {
|
||||
|
|
@ -1583,7 +1592,7 @@ void VulkanExampleBase::handleAppCommand(android_app * app, int32_t cmd)
|
|||
break;
|
||||
}
|
||||
}
|
||||
#elif (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
#elif (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
||||
#if defined(VK_EXAMPLE_XCODE_GENERATED)
|
||||
@interface AppDelegate : NSObject<NSApplicationDelegate>
|
||||
{
|
||||
|
|
@ -1638,10 +1647,20 @@ dispatch_group_t concurrentGroup;
|
|||
@end
|
||||
|
||||
const std::string getAssetPath() {
|
||||
#if defined(VK_EXAMPLE_ASSETS_DIR)
|
||||
return VK_EXAMPLE_ASSETS_DIR;
|
||||
#else
|
||||
return [NSBundle.mainBundle.resourcePath stringByAppendingString: @"/../../assets/"].UTF8String;
|
||||
#endif
|
||||
}
|
||||
|
||||
const std::string getShaderBasePath() { return [NSBundle.mainBundle.resourcePath stringByAppendingString: @"/../../shaders/"].UTF8String; }
|
||||
const std::string getShaderBasePath() {
|
||||
#if defined(VK_EXAMPLE_SHADERS_DIR)
|
||||
return VK_EXAMPLE_SHADERS_DIR;
|
||||
#else
|
||||
return [NSBundle.mainBundle.resourcePath stringByAppendingString: @"/../../shaders/"].UTF8String;
|
||||
#endif
|
||||
}
|
||||
|
||||
static CVReturn displayLinkOutputCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *inNow,
|
||||
const CVTimeStamp *inOutputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut,
|
||||
|
|
@ -1899,8 +1918,14 @@ void* VulkanExampleBase::setupWindow(void* view)
|
|||
[window setDelegate:nsView];
|
||||
[window setContentView:nsView];
|
||||
this->view = (__bridge void*)nsView;
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
this->metalLayer = (CAMetalLayer*)nsView.layer;
|
||||
#endif
|
||||
#else
|
||||
this->view = view;
|
||||
#if defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
this->metalLayer = (CAMetalLayer*)layer;
|
||||
#endif
|
||||
#endif
|
||||
return view;
|
||||
}
|
||||
|
|
@ -3236,6 +3261,8 @@ void VulkanExampleBase::initSwapchain()
|
|||
swapChain.initSurface(androidApp->window);
|
||||
#elif (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||
swapChain.initSurface(view);
|
||||
#elif defined(VK_USE_PLATFORM_METAL_EXT)
|
||||
swapChain.initSurface(metalLayer);
|
||||
#elif defined(VK_USE_PLATFORM_DIRECTFB_EXT)
|
||||
swapChain.initSurface(dfb, surface);
|
||||
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue