[-,Mesa,08/10] i965: Make BLORP's BlitFramebuffer follow the GL 4.4 sRGB rules.

Submitted by Kenneth Graunke on Aug. 4, 2016, 11:14 p.m.


Message ID 20160804231451.9994-9-kenneth@whitecape.org
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Kenneth Graunke Aug. 4, 2016, 11:14 p.m.
OpenGL 4.4 specifies that BlitFramebuffer should perform sRGB encode
and decode like ES 3.x does, but only when GL_FRAMEBUFFER_SRGB is
enabled.  This is technically incompatible in certain cases, but is
more consistent across GL, ES, and WebGL, and more flexible.

The NVIDIA 367.35 drivers appear to follow this behavior.

For the awful spec analysis, please read Piglit's
tests/spec/arb_framebuffer_srgb/blit.c, which explains the differences
between GL 4.1, 4.2, 4.3 (2012), 4.3 (2013), and 4.4, and why this
is the right rule to implement.

Note that ctx->Color.sRGBEnabled is initialized to _mesa_is_gles(ctx),
and ES doesn't have enable/disable flags for GL_FRAMEBUFFER_SRGB, so
it's effectively on all the time.  This means the ES behavior should
be unchanged.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 20bbe7f..b903de1 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -61,11 +61,14 @@  do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit,
               GLfloat dstX0, GLfloat dstY0, GLfloat dstX1, GLfloat dstY1,
               GLenum filter, bool mirror_x, bool mirror_y)
+   const struct gl_context *ctx = &brw->ctx;
    /* Find source/dst miptrees */
    struct intel_mipmap_tree *src_mt = find_miptree(buffer_bit, src_irb);
    struct intel_mipmap_tree *dst_mt = find_miptree(buffer_bit, dst_irb);
-   const bool es = _mesa_is_gles(&brw->ctx);
+   const bool do_srgb = ctx->Color.sRGBEnabled;
    /* Do the blit */
                            src_mt, src_irb->mt_level, src_irb->mt_layer,
@@ -75,7 +78,7 @@  do_blorp_blit(struct brw_context *brw, GLbitfield buffer_bit,
                            srcX0, srcY0, srcX1, srcY1,
                            dstX0, dstY0, dstX1, dstY1,
                            filter, mirror_x, mirror_y,
-                           es, es);
+                           do_srgb, do_srgb);
    dst_irb->need_downsample = true;