X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_cb_fbo.c;h=5b9e2037423ef2c7f0432fba74c592c1ba706da4;hb=a65e9706035c0e348307e76fdeeed0910ec8c68e;hp=ae49434cac934a4a99584e613e7d11056bc2d655;hpb=fb5d9e1199cabe653ae1bb822bb66ce9f0ce7f55;p=mesa.git diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index ae49434cac9..5b9e2037423 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -74,11 +74,8 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, enum pipe_format format; struct pipe_surface surf_tmpl; - 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); if (format == PIPE_FORMAT_NONE) { return FALSE; @@ -90,6 +87,7 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, strb->Base.Format = st_pipe_format_to_mesa_format(format); strb->Base._BaseFormat = _mesa_base_fbo_format(ctx, internalFormat); strb->Base.DataType = st_format_datatype(format); + strb->format = format; strb->defined = GL_FALSE; /* undefined contents now */ @@ -272,7 +270,8 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT; break; case PIPE_FORMAT_R16G16B16A16_SNORM: - strb->Base.InternalFormat = GL_RGBA16; + /* accum buffer */ + strb->Base.InternalFormat = GL_RGBA16_SNORM; break; case PIPE_FORMAT_R8_UNORM: strb->Base.InternalFormat = GL_R8; @@ -353,7 +352,7 @@ st_render_texture(struct gl_context *ctx, return; /* get pointer to texture image we're rendeing to */ - texImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel]; + texImage = _mesa_get_attachment_teximage(att); /* create new renderbuffer which wraps the texture image */ rb = st_new_renderbuffer(ctx, 0); @@ -431,14 +430,11 @@ static void st_finish_render_texture(struct gl_context *ctx, struct gl_renderbuffer_attachment *att) { - struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(att->Renderbuffer); if (!strb) return; - st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL); - strb->rtt = NULL; /* @@ -474,8 +470,7 @@ st_validate_attachment(struct gl_context *ctx, return GL_FALSE; format = stObj->pt->format; - texFormat = - stObj->base.Image[att->CubeMapFace][att->TextureLevel]->TexFormat; + texFormat = _mesa_get_attachment_teximage_const(att)->TexFormat; /* If the encoding is sRGB and sRGB rendering cannot be enabled, * check for linear format support instead. @@ -488,7 +483,7 @@ st_validate_attachment(struct gl_context *ctx, return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, - stObj->pt->nr_samples, bindings, 0); + stObj->pt->nr_samples, bindings); } @@ -532,6 +527,9 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) const struct gl_renderbuffer_attachment *stencil = &fb->Attachment[BUFFER_STENCIL]; GLuint i; + enum pipe_format first_format = PIPE_FORMAT_NONE; + boolean mixed_formats = + screen->get_param(screen, PIPE_CAP_MIXED_COLORBUFFER_FORMATS) != 0; if (depth->Type && stencil->Type && depth->Type != stencil->Type) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; @@ -565,13 +563,33 @@ st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb) return; } for (i = 0; i < ctx->Const.MaxColorAttachments; i++) { + struct gl_renderbuffer_attachment *att = + &fb->Attachment[BUFFER_COLOR0 + i]; + enum pipe_format format; + if (!st_validate_attachment(ctx, screen, - &fb->Attachment[BUFFER_COLOR0 + i], + att, PIPE_BIND_RENDER_TARGET)) { fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; return; } + + if (!mixed_formats) { + /* Disallow mixed formats. */ + if (att->Type != GL_NONE) { + format = st_renderbuffer(att->Renderbuffer)->surface->format; + } else { + continue; + } + + if (first_format == PIPE_FORMAT_NONE) { + first_format = format; + } else if (format != first_format) { + fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT; + return; + } + } } }