/* If an sRGB framebuffer is unsupported, sRGB formats behave like linear
* formats.
*/
- if (!ctx->Extensions.EXT_framebuffer_sRGB) {
+ if (!ctx->Extensions.EXT_sRGB) {
internalFormat = _mesa_get_linear_internalformat(internalFormat);
}
/* If the encoding is sRGB and sRGB rendering cannot be enabled,
* check for linear format support instead.
* Later when we create a surface, we change the format to a linear one. */
- if (!ctx->Extensions.EXT_framebuffer_sRGB &&
+ if (!ctx->Extensions.EXT_sRGB &&
_mesa_get_format_color_encoding(texFormat) == GL_SRGB) {
const mesa_format linearFormat = _mesa_get_srgb_format_linear(texFormat);
format = st_mesa_format_to_pipe_format(st_context(ctx), linearFormat);
PIPE_FORMAT_B10G10R10A2_UINT },
GL_TRUE }, /* at least one format must be supported */
- { { o(EXT_framebuffer_sRGB) },
+ { { o(EXT_sRGB) },
{ PIPE_FORMAT_A8B8G8R8_SRGB,
PIPE_FORMAT_B8G8R8A8_SRGB,
PIPE_FORMAT_R8G8B8A8_SRGB },
extensions->ARB_texture_buffer_object_rgb32 &&
extensions->ARB_shader_image_load_store;
+ extensions->EXT_framebuffer_sRGB =
+ screen->get_param(screen, PIPE_CAP_DEST_SURFACE_SRGB_CONTROL) &&
+ extensions->EXT_sRGB;
+
/* Unpacking a varying in the fragment shader costs 1 texture indirection.
* If the number of available texture indirections is very limited, then we
* prefer to disable varying packing rather than run the risk of varying
*/
static boolean
st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
- gl_buffer_index idx)
+ gl_buffer_index idx, bool prefer_srgb)
{
struct gl_renderbuffer *rb;
enum pipe_format format;
break;
default:
format = stfb->iface->visual->color_format;
- if (stfb->Base.Visual.sRGBCapable)
+ if (prefer_srgb)
format = util_format_srgb(format);
sw = FALSE;
break;
struct st_framebuffer *stfb;
struct gl_config mode;
gl_buffer_index idx;
+ bool prefer_srgb = false;
if (!stfbi)
return NULL;
* format such that util_format_srgb(visual->color_format) can be supported
* by the pipe driver. We still need to advertise the capability here.
*
- * For GLES, however, sRGB framebuffer write is controlled only by the
- * capability of the framebuffer. There is GL_EXT_sRGB_write_control to
- * give applications the control back, but sRGB write is still enabled by
- * default. To avoid unexpected results, we should not advertise the
- * capability. This could change when we add support for
- * EGL_KHR_gl_colorspace.
+ * For GLES, however, sRGB framebuffer write is initially only controlled
+ * by the capability of the framebuffer, with GL_EXT_sRGB_write_control
+ * control is given back to the applications, but GL_FRAMEBUFFER_SRGB is
+ * still enabled by default since this is the behaviour when
+ * EXT_sRGB_write_control is not available. Since GL_EXT_sRGB_write_control
+ * brings GLES on par with desktop GLs EXT_framebuffer_sRGB, in mesa this
+ * is also expressed by using the same extension flag
*/
- if (_mesa_is_desktop_gl(st->ctx)) {
+ if (st->ctx->Extensions.EXT_framebuffer_sRGB) {
struct pipe_screen *screen = st->pipe->screen;
const enum pipe_format srgb_format =
util_format_srgb(stfbi->visual->color_format);
PIPE_TEXTURE_2D, stfbi->visual->samples,
stfbi->visual->samples,
(PIPE_BIND_DISPLAY_TARGET |
- PIPE_BIND_RENDER_TARGET)))
+ PIPE_BIND_RENDER_TARGET))) {
mode.sRGBCapable = GL_TRUE;
+ /* Since GL_FRAMEBUFFER_SRGB is enabled by default on GLES we must not
+ * create renderbuffers with an sRGB format derived from the
+ * visual->color_format, but we still want sRGB for desktop GL.
+ */
+ prefer_srgb = _mesa_is_desktop_gl(st->ctx);
+ }
}
_mesa_initialize_window_framebuffer(&stfb->Base, &mode);
/* add the color buffer */
idx = stfb->Base._ColorDrawBufferIndexes[0];
- if (!st_framebuffer_add_renderbuffer(stfb, idx)) {
+ if (!st_framebuffer_add_renderbuffer(stfb, idx, prefer_srgb)) {
free(stfb);
return NULL;
}
- st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH);
- st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM);
+ st_framebuffer_add_renderbuffer(stfb, BUFFER_DEPTH, false);
+ st_framebuffer_add_renderbuffer(stfb, BUFFER_ACCUM, false);
stfb->stamp = 0;
st_framebuffer_update_attachments(stfb);
return FALSE;
}
- if (!st_framebuffer_add_renderbuffer(stfb, idx))
+ if (!st_framebuffer_add_renderbuffer(stfb, idx,
+ stfb->Base.Visual.sRGBCapable))
return FALSE;
st_framebuffer_update_attachments(stfb);