From 124ad88924b3863162e8fd5936edeb5d0b39855c Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 5 Jul 2023 11:50:21 -0700 Subject: [PATCH 1/3] Fix egl opengl initialization on win32 --- src/Windows/Avalonia.Win32/Win32GlManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Windows/Avalonia.Win32/Win32GlManager.cs b/src/Windows/Avalonia.Win32/Win32GlManager.cs index b3760a37e1..ebb708f4c5 100644 --- a/src/Windows/Avalonia.Win32/Win32GlManager.cs +++ b/src/Windows/Avalonia.Win32/Win32GlManager.cs @@ -20,6 +20,10 @@ static class Win32GlManager { AvaloniaLocator.CurrentMutable.Bind().ToConstant(gl); } + if (gl is IPlatformGraphicsOpenGlContextFactory openGlFactory) + { + AvaloniaLocator.CurrentMutable.Bind().ToConstant(openGlFactory); + } return gl; } From 21f4a2044bb3e1fe79ef9fc5c630c3ea10dc245b Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 5 Jul 2023 11:50:33 -0700 Subject: [PATCH 2/3] Minor doc fix --- src/Avalonia.Base/Platform/Storage/PickerOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs index ed061aa2d5..07f99f32c8 100644 --- a/src/Avalonia.Base/Platform/Storage/PickerOptions.cs +++ b/src/Avalonia.Base/Platform/Storage/PickerOptions.cs @@ -6,7 +6,7 @@ public class PickerOptions { /// - /// Gets or sets the text that appears in the title bar of a folder dialog. + /// Gets or sets the text that appears in the title bar of a picker. /// public string? Title { get; set; } From c4178c8a4b0c6f561bdfca9dec275b07eccb44a5 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Wed, 5 Jul 2023 13:14:48 -0700 Subject: [PATCH 3/3] Fix WGL crash in virtual machine --- src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs b/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs index e207bc23ab..85cab1d18e 100644 --- a/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs +++ b/src/Windows/Avalonia.Win32/OpenGl/WglDisplay.cs @@ -38,12 +38,10 @@ namespace Avalonia.Win32.OpenGl [MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))] [MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))] - [MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))] private static bool Initialize() => _initialized ??= InitializeCore(); [MemberNotNullWhen(true, nameof(s_wglChoosePixelFormatArb))] [MemberNotNullWhen(true, nameof(s_wglCreateContextAttribsArb))] - [MemberNotNullWhen(true, nameof(s_glDebugMessageCallback))] private static bool InitializeCore() { Dispatcher.UIThread.VerifyAccess(); @@ -74,9 +72,9 @@ namespace Avalonia.Win32.OpenGl Marshal.GetDelegateForFunctionPointer( wglGetProcAddress("wglChoosePixelFormatARB")); - s_glDebugMessageCallback = - Marshal.GetDelegateForFunctionPointer( - wglGetProcAddress("glDebugMessageCallback")); + s_glDebugMessageCallback = wglGetProcAddress("glDebugMessageCallback") is { } setDebugCallback && setDebugCallback != default ? + Marshal.GetDelegateForFunctionPointer(setDebugCallback) : + null; var formats = new int[1]; @@ -144,8 +142,12 @@ namespace Avalonia.Win32.OpenGl }); } - using(new WglRestoreContext(dc, context, null)) - s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero); + if (s_glDebugMessageCallback is not null) + { + using (new WglRestoreContext(dc, context, null)) + s_glDebugMessageCallback(Marshal.GetFunctionPointerForDelegate(_debugCallback), IntPtr.Zero); + } + if (context != IntPtr.Zero) return new WglContext(shareContext, version, context, window, dc, _defaultPixelFormat, _defaultPfd);