Re: [Mesa-dev] [PATCH 01/38] main: Add utility function _mesa_lookup_framebuffer_err.

2015-04-27 Thread Anuj Phogat
On Tue, Mar 3, 2015 at 5:31 PM, Laura Ekstrand la...@jlekstrand.net wrote:
 ---
  src/mesa/main/fbobject.c | 18 ++
  src/mesa/main/fbobject.h |  4 
  2 files changed, 22 insertions(+)

 diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
 index f8d0d92..8c2eb25 100644
 --- a/src/mesa/main/fbobject.c
 +++ b/src/mesa/main/fbobject.c
 @@ -136,6 +136,24 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint 
 id)
 return fb;
  }

 +/**
 + * A convenience function for direct state access that throws
 + * GL_INVALID_OPERATION if the framebuffer id is not found in the hash table.
 + */
 +struct gl_framebuffer *
 +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
 + const char *func)
 +{
 +   struct gl_framebuffer *fb;
 +
 +   fb = _mesa_lookup_framebuffer(ctx, id);
 +   if (!fb)
 +  _mesa_error(ctx, GL_INVALID_OPERATION,
 +  %s(non-generated framebuffer name=%u), func, id);
 +
 +   return fb;
 +}
 +

  /**
   * Mark the given framebuffer as invalid.  This will force the
 diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
 index 77fdef4..7aa5205 100644
 --- a/src/mesa/main/fbobject.h
 +++ b/src/mesa/main/fbobject.h
 @@ -67,6 +67,10 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint 
 id);
  extern struct gl_framebuffer *
  _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);

 +extern struct gl_framebuffer *
 +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
 + const char *func);
 +

  void
  _mesa_update_texture_renderbuffer(struct gl_context *ctx,
 --
 2.1.0

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

With Fredrik's comment fixed:
Reviewed-by: Anuj Phogat anuj.pho...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/38] main: Add utility function _mesa_lookup_framebuffer_err.

2015-04-09 Thread Fredrik Höglund
On Wednesday 04 March 2015, Laura Ekstrand wrote:
 ---
  src/mesa/main/fbobject.c | 18 ++
  src/mesa/main/fbobject.h |  4 
  2 files changed, 22 insertions(+)
 
 diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
 index f8d0d92..8c2eb25 100644
 --- a/src/mesa/main/fbobject.c
 +++ b/src/mesa/main/fbobject.c
 @@ -136,6 +136,24 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint 
 id)
 return fb;
  }
  
 +/**
 + * A convenience function for direct state access that throws
 + * GL_INVALID_OPERATION if the framebuffer id is not found in the hash table.
 + */
 +struct gl_framebuffer *
 +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
 + const char *func)
 +{
 +   struct gl_framebuffer *fb;
 +
 +   fb = _mesa_lookup_framebuffer(ctx, id);
 +   if (!fb)
 +  _mesa_error(ctx, GL_INVALID_OPERATION,
 +  %s(non-generated framebuffer name=%u), func, id);
 +
 +   return fb;
 +}
 +

I think this function should also generate GL_INVALID_OPERATION when
the looked-up framebuffer is DummyFramebuffer.

All the DSA entry points require that the framebuffer exists.

  /**
   * Mark the given framebuffer as invalid.  This will force the
 diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
 index 77fdef4..7aa5205 100644
 --- a/src/mesa/main/fbobject.h
 +++ b/src/mesa/main/fbobject.h
 @@ -67,6 +67,10 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint 
 id);
  extern struct gl_framebuffer *
  _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
  
 +extern struct gl_framebuffer *
 +_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
 + const char *func);
 +
  
  void
  _mesa_update_texture_renderbuffer(struct gl_context *ctx,
 

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev