Macos ios fixes (#1192)
* Configure MoltenVK to use a dedicated compute queue for compute[*] examples with sync barriers * Modify descriptorindexing example for iOS and variable descriptor count limitations on MoltenVK * Remove obsolete macOS #ifdefs no longer needed for modern MoltenVK versions * Update iOS project to fix missing vkloader.c reference and revise example list * Set required features and API version for VVL in debugprintf example * Remove unnecessary Apple-specific code from descriptorindexing example * Add Layer Settings capability to VulkanExampleBase::createInstance() * Replace setenv() in examples with Layer Settings configuration for macOS/iOS * Update comments in examples.h and fix missing initializer in computeraytracing example * Update imgui overlay and example to support iOS Simulator * Update more comments in examples.h and remove redundant initializers in deferred* examples * Separate variable descriptor count declarations for apple and non-apple platforms * Consolidate variable descriptor count declarations for apple vs. non-apple platforms * Configure MoltenVK with a dedicated compute queue in VulkanExampleBase() and remove from samples
This commit is contained in:
parent
e1c962289f
commit
9a562a5426
17 changed files with 221 additions and 83 deletions
111
apple/examples.h
111
apple/examples.h
|
|
@ -40,6 +40,11 @@
|
|||
# include "../examples/triangle/triangle.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. MoltenVK does not yet support Vulkan 1.3
|
||||
#ifdef MVK_trianglevulkan13
|
||||
# include "../examples/trianglevulkan13/trianglevulkan13.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_pipelines
|
||||
# include "../examples/pipelines/pipelines.cpp"
|
||||
#endif
|
||||
|
|
@ -72,6 +77,7 @@
|
|||
# include "../examples/texturecubemap/texturecubemap.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support cube map arrays.
|
||||
#ifdef MVK_texturecubemaparray
|
||||
# include "../examples/texturecubemaparray/texturecubemaparray.cpp"
|
||||
#endif
|
||||
|
|
@ -134,32 +140,31 @@
|
|||
# include "../examples/shadowmapping/shadowmapping.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support rendering to array (layered) attachments.
|
||||
#ifdef MVK_shadowmappingcascade
|
||||
# include "../examples/shadowmappingcascade/shadowmappingcascade.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support rendering to array (layered) attachments.
|
||||
#ifdef MVK_shadowmappingomni
|
||||
# include "../examples/shadowmappingomni/shadowmappingomni.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support arrays of samplers.
|
||||
#ifdef MVK_texturemipmapgen
|
||||
# include "../examples/texturemipmapgen/texturemipmapgen.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support blitting to linear tiled images.
|
||||
#ifdef MVK_screenshot
|
||||
# include "../examples/screenshot/screenshot.cpp"
|
||||
#endif
|
||||
|
||||
// Runs, but some Apple GPUs may not support stores and atomic operations in the fragment stage.
|
||||
// Not supported on iOS Simulator due to VkDeviceMemory resource limitations.
|
||||
#ifdef MVK_oit
|
||||
# include "../examples/oit/oit.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Sparse image binding and residency not supported by MoltenVK/Metal.
|
||||
#ifdef MVK_texturesparseresidency
|
||||
# include "../examples/texturesparseresidency/texturesparseresidency.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
// PERFORMANCE
|
||||
|
||||
|
|
@ -171,6 +176,7 @@
|
|||
# include "../examples/instancing/instancing.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support indirect drawing.
|
||||
#ifdef MVK_indirectdraw
|
||||
# include "../examples/indirectdraw/indirectdraw.cpp"
|
||||
#endif
|
||||
|
|
@ -179,11 +185,16 @@
|
|||
# include "../examples/occlusionquery/occlusionquery.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. MoltenVK/Metal does not support pipeline statistics.
|
||||
// Does not run. MoltenVK/Metal does not support pipeline statistics.
|
||||
#ifdef MVK_pipelinestatistics
|
||||
# include "../examples/pipelinestatistics/pipelinestatistics.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Sparse image binding and residency not supported by MoltenVK/Metal.
|
||||
#ifdef MVK_texturesparseresidency
|
||||
# include "../examples/texturesparseresidency/texturesparseresidency.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
// PHYSICALLY BASED RENDERING
|
||||
|
||||
|
|
@ -242,6 +253,7 @@
|
|||
# include "../examples/computecloth/computecloth.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support indirect drawing.
|
||||
#ifdef MVK_computecullandlod
|
||||
# include "../examples/computecullandlod/computecullandlod.cpp"
|
||||
#endif
|
||||
|
|
@ -262,14 +274,17 @@
|
|||
|
||||
// TESSELLATION
|
||||
|
||||
// Not supported on iOS Simulator which does not support tessellation shaders.
|
||||
#ifdef MVK_displacement
|
||||
# include "../examples/displacement/displacement.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support tessellation shaders.
|
||||
#ifdef MVK_terraintessellation
|
||||
# include "../examples/terraintessellation/terraintessellation.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support tessellation shaders.
|
||||
#ifdef MVK_tessellation
|
||||
# include "../examples/tessellation/tessellation.cpp"
|
||||
#endif
|
||||
|
|
@ -277,52 +292,52 @@
|
|||
|
||||
// RAY TRACING - Currently unsupported by MoltenVK/Metal
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingbasic
|
||||
# include "../examples/raytracingbasic/raytracingbasic.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingshadows
|
||||
# include "../examples/raytracingshadows/raytracingshadows.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingreflections
|
||||
# include "../examples/raytracingreflections/raytracingreflections.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingtextures
|
||||
# include "../examples/raytracingtextures/raytracingtextures.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingcallable
|
||||
# include "../examples/raytracingcallable/raytracingcallable.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingintersection
|
||||
# include "../examples/raytracingintersection/raytracingintersection.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracinggltf
|
||||
# include "../examples/raytracinggltf/raytracinggltf.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_rayquery
|
||||
# include "../examples/rayquery/rayquery.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingpositionfetch
|
||||
# include "../examples/raytracingpositionfetch/raytracingpositionfetch.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Missing Vulkan extensions for ray tracing
|
||||
// Does not run. Missing Vulkan extensions for ray tracing.
|
||||
#ifdef MVK_raytracingsbtdata
|
||||
# include "../examples/raytracingsbtdata/raytracingsbtdata.cpp"
|
||||
#endif
|
||||
|
|
@ -356,25 +371,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
// EFFECTS
|
||||
|
||||
#ifdef MVK_radialblur
|
||||
# include "../examples/radialblur/radialblur.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_bloom
|
||||
# include "../examples/bloom/bloom.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_parallaxmapping
|
||||
# include "../examples/parallaxmapping/parallaxmapping.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_sphericalenvmapping
|
||||
# include "../examples/sphericalenvmapping/sphericalenvmapping.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
// EXTENSIONS
|
||||
|
||||
// Does not run. Requires VK_EXT_conservative_rasterization.
|
||||
|
|
@ -390,6 +386,7 @@
|
|||
# include "../examples/inlineuniformblocks/inlineuniformblocks.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator which does not support rendering to array (layered) attachments.
|
||||
#ifdef MVK_multiview
|
||||
# include "../examples/multiview/multiview.cpp"
|
||||
#endif
|
||||
|
|
@ -401,7 +398,6 @@
|
|||
|
||||
// Runs on MoltenVK 1.2.5 or later with VK_KHR_shader_non_semantic_info extension and VK_LAYER_KHRONOS_validation enabled.
|
||||
// No VK_LAYER_KHRONOS_validation layer when using MoltenVK examples project, builds/runs fine using vulkanExamples project.
|
||||
// Enable VK_LAYER_KHRONOS_validation layer with khronos_validation.enables = VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT
|
||||
//#ifdef MVK_debugprintf
|
||||
//# include "../examples/debugprintf/debugprintf.cpp"
|
||||
//#endif
|
||||
|
|
@ -419,7 +415,8 @@
|
|||
# include "../examples/variablerateshading/variablerateshading.cpp"
|
||||
#endif
|
||||
|
||||
// Runs on macOS 11.0 or later with Metal argument buffers enabled. Not yet supported on iOS.
|
||||
// Runs on macOS 11.0 or later with Metal argument buffers enabled.
|
||||
// Supported on iOS (not Simulator) as of MoltenVK version 1.2.10 / Vulkan SDK 1.3.290
|
||||
#ifdef MVK_descriptorindexing
|
||||
# include "../examples/descriptorindexing/descriptorindexing.cpp"
|
||||
#endif
|
||||
|
|
@ -428,6 +425,10 @@
|
|||
# include "../examples/dynamicrendering/dynamicrendering.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_dynamicrenderingmultisampling
|
||||
# include "../examples/dynamicrenderingmultisampling/dynamicrenderingmultisampling.cpp"
|
||||
#endif
|
||||
|
||||
// Does not run. Requires VK_KHR_pipeline_library and VK_EXT_graphics_pipeline_library.
|
||||
#ifdef MVK_graphicspipelinelibrary
|
||||
# include "../examples/graphicspipelinelibrary/graphicspipelinelibrary.cpp"
|
||||
|
|
@ -448,17 +449,49 @@
|
|||
# include "../examples/shaderobjects/shaderobjects.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_hostimagecopy
|
||||
# include "../examples/hostimagecopy/hostimagecopy.cpp"
|
||||
#endif
|
||||
|
||||
// Not supported on iOS Simulator.
|
||||
#ifdef MVK_bufferdeviceaddress
|
||||
# include "../examples/bufferdeviceaddress/bufferdeviceaddress.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_timelinesemaphore
|
||||
# include "../examples/timelinesemaphore/timelinesemaphore.cpp"
|
||||
#endif
|
||||
|
||||
// Runs, but most VK_EXT_extended_dynamic_state3 features not supported on MoltenVK.
|
||||
#ifdef MVK_dynamicstate
|
||||
# include "../examples/dynamicstate/dynamicstate.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
// EFFECTS
|
||||
|
||||
#ifdef MVK_radialblur
|
||||
# include "../examples/radialblur/radialblur.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_bloom
|
||||
# include "../examples/bloom/bloom.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_parallaxmapping
|
||||
# include "../examples/parallaxmapping/parallaxmapping.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_sphericalenvmapping
|
||||
# include "../examples/sphericalenvmapping/sphericalenvmapping.cpp"
|
||||
#endif
|
||||
|
||||
|
||||
// MISC
|
||||
|
||||
// Not supported on iOS Simulator which does not support indexed drawing with a non-zero base instance.
|
||||
#ifdef MVK_gears
|
||||
# include "../examples/gears/gears.cpp"
|
||||
# include "../examples/gears/vulkangear.cpp"
|
||||
#endif
|
||||
|
||||
#ifdef MVK_vulkanscene
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@
|
|||
AAEE728A2BD6003F0053521D /* shaders in Resources */ = {isa = PBXBuildFile; fileRef = AAEE72892BD6003F0053521D /* shaders */; };
|
||||
AAEE728C2BD600830053521D /* assets in Resources */ = {isa = PBXBuildFile; fileRef = AAEE728B2BD600830053521D /* assets */; };
|
||||
AAEE728E2BD600970053521D /* shaders in Resources */ = {isa = PBXBuildFile; fileRef = AAEE728D2BD600970053521D /* shaders */; };
|
||||
AAF62FC42D6C319900E69F39 /* vkloader.c in Sources */ = {isa = PBXBuildFile; fileRef = AAF62FC32D6C319900E69F39 /* vkloader.c */; };
|
||||
AAF62FC52D6C319900E69F39 /* vkloader.c in Sources */ = {isa = PBXBuildFile; fileRef = AAF62FC32D6C319900E69F39 /* vkloader.c */; };
|
||||
C9A79EFC204504E000696219 /* VulkanUIOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9A79EFB204504E000696219 /* VulkanUIOverlay.cpp */; };
|
||||
C9A79EFD2045051D00696219 /* VulkanUIOverlay.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C9A79EFB204504E000696219 /* VulkanUIOverlay.cpp */; };
|
||||
C9A79EFE2045051D00696219 /* VulkanUIOverlay.h in Sources */ = {isa = PBXBuildFile; fileRef = C9A79EFA204504E000696219 /* VulkanUIOverlay.h */; };
|
||||
|
|
@ -200,6 +202,7 @@
|
|||
AAEE72892BD6003F0053521D /* shaders */ = {isa = PBXFileReference; lastKnownFileType = folder; name = shaders; path = ../shaders; sourceTree = "<group>"; };
|
||||
AAEE728B2BD600830053521D /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = assets; path = ../assets; sourceTree = "<group>"; };
|
||||
AAEE728D2BD600970053521D /* shaders */ = {isa = PBXFileReference; lastKnownFileType = folder; name = shaders; path = ../shaders; sourceTree = "<group>"; };
|
||||
AAF62FC32D6C319900E69F39 /* vkloader.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = vkloader.c; path = ../external/ktx/lib/vkloader.c; sourceTree = "<group>"; };
|
||||
C9788FD02044D78D00AB0892 /* benchmark.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = benchmark.hpp; sourceTree = "<group>"; };
|
||||
C9A79EFA204504E000696219 /* VulkanUIOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VulkanUIOverlay.h; sourceTree = "<group>"; };
|
||||
C9A79EFB204504E000696219 /* VulkanUIOverlay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VulkanUIOverlay.cpp; sourceTree = "<group>"; };
|
||||
|
|
@ -295,6 +298,7 @@
|
|||
A951FF011E9C349000FA9144 /* frustum.hpp */,
|
||||
A951FF021E9C349000FA9144 /* keycodes.hpp */,
|
||||
A951FF031E9C349000FA9144 /* threadpool.hpp */,
|
||||
AAF62FC32D6C319900E69F39 /* vkloader.c */,
|
||||
);
|
||||
name = base;
|
||||
path = ../base;
|
||||
|
|
@ -567,6 +571,7 @@
|
|||
AA54A6BE26E52CE300485C4A /* checkheader.c in Sources */,
|
||||
A9B67B7C1C3AAE9800373FFD /* main.m in Sources */,
|
||||
AA54A1B826E5275300485C4A /* VulkanDevice.cpp in Sources */,
|
||||
AAF62FC42D6C319900E69F39 /* vkloader.c in Sources */,
|
||||
AA54A1C026E5276C00485C4A /* VulkanSwapChain.cpp in Sources */,
|
||||
AA54A6E426E52CE400485C4A /* imgui_demo.cpp in Sources */,
|
||||
AA54A6E026E52CE400485C4A /* imgui.cpp in Sources */,
|
||||
|
|
@ -602,6 +607,7 @@
|
|||
AA54A6D926E52CE400485C4A /* swap.c in Sources */,
|
||||
AA54A6BF26E52CE300485C4A /* checkheader.c in Sources */,
|
||||
A951FF1C1E9C349000FA9144 /* VulkanTools.cpp in Sources */,
|
||||
AAF62FC52D6C319900E69F39 /* vkloader.c in Sources */,
|
||||
A951FF1A1E9C349000FA9144 /* vulkanexamplebase.cpp in Sources */,
|
||||
A9B67B8D1C3AAEA200373FFD /* DemoViewController.mm in Sources */,
|
||||
AA54A6E526E52CE400485C4A /* imgui_demo.cpp in Sources */,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
[(DemoViewController *)_viewController appInBackground];
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
|
|
@ -36,6 +37,7 @@
|
|||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
[(DemoViewController *)_viewController appInForeground];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
/** The main view controller for the demo storyboard. */
|
||||
@interface DemoViewController : UIViewController <UIKeyInput>
|
||||
-(void) appInBackground;
|
||||
-(void) appInForeground;
|
||||
-(void) shutdownExample;
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ CALayer* layer;
|
|||
MVKExample* _mvkExample;
|
||||
CADisplayLink* _displayLink;
|
||||
BOOL _viewHasAppeared;
|
||||
BOOL _appInForeground;
|
||||
CGPoint _startPoint;
|
||||
}
|
||||
|
||||
|
|
@ -75,6 +76,7 @@ CALayer* layer;
|
|||
[self.view addGestureRecognizer: pinchSelector];
|
||||
|
||||
_viewHasAppeared = NO;
|
||||
_appInForeground = NO;
|
||||
}
|
||||
|
||||
-(void) viewDidAppear: (BOOL) animated {
|
||||
|
|
@ -85,8 +87,18 @@ CALayer* layer;
|
|||
-(BOOL) canBecomeFirstResponder { return _viewHasAppeared; }
|
||||
|
||||
-(void) renderFrame {
|
||||
//_mvkExample->renderFrame();
|
||||
_mvkExample->displayLinkOutputCb(); // SRS - Call displayLinkOutputCb() to animate frames vs. renderFrame() for static image
|
||||
if (_appInForeground)
|
||||
{
|
||||
_mvkExample->displayLinkOutputCb(); // SRS - Call displayLinkOutputCb() to render/animate at displayLink frame rate
|
||||
}
|
||||
}
|
||||
|
||||
- (void)appInForeground {
|
||||
_appInForeground = YES;
|
||||
}
|
||||
|
||||
- (void)appInBackground {
|
||||
_appInForeground = NO;
|
||||
}
|
||||
|
||||
-(void) shutdownExample {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue