[Mesa-dev] [PATCH v3 15/17] main: Added entry point for glGetNamedRenderbufferParameteriv

Martin Peres martin.peres at linux.intel.com
Tue Mar 24 02:06:16 PDT 2015


On 24/03/15 00:12, Laura Ekstrand wrote:
>
>
> On Mon, Mar 23, 2015 at 12:04 PM, Martin Peres 
> <martin.peres at linux.intel.com <mailto:martin.peres at linux.intel.com>> 
> wrote:
>
>     v2:
>     - improve an error message
>
>     Reviewed-by: Laura Ekstrand <laura at jlekstrand.net
>     <mailto:laura at jlekstrand.net>>
>
>     v3:
>     - move a test to less generic functions
>     - fix an alignment
>
>     Signed-off-by: Martin Peres <martin.peres at linux.intel.com
>     <mailto:martin.peres at linux.intel.com>>
>     ---
>      src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 +++
>      src/mesa/main/fbobject.c                       | 63
>     +++++++++++++++++++-------
>      src/mesa/main/fbobject.h      |  4 ++
>      src/mesa/main/tests/dispatch_sanity.cpp        |  1 +
>      4 files changed, 57 insertions(+), 17 deletions(-)
>
>     diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml
>     b/src/mapi/glapi/gen/ARB_direct_state_access.xml
>     index 976dcc8..d4e1f7c 100644
>     --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
>     +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
>     @@ -159,6 +159,12 @@
>            <param name="renderbuffers" type="GLuint *" />
>         </function>
>
>     +   <function name="GetNamedRenderbufferParameteriv" offset="assign">
>     +      <param name="renderbuffer" type="GLuint" />
>     +      <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 8083bc1..ee4ad1f 100644
>     --- a/src/mesa/main/fbobject.c
>     +++ b/src/mesa/main/fbobject.c
>     @@ -1993,24 +1993,13 @@ _es_RenderbufferStorageEXT(GLenum target,
>     GLenum internalFormat,
>      }
>
>
>     -void GLAPIENTRY
>     -_mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname,
>     GLint *params)
>     +static void
>     +get_render_buffer_parameteriv(struct gl_context *ctx,
>     +                              struct gl_renderbuffer *rb, GLenum
>     pname,
>     +                              GLint *params, bool dsa)
>      {
>     -   struct gl_renderbuffer *rb;
>     -   GET_CURRENT_CONTEXT(ctx);
>     -
>     -   if (target != GL_RENDERBUFFER_EXT) {
>     -      _mesa_error(ctx, GL_INVALID_ENUM,
>     - "glGetRenderbufferParameterivEXT(target)");
>     -      return;
>     -   }
>     -
>     -   rb = ctx->CurrentRenderbuffer;
>     -   if (!rb) {
>     -      _mesa_error(ctx, GL_INVALID_OPERATION,
>     -                  "glGetRenderbufferParameterivEXT");
>     -      return;
>     -   }
>
> I think passing in a const char *caller would be better than a bool 
> dsa, since the only thing you are using dsa for is determining the 
> name of the calling function.

Agreed. I used func as a name to stay consistent with the rest of my code.

>     +   const char *func = dsa ? "glGetNamedRenderbufferParameteriv" :
>     + "glGetRenderbufferParameteriv";
>
>         /* No need to flush here since we're just quering state which is
>          * not effected by rendering.
>     @@ -2042,10 +2031,50 @@ _mesa_GetRenderbufferParameteriv(GLenum
>     target, GLenum pname, GLint *params)
>            }
>            /* fallthrough */
>         default:
>     +      _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname=%s)", func,
>     +                  _mesa_lookup_enum_by_nr(pname));
>     +      return;
>     +   }
>     +}
>     +
>     +
>     +void GLAPIENTRY
>     +_mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname,
>     GLint *params)
>     +{
>     +   GET_CURRENT_CONTEXT(ctx);
>     +
>     +   if (target != GL_RENDERBUFFER_EXT) {
>            _mesa_error(ctx, GL_INVALID_ENUM,
>      "glGetRenderbufferParameterivEXT(target)");
>            return;
>         }
>     +
>     +   if (!ctx->CurrentRenderbuffer) {
>     +      _mesa_error(ctx, GL_INVALID_OPERATION,
>     "glGetRenderbufferParameterivEXT"
>     +                  "(no renderbuffer bound)");
>     +      return;
>     +   }
>     +
>     +   get_render_buffer_parameteriv(ctx, ctx->CurrentRenderbuffer,
>     pname,
>     +                                 params, false);
>     +}
>     +
>     +
>     +void GLAPIENTRY
>     +_mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum
>     pname,
>     +                                      GLint *params)
>     +{
>     +   GET_CURRENT_CONTEXT(ctx);
>     +
>     +   struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx,
>     renderbuffer);
>
> You need to check if !rb here, too, in case you get rb = NULL.

Done, this is indeed necessary after this small re-factoring.

>     +   if (rb == &DummyRenderbuffer) {
>     +      /* ID was reserved, but no real renderbuffer object made yet */
>     +      _mesa_error(ctx, GL_INVALID_OPERATION,
>     "glGetNamedRenderbufferParameteriv"
>     +                  "(invalid renderbuffer %i)", renderbuffer);
>     +      return;
>     +   }
>     +
>     +   get_render_buffer_parameteriv(ctx, rb, pname, params, true);
>      }
>
>
>     diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
>     index 9ab6b0b..b92149b 100644
>     --- a/src/mesa/main/fbobject.h
>     +++ b/src/mesa/main/fbobject.h
>     @@ -137,6 +137,10 @@ extern void GLAPIENTRY
>      _mesa_GetRenderbufferParameteriv(GLenum target, GLenum pname,
>                                          GLint *params);
>
>     +void GLAPIENTRY
>     +_mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum
>     pname,
>     +                                      GLint *params);
>     +
>      extern GLboolean GLAPIENTRY
>      _mesa_IsFramebuffer(GLuint framebuffer);
>
>     diff --git a/src/mesa/main/tests/dispatch_sanity.cpp
>     b/src/mesa/main/tests/dispatch_sanity.cpp
>     index 5383865..bb573d4 100644
>     --- a/src/mesa/main/tests/dispatch_sanity.cpp
>     +++ b/src/mesa/main/tests/dispatch_sanity.cpp
>     @@ -944,6 +944,7 @@ const struct function
>     gl_core_functions_possible[] = {
>         { "glGetNamedBufferPointerv", 45, -1 },
>         { "glGetNamedBufferSubData", 45, -1 },
>         { "glCreateRenderbuffers", 45, -1 },
>     +   { "glGetNamedRenderbufferParameteriv", 45, -1 },
>         { "glCreateTextures", 45, -1 },
>         { "glTextureStorage1D", 45, -1 },
>         { "glTextureStorage2D", 45, -1 },
>     --
>     2.3.3
>
>     _______________________________________________
>     mesa-dev mailing list
>     mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
>     http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>



More information about the mesa-dev mailing list