Add updated iOS App support to the Vulkan examples (#1119)

* 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

* Add iOS App support for Vulkan examples on simulator and physical devices

* Add continuous integration (CI) script for iOS

* Update CI script to build iOS using Xcode 14 via macos-12 runner-image

* Update iOS project docs for Xcode 14 and rename ios folder to apple

* Update macOS docs and CI script to use LIBOMP_PREFIX for OpenMP library path

* Delete benchmark-all-validate.py

Delete benchmark script as per feedback from Sascha Willems

* Update debugprintf example documentation in examples.h
This commit is contained in:
SRSaunders 2024-05-22 15:07:27 -04:00 committed by GitHub
parent 3d4446fa15
commit ba927eab6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2755 additions and 9 deletions

135
apple/MVKExample.cpp Normal file
View file

@ -0,0 +1,135 @@
/*
* MVKExample.cpp
*
* Copyright (c) 2016-2017 The Brenwill Workshop Ltd.
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include "MVKExample.h"
#include "examples.h"
void MVKExample::renderFrame() {
_vulkanExample->renderFrame();
}
void MVKExample::displayLinkOutputCb() { // SRS - expose VulkanExampleBase::displayLinkOutputCb() to DemoViewController
_vulkanExample->displayLinkOutputCb();
}
void MVKExample::keyPressed(uint32_t keyChar) { // SRS - handle keyboard key presses only (e.g. Pause, Space, etc)
switch (keyChar)
{
case KEY_P:
_vulkanExample->paused = !_vulkanExample->paused;
break;
case KEY_1: // SRS - support keyboards with no function keys
case KEY_F1:
_vulkanExample->UIOverlay.visible = !_vulkanExample->UIOverlay.visible;
_vulkanExample->UIOverlay.updated = true;
break;
default:
_vulkanExample->keyPressed(keyChar);
break;
}
}
void MVKExample::keyDown(uint32_t keyChar) { // SRS - handle physical keyboard key down/up actions and presses
switch (keyChar)
{
case KEY_W:
case KEY_Z: // for French AZERTY keyboards
_vulkanExample->camera.keys.up = true;
break;
case KEY_S:
_vulkanExample->camera.keys.down = true;
break;
case KEY_A:
case KEY_Q: // for French AZERTY keyboards
_vulkanExample->camera.keys.left = true;
break;
case KEY_D:
_vulkanExample->camera.keys.right = true;
break;
default:
MVKExample::keyPressed(keyChar);
break;
}
}
void MVKExample::keyUp(uint32_t keyChar) {
switch (keyChar)
{
case KEY_W:
case KEY_Z: // for French AZERTY keyboards
_vulkanExample->camera.keys.up = false;
break;
case KEY_S:
_vulkanExample->camera.keys.down = false;
break;
case KEY_A:
case KEY_Q: // for French AZERTY keyboards
_vulkanExample->camera.keys.left = false;
break;
case KEY_D:
_vulkanExample->camera.keys.right = false;
break;
default:
break;
}
}
void MVKExample::mouseDown(double x, double y) {
_vulkanExample->mouseState.position = glm::vec2(x, y);
_vulkanExample->mouseState.buttons.left = true;
}
void MVKExample::mouseUp() {
_vulkanExample->mouseState.buttons.left = false;
}
void MVKExample::rightMouseDown(double x, double y) {
_vulkanExample->mouseState.position = glm::vec2(x, y);
_vulkanExample->mouseState.buttons.right = true;
}
void MVKExample::rightMouseUp() {
_vulkanExample->mouseState.buttons.right = false;
}
void MVKExample::otherMouseDown(double x, double y) {
_vulkanExample->mouseState.position = glm::vec2(x, y);
_vulkanExample->mouseState.buttons.middle = true;
}
void MVKExample::otherMouseUp() {
_vulkanExample->mouseState.buttons.middle = false;
}
void MVKExample::mouseDragged(double x, double y) {
_vulkanExample->mouseDragged(x, y);
}
void MVKExample::scrollWheel(short wheelDelta) {
_vulkanExample->camera.translate(glm::vec3(0.0f, 0.0f, wheelDelta * 0.05f * _vulkanExample->camera.movementSpeed));
_vulkanExample->viewUpdated = true;
}
void MVKExample::fullScreen(bool fullscreen) {
_vulkanExample->settings.fullscreen = fullscreen;
}
MVKExample::MVKExample(void* view, double scaleUI) {
_vulkanExample = new VulkanExample();
_vulkanExample->initVulkan();
_vulkanExample->setupWindow(view);
_vulkanExample->settings.vsync = true; // SRS - set vsync flag since this iOS/macOS example app uses displayLink vsync rendering
_vulkanExample->UIOverlay.scale = scaleUI; // SRS - set UIOverlay scale to maintain relative proportions/readability on retina displays
_vulkanExample->prepare();
_vulkanExample->renderLoop(); // SRS - this inits destWidth/destHeight/lastTimestamp/tPrevEnd, then falls through and returns
}
MVKExample::~MVKExample() {
vkDeviceWaitIdle(_vulkanExample->vulkanDevice->logicalDevice);
delete(_vulkanExample);
}