Browse Source
Merge pull request #3363 from PJB3005/19-12-16-egl
Fix loading EGL functions on GLX.
pull/3369/head
danwalmsley
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
2 deletions
-
src/Avalonia.X11/Glx/Glx.cs
-
src/Avalonia.X11/Glx/GlxDisplay.cs
|
|
|
@ -84,8 +84,24 @@ namespace Avalonia.X11.Glx |
|
|
|
[GlEntryPoint("glGetError")] |
|
|
|
public GlGetError GetError { get; } |
|
|
|
|
|
|
|
public GlxInterface() : base(GlxGetProcAddress) |
|
|
|
public GlxInterface() : base(SafeGetProcAddress) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
// Ignores egl functions.
|
|
|
|
// On some Linux systems, glXGetProcAddress will return valid pointers for even EGL functions.
|
|
|
|
// This makes Skia try to load some data from EGL,
|
|
|
|
// which can then cause segmentation faults because they return garbage.
|
|
|
|
public static IntPtr SafeGetProcAddress(string proc, bool optional) |
|
|
|
{ |
|
|
|
if (proc.StartsWith("egl", StringComparison.InvariantCulture)) |
|
|
|
{ |
|
|
|
return IntPtr.Zero; |
|
|
|
} |
|
|
|
|
|
|
|
return GlxConverted(proc, optional); |
|
|
|
} |
|
|
|
|
|
|
|
private static readonly Func<string, bool, IntPtr> GlxConverted = ConvertNative(GlxGetProcAddress); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -87,7 +87,7 @@ namespace Avalonia.X11.Glx |
|
|
|
ImmediateContext.MakeCurrent(); |
|
|
|
var err = Glx.GetError(); |
|
|
|
|
|
|
|
GlInterface = new GlInterface(GlxInterface.GlxGetProcAddress); |
|
|
|
GlInterface = new GlInterface(GlxInterface.SafeGetProcAddress); |
|
|
|
if (GlInterface.Version == null) |
|
|
|
throw new OpenGlException("GL version string is null, aborting"); |
|
|
|
if (GlInterface.Renderer == null) |
|
|
|
|