-
-
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
Graphics context management #9639
Conversation
8a6bab1
to
a809faa
Compare
551e8e1
to
eaf2ce3
Compare
You can test this PR using the following package version. |
You can test this PR using the following package version. |
Egl = new EglInterface(eglGetProcAddress), | ||
PlatformType = 0x31D7, | ||
PlatformDisplay = device, | ||
SupportsMultipleContexts = true, |
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.
API-wise, what's a point of SupportsMultipleContexts = true
when IPlatformGraphics.CreateContext
always throws an exception?
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.
There is a difference between DrmOutput
and EglDisplay
DrmOutput
uses a pre-existing context to produce a render target and that can not use any other context to use said render targetEglDisplay
needs to know if the native EGLDisplay can be trusted to create multiple contexts (which is the case here).
For example ANGLE uses single ID3D11Device for all contexts created from a single EGLDisplay which causes threading issues and native crashes, so we can't trust it to create multiple contexts properly.
We can change DrmOutput.CreateContext to allow context creation, but those contexts would be kinda useless.
@@ -19,6 +19,7 @@ | |||
using Avalonia.Utilities; | |||
using Avalonia.Win32.Input; | |||
using Avalonia.Win32.Interop; | |||
using JetBrains.Annotations; |
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.
I want to remove JetBrains.Annotations at all from the repository. It can be and should be replaced with nullable attributes.
Out of scope of this PR tho.
src/Windows/Avalonia.Win32/WinRT/Composition/WinUiCompositedWindowSurface.cs
Outdated
Show resolved
Hide resolved
…Avalonia into feature/context-management-8
You can test this PR using the following package version. |
@kekekeks does this PR fix Avalonia's OpenGL control rendering issues in windows os? |
You can test this PR using the following package version. |
No, this particular PR just fixes EGL_CONTEXT_LOST and provides better infrastructure for adding rendering backends |
@kekekeks are there any plans for fixing OpenGL control rendering issues in windows os soon? |
That's awesome thanks! |
You can test this PR using the following package version. |
see if you can break this with this DX commandline command |
You can test this PR using the following package version. |
@ltetak it works with normal avalonia setup. But segfaults with UseWGL enabled with no meaningful error. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
To survive a driver reset, our renderers need to be able to recreate the entire graphics infrastructure from scratch.
We also have a problem with graphics subsystem initialization blocking the rest of our initialization code on the UI thread, which is hurtful for embedded scenarious where initial GPU initialization might take some time due to drviver init, connected display scans, etc. So we'd rather initialize the GPU stuff on the render thread.
To do that, we need the renderer to be in control of the graphics resources rather than holding those in some static fields in SkiaPlatform.
Compositor would accept IPlatformGraphics directly, Deferred and Immediate renderers would use a wrapper object that creates the context on-demand
Renderer would be the sole entity that holds a reference to the graphics context. That causes a problem with texture-sharing powered opengl controls. For such controls the render platform context should expose:
while IRenderer now has
In case when the user wants to reuse their VkDevice, a similar interface will be provided as well. ValueTask is here due to the renderer potentially ticking on a background thread, so if context wasn't yet created, we need to wait for the next renderer tick.
Fixes #4128 #8320