Bug 89636

Summary: dEQP-GLES3: Blit operation should perform sRGB encoding/decoding in OpenGL ES 3.0
Product: Mesa Reporter: Antia Puentes <apuentes>
Component: Drivers/DRI/i965Assignee: Kenneth Graunke <kenneth>
Status: RESOLVED FIXED QA Contact: Intel 3D Bugs Mailing List <intel-3d-bugs>
Severity: normal    
Priority: medium CC: apuentes
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Bug Depends on:    
Bug Blocks: 94448    

Description Antia Puentes 2015-03-18 07:15:09 UTC
Failed tests:
 [37 tests]
      * dEQP-GLES3.functional.fbo.blit.conversion.rgba8_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgba8
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgb10_a2
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgba4
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgb5_a1
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgb8
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgb565
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rg8
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_r8
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgba32f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rgba16f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_r11f_g11f_b10f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rg32f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_rg16f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_r32f
      * dEQP-GLES3.functional.fbo.blit.conversion.srgb8_alpha8_to_r16f
      * dEQP-GLES3.functional.fbo.blit.conversion.rgb10_a2_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgba4_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgb5_a1_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgb8_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgb565_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rg8_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.r8_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgba32f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rgba16f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.r11f_g11f_b10f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rg32f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.rg16f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.r32f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.conversion.r16f_to_srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_nearest_scale_blit_from_default
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_nearest_scale_blit_to_default
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_scale_blit_from_default
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_scale_blit_to_default
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_out_of_bounds_blit_from_default
      * dEQP-GLES3.functional.fbo.blit.default_framebuffer.srgb8_alpha8_linear_out_of_bounds_blit_to_default

The tests fail because they expect sRGB enconding to be done during the blit operation if the destination framebuffer is sRGB, and sRGB decoding when reading if the read framebuffer is sRGB.

 - From section 4.3.3 ("Copying Pixels") of the OpenGL ES 3.0 specification (page 198):

        "When values are taken from the read buffer, if the value of
        FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the framebuffer
        attachment corresponding to the read buffer is SRGB (see section
        6.1.13), the red, green, and blue components are converted from
        the non-linear sRGB color space according to equation 3.24.
        
        When values are written to the draw buffers, blit operations
        bypass the fragment pipeline. The only fragment operations which
        affect a blit are the pixel ownership test, the scissor test,
        and sRGB conversion (see section 4.1.8). Color, depth, and
        stencil masks (see section 4.2.2) are ignored."

However, Mesa does not do any sRGB encoding/decoding during the blit. For more information see: http://lists.freedesktop.org/archives/mesa-dev/2015-February/077681.html
Comment 1 Antia Puentes 2015-03-18 07:22:12 UTC
If during the blorp blit operation, we do not linearize the format of the surface in "brw_blorp_surface_info::set" the tests passed.
Comment 2 Kenneth Graunke 2016-03-09 01:02:19 UTC
The equivalent fix in Meta (blitframebuffer_texture) seems to be calling _mesa_set_framebuffer_srgb(ctx, drawFb->Visual.sRGBCapable).
Comment 3 Kenneth Graunke 2016-03-21 21:15:20 UTC
This should be fixed on Gen8+ with:

commit eee8a53906f72635423931430e667159c88613bb
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Tue Mar 8 00:34:14 2016 -0800

    meta: Make BlitFramebuffer() do sRGB encoding in ES 3.x.

and on Gen6-7 with:

commit 4b0a5b21ae39756919d739015fcc835f2901337f
Author: Kenneth Graunke <kenneth@whitecape.org>
Date:   Wed Mar 16 20:19:50 2016 -0700

    i965/blorp: Make BlitFramebuffer() do sRGB encoding in ES 3.x.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.