-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
macOS rendering update + initial metal support #11914
Conversation
kekekeks
commented
Jun 27, 2023
•
edited
Loading
edited
- software framebuffer render target now has to be explicitly created
- software rendering is now supported again for macOS (should allow running apps on mac VMs, fixes macOS application doesn't work in VM environment (or without a GPU) #10770)
- use a surface queue instead of rendering to a single IOSurface since it causes glitches under some circumstances
- added experimental metal support (proof of concept, not production ready)
If I understand correctly, with this Avalonia can render directly to metal without any abstraction in-between, correct? If so, this is a fantastic surprise addition for 11.0! |
It's directly to metal, however it's still experimental and has window resize issues. |
Well, it's great first step! Awesome work! |
You can test this PR using the following package version. |
That's a cool addition, great job! Does it make GpuInterop support any easier/possible? Or it doesn't matter? https://github.com/AvaloniaUI/Avalonia/tree/master/samples/GpuInterop sample didn't support Mac, I wonder if now it could work? I would love to embed Vulkan in my app, via MoltenVK on mac. |
_contextCtor = typeof(GRContext).GetConstructor( | ||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, | ||
new[] { typeof(IntPtr), typeof(bool) }, null) ?? throw new MissingMemberException("GRContext.ctor(IntPtr,bool)"); | ||
|
||
|
||
_renderTargetCtor = typeof(GRBackendRenderTarget).GetConstructor( | ||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, | ||
new[] { typeof(IntPtr), typeof(bool) }, null) ?? throw new MissingMemberException("GRContext.ctor(IntPtr,bool)"); | ||
|
||
_contextOptionsToNative = typeof(GRContextOptions).GetMethod("ToNative", | ||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) | ||
?? throw new MissingMemberException("GRContextOptions.ToNative()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid trimming issues, please add these attributes on SkiaMetalApi ctor.
[DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicConstructors, typeof(GRContext))]
[DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicConstructors, typeof(GRBackendRenderTarget))]
[DynamicDependency(DynamicallyAccessedMemberTypes.NonPublicMethods, typeof(GRContextOptions))]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have not tested it, but should work without any rd.xml iles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also possible to write a specific member signature in the DynamicDependency attribute, but only if you know exactly one needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just to ensure that "We use reflection only on member that are guaranteed to be referenced by OpenGL gpu code" is actually not a problem, as I have doubts. Something like GRContextOptions.ToNative could be trimmed out otherwise.
@BAndysc |
# Conflicts: # src/Avalonia.Native/AvaloniaNativePlatform.cs # src/Avalonia.Native/AvaloniaNativePlatformExtensions.cs # src/Avalonia.Native/PopupImpl.cs # src/Avalonia.Native/WindowImpl.cs # src/Avalonia.Native/WindowImplBase.cs
You can test this PR using the following package version. |