Using OpenGL 3.0 with MSOpenTech ANGLE

Typically ANGLE library is used with OpenGL 2.0, but I successfully tried to enable OpenGL 3.0:

const EGLint contextAttributes[] = 

and used some OpenGL 3.0 features in my Universal Windows App. But today I tried to compile my application with the new version of ANGLE library and got EGL_BAD_CONFIG error while creating the OpenGL context. The source code that returns this error checks some EGL_OPENGL_ES3_BIT_KHR that is not set in the new version:

if (clientMajorVersion == 3 && !(configuration->conformant & EGL_OPENGL_ES3_BIT_KHR))
    return Error(EGL_BAD_CONFIG);

some new flag mUseDirectRendering, that is not used here in the previous version prevents it from being set:

config.conformant = (!mUseDirectRendering && mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0) ? (EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR) : 0;

mUseDirectRendering in its turn is set with the following code:

mUseDirectRendering =
    !!(attributes.get(EGL_PLATFORM_ANGLE_EXPERIMENTAL_DIRECT_RENDERING, defaultDirectRendering));

where attributes is the display attributes that I pass to eglGetPlatformDisplayEXT. Obviously the first solution is to set EGL_PLATFORM_ANGLE_EXPERIMENTAL_DIRECT_RENDERING to EGL_FALSE, but it is not enough because new ANGLE redirects EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER to EGL_PLATFORM_ANGLE_EXPERIMENTAL_DIRECT_RENDERING with the following code:

if (foundRenderToBackbuffer)
    attribMap.insert(EGL_PLATFORM_ANGLE_EXPERIMENTAL_DIRECT_RENDERING, requestedAllowRenderToBackBuffer);

So the new version of ANGLE works only with the following display attributes:

const EGLint defaultDisplayAttributes[] =
    // These are the default display attributes, used to request ANGLE's D3D11 renderer.
    // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+.

    // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices.
    // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it.
    // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call 
    // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. 
    // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement.


The ANGLE documentation says that this EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is a big performance win, and commenting it out can reduce performance on some mobile devices, so probably it does not make a sense to upgrade to the new version until this optimization is supported with OpenGL 3.0.

Leave a Reply

Your email address will not be published. Required fields are marked *