[Mesa-dev] [PATCH V4 1/3] mesa: implement GL_MAX_VERTEX_ATTRIB_STRIDE
Ian Romanick
idr at freedesktop.org
Fri Aug 22 15:21:51 PDT 2014
Patches 1 and 3 are
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
On 08/20/2014 01:14 AM, Timothy Arceri wrote:
> V2: moved test for the VertexAttrib*Pointer() functions
> to update_array(), and made constant available for drivers to set
>
> 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've 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.
>
> Finally I've assumed that 2048 is an ok value for i965.
>
> V4: add cap for all gallium drivers set to default (except r600g)
>
> V3: adds values for r600g and radeonsi (I'm unsable to test either of these patches)
>
> src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml | 1 +
> src/mesa/main/context.c | 3 +++
> src/mesa/main/get_hash_params.py | 3 +++
> src/mesa/main/mtypes.h | 3 +++
> src/mesa/main/varray.c | 22 ++++++++++++++++++++++
> 5 files changed, 32 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/context.c b/src/mesa/main/context.c
> index 2320842..fbdbd68 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -670,6 +670,9 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
> ? GL_CONTEXT_CORE_PROFILE_BIT
> : GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
>
> + /* GL 4.4 */
> + consts->MaxVertexAttribStride = 2048;
> +
> /** GL_EXT_gpu_shader4 */
> consts->MinProgramTexelOffset = -8;
> consts->MaxProgramTexelOffset = 7;
> diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
> index ff85820..aace8a5 100644
> --- a/src/mesa/main/get_hash_params.py
> +++ b/src/mesa/main/get_hash_params.py
> @@ -712,6 +712,9 @@ descriptor=[
> [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32" ],
> [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32" ],
>
> +# GL 4.4
> + [ "MAX_VERTEX_ATTRIB_STRIDE", "CONTEXT_ENUM(Const.MaxVertexAttribStride), NO_EXTRA" ],
> +
> # GL_ARB_robustness
> [ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ],
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index cb2a4df..adb6788 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3414,6 +3414,9 @@ struct gl_constants
> /** OpenGL version 3.2 */
> GLbitfield ProfileMask; /**< Mask of CONTEXT_x_PROFILE_BIT */
>
> + /** OpenGL version 4.4 */
> + GLuint MaxVertexAttribStride;
> +
> /** GL_EXT_transform_feedback */
> GLuint MaxTransformFeedbackBuffers;
> GLuint MaxTransformFeedbackSeparateComponents;
> diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
> index 5d3cc2a..7d169f9 100644
> --- a/src/mesa/main/varray.c
> +++ b/src/mesa/main/varray.c
> @@ -424,6 +424,13 @@ update_array(struct gl_context *ctx,
> return;
> }
>
> + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> + stride > ctx->Const.MaxVertexAttribStride) {
> + _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
> + "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
> + return;
> + }
> +
> /* Page 29 (page 44 of the PDF) of the OpenGL 3.3 spec says:
> *
> * "An INVALID_OPERATION error is generated under any of the following
> @@ -1437,6 +1444,13 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
> return;
> }
>
> + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> + stride > ctx->Const.MaxVertexAttribStride) {
> + _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 +1579,14 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
> continue;
> }
>
> + if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
> + strides[i] > ctx->Const.MaxVertexAttribStride) {
> + _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)];
>
More information about the mesa-dev
mailing list