Because OpenGL is being deprecated by Apple, use Metal instead of OpenGL for main VM window in OS X.
Metal only works in 64 bits mode. So, I also made the needed changes to keep using OpenGL in the 32 bits version of the OS X VM. You can view, comment on, or merge this pull request online at:
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306
-- Commit Summary --
* I ported the main OS X view from OpenGL into Metal. * Disable restoring OpenGL context hack in ioProcessEvents when using Metal for the main window.
-- File Changes --
M build.macos32x86/common/Makefile.app (4) M build.macos32x86/common/Makefile.flags (2) M build.macos64x64/common/Makefile.app (8) M build.macos64x64/common/Makefile.flags (7) M build.macos64x64/common/Makefile.rules (10) M build.macos64x64/common/Makefile.vm (1) M platforms/iOS/vm/Common/Classes/sqSqueakEventsAPI.m (14) A platforms/iOS/vm/English.lproj/MainMenu-opengl.xib (1261) M platforms/iOS/vm/English.lproj/MainMenu.xib (8) M platforms/iOS/vm/OSX/SqViewBitmapConversion.m (5) M platforms/iOS/vm/OSX/SqViewClut.m (5) A platforms/iOS/vm/OSX/SqueakMainShaders.metal (73) M platforms/iOS/vm/OSX/SqueakOSXAppDelegate.m (5) A platforms/iOS/vm/OSX/sqSqueakOSXMetalView.h (93) A platforms/iOS/vm/OSX/sqSqueakOSXMetalView.m (772)
-- Patch Links --
https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306.patch https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306.diff
@ronsaldo pushed 1 commit.
ea78e18 Set the version of the metal shading language to use.
This is great! Could @johnmci have a look at this please? I'm not very familiar with the OpenGL API or Metal API...
@ronsaldo pushed 1 commit.
24705af Use osx-metal1.1 instead macos-metal1.1.
@ronsaldo pushed 1 commit.
367164d Another attempt to build shaders on CI.
@ronsaldo pushed 1 commit.
4380ab9 I added a workaround for the different versions of the metallib tool.
@ronsaldo pushed 1 commit.
8841c0b Embed statically the compiled metal shaders as a workaround for CI problems.
On Sat, Nov 10, 2018 at 11:24:46PM -0800, Ronie Salgado wrote:
Because OpenGL is being deprecated by Apple, use Metal instead of OpenGL for main VM window in OS X.
Very nice to see this :-)
Dave
@eliotmiranda pushed 1 commit.
0b15880 Update Makefile.app
@eliotmiranda pushed 1 commit.
e42d3d1 Update Makefile.rules
Hi Ronie, can you add a comment to platforms/iOS/vm/OSX/SqueakMainShaders.metal.inc to explain what's in SqueakMainShaders_metallib? This is some mysterious s&%t ;-)
Superb work, Ronie. So thorough. Shame about the selector comparisons in doCommandBySelector:; I know the time isn't an issue but it's ugly :-) I suppose we could implement the selectors instead.
@ronsaldo pushed 1 commit.
6e1da75 Adding a comment on the embedded compiled shaders.
About platforms/iOS/vm/OSX/SqueakMainShaders.metal.inc , I agree, but the metal build tools were not working on CI, and I did not want to bump up the required version of XCode. So I ended copying the approach of offline compilation from SDL2. I just added the comment.
Well as for the doCommandBySelector; comparison, I copied most of the event related stuff from the sqSqueakOSXOpenGLView.m and sqSqueakOSXCGView.m . I think that someone else should refactor these parts in order to avoid code duplication.
@ronsaldo maybe it's time to bump the macOS version our CI uses? The binaries should still work on older macOS systems, right?
Lets not allow this go stale. What is blocking it? Can the CI be bumped to check how it fits with recent movement of Cog branch. @eliotmiranda, are you satisfied with Ronnie's commit 6e1da75? @fniephaus, unless its blocking, lets move any macOS version bump to a separate issue. @johnmci, are you available to review? otherwise please advise us not to wait.
Please respond... @eliotmiranda, are you satisfied with Ronnie's commit 6e1da75? @johnmci, are you available to review as Fabio requested? otherwise please advise us not to wait. @fniephaus, unless its blocking, can any macOS version bump be done in a separate issue?
unless its blocking, can any macOS version bump be done in a separate issue?
Sure, no need to bump the version at all if it's not required by this change.
I got super excited about this PR again, so I merged it locally into `Cog` and build a Squeak VM. I'm on macOS Mojave and my MacBook has a Retina Display. Unfortunately, I am seeing this when opening the Squeak-5.2 release image:
![image](https://user-images.githubusercontent.com/2368856/51002398-6dbb0800-1533-11e...)
Mouse events seem to work fine, so only the rendering is off for some reason.
fniephaus commented on this pull request.
- // Alawys try to fill the texture with the pixels.
+ if ( fullScreendispBitsIndex ) { + [self loadTexturesFrom: fullScreendispBitsIndex subRectangle: (clippyIsEmpty ? rect : NSRectFromCGRect(clippy))]; + //[self loadTexturesFrom: fullScreendispBitsIndex subRectangle: rect]; + clippyIsEmpty = YES; + syncNeeded = NO; + } + + MTLRenderPassDescriptor *renderPassDescriptor = self.currentRenderPassDescriptor; + if(renderPassDescriptor != nil && self.currentDrawable) + { + currentCommandBuffer = [graphicsCommandQueue commandBuffer]; + currentRenderEncoder = [currentCommandBuffer renderCommandEncoderWithDescriptor: renderPassDescriptor]; + + // Set the viewport. + [currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, lastFrameSize.size.width, lastFrameSize.size.height}];
When I change this line to ```c [currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, lastFrameSize.size.width * 2, lastFrameSize.size.height * 2}]; ```
the problem I mentioned in https://github.com/OpenSmalltalk/opensmalltalk-vm/pull/306#issuecomment-4532... goes away. But this is probably not the right fix.
krono commented on this pull request.
- // Alawys try to fill the texture with the pixels.
+ if ( fullScreendispBitsIndex ) { + [self loadTexturesFrom: fullScreendispBitsIndex subRectangle: (clippyIsEmpty ? rect : NSRectFromCGRect(clippy))]; + //[self loadTexturesFrom: fullScreendispBitsIndex subRectangle: rect]; + clippyIsEmpty = YES; + syncNeeded = NO; + } + + MTLRenderPassDescriptor *renderPassDescriptor = self.currentRenderPassDescriptor; + if(renderPassDescriptor != nil && self.currentDrawable) + { + currentCommandBuffer = [graphicsCommandQueue commandBuffer]; + currentRenderEncoder = [currentCommandBuffer renderCommandEncoderWithDescriptor: renderPassDescriptor]; + + // Set the viewport. + [currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, lastFrameSize.size.width, lastFrameSize.size.height}];
Welcome to the cool world of backing scale factor.
see - https://github.com/OpenSmalltalk/opensmalltalk-vm/compare/krono/highdpi-v2#d... - https://github.com/OpenSmalltalk/opensmalltalk-vm/compare/krono/highdpi-v2#d...
and the like
Hi Ben,
On Thu, Jan 10, 2019 at 5:06 AM Ben Coman notifications@github.com wrote:
Please respond... @eliotmiranda https://github.com/eliotmiranda, are you satisfied with Ronnie's commit 6e1da75 https://github.com/OpenSmalltalk/opensmalltalk-vm/commit/6e1da7500a653eb906606562145a8f863e25fab4 ?
yes
@johnmci https://github.com/johnmci, are you available to review as Fabio requested? otherwise please advise us not to wait. @fniephaus https://github.com/fniephaus, unless its blocking, can any macOS version bump be done in a separate issue?
_,,,^..^,,,_ best, Eliot
@ronsaldo pushed 1 commit.
9b119d1d8ea5ff4623d9c576cdbcec9af294d9e7 Use the size of the drawable, instead of the size of the frame. This should fix the HiDPI bug.
ronsaldo commented on this pull request.
- // Alawys try to fill the texture with the pixels.
+ if ( fullScreendispBitsIndex ) { + [self loadTexturesFrom: fullScreendispBitsIndex subRectangle: (clippyIsEmpty ? rect : NSRectFromCGRect(clippy))]; + //[self loadTexturesFrom: fullScreendispBitsIndex subRectangle: rect]; + clippyIsEmpty = YES; + syncNeeded = NO; + } + + MTLRenderPassDescriptor *renderPassDescriptor = self.currentRenderPassDescriptor; + if(renderPassDescriptor != nil && self.currentDrawable) + { + currentCommandBuffer = [graphicsCommandQueue commandBuffer]; + currentRenderEncoder = [currentCommandBuffer renderCommandEncoderWithDescriptor: renderPassDescriptor]; + + // Set the viewport. + [currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, lastFrameSize.size.width, lastFrameSize.size.height}];
Hi, sorry for taking too long. I was completely busy with my job. I just changed the code to use the size from the drawableSurface property, instead of the size of the window. Can you check whether this fixes the issue or not?
Merged #306 into Cog.
vm-dev@lists.squeakfoundation.org