From c221101e6f29d674442f0dc1dff5e1ed33c4c63d Mon Sep 17 00:00:00 2001 From: Ivan Belyavtsev Date: Tue, 16 Jul 2024 14:14:00 +0300 Subject: [PATCH 1/4] replace malloc.h with stdlib.h POSIX-compatible systems defines malloc in stdlib.h --- Source/DeviceInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DeviceInfo.cpp b/Source/DeviceInfo.cpp index 59902ac..49626f0 100644 --- a/Source/DeviceInfo.cpp +++ b/Source/DeviceInfo.cpp @@ -1,7 +1,7 @@ // © 2021 NVIDIA Corporation #include -#include +#include #define NRI_FORCE_C From 30a988973af54d5bfa5040ac06a29110dc981085 Mon Sep 17 00:00:00 2001 From: Ivan Belyavtsev Date: Tue, 16 Jul 2024 14:15:48 +0300 Subject: [PATCH 2/4] added macos specific loader and extensions --- Source/Wrapper.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Wrapper.cpp b/Source/Wrapper.cpp index d043d5a..be7cade 100644 --- a/Source/Wrapper.cpp +++ b/Source/Wrapper.cpp @@ -13,6 +13,9 @@ #define VK_USE_PLATFORM_WIN32_KHR 1 const char* VULKAN_LOADER_NAME = "vulkan-1.dll"; +#elif __APPLE__ + #define VK_USE_PLATFORM_METAL_EXT 1 + const char* VULKAN_LOADER_NAME = "libvulkan.dylib"; #else #define VK_USE_PLATFORM_XLIB_KHR 1 const char* VULKAN_LOADER_NAME = "libvulkan.so"; @@ -227,6 +230,8 @@ void Sample::CreateVulkanDevice() #ifdef _WIN32 const char* instanceExtensions[] = { VK_KHR_WIN32_SURFACE_EXTENSION_NAME, VK_KHR_SURFACE_EXTENSION_NAME }; +#elif __APPLE__ + const char* instanceExtensions[] = { VK_EXT_METAL_SURFACE_EXTENSION_NAME }; #else const char* instanceExtensions[] = { VK_KHR_XLIB_SURFACE_EXTENSION_NAME }; #endif @@ -778,7 +783,7 @@ void Sample::RenderFrame(uint32_t frameIndex) FreeLibrary((HMODULE)&library); } -#elif defined(__linux__) +#elif defined(__linux__) || defined(__APPLE__) #include From eeada98a032a629cdf2c1063b33b0d8263ecdb85 Mon Sep 17 00:00:00 2001 From: Ivan Belyavtsev Date: Tue, 16 Jul 2024 14:17:42 +0300 Subject: [PATCH 3/4] explicit cast to int16_t MacOS CLang is required an explicit cast --- Source/Clear.cpp | 2 +- Source/Readback.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Clear.cpp b/Source/Clear.cpp index e002bc7..b55b506 100644 --- a/Source/Clear.cpp +++ b/Source/Clear.cpp @@ -181,7 +181,7 @@ void Sample::RenderFrame(uint32_t frameIndex) NRI.CmdClearAttachments(commandBuffer, &clearDesc, 1, &rect2, 1); clearDesc.value.color32f = {0.0f, 0.0f, 1.0f, 1.0f}; - nri::Rect rect3 = { 0, y * 2, w, h3 }; + nri::Rect rect3 = { 0, (int16_t)(y * 2), w, h3 }; NRI.CmdClearAttachments(commandBuffer, &clearDesc, 1, &rect3, 1); } NRI.CmdEndRendering(commandBuffer); diff --git a/Source/Readback.cpp b/Source/Readback.cpp index 56f98ad..6bdd64c 100644 --- a/Source/Readback.cpp +++ b/Source/Readback.cpp @@ -273,7 +273,7 @@ void Sample::RenderFrame(uint32_t frameIndex) NRI.CmdClearAttachments(commandBuffer, &clearDesc, 1, &rect2, 1); clearDesc.value.color32f = {0.0f, 0.0f, 1.0f, 1.0f}; - nri::Rect rect3 = { 0, y * 2, w, h3 }; + nri::Rect rect3 = { 0, (int16_t)(y * 2), w, h3 }; NRI.CmdClearAttachments(commandBuffer, &clearDesc, 1, &rect3, 1); RenderUI(NRI, NRI, *m_Streamer, commandBuffer, 1.0f, true); From a9e22bdc265f64b925520dac6eca867912fce2fd Mon Sep 17 00:00:00 2001 From: Ivan Belyavtsev Date: Tue, 16 Jul 2024 14:18:26 +0300 Subject: [PATCH 4/4] updated macos build instructions --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 24d2631..a22383e 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,16 @@ Or by running scripts only: - Clone project and init submodules - Generate and build project using **cmake** +### MacOS (aarch64) +- Install **VulkanSDK** +- Setup environment variables using `setup-env.sh` from VulkanSDK (e.x. `source ~/VulkanSDK/1.3.283.0/setup-env.sh`) +- Clone project and init submodules +- Generate and build project using **cmake** + +Or by running scripts only: +- Run `./1-Deploy.sh` +- Run `./2-Build.sh` + ### CMake options `-DUSE_MINIMAL_DATA=ON` - download minimal resource package (90MB)