[Mesa-dev] [PATCH 6/8] mesa: Add skeleton implementations of glInvalidateBuffer{Sub, }Data

Brian Paul brian.e.paul at gmail.com
Mon Aug 13 19:55:20 PDT 2012


On Mon, Aug 13, 2012 at 7:23 PM, Ian Romanick <idr at freedesktop.org> wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> These are part of GL_ARB_invalidate_subdata (but not OpenGL ES 3.0).
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/mesa/main/bufferobj.c |   93 +++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 93 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 396408f..9da2663 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -2200,6 +2200,94 @@ _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
>     }
>  }
>
> +static void GLAPIENTRY
> +_mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
> +                              GLsizeiptr length)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_buffer_object *bufObj;
> +   const GLintptr end = offset + length;
> +
> +   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
> +   if (!bufObj) {
> +      _mesa_error(ctx, GL_INVALID_VALUE,
> +                  "glInvalidateBufferSubData(name = 0x%x) invalid object",
> +                  buffer);
> +      return;
> +   }
> +
> +   /* The GL_ARB_invalidate_subdata spec says:
> +    *
> +    *     "An INVALID_VALUE error is generated if <offset> or <length> is
> +    *     negative, or if <offset> + <length> is greater than the value of
> +    *     BUFFER_SIZE."
> +    */
> +   if (end < 0 || end > bufObj->Size) {
> +      _mesa_error(ctx, GL_INVALID_VALUE,
> +                  "glInvalidateBufferSubData(invalid offset or length)");
> +      return;
> +   }
> +
> +   /* The GL_ARB_invalidate_subdata spec says:
> +    *
> +    *     "An INVALID_OPERATION error is generated if the buffer is currently
> +    *     mapped by MapBuffer, or if the invalidate range intersects the range
> +    *     currently mapped by MapBufferRange."
> +    */
> +   if (bufObj->Pointer) {

We have a _mesa_bufferobj_mapped() helper in bufferobj.h that could be
used there.
Same thing in another place below.


> +      const GLintptr mapEnd = bufObj->Offset + bufObj->Length;
> +
> +      /* The regions do not overlap if and only if the end of the discard
> +       * region is before the mapped region or the start of the discard region
> +       * is after the mapped region.
> +       */
> +      if (!(end <= bufObj->Offset || offset > mapEnd)) {
> +         _mesa_error(ctx, GL_INVALID_OPERATION,
> +                     "glInvalidateBufferSubData(intersection with mapped "
> +                     "range)");
> +         return;
> +      }
> +   }
> +
> +   /* We don't actually do anything for this yet.  Just return after
> +    * validating the parameters and generating the required errors.
> +    */
> +   return;
> +}
> +
> +static void GLAPIENTRY
> +_mesa_InvalidateBufferData(GLuint buffer)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_buffer_object *bufObj;
> +
> +   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
> +   if (!bufObj) {
> +      _mesa_error(ctx, GL_INVALID_VALUE,
> +                  "glInvalidateBufferData(name = 0x%x) invalid object",
> +                  buffer);
> +      return;
> +   }
> +
> +   /* The GL_ARB_invalidate_subdata spec says:
> +    *
> +    *     "An INVALID_OPERATION error is generated if the buffer is currently
> +    *     mapped by MapBuffer, or if the invalidate range intersects the range
> +    *     currently mapped by MapBufferRange."
> +    */
> +   if (bufObj->Pointer) {

Same thing here.


> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glInvalidateBufferData(intersection with mapped "
> +                  "range)");
> +      return;
> +   }
> +
> +   /* We don't actually do anything for this yet.  Just return after
> +    * validating the parameters and generating the required errors.
> +    */
> +   return;
> +}
> +
>  void
>  _mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp)
>  {
> @@ -2220,4 +2308,9 @@ _mesa_init_bufferobj_dispatch(struct gl_context *ctx, struct _glapi_table *disp)
>        SET_BindBufferRangeEXT(disp, _mesa_BindBufferRange);
>        SET_BindBufferBaseEXT(disp, _mesa_BindBufferBase);
>     }
> +
> +   if (ctx->API == API_OPENGL || ctx->API == API_OPENGL_CORE) {
> +      SET_InvalidateBufferData(disp, _mesa_InvalidateBufferData);
> +      SET_InvalidateBufferSubData(disp, _mesa_InvalidateBufferSubData);
> +   }
>  }
> --
> 1.7.6.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list