This is the branch with the port of the B3DAccelerator plugin to Metal. Most the examples in Balloon3D are working with this new plugin, after forcing it by modifying:
B3DSceneMorph >> accelerationEnabled "Return true if hardware acceleration is enabled" "self accelerationSuspended ifTrue:[^false]. ^self valueOfProperty: #accelerationEnabled ifAbsent:[false]" ^ true
Shaders are now compiled in runtime, from source code which is embedded in a C-string.
In addition to these changes, in the last commit I did some refactoring of the Metal VM code. I am copying the message of that commit:
- I introduced a hack to select the type of rendering view in runtime. - I am compiling by again the old core graphics based renderer, but this is only used when the -core-graphics option is passed in the command line. - I added dummy headless view, that does not render and stubs most of the event. - I added the -metal, -opengl, and -core-graphics command line options for selecting the rendering backend. - I am testing the Metal implementation by compiling the shader library. If the shader library compilation fails, then Metal will not be used, and instead OpenGL will be used as a fallback, by default. You can view, comment on, or merge this pull request online at:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/382
-- Commit Summary --
* I am starting to reimplement the B3DAcceleratorPlugin using Metal. So far I managed to get a black screen by using the extra layers mechanism, * Creating the depth-stencil buffer, and clearing the screen. * I am starting to render a bit. * I am starting to implement the lighting model in the metal based B3DAcceleratorPlugin. * Add a -1 offset to the B3D indices going to Metal. * Merge branch 'Cog' into feature/metal_b3d * I implemented the Squeak3D lighting model above metal. * Merge branch 'Cog' into feature/metal_b3d * Merge branch 'Cog' into feature/metal_b3d * I introduced a hack to select the type of rendering view in runtime.
-- File Changes --
M .clang_complete (3) M build.macos32x86/common/Makefile.app (4) M build.macos32x86/common/Makefile.flags (2) M build.macos64x64/common/Makefile.flags (2) M build.macos64x64/common/Makefile.vm (2) M platforms/Cross/plugins/B3DAcceleratorPlugin/B3DAcceleratorPlugin.h (90) A platforms/iOS/plugins/B3DAcceleratorPlugin/B3DMetalShaders.metal (230) M platforms/iOS/plugins/B3DAcceleratorPlugin/Makefile (12) M platforms/iOS/plugins/B3DAcceleratorPlugin/sqMacOpenGL.m (5) A platforms/iOS/plugins/B3DAcceleratorPlugin/sqMetalRenderer.h (131) A platforms/iOS/plugins/B3DAcceleratorPlugin/sqMetalRenderer.m (1179) A platforms/iOS/plugins/B3DAcceleratorPlugin/sqMetalStructures.h (121) M platforms/iOS/vm/Common/main.m (22) M platforms/iOS/vm/English.lproj/MainMenu.xib (6) M platforms/iOS/vm/OSX/SqViewBitmapConversion.m (263) A platforms/iOS/vm/OSX/SqViewBitmapConversion.m.inc (271) M platforms/iOS/vm/OSX/SqViewClut.m (115) A platforms/iOS/vm/OSX/SqViewClut.m.inc (91) M platforms/iOS/vm/OSX/SqueakMainShaders.metal (32) D platforms/iOS/vm/OSX/SqueakMainShaders.metal.inc (822) M platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m (12) M platforms/iOS/vm/OSX/sqSqueakOSXApplication.m (34) M platforms/iOS/vm/OSX/sqSqueakOSXCGView.h (4) A platforms/iOS/vm/OSX/sqSqueakOSXHeadlessView.h (69) A platforms/iOS/vm/OSX/sqSqueakOSXHeadlessView.m (350) M platforms/iOS/vm/OSX/sqSqueakOSXMetalView.h (9) M platforms/iOS/vm/OSX/sqSqueakOSXMetalView.m (206) M platforms/iOS/vm/OSX/sqSqueakOSXOpenGLView.h (2) M platforms/iOS/vm/OSX/sqSqueakOSXOpenGLView.m (4) A platforms/iOS/vm/OSX/sqSqueakOSXViewFactory.h (22) A platforms/iOS/vm/OSX/sqSqueakOSXViewFactory.m (72) D scripts/build-metal-shaders.sh (29)
-- Patch Links --
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/382.patch https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/382.diff
When I try and compile on 64-bit (build.macos64x64/squeak.cog.spur; macOS High Sierra 10.13.6; clang --version: Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin17.7.0) I get the following error message:
../../platforms/iOS/vm/OSX/sqSqueakOSXMetalView.m:79:17: error: ARC forbids Objective-C objects in struct
that line is the "texture" declaration in
typedef struct ExtraLayer { id<MTLTexture> texture; int x, y; int w, h; } ExtraLayer;
Not sure if this fits here, but if I download the latest Pharo 7 VM on macOS High Sierra, the VM seems not to start properly, resulting in a black window and:
``` 2019-03-27 11:48:46.282 Pharo[1041:7933912] Pipeline state creation error: Function screenQuadFragmentShader is using language version 2.1 which is incompatible with this OS. ```
I looked into this a while ago, and there should be some flags to enable Metal 1 compatibility, then we would get at least down to El Capitan support. Adding Metal as required dependency is a non-backwards-compatible change, this should be handled with care (e.g. do we need non-metal builds, archive old non-metal builds for older OSs?).
Merged #382 into Cog.
Hi @maenu,
can you work with @ronsaldo to look at getting down to El Capitan support? Right now I'm on High Sierra (10.3) and Metal 2 doesn't even work there-on.
I will have a look, maybe @ronsaldo is even at PharoDays next week?
Sorry to revive the merged thread, but what is the state on this?
I just built the macOS 64bit Pharo Cog VM on HighSierra, Metal seems to be enabled (`-DUSE_METAL=1`), and the VM runs my image. But downloading a fresh VM from Pharo downloads gives me `2019-03-27 11:48:46.282 Pharo[1041:7933912] Pipeline state creation error: Function screenQuadFragmentShader is using language version 2.1 which is incompatible with this OS.` again.
My current hypothesis is, that the downloaded VM is built on a newer macOS, which removes the compatibility for High Sierra. Anybody knows how this happens and how we could trick a newer macOS in building a VM with a High Sierra compatibility?
The only thing I found to control compatibility is the `-mmacosx-version-min`, which is `10.7` in my local build. It looks like there is nothing other than this flag to achieve compatibility, see also https://github.com/gfx-rs/gfx/blob/master/src/backend/metal/build.rs.
@maenu That is interesting. Did you download that VM from bintray? That also looks like an error from the older version.
@ronsaldo I got the VM with `curl https://get.pharo.org/64/70+vmLatest | bash`. Maybe that is not really the latest VM.
vm-dev@lists.squeakfoundation.org