[Mesa-dev] [PATCH 14/38] main: Add entry point GetNamedFramebufferAttachmentParameteriv.

Fredrik Höglund fredrik at kde.org
Sun Apr 12 08:49:18 PDT 2015


On Wednesday 04 March 2015, Laura Ekstrand wrote:
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |   7 ++
>  src/mesa/main/fbobject.c                       | 131 ++++++++++++++++---------
>  src/mesa/main/fbobject.h                       |  10 ++
>  src/mesa/main/tests/dispatch_sanity.cpp        |   1 +
>  4 files changed, 103 insertions(+), 46 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 20c2e7b..36de3c1 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -146,6 +146,13 @@
>        <param name="target" type="GLenum" />
>     </function>
>  
> +   <function name="GetNamedFramebufferAttachmentParameteriv" offset="assign">
> +      <param name="framebuffer" type="GLuint" />
> +      <param name="attachment" type="GLenum" />
> +      <param name="pname" type="GLenum" />
> +      <param name="params" type="GLint *" />
> +   </function>
> +
>     <!-- Texture object functions -->
>  
>     <function name="CreateTextures" offset="assign">
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 6ed82d5..467a8cd 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -3142,25 +3142,18 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
>  }
>  
>  
> -void GLAPIENTRY
> -_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
> -                                          GLenum pname, GLint *params)
> +void
> +_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
> +                                           struct gl_framebuffer *buffer,
> +                                           GLenum attachment, GLenum pname,
> +                                           GLint *params, const char *caller)
>  {
>     const struct gl_renderbuffer_attachment *att;
> -   struct gl_framebuffer *buffer;
>     GLenum err;
> -   GET_CURRENT_CONTEXT(ctx);
>  
>     /* The error differs in GL and GLES. */
>     err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
>  
> -   buffer = get_framebuffer_target(ctx, target);
> -   if (!buffer) {
> -      _mesa_error(ctx, GL_INVALID_ENUM,
> -                  "glGetFramebufferAttachmentParameteriv(target)");
> -      return;
> -   }
> -
>     if (_mesa_is_winsys_fbo(buffer)) {
>        /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
>         * says:
> @@ -3175,15 +3168,15 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        if ((!_mesa_is_desktop_gl(ctx) ||
>             !ctx->Extensions.ARB_framebuffer_object)
>            && !_mesa_is_gles3(ctx)) {
> -	 _mesa_error(ctx, GL_INVALID_OPERATION,
> -		     "glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
> -	 return;
> +         _mesa_error(ctx, GL_INVALID_OPERATION, "%s(bound FBO = 0)", caller);
> +         return;

The fbo might not be the bound fbo in the DSA case.

>        }
>  
>        if (_mesa_is_gles3(ctx) && attachment != GL_BACK &&
>            attachment != GL_DEPTH && attachment != GL_STENCIL) {
>           _mesa_error(ctx, GL_INVALID_ENUM,
> -                     "glGetFramebufferAttachmentParameteriv(attachment)");
> +                     "%s(invalid attachment %s)", caller,
> +                     _mesa_lookup_enum_by_nr(attachment));
>           return;
>        }
>        /* the default / window-system FBO */
> @@ -3195,8 +3188,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>     }
>  
>     if (att == NULL) {
> -      _mesa_error(ctx, GL_INVALID_ENUM,
> -                  "glGetFramebufferAttachmentParameteriv(attachment)");
> +      _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
> +                  _mesa_lookup_enum_by_nr(attachment));
>        return;
>     }
>  
> @@ -3210,9 +3203,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>            *    attachment, since it does not have a single format."
>            */
>           _mesa_error(ctx, GL_INVALID_OPERATION,
> -                     "glGetFramebufferAttachmentParameteriv("
> -                     "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
> -                     " is invalid for depth+stencil attachment)");
> +                     "%s(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
> +                     " is invalid for depth+stencil attachment)", caller);
>           return;
>        }
>        /* the depth and stencil attachments must point to the same buffer */
> @@ -3220,8 +3212,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT);
>        if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) {
>           _mesa_error(ctx, GL_INVALID_OPERATION,
> -                     "glGetFramebufferAttachmentParameteriv(DEPTH/STENCIL"
> -                     " attachments differ)");
> +                     "%s(DEPTH/STENCIL attachments differ)", caller);
>           return;
>        }
>     }
> @@ -3235,10 +3226,10 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        return;
>     case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
>        if (att->Type == GL_RENDERBUFFER_EXT) {
> -	 *params = att->Renderbuffer->Name;
> +         *params = att->Renderbuffer->Name;
>        }
>        else if (att->Type == GL_TEXTURE) {
> -	 *params = att->Texture->Name;
> +         *params = att->Texture->Name;
>        }
>        else {
>           assert(att->Type == GL_NONE);
> @@ -3251,11 +3242,11 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        return;
>     case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
>        if (att->Type == GL_TEXTURE) {
> -	 *params = att->TextureLevel;
> +         *params = att->TextureLevel;
>        }

Whitespace only changes should preferably be done in a separate patch.

>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        }
>        else {
>           goto invalid_pname_enum;
> @@ -3271,8 +3262,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>           }
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        }
>        else {
>           goto invalid_pname_enum;
> @@ -3282,8 +3273,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        if (ctx->API == API_OPENGLES) {
>           goto invalid_pname_enum;
>        } else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        } else if (att->Type == GL_TEXTURE) {
>           if (att->Texture && (att->Texture->Target == GL_TEXTURE_3D ||
>               att->Texture->Target == GL_TEXTURE_2D_ARRAY)) {
> @@ -3304,8 +3295,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>           goto invalid_pname_enum;
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        }
>        else {
>           if (ctx->Extensions.EXT_framebuffer_sRGB) {
> @@ -3327,8 +3318,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>           goto invalid_pname_enum;
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        }
>        else {
>           mesa_format format = att->Renderbuffer->Format;
> @@ -3343,9 +3334,9 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>           if (_mesa_is_gles3(ctx) &&
>               attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
>              _mesa_error(ctx, GL_INVALID_OPERATION,
> -                        "glGetFramebufferAttachmentParameteriv(cannot query "
> +                        "%s(cannot query "
>                          "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE of "
> -                        "GL_DEPTH_STENCIL_ATTACHMENT");
> +                        "GL_DEPTH_STENCIL_ATTACHMENT", caller);

There is a missing ')' at the end of the string here.

>              return;
>           }
>  
> @@ -3379,8 +3370,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>           goto invalid_pname_enum;
>        }
>        else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        }
>        else if (att->Texture) {
>           const struct gl_texture_image *texImage =
> @@ -3399,8 +3390,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>                                        att->Renderbuffer->Format);
>        }
>        else {
> -         _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:"
> -                       " invalid FBO attachment structure");
> +         _mesa_problem(ctx, "%s: invalid FBO attachment structure", caller);
>        }
>        return;
>     case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
> @@ -3409,8 +3399,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>        } else if (att->Type == GL_TEXTURE) {
>           *params = att->Layered;
>        } else if (att->Type == GL_NONE) {
> -         _mesa_error(ctx, err,
> -                     "glGetFramebufferAttachmentParameteriv(pname)");
> +         _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
> +                     _mesa_lookup_enum_by_nr(pname));
>        } else {
>           goto invalid_pname_enum;
>        }
> @@ -3422,11 +3412,60 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>     return;
>  
>  invalid_pname_enum:
> -   _mesa_error(ctx, GL_INVALID_ENUM,
> -               "glGetFramebufferAttachmentParameteriv(pname)");
> +   _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname %s)", caller,
> +               _mesa_lookup_enum_by_nr(pname));
>     return;
>  }
>  

There should be two blank lines between the functions.

> +void GLAPIENTRY
> +_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
> +                                          GLenum pname, GLint *params)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *buffer;
> +
> +   buffer = get_framebuffer_target(ctx, target);
> +   if (!buffer) {
> +      _mesa_error(ctx, GL_INVALID_ENUM,
> +                  "glGetFramebufferAttachmentParameteriv(invalid target %s)",
> +                  _mesa_lookup_enum_by_nr(target));
> +      return;
> +   }
> +
> +   _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
> +                                              params,
> +                                    "glGetFramebufferAttachmentParameteriv");
> +}
> +

Here too.

> +void GLAPIENTRY
> +_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
> +                                               GLenum attachment,
> +                                               GLenum pname, GLint *params)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_framebuffer *buffer;
> +
> +   if (framebuffer) {
> +      buffer = _mesa_lookup_framebuffer_err(ctx, framebuffer,
> +                              "glGetNamedFramebufferAttachmentParameteriv");
> +      if (!buffer)
> +         return;
> +   }
> +   else {
> +      /*
> +       * Section 9.2 Binding and Managing Framebuffer Objects of the OpenGL
> +       * 4.5 core spec (30.10.2014, PDF page 314):
> +       *    "If framebuffer is zero, then the default draw framebuffer is
> +       *    queried."
> +       */
> +      buffer = ctx->WinSysDrawBuffer;
> +   }
> +
> +   _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
> +                                              params,
> +                              "glGetNamedFramebufferAttachmentParameteriv");
> +}
> +
>  
>  static void
>  invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
> diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
> index f078097..fabeed9 100644
> --- a/src/mesa/main/fbobject.h
> +++ b/src/mesa/main/fbobject.h
> @@ -126,6 +126,12 @@ extern GLenum
>  _mesa_check_framebuffer_status(struct gl_context *ctx,
>                                 struct gl_framebuffer *fb);
>  
> +extern void
> +_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
> +                                           struct gl_framebuffer *buffer,
> +                                           GLenum attachment, GLenum pname,
> +                                           GLint *params, const char *caller);
> +
>  
>  extern GLboolean GLAPIENTRY
>  _mesa_IsRenderbuffer(GLuint renderbuffer);
> @@ -228,6 +234,10 @@ _mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
>  extern void GLAPIENTRY
>  _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
>                                               GLenum pname, GLint *params);
> +extern void GLAPIENTRY
> +_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
> +                                               GLenum attachment,
> +                                               GLenum pname, GLint *params);
>  
>  extern void GLAPIENTRY
>  _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
> index 4dfac5c..a6d8523 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -975,6 +975,7 @@ const struct function gl_core_functions_possible[] = {
>     { "glNamedFramebufferTexture", 45, -1 },
>     { "glNamedFramebufferTextureLayer", 45, -1 },
>     { "glCheckNamedFramebufferStatus", 45, -1 },
> +   { "glGetNamedFramebufferAttachmentParameteriv", 45, -1 },
>     { "glCreateTextures", 45, -1 },
>     { "glTextureStorage1D", 45, -1 },
>     { "glTextureStorage2D", 45, -1 },
> 



More information about the mesa-dev mailing list