microsoft / angle

ANGLE: OpenGL ES to DirectX translation
Other
615 stars 166 forks source link

sRGB back buffer supported? #103

Closed kircher1 closed 7 years ago

kircher1 commented 7 years ago

Initializing EGL with an sRGB backbuffer does not fail, but it also has no affect on the output image. Are sRGB back buffers supported?

EGL initialization configuration below... Note, I'm using an ES 3 context.

    const EGLint configAttributes[] =
    {
        EGL_RED_SIZE, 8,
        EGL_GREEN_SIZE, 8,
        EGL_BLUE_SIZE, 8,
        EGL_ALPHA_SIZE, 8,
        EGL_DEPTH_SIZE, 24,
        EGL_STENCIL_SIZE, 8,
        // None of these configs affects output. 
        //EGL_COLORSPACE,  EGL_COLORSPACE_sRGB, 
        //EGL_GL_COLORSPACE_KHR, EGL_GL_COLORSPACE_SRGB_KHR,
        //EGL_VG_COLORSPACE, EGL_VG_COLORSPACE_sRGB,
        EGL_NONE
    };

    const EGLint contextAttributes[] =
    {
        EGL_CONTEXT_CLIENT_VERSION, 3,
        EGL_NONE
    };

    const EGLint surfaceAttributes[] =
    {
        // EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER is part of the same optimization as EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER (see above).
        // If you have compilation issues with it then please update your Visual Studio templates.
        EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE,
        EGL_NONE
    };

    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_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, 

        // 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_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE,

        // 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.
        EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE,
        EGL_NONE,
    };
austinkinross commented 7 years ago

Sorry, ANGLE doesn't support these EGL attributes. While ANGLE fully supports OpenGL ES2 and 3, its EGL support is a bit patchy in places.

You can see a superset of the EGL config attributes that ANGLE supports in this file (see Display::getConfigAttrib). Note that not all of these attributes are supported by ANGLE's D3D11 backend.

ANGLE does support sRGB textures in OpenGL ES 3 (and 2 via an extension); see these tests for an example.

Hope this helps, Austin

kircher1 commented 7 years ago

Got it, thanks for the info. I have been using sRGB textures with success. To work around the lack of sRGB back buffer/render targets, the conversion from linear to sRGB is being performed at the end of the fragment shader(s). It's not necessarily perfect, but works well enough.

I wanted to point out though that an sRGB render target (i.e. color attachment to a frame buffer) falls more in the realm of GL than EGL, and it doesn't appear that works either.

Overall, any idea if sRGB render target/back buffer support is on the back log? If I remember correctly sRGB render targets are pretty easy to work with in D3D11 unless MSAA is involved. In that case, I recall MSDN saying that an extra full screen pass was required to copy sRGB data to the back buffer or something. Didn't seem trivial.

austinkinross commented 7 years ago

We (at Microsoft) don't intend to add further sRGB support to ANGLE in the near future, but other contributors may be planning it! Feel free to ask over on the master ANGLE project discussion board.

austinkinross commented 7 years ago

I'm closing this issue now since it's been inactive for a while. Please feel free to reactivate it if you have further questions!

Thanks, Austin