|
|
@@ -305,7 +305,7 @@ st_framebuffer_update_attachments(struct st_framebuffer *stfb) |
|
|
|
*/ |
|
|
|
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; |
|
|
@@ -328,7 +328,7 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb, |
|
|
|
break; |
|
|
|
default: |
|
|
|
format = stfb->iface->visual->color_format; |
|
|
|
if (stfb->Base.Visual.sRGBCapable) |
|
|
|
if (prefer_srgb) |
|
|
|
format = util_format_srgb(format); |
|
|
|
sw = FALSE; |
|
|
|
break; |
|
|
@@ -446,6 +446,7 @@ st_framebuffer_create(struct st_context *st, |
|
|
|
struct st_framebuffer *stfb; |
|
|
|
struct gl_config mode; |
|
|
|
gl_buffer_index idx; |
|
|
|
bool prefer_srgb = false; |
|
|
|
|
|
|
|
if (!stfbi) |
|
|
|
return NULL; |
|
|
@@ -467,14 +468,15 @@ st_framebuffer_create(struct st_context *st, |
|
|
|
* 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); |
|
|
@@ -485,8 +487,14 @@ st_framebuffer_create(struct st_context *st, |
|
|
|
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); |
|
|
@@ -497,13 +505,13 @@ st_framebuffer_create(struct st_context *st, |
|
|
|
|
|
|
|
/* 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); |
|
|
@@ -1209,7 +1217,8 @@ st_manager_add_color_renderbuffer(struct st_context *st, |
|
|
|
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); |