Browse Source

support any gles version with angle using angle options.

pull/4675/head
Dan Walmsley 6 years ago
parent
commit
a6d83cd32a
  1. 8
      src/Avalonia.OpenGL/AngleOptions.cs
  2. 63
      src/Avalonia.OpenGL/EglDisplay.cs
  3. 2
      src/Avalonia.X11/Glx/GlxDisplay.cs
  4. 4
      src/Avalonia.X11/Glx/GlxPlatformFeature.cs
  5. 4
      src/Avalonia.X11/X11Platform.cs

8
src/Avalonia.OpenGL/AngleOptions.cs

@ -10,6 +10,14 @@ namespace Avalonia.OpenGL
DirectX11 DirectX11
} }
public IList<GlVersion> GlProfiles { get; set; } = new List<GlVersion>
{
new GlVersion(GlProfileType.OpenGLES, 3, 2),
new GlVersion(GlProfileType.OpenGLES, 3, 1),
new GlVersion(GlProfileType.OpenGLES, 3, 0),
new GlVersion(GlProfileType.OpenGLES, 2, 0)
};
public IList<PlatformApi> AllowedPlatformApis { get; set; } = null; public IList<PlatformApi> AllowedPlatformApis { get; set; } = null;
} }
} }

63
src/Avalonia.OpenGL/EglDisplay.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Avalonia.Platform.Interop; using Avalonia.Platform.Interop;
using static Avalonia.OpenGL.EglConsts; using static Avalonia.OpenGL.EglConsts;
@ -61,45 +62,45 @@ namespace Avalonia.OpenGL
if (!_egl.Initialize(_display, out var major, out var minor)) if (!_egl.Initialize(_display, out var major, out var minor))
throw OpenGlException.GetFormattedException("eglInitialize", _egl); throw OpenGlException.GetFormattedException("eglInitialize", _egl);
foreach (var cfg in new[] var glProfiles = AvaloniaLocator.Current.GetService<AngleOptions>()?.GlProfiles
?? new[]
{
new GlVersion(GlProfileType.OpenGLES, 3, 2),
new GlVersion(GlProfileType.OpenGLES, 3, 1),
new GlVersion(GlProfileType.OpenGLES, 3, 0),
new GlVersion(GlProfileType.OpenGLES, 2, 0)
};
var cfgs = glProfiles.Select(x =>
{ {
new var typeBit = EGL_OPENGL_ES3_BIT;
{
Attributes = new[] switch (x.Major)
{
EGL_CONTEXT_MAJOR_VERSION, 3,
EGL_CONTEXT_MINOR_VERSION, 1,
EGL_NONE
},
Api = EGL_OPENGL_ES_API,
RenderableTypeBit = EGL_OPENGL_ES3_BIT,
Version = new GlVersion(GlProfileType.OpenGLES, 3, 1)
},
new
{ {
Attributes = new[] case 2:
{ typeBit = EGL_OPENGL_ES2_BIT;
EGL_CONTEXT_MAJOR_VERSION, 3, break;
EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE case 1:
}, typeBit = EGL_OPENGL_ES_BIT;
Api = EGL_OPENGL_ES_API, break;
RenderableTypeBit = EGL_OPENGL_ES3_BIT, }
Version = new GlVersion(GlProfileType.OpenGLES, 3, 0)
}, return new
new
{ {
Attributes = new[] Attributes = new[]
{ {
EGL_CONTEXT_MAJOR_VERSION, 2, EGL_CONTEXT_MAJOR_VERSION, x.Major,
EGL_CONTEXT_MINOR_VERSION, 0, EGL_CONTEXT_MINOR_VERSION, x.Minor,
EGL_NONE EGL_NONE
}, },
Api = EGL_OPENGL_ES_API, Api = EGL_OPENGL_ES_API,
RenderableTypeBit = EGL_OPENGL_ES2_BIT, RenderableTypeBit = typeBit,
Version = new GlVersion(GlProfileType.OpenGLES, 2, 0) Version = x
}, };
}) });
foreach (var cfg in cfgs)
{ {
if (!_egl.BindApi(cfg.Api)) if (!_egl.BindApi(cfg.Api))
continue; continue;

2
src/Avalonia.X11/Glx/GlxDisplay.cs

@ -18,7 +18,7 @@ namespace Avalonia.X11.Glx
public XVisualInfo* VisualInfo => _visual; public XVisualInfo* VisualInfo => _visual;
public GlxContext DeferredContext { get; } public GlxContext DeferredContext { get; }
public GlxInterface Glx { get; } = new GlxInterface(); public GlxInterface Glx { get; } = new GlxInterface();
public GlxDisplay(X11Info x11, List<GlVersion> probeProfiles) public GlxDisplay(X11Info x11, IList<GlVersion> probeProfiles)
{ {
_x11 = x11; _x11 = x11;
_probeProfiles = probeProfiles.ToList(); _probeProfiles = probeProfiles.ToList();

4
src/Avalonia.X11/Glx/GlxPlatformFeature.cs

@ -12,7 +12,7 @@ namespace Avalonia.X11.Glx
public GlxContext DeferredContext { get; private set; } public GlxContext DeferredContext { get; private set; }
public IGlContext MainContext => DeferredContext; public IGlContext MainContext => DeferredContext;
public static bool TryInitialize(X11Info x11, List<GlVersion> glProfiles) public static bool TryInitialize(X11Info x11, IList<GlVersion> glProfiles)
{ {
var feature = TryCreate(x11, glProfiles); var feature = TryCreate(x11, glProfiles);
if (feature != null) if (feature != null)
@ -24,7 +24,7 @@ namespace Avalonia.X11.Glx
return false; return false;
} }
public static GlxGlPlatformFeature TryCreate(X11Info x11, List<GlVersion> glProfiles) public static GlxGlPlatformFeature TryCreate(X11Info x11, IList<GlVersion> glProfiles)
{ {
try try
{ {

4
src/Avalonia.X11/X11Platform.cs

@ -103,7 +103,7 @@ namespace Avalonia
public bool UseDBusMenu { get; set; } public bool UseDBusMenu { get; set; }
public bool UseDeferredRendering { get; set; } = true; public bool UseDeferredRendering { get; set; } = true;
public List<GlVersion> GlProfiles { get; set; } = new List<GlVersion> public IList<GlVersion> GlProfiles { get; set; } = new List<GlVersion>
{ {
new GlVersion(GlProfileType.OpenGL, 4, 0), new GlVersion(GlProfileType.OpenGL, 4, 0),
new GlVersion(GlProfileType.OpenGL, 3, 2), new GlVersion(GlProfileType.OpenGL, 3, 2),
@ -113,7 +113,7 @@ namespace Avalonia
new GlVersion(GlProfileType.OpenGLES, 2, 0) new GlVersion(GlProfileType.OpenGLES, 2, 0)
}; };
public List<string> GlxRendererBlacklist { get; set; } = new List<string> public IList<string> GlxRendererBlacklist { get; set; } = new List<string>
{ {
// llvmpipe is a software GL rasterizer. If it's returned by glGetString, // llvmpipe is a software GL rasterizer. If it's returned by glGetString,
// that usually means that something in the system is horribly misconfigured // that usually means that something in the system is horribly misconfigured

Loading…
Cancel
Save