From 490ce4bdc5fa09410a8f41ece55cf3883345162b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Wed, 13 May 2015 10:10:31 +0300 Subject: [PATCH] mesa: fix GetFramebufferAttachmentParameteriv query for GL_NONE type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In desktop GL name and type can be queried even if the attachment point does not exist. In this case we should return GL_NONE as type and 0 as the name. Signed-off-by: Tapani Pälli --- src/mesa/main/fbobject.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index 27cf97f..39931ce 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -2954,7 +2954,22 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, att = get_attachment(ctx, buffer, attachment); } - if (att == NULL) { + /* In desktop GL name and type can be queried even if the attachment point + * does not exist. In this case we should return GL_NONE as type and 0 as + * the name. + * + * From the OpenGL 4.4 spec page 313: + * + * "If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is NONE, then + * either no framebuffer is bound to target; or the default framebuffer + * is bound, attachment is DEPTH or STENCIL , and the number of depth + * or stencil bits, respectively, is zero. In this case querying pname + * FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero, and all other + * queries will generate an INVALID_OPERATION error." + */ + if (att == NULL && (!_mesa_is_desktop_gl(ctx) || + ((pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE && + pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)))) { _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferAttachmentParameteriv(attachment)"); return; @@ -2990,10 +3005,18 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, switch (pname) { case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: + if (att == NULL) { + *params = GL_NONE; + return; + } *params = _mesa_is_winsys_fbo(buffer) ? GL_FRAMEBUFFER_DEFAULT : att->Type; return; case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: + if (att == NULL) { + *params = 0; + return; + } if (att->Type == GL_RENDERBUFFER_EXT) { *params = att->Renderbuffer->Name; } -- 2.1.0