Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Mac M2 apple silicon chip supported? #599

Open
ad184hl opened this issue Aug 8, 2023 · 16 comments
Open

Is Mac M2 apple silicon chip supported? #599

ad184hl opened this issue Aug 8, 2023 · 16 comments

Comments

@ad184hl
Copy link

ad184hl commented Aug 8, 2023

I am trying to use the MacOS build flow according to the document, but it has error when build:

clang: error: the clang compiler does not support '-march=core2'

I searched the internet, looks like I need to change the cmake setting, for example:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64 -march=armv8-a")

But since I auto generated the config using the following:

cmake -G Xcode -T buildsystem=1  \
      -S. -Bcmake-build-macos    \
      -DCMAKE_BUILD_TYPE=Release \
      -DURHO3D_SAMPLES=ON

I am not sure where I should change the setting.

I tried to add options in the build step according to this, e.g.

-DCMAKE_CXX_FLAGS='-march=xxx -mcpu=apple-m1 xxx'

but none worked.

@ad184hl ad184hl changed the title Do we know if Mac M2 chip is supported? Is Mac M2 apple silicon chip supported? Aug 9, 2023
@rbnpontes
Copy link
Contributor

We don't had tested on Mac M2, and the new macOS has some issues that we need to fix like SSE.
Try to use this argument on cmake: -DCMAKE_OSX_ARCHITECTURES=arm64 -DURHO3D_GLOW=OFF -DURHO3D_SSE=OFF

@ad184hl
Copy link
Author

ad184hl commented Aug 9, 2023

Unfortunately, still not working, thanks though since this repo is being updated frequently.

We don't had tested on Mac M2, and the new macOS has some issues that we need to fix like SSE.
Try to use this argument on cmake: -DCMAKE_OSX_ARCHITECTURES=arm64 -DURHO3D_GLOW=OFF -DURHO3D_SSE=OFF

@rbnpontes
Copy link
Contributor

Does the error still persist or has the error changed?

@ad184hl
Copy link
Author

ad184hl commented Aug 11, 2023

Does the error still persist or has the error changed?

still persist, the same error, with some sample context:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /var/folders/hb/z303fv6x1cg0r1v9ltfvqh0h0000gp/C/com.apple.DeveloperTools/14.3-14E222b/Xcode/SDKStatCaches.noindex/macosx13.3-22E245-.sdkstatcache -target arm64-apple-macos13.3 -fmessage-length\=179 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O3 -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-return-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -DCMAKE_INTDIR\=\"Debug\" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-move -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-range-loop-analysis -Wno-semicolon-before-method-body -I/Users/xxx/git_folder/rbfx/cmake-build-macos/lib/Debug/include -isystem /Users/xxx/git_folder/rbfx/Source/ThirdParty/crunch/include -isystem /Users/xxx/git_folder/rbfx/Source/ThirdParty/crunch/include/crunch -isystem /Users/xxx/git_folder/rbfx/Source/ThirdParty/crunch/crnlib -I/Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/DerivedSources-normal/arm64 -I/Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/DerivedSources/arm64 -I/Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/DerivedSources -F/Users/xxx/git_folder/rbfx/cmake-build-macos/lib/Debug -mcpu\=apple-m1 -arch arm64 -march\=armv8-a -w -std\=gnu++17 -fPIC -fomit-frame-pointer -ffast-math -fno-math-errno -fno-strict-aliasing -Wall -Wno-unused-value -Wno-unused -march\=core2 -MMD -MT dependencies -MF /Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/Objects-normal/arm64/lzma_LzmaLib.d --serialize-diagnostics /Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/Objects-normal/arm64/lzma_LzmaLib.dia -c /Users/xxx/git_folder/rbfx/Source/ThirdParty/crunch/crnlib/lzma_LzmaLib.cpp -o /Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/Objects-normal/arm64/lzma_LzmaLib.o
clang: error: the clang compiler does not support '-march=core2'

@rbnpontes
Copy link
Contributor

It seems this property is included by the crunch lib, try to disable tools URHO3D_TOOL=OFF and build again, lets see if this work

@ad184hl
Copy link
Author

ad184hl commented Aug 12, 2023

still not working.
I found the error mostly comes from the crnlib:

The following build commands failed:
	CompileC /Users/xxx/git_folder/rbfx/cmake-build-macos/build/crnlib.build/Debug/Objects-normal/arm64/lzma_LzmaLib.o /Users/xxx/git_folder/rbfx/Source/ThirdParty/crunch/crnlib/lzma_LzmaLib.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'crnlib' from project 'rbfx')

do you know any other feature I can disable for that crnlib? I checked that lib and I am not familiar with what this DXT feature is doing.

@rbnpontes
Copy link
Contributor

This error comes from crunch lib, you can disable this lib at Source/ThirdParty/crunch/CMakeList.txt on line 55, you can comment and generate again the project.
Make sure you have deleted cmake cache and use -DURHO3D_TOOL=OFF as option and let's see whats happen

@ad184hl
Copy link
Author

ad184hl commented Aug 13, 2023

Somehow I have to comment out the whole Source/ThirdParty/crunch/CMakeList.txt file, not sure why.
But got new error.

In file included from /Users/xxx/git_folder/rbfx/Source/Urho3D/Graphics/View.cpp:36:
In file included from /Users/xxx/git_folder/rbfx/Source/Urho3D/Graphics/../Graphics/GraphicsImpl.h:29:
/Users/xxx/git_folder/rbfx/Source/Urho3D/Graphics/OpenGL/OGLGraphicsImpl.h:46:10: fatal error: 'GLES2/gl2.h' file not found
#include <GLES2/gl2.h>
         ^~~~~~~~~~~~~
1 warning and 1 error generated.

I briefly checked the build option, does not know anything could disable the GLES.

I found another thread claiming upgrading SDL version could resolve the Apple Mx Chip support, not sure if that is the same issue here.

@rbnpontes
Copy link
Contributor

Great, you've reached an important point. This problem occurs because include headers on MacOS is different.
Basically you must change #include <GLES2/gl2.h> to #include<OpenGL/gl3.h>, unfortunately this error is not easy to be solved.
I really high recommend you to use diligent branch instead of master, otherwise you will reach resolving a lot of problems that will be discarded in the future by the diligent feature.
Diligent branch is currently experimental and we don't have any release date soon, but it works very well on new Mac(a least on my Mac M1) and diligent branch is very active by the @eugeneko, he's the owner of this project.
Diligent branch brings a whole new backend rendering like Vulkan and D3D12 (Vulkan runs on top of MoltenVk) and we have fix this OpenGL issues. You can see our work here Diligent Renderer integration

Before you go to diligent branch, read this first:

  • If you have any problem about crunch on diligent branch you can use the workaround of disable crunch
  • You must install VulkanSDK if you need Vulkan, basically you need to setup vulkan sdk in you environment paths and run cmake
  • If you deal with any other problems, feel free to share here or use our Discord channel and feel free to send me message if you want. Due to expensive mac machines we really need persons that is testing diligent branch.

@ad184hl
Copy link
Author

ad184hl commented Aug 14, 2023

Ah, Great! I finally got it to work!
Thanks @rbnpontes for the step by step debugging.

Summary Instruction for Mac M2 Chip:

  1. Switch to diligent branch;
  2. Comment out (or delete) the whole file Source/ThirdParty/crunch/CMakeList.txt file to disable crnlib;
  3. Use the following cmake config:
      cmake -G Xcode -T buildsystem=1  \
        -S. -Bcmake-build-macos    \
        -DCMAKE_BUILD_TYPE=Release \
        -DURHO3D_SAMPLES=ON -DCMAKE_OSX_ARCHITECTURES=arm64 \
        -DURHO3D_GLOW=OFF -DURHO3D_SSE=OFF \
        -DURHO3D_TOOL=OFF\
    
  4. Build with cmake --build cmake-build-macos.

However, I found there are some rendering issues by quickly browsing through the samples.
Probably it's better to start another thread, but I'll attach my screen record video here to make it more clearer.
Video Link

Generally, rendering for terrains/cars/water has some issue; Physics scene has som glitch when rotating camera; Physics stress test and some other scenes could not render completely; The cube did not render for the Ragdoll sample, etc.
I'll probably take a deeper look in several weeks when I have time, so I can setup some sample project with more error log printing to identify the issue. But let me know if you need to test with M2 chips sometime.

@eugeneko
Copy link
Member

but I'll attach my screen record video here to make it more clearer

Holy shit that looks broken xD
Do you have similar issues with master branch?

@rbnpontes
Copy link
Contributor

but I'll attach my screen record video here to make it more clearer

Holy shit that looks broken xD

Do you have similar issues with master branch?

Master branch is completely broken on new Mac, I tried to help him but it has a mountain of issues that needs to be solved to make build works, diligent branch seems very stable on new Mac

@ad184hl
Copy link
Author

ad184hl commented Aug 18, 2023

I just took a quick look at the default log print

[23:05:10] [info] [main] : ConfigFile 'EngineParameters.json' is not found
[23:05:10] [info] [main] : ConfigFile overrides 'conf://EngineParameters.json' are loaded
2023-08-17 23:05:10.030713-0700 Samples[70252:10013844] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x60000163a640> F8BB1C28-BAE8-11D6-9C31-00039315CD46
[23:05:10] [info] [main] : Loaded static plugin 'Builtin.SceneViewer'
[23:05:10] [info] [main] : Created 11 worker threads
2023-08-17 23:05:10.248295-0700 Samples[70252:10013844] [Window] Warning: Window SDLWindow 0x14c7437f0 ordered front from a non-active application and may order beneath the active application's windows.
[23:05:10] [info] [main] : [diligent] User-defined allocator is not provided. Using default allocator.
[23:05:10] [info] [main] : [diligent] Attached to OpenGL 4.1 context (4.1 Metal - 83.1, Apple M2 Pro)
[23:05:10] [info] [main] : [diligent] GPU Vendor: apple
[23:05:10] [info] [main] : [diligent] Disabling separable shader programs
[23:05:10] [info] [main] : RenderDevice is initialized for OpenGL: size=2048x1536px (1024x768dp), color=TEX_FORMAT_RGBA8_UNORM_SRGB, depth=TEX_FORMAT_D32_FLOAT_S8X24_UINT
[23:05:10] [info] [main] : Set screen mode: 2048x1536 pixels at 120 Hz at monitor 0 [Windowed] [Resizable]
[23:05:10] [info] [main] : Initialized input
[23:05:10] [info] [main] : Initialized renderer
[23:05:10] [error] [main] : Failed to create GPU Pipeline State Cache.
[23:05:11] [info] [main] : Set audio mode 44100 Hz 5.1 Surround interpolated
[23:05:11] [info] [main] : Initialized engine
[23:05:11] [error] [main] : Individual file watching not supported by this OS version, can not start watching path /Users/xxx/Library/Application Support/Urho3D Rebel Fork/Built-in Samples/
[23:05:11] [error] [main] : Individual file watching not supported by this OS version, can not start watching path /Users/xxx/git_folder/rbfx/cmake-build-clion/bin/Debug/Samples.app/Contents/MacOS/../Resources/Data/
[23:05:11] [error] [main] : Individual file watching not supported by this OS version, can not start watching path /Users/xxx/git_folder/rbfx/cmake-build-clion/bin/Debug/Samples.app/Contents/MacOS/../Resources/CoreData/
[23:05:11] [info] [main] : Loaded font face 'Noto Sans' [regular] from 'Fonts/NotoSans-Condensed.ttf'.
[23:05:11] [info] [main] : Loaded font face 'Noto Sans' [bold] from 'Fonts/NotoSans-CondensedBold.ttf'.
[23:05:11] [info] [main] : Loaded font face 'Noto Sans' [italic, bold] from 'Fonts/NotoSans-CondensedBoldItalic.ttf'.
[23:05:11] [info] [main] : Loaded font face 'Noto Sans' [italic] from 'Fonts/NotoSans-CondensedItalic.ttf'.
2023-08-17 23:05:11.456890-0700 Samples[70252:10013844] AudioHardware-mac-imp.cpp:660    AudioObjectGetPropertyData: no object with given ID 0
[23:05:11] [info] [main] : Set audio mode 44100 Hz 5.1 Surround interpolated
[23:05:11] [info] [main] : [diligent] Resizing the swap chain to 2918x1832
[23:05:11] [info] [main] : Swap chain is resized to 2918x1832px (1459x916dp)
[23:05:17] [info] [main] : [diligent] Resizing the swap chain to 1644x934
[23:05:17] [info] [main] : Swap chain is resized to 1644x934px (822x467dp)
[23:05:40] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:05:45] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:05:50] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:05:53] [warning] [main] : Image 'Models/Kachujin/Textures/Kachujin_normal.png' is converted to RGBA8 format on upload to GPU
[23:05:53] [warning] [main] : Image 'Models/Kachujin/Textures/Kachujin_specular.png' is converted to RGBA8 format on upload to GPU
[23:05:56] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:06:01] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:06:05] [warning] [main] : Image 'Models/Mutant/Textures/Mutant_diffuse.jpg' is converted to RGBA8 format on upload to GPU
[23:06:06] [warning] [main] : Image 'Models/Mutant/Textures/Mutant_normal.jpg' is converted to RGBA8 format on upload to GPU
[23:06:06] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS
[23:06:19] [error] [main] : [diligent] glDrawElementsInstancedBaseInstance is not supported on MacOS

I think there is some issue with the glDrawElementsInstancedBaseInstance not supported.

@eugeneko
Copy link
Member

That's interesting.
We already have a fallback in case this function is not supported, we probably should extend it:
image

@eugeneko
Copy link
Member

@ad184hl Can you try hardcoding drawBaseInstance_ to false and check if it fixes the issue for you?

@ad184hl
Copy link
Author

ad184hl commented Aug 18, 2023

@ad184hl Can you try hardcoding drawBaseInstance_ to false and check if it fixes the issue for you?

@eugeneko
Yes! It works! All the Sample project works now (only the Ribbon one crash, I'll check later).
Interesting, so should we also mark the MacOS as the OpenGLBackend directly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants