X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_cb_fbo.c;h=0b0ad16eaaa98403ac9374abdb590269bbce36fe;hb=cdca3c58aa2d9549f5188910e2a77b438516714f;hp=cd718a31a145925712be1163d0d29352a448efb3;hpb=4c7001462607e6e99e474d6271dd481d3f8f201c;p=mesa.git diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index cd718a31a14..0b0ad16eaaa 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -38,6 +38,7 @@ #include "main/fbobject.h" #include "main/framebuffer.h" #include "main/macros.h" +#include "main/mfeatures.h" #include "main/renderbuffer.h" #include "pipe/p_context.h" @@ -61,7 +62,8 @@ * during window resize. */ static GLboolean -st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb, +st_renderbuffer_alloc_storage(struct gl_context * ctx, + struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { @@ -75,7 +77,8 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *r if (strb->format != PIPE_FORMAT_NONE) format = strb->format; else - format = st_choose_renderbuffer_format(screen, internalFormat, rb->NumSamples); + format = st_choose_renderbuffer_format(screen, internalFormat, + rb->NumSamples); /* init renderbuffer fields */ strb->Base.Width = width; @@ -387,7 +390,7 @@ st_render_texture(struct gl_context *ctx, /* new surface for rendering into the texture */ memset(&surf_tmpl, 0, sizeof(surf_tmpl)); - surf_tmpl.format = strb->texture->format; + surf_tmpl.format = ctx->Color.sRGBEnabled ? strb->texture->format : util_format_linear(strb->texture->format); surf_tmpl.usage = PIPE_BIND_RENDER_TARGET; surf_tmpl.u.tex.level = strb->rtt_level; surf_tmpl.u.tex.first_layer = strb->rtt_face + strb->rtt_slice; @@ -445,11 +448,14 @@ st_finish_render_texture(struct gl_context *ctx, * Validate a renderbuffer attachment for a particular set of bindings. */ static GLboolean -st_validate_attachment(struct pipe_screen *screen, +st_validate_attachment(struct gl_context *ctx, + struct pipe_screen *screen, const struct gl_renderbuffer_attachment *att, unsigned bindings) { const struct st_texture_object *stObj = st_texture_object(att->Texture); + enum pipe_format format; + gl_format texFormat; /* Only validate texture attachments for now, since * st_renderbuffer_alloc_storage makes sure that @@ -461,7 +467,20 @@ st_validate_attachment(struct pipe_screen *screen, if (!stObj) return GL_FALSE; - return screen->is_format_supported(screen, stObj->pt->format, + format = stObj->pt->format; + texFormat = + stObj->base.Image[att->CubeMapFace][att->TextureLevel]->TexFormat; + + /* 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->Const.sRGBCapable && + _mesa_get_format_color_encoding(texFormat) == GL_SRGB) { + const gl_format linearFormat = _mesa_get_srgb_format_linear(texFormat); + format = st_mesa_format_to_pipe_format(linearFormat); + } + + return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, stObj->pt->nr_samples, bindings, 0); } @@ -525,20 +544,23 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) return; } - if (!st_validate_attachment(screen, + if (!st_validate_attachment(ctx, + screen, depth, PIPE_BIND_DEPTH_STENCIL)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } - if (!st_validate_attachment(screen, + if (!st_validate_attachment(ctx, + screen, stencil, PIPE_BIND_DEPTH_STENCIL)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { - if (!st_validate_attachment(screen, + if (!st_validate_attachment(ctx, + screen, &fb->Attachment[BUFFER_COLOR0 + i], PIPE_BIND_RENDER_TARGET)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;