diff options
author | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-11-06 12:16:30 +0100 |
---|---|---|
committer | Pierre-Eric Pelloux-Prayer <[email protected]> | 2019-11-19 08:49:45 +0100 |
commit | b78e2a197a1dd866024b0dc97689a006c0e6798f (patch) | |
tree | 0d7ce500f1954e6a8bcaff2d5aab004b8d65eb26 /src/mesa/main | |
parent | a807b8c0a893a437534df5292fe70c54c8d8332b (diff) |
mesa: add ARB_instanced_arrays EXT_dsa function
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/tests/dispatch_sanity.cpp | 1 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 49 | ||||
-rw-r--r-- | src/mesa/main/varray.h | 2 |
3 files changed, 52 insertions, 0 deletions
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index a34879ff17e..02ed6374317 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -546,6 +546,7 @@ const struct function common_desktop_functions_possible[] = { /* GL_ARB_instanced_arrays */ { "glVertexAttribDivisorARB", 31, -1 }, + { "glVertexArrayVertexAttribDivisorEXT", 31, -1 }, /* GL_NV_texture_barrier */ { "glTextureBarrierNV", 31, -1 }, diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 8db6f13a319..d046d5af302 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2558,6 +2558,55 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor) } +void GLAPIENTRY +_mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor) +{ + GET_CURRENT_CONTEXT(ctx); + + const gl_vert_attrib genericIndex = VERT_ATTRIB_GENERIC(index); + struct gl_vertex_array_object * vao; + /* The ARB_instanced_arrays spec says: + * + * "The vertex array object named by vaobj must + * be generated by GenVertexArrays (and not since deleted); + * otherwise an INVALID_OPERATION error is generated." + */ + vao = _mesa_lookup_vao_err(ctx, vaobj, + false, + "glVertexArrayVertexAttribDivisorEXT"); + if (!vao) + return; + + if (!ctx->Extensions.ARB_instanced_arrays) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexArrayVertexAttribDivisorEXT()"); + return; + } + + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glVertexArrayVertexAttribDivisorEXT(index = %u)", index); + return; + } + + assert(genericIndex < ARRAY_SIZE(vao->VertexAttrib)); + + /* The ARB_vertex_attrib_binding spec says: + * + * "The command + * + * void VertexAttribDivisor(uint index, uint divisor); + * + * is equivalent to (assuming no errors are generated): + * + * VertexAttribBinding(index, index); + * VertexBindingDivisor(index, divisor);" + */ + _mesa_vertex_attrib_binding(ctx, vao, genericIndex, genericIndex); + vertex_binding_divisor(ctx, vao, genericIndex, divisor); +} + + + static ALWAYS_INLINE void vertex_array_vertex_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao, diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index fb490f1a586..9c1ed9efeac 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -317,6 +317,8 @@ extern void GLAPIENTRY _mesa_VertexAttribDivisor_no_error(GLuint index, GLuint divisor); extern void GLAPIENTRY _mesa_VertexAttribDivisor(GLuint index, GLuint divisor); +extern void GLAPIENTRY +_mesa_VertexArrayVertexAttribDivisorEXT(GLuint vaobj, GLuint index, GLuint divisor); static inline unsigned _mesa_primitive_restart_index(const struct gl_context *ctx, |