[Mesa-dev] [PATCH 1/3] mesa: implement GL_MAX_VERTEX_ATTRIB_STRIDE

Marek Olšák maraeo at gmail.com
Thu Aug 14 15:57:07 PDT 2014


Hi Timothy,

The maximum stride is 2047 with r600g and 2048 with radeonsi. It would
be better if there was a way for drivers to set this limit.

Marek

On Fri, Aug 15, 2014 at 12:10 AM, Timothy Arceri <t_arceri at yahoo.com.au> wrote:
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
>  Although 4.4 is a while away GL_MAX_VERTEX_ATTRIB_STRIDE is used in
>  the ARB_direct_state_access spec so it seemed worth while adding this now.
>
>  I added MAX_VERTEX_ATTRIB_STRIDE to ARB_vertex_attrib_binding.xml
>  as it didn't seem like it was worth putting it somewhere on its own
>  as its really just a bug fix. Let me know if this should be moved.
>
>  Piglit tests:
>  http://lists.freedesktop.org/archives/piglit/2014-August/012149.html
>
>  src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml |  1 +
>  src/mesa/main/config.h                           |  5 ++++
>  src/mesa/main/get_hash_params.py                 |  1 +
>  src/mesa/main/varray.c                           | 29 ++++++++++++++++++++++++
>  4 files changed, 36 insertions(+)
>
> diff --git a/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml b/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml
> index 0ee6a3c..7e62688 100644
> --- a/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml
> +++ b/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml
> @@ -53,6 +53,7 @@
>      <enum name="VERTEX_BINDING_STRIDE" value="0x82D8"/>
>      <enum name="MAX_VERTEX_ATTRIB_RELATIVE_OFFSET" value="0x82D9"/>
>      <enum name="MAX_VERTEX_ATTRIB_BINDINGS" value="0x82DA"/>
> +    <enum name="MAX_VERTEX_ATTRIB_STRIDE" value="0x82E5"/>
>
>  </category>
>  </OpenGLAPI>
> diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
> index 4ec4b75..9513ed5 100644
> --- a/src/mesa/main/config.h
> +++ b/src/mesa/main/config.h
> @@ -204,6 +204,11 @@
>  #define MAX_PROGRAM_OUTPUTS            64
>  /*@}*/
>
> +/** For GL 4.4 */
> +/*@{*/
> +#define MAX_VERTEX_ATTRIB_STRIDE 2048
> +/*@}*/
> +
>  /** For GL_ARB_vertex_program */
>  /*@{*/
>  #define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index ff85820..2de9ef0 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -763,6 +763,7 @@ descriptor=[
>  # GL_ARB_vertex_attrib_binding
>    [ "MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA" ],
>    [ "MAX_VERTEX_ATTRIB_BINDINGS", "CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA" ],
> +  [ "MAX_VERTEX_ATTRIB_STRIDE", "CONST(MAX_VERTEX_ATTRIB_STRIDE), NO_EXTRA" ],
>
>  # GL_ARB_shader_image_load_store
>    [ "MAX_IMAGE_UNITS", "CONTEXT_INT(Const.MaxImageUnits), extra_ARB_shader_image_load_store"],
> diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
> index 230fb30..6b43260 100644
> --- a/src/mesa/main/varray.c
> +++ b/src/mesa/main/varray.c
> @@ -655,6 +655,13 @@ _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
>        return;
>     }
>
> +   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> +       stride > MAX_VERTEX_ATTRIB_STRIDE) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointer(stride=%d > "
> +                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
> +      return;
> +   }
> +
>     update_array(ctx, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index),
>                  legalTypes, 1, BGRA_OR_4,
>                  size, type, stride, normalized, GL_FALSE, ptr);
> @@ -683,6 +690,13 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
>        return;
>     }
>
> +   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> +       stride > MAX_VERTEX_ATTRIB_STRIDE) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(stride=%d > "
> +                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
> +      return;
> +   }
> +
>     update_array(ctx, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index),
>                  legalTypes, 1, 4,
>                  size, type, stride, normalized, integer, ptr);
> @@ -1437,6 +1451,13 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
>        return;
>     }
>
> +   if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> +       stride > MAX_VERTEX_ATTRIB_STRIDE) {
> +      _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffer(stride=%d > "
> +                  "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
> +      return;
> +   }
> +
>     if (buffer == vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj->Name) {
>        vbo = vao->VertexBinding[VERT_ATTRIB_GENERIC(bindingIndex)].BufferObj;
>     } else if (buffer != 0) {
> @@ -1565,6 +1586,14 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
>           continue;
>        }
>
> +      if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> +          strides[i] > MAX_VERTEX_ATTRIB_STRIDE) {
> +         _mesa_error(ctx, GL_INVALID_VALUE,
> +                     "glBindVertexBuffers(strides[%u]=%d > "
> +                     "GL_MAX_VERTEX_ATTRIB_STRIDE)", i, strides[i]);
> +         continue;
> +      }
> +
>        if (buffers[i]) {
>           struct gl_vertex_buffer_binding *binding =
>              &vao->VertexBinding[VERT_ATTRIB_GENERIC(first + i)];
> --
> 1.9.3
>
> _______________________________________________
> 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