[Mesa-dev] [PATCH 13/14] mesa/vbo: add KHR_no_error support to DrawElements*() functions

Nicolai Hähnle nhaehnle at gmail.com
Thu Apr 13 09:58:35 UTC 2017


On 13.04.2017 01:42, Timothy Arceri wrote:
> ---
>  src/mesa/vbo/vbo_exec_array.c | 158 +++++++++++++++++++++++++++---------------
>  1 file changed, 104 insertions(+), 54 deletions(-)
>
> diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
> index 6e3cd5a..d85c7ad 100644
> --- a/src/mesa/vbo/vbo_exec_array.c
> +++ b/src/mesa/vbo/vbo_exec_array.c
> @@ -979,129 +979,165 @@ vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end,
>
>  /**
>   * Called by glDrawElements() in immediate mode.
>   */
>  static void GLAPIENTRY
>  vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type,
>                        const GLvoid * indices)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
> -                  _mesa_enum_to_string(mode), count,
> -                  _mesa_enum_to_string(type), indices);

MESA_VERBOSE is #define'd to 0 in non-debug builds, so I think you 
should not move this debug print (applies elsewhere as well).

Cheers,
Nicolai


> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
>
> -   if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
> -      return;
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n",
> +                     _mesa_enum_to_string(mode), count,
> +                     _mesa_enum_to_string(type), indices);
> +
> +      if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices, 0, 1, 0);
>  }
>
>
>  /**
>   * Called by glDrawElementsBaseVertex() in immediate mode.
>   */
>  static void GLAPIENTRY
>  vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type,
>                                  const GLvoid * indices, GLint basevertex)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
> -                  _mesa_enum_to_string(mode), count,
> -                  _mesa_enum_to_string(type), indices, basevertex);
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
>
> -   if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
> -      return;
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n",
> +                     _mesa_enum_to_string(mode), count,
> +                     _mesa_enum_to_string(type), indices, basevertex);
> +
> +      if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices, basevertex, 1, 0);
>  }
>
>
>  /**
>   * Called by glDrawElementsInstanced() in immediate mode.
>   */
>  static void GLAPIENTRY
>  vbo_exec_DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
>                                 const GLvoid * indices, GLsizei numInstances)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
> -                  _mesa_enum_to_string(mode), count,
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
> +
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx, "glDrawElementsInstanced(%s, %d, %s, %p, %d)\n",
> +                     _mesa_enum_to_string(mode), count,
>                    _mesa_enum_to_string(type), indices, numInstances);
>
> -   if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
> -                                             numInstances))
> -      return;
> +      if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type,
> +                                                indices, numInstances))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices, 0, numInstances, 0);
>  }
>
>
>  /**
>   * Called by glDrawElementsInstancedBaseVertex() in immediate mode.
>   */
>  static void GLAPIENTRY
>  vbo_exec_DrawElementsInstancedBaseVertex(GLenum mode, GLsizei count,
>                                           GLenum type, const GLvoid * indices,
>                                           GLsizei numInstances,
>                                           GLint basevertex)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx,
> -                  "glDrawElementsInstancedBaseVertex(%s, %d, %s, %p, %d; %d)\n",
> -                  _mesa_enum_to_string(mode), count,
> -                  _mesa_enum_to_string(type), indices,
> -                  numInstances, basevertex);
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
>
> -   if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
> -                                             numInstances))
> -      return;
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx,
> +                     "glDrawElementsInstancedBaseVertex"
> +                     "(%s, %d, %s, %p, %d; %d)\n",
> +                     _mesa_enum_to_string(mode), count,
> +                     _mesa_enum_to_string(type), indices,
> +                     numInstances, basevertex);
> +
> +      if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type,
> +                                                indices, numInstances))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices,
>                                     basevertex, numInstances, 0);
>  }
>
>
>  /**
>   * Called by glDrawElementsInstancedBaseInstance() in immediate mode.
>   */
>  static void GLAPIENTRY
>  vbo_exec_DrawElementsInstancedBaseInstance(GLenum mode, GLsizei count,
>                                             GLenum type,
>                                             const GLvoid *indices,
>                                             GLsizei numInstances,
>                                             GLuint baseInstance)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx,
> -                  "glDrawElementsInstancedBaseInstance"
> -                  "(%s, %d, %s, %p, %d, %d)\n",
> -                  _mesa_enum_to_string(mode), count,
> -                  _mesa_enum_to_string(type), indices,
> -                  numInstances, baseInstance);
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
>
> -   if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
> -                                             numInstances))
> -      return;
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx,
> +                     "glDrawElementsInstancedBaseInstance"
> +                     "(%s, %d, %s, %p, %d, %d)\n",
> +                     _mesa_enum_to_string(mode), count,
> +                     _mesa_enum_to_string(type), indices,
> +                     numInstances, baseInstance);
> +
> +      if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type,
> +                                                indices, numInstances))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices, 0, numInstances,
>                                     baseInstance);
>  }
>
>
>  /**
>   * Called by glDrawElementsInstancedBaseVertexBaseInstance() in immediate mode.
>   */
> @@ -1109,31 +1145,38 @@ static void GLAPIENTRY
>  vbo_exec_DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
>                                                       GLsizei count,
>                                                       GLenum type,
>                                                       const GLvoid *indices,
>                                                       GLsizei numInstances,
>                                                       GLint basevertex,
>                                                       GLuint baseInstance)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx,
> -                  "glDrawElementsInstancedBaseVertexBaseInstance"
> -                  "(%s, %d, %s, %p, %d, %d, %d)\n",
> -                  _mesa_enum_to_string(mode), count,
> -                  _mesa_enum_to_string(type), indices,
> -                  numInstances, basevertex, baseInstance);
> -
> -   if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type, indices,
> -                                             numInstances))
> -      return;
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
> +
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx,
> +                     "glDrawElementsInstancedBaseVertexBaseInstance"
> +                     "(%s, %d, %s, %p, %d, %d, %d)\n",
> +                     _mesa_enum_to_string(mode), count,
> +                     _mesa_enum_to_string(type), indices,
> +                    numInstances, basevertex, baseInstance);
> +
> +      if (!_mesa_validate_DrawElementsInstanced(ctx, mode, count, type,
> +                                                indices, numInstances))
> +         return;
> +   }
>
>     vbo_validated_drawrangeelements(ctx, mode, GL_FALSE, ~0, ~0,
>                                     count, type, indices, basevertex,
>                                     numInstances, baseInstance);
>  }
>
>
>  /**
>   * Inner support for both _mesa_MultiDrawElements() and
>   * _mesa_MultiDrawRangeElements().
> @@ -1555,27 +1598,34 @@ vbo_exec_DrawArraysIndirect(GLenum mode, const GLvoid *indirect)
>
>     vbo_validated_drawarraysindirect(ctx, mode, indirect);
>  }
>
>
>  static void GLAPIENTRY
>  vbo_exec_DrawElementsIndirect(GLenum mode, GLenum type, const GLvoid *indirect)
>  {
>     GET_CURRENT_CONTEXT(ctx);
>
> -   if (MESA_VERBOSE & VERBOSE_DRAW)
> -      _mesa_debug(ctx, "glDrawElementsIndirect(%s, %s, %p)\n",
> -                  _mesa_enum_to_string(mode),
> -                  _mesa_enum_to_string(type), indirect);
> +   if (_mesa_is_no_error_enabled(ctx)) {
> +      FLUSH_CURRENT(ctx, 0);
>
> -   if (!_mesa_validate_DrawElementsIndirect(ctx, mode, type, indirect))
> -      return;
> +      if (ctx->NewState)
> +         _mesa_update_state(ctx);
> +   } else {
> +      if (MESA_VERBOSE & VERBOSE_DRAW)
> +         _mesa_debug(ctx, "glDrawElementsIndirect(%s, %s, %p)\n",
> +                     _mesa_enum_to_string(mode),
> +                     _mesa_enum_to_string(type), indirect);
> +
> +      if (!_mesa_validate_DrawElementsIndirect(ctx, mode, type, indirect))
> +         return;
> +   }
>
>     if (skip_validated_draw(ctx))
>        return;
>
>     vbo_validated_drawelementsindirect(ctx, mode, type, indirect);
>  }
>
>
>  static void GLAPIENTRY
>  vbo_exec_MultiDrawArraysIndirect(GLenum mode, const GLvoid *indirect,
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list