From 8b6d19413f05077f4d337273a12abb5cbb67c3b5 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 7 Nov 2019 13:47:17 +0100 Subject: [PATCH] mesa: add ARB_vertex_attrib_binding glVertexArray* functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We can't simply alias ARB_direct_state_access functions because those fail if the vao has never been bound before. Reviewed-by: Marek Olšák --- .../glapi/gen/ARB_vertex_attrib_binding.xml | 45 ++++++++++ src/mapi/glapi/gen/static_data.py | 6 ++ src/mesa/main/tests/dispatch_sanity.cpp | 11 +-- src/mesa/main/varray.c | 87 +++++++++++++++++++ src/mesa/main/varray.h | 27 ++++++ 5 files changed, 171 insertions(+), 5 deletions(-) diff --git a/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml b/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml index 9dc57f4612b..2270e6a29c9 100644 --- a/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml +++ b/src/mapi/glapi/gen/ARB_vertex_attrib_binding.xml @@ -46,6 +46,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 7bc95ae383e..335fc87576d 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1625,6 +1625,12 @@ offsets = { "TextureBufferRangeEXT": 1589, "TextureStorage2DMultisampleEXT": 1590, "TextureStorage3DMultisampleEXT": 1591, + "VertexArrayBindVertexBufferEXT": 1592, + "VertexArrayVertexAttribFormatEXT": 1593, + "VertexArrayVertexAttribIFormatEXT": 1594, + "VertexArrayVertexAttribLFormatEXT": 1595, + "VertexArrayVertexAttribBindingEXT": 1596, + "VertexArrayVertexBindingDivisorEXT": 1597, } functions = [ diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index fdd647a3d1e..66b77d09598 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -869,11 +869,12 @@ const struct function common_desktop_functions_possible[] = { { "glVertexAttribLFormat", 43, -1 }, { "glVertexAttribBinding", 43, -1 }, { "glVertexBindingDivisor", 43, -1 }, -// { "glVertexArrayBindVertexBufferEXT", 43, -1 }, // XXX: Add to xml -// { "glVertexArrayVertexAttribFormatEXT", 43, -1 }, // XXX: Add to xml -// { "glVertexArrayVertexAttribIFormatEXT", 43, -1 }, // XXX: Add to xml -// { "glVertexArrayVertexAttribBindingEXT", 43, -1 }, // XXX: Add to xml -// { "glVertexArrayVertexBindingDivisorEXT", 43, -1 }, // XXX: Add to xml + { "glVertexArrayBindVertexBufferEXT", 43, -1 }, + { "glVertexArrayVertexAttribFormatEXT", 43, -1 }, + { "glVertexArrayVertexAttribIFormatEXT", 43, -1 }, + { "glVertexArrayVertexAttribLFormatEXT", 43, -1 }, + { "glVertexArrayVertexAttribBindingEXT", 43, -1 }, + { "glVertexArrayVertexBindingDivisorEXT", 43, -1 }, { "glFramebufferParameteri", 43, -1 }, { "glGetFramebufferParameteriv", 43, -1 }, { "glNamedFramebufferParameteriEXT", 43, -1 }, diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 0d272ed9c30..f93ad810984 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -2775,6 +2775,21 @@ _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, } +void GLAPIENTRY +_mesa_VertexArrayBindVertexBufferEXT(GLuint vaobj, GLuint bindingIndex, GLuint buffer, + GLintptr offset, GLsizei stride) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object *vao; + vao = _mesa_lookup_vao_err(ctx, vaobj, true, "glVertexArrayBindVertexBufferEXT"); + if (!vao) + return; + + vertex_array_vertex_buffer_err(ctx, vao, bindingIndex, buffer, offset, + stride, "glVertexArrayBindVertexBufferEXT"); +} + + static ALWAYS_INLINE void vertex_array_vertex_buffers(struct gl_context *ctx, struct gl_vertex_array_object *vao, @@ -3137,6 +3152,18 @@ _mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size, } +void GLAPIENTRY +_mesa_VertexArrayVertexAttribFormatEXT(GLuint vaobj, GLuint attribIndex, GLint size, + GLenum type, GLboolean normalized, + GLuint relativeOffset) +{ + vertex_array_attrib_format(vaobj, true, attribIndex, size, type, normalized, + GL_FALSE, GL_FALSE, ATTRIB_FORMAT_TYPES_MASK, + BGRA_OR_4, relativeOffset, + "glVertexArrayVertexAttribFormatEXT"); +} + + void GLAPIENTRY _mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, @@ -3149,6 +3176,18 @@ _mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex, } +void GLAPIENTRY +_mesa_VertexArrayVertexAttribIFormatEXT(GLuint vaobj, GLuint attribIndex, + GLint size, GLenum type, + GLuint relativeOffset) +{ + vertex_array_attrib_format(vaobj, true, attribIndex, size, type, GL_FALSE, + GL_TRUE, GL_FALSE, ATTRIB_IFORMAT_TYPES_MASK, + 4, relativeOffset, + "glVertexArrayVertexAttribIFormatEXT"); +} + + void GLAPIENTRY _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, @@ -3161,6 +3200,18 @@ _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex, } +void GLAPIENTRY +_mesa_VertexArrayVertexAttribLFormatEXT(GLuint vaobj, GLuint attribIndex, + GLint size, GLenum type, + GLuint relativeOffset) +{ + vertex_array_attrib_format(vaobj, true, attribIndex, size, type, GL_FALSE, + GL_FALSE, GL_TRUE, ATTRIB_LFORMAT_TYPES_MASK, + 4, relativeOffset, + "glVertexArrayVertexAttribLFormatEXT"); +} + + static void vertex_array_attrib_binding(struct gl_context *ctx, struct gl_vertex_array_object *vao, @@ -3267,6 +3318,20 @@ _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingI } +void GLAPIENTRY +_mesa_VertexArrayVertexAttribBindingEXT(GLuint vaobj, GLuint attribIndex, GLuint bindingIndex) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object *vao; + vao = _mesa_lookup_vao_err(ctx, vaobj, true, "glVertexArrayVertexAttribBindingEXT"); + if (!vao) + return; + + vertex_array_attrib_binding(ctx, vao, attribIndex, bindingIndex, + "glVertexArrayVertexAttribBindingEXT"); +} + + static void vertex_array_binding_divisor(struct gl_context *ctx, struct gl_vertex_array_object *vao, @@ -3362,6 +3427,28 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, } +void GLAPIENTRY +_mesa_VertexArrayVertexBindingDivisorEXT(GLuint vaobj, GLuint bindingIndex, + GLuint divisor) +{ + struct gl_vertex_array_object *vao; + GET_CURRENT_CONTEXT(ctx); + + /* The ARB_direct_state_access specification says: + * + * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor + * if is not [compatibility profile: zero or] the name of an + * existing vertex array object." + */ + vao = _mesa_lookup_vao_err(ctx, vaobj, true, "glVertexArrayVertexBindingDivisorEXT"); + if (!vao) + return; + + vertex_array_binding_divisor(ctx, vao, bindingIndex, divisor, + "glVertexArrayVertexBindingDivisorEXT"); +} + + void _mesa_copy_vertex_attrib_array(struct gl_context *ctx, struct gl_array_attributes *dst, diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 9c1ed9efeac..247fcb1d7f7 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -355,6 +355,10 @@ extern void GLAPIENTRY _mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer, GLintptr offset, GLsizei stride); +extern void GLAPIENTRY +_mesa_VertexArrayBindVertexBufferEXT(GLuint vaobj, GLuint bindingIndex, GLuint buffer, + GLintptr offset, GLsizei stride); + void GLAPIENTRY _mesa_BindVertexBuffers_no_error(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, @@ -384,6 +388,11 @@ _mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, GLboolean normalized, GLuint relativeOffset); +extern void GLAPIENTRY +_mesa_VertexArrayVertexAttribFormatEXT(GLuint vaobj, GLuint attribIndex, GLint size, + GLenum type, GLboolean normalized, + GLuint relativeOffset); + extern void GLAPIENTRY _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type, GLuint relativeOffset); @@ -393,6 +402,11 @@ _mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, GLuint relativeOffset); +extern void GLAPIENTRY +_mesa_VertexArrayVertexAttribIFormatEXT(GLuint vaobj, GLuint attribIndex, + GLint size, GLenum type, + GLuint relativeOffset); + extern void GLAPIENTRY _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type, GLuint relativeOffset); @@ -402,6 +416,11 @@ _mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex, GLint size, GLenum type, GLuint relativeOffset); +extern void GLAPIENTRY +_mesa_VertexArrayVertexAttribLFormatEXT(GLuint vaobj, GLuint attribIndex, + GLint size, GLenum type, + GLuint relativeOffset); + void GLAPIENTRY _mesa_VertexAttribBinding_no_error(GLuint attribIndex, GLuint bindingIndex); @@ -416,6 +435,10 @@ extern void GLAPIENTRY _mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingIndex); +extern void GLAPIENTRY +_mesa_VertexArrayVertexAttribBindingEXT(GLuint vaobj, GLuint attribIndex, + GLuint bindingIndex); + void GLAPIENTRY _mesa_VertexBindingDivisor_no_error(GLuint bindingIndex, GLuint divisor); @@ -430,6 +453,10 @@ extern void GLAPIENTRY _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor); +extern void GLAPIENTRY +_mesa_VertexArrayVertexBindingDivisorEXT(GLuint vaobj, GLuint bindingIndex, + GLuint divisor); + extern void _mesa_copy_vertex_attrib_array(struct gl_context *ctx, -- 2.30.2