From febedee4f6ca9f95228de511e968951b94644d12 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Sat, 26 Oct 2019 10:42:07 +0200 Subject: [PATCH] mesa: add EXT_dsa glGetVertexArray* 4 functions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The implementation doesn't share much with get.c because: * the refactoring needed for get.c to not depend on ctx->Array.VAO would be quite large * glGetVertexArray* would still need to filter pname to only accept the one specified by the spec * these functions are getter, the implementation is trivial (the complexity is in the correct filtering of pname input) Reviewed-by: Marek Olšák --- .../glapi/gen/EXT_direct_state_access.xml | 26 ++ src/mapi/glapi/gen/static_data.py | 4 + src/mesa/main/tests/dispatch_sanity.cpp | 8 +- src/mesa/main/varray.c | 264 ++++++++++++++++++ src/mesa/main/varray.h | 11 + 5 files changed, 309 insertions(+), 4 deletions(-) diff --git a/src/mapi/glapi/gen/EXT_direct_state_access.xml b/src/mapi/glapi/gen/EXT_direct_state_access.xml index 6c2dcedd645..bcabf7d29ca 100644 --- a/src/mapi/glapi/gen/EXT_direct_state_access.xml +++ b/src/mapi/glapi/gen/EXT_direct_state_access.xml @@ -1170,6 +1170,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 0bf2377f739..6e84132e563 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1612,6 +1612,10 @@ offsets = { "DisableVertexArrayEXT": 1576, "EnableVertexArrayAttribEXT": 1577, "DisableVertexArrayAttribEXT": 1578, + "GetVertexArrayIntegervEXT": 1579, + "GetVertexArrayPointervEXT": 1580, + "GetVertexArrayIntegeri_vEXT": 1581, + "GetVertexArrayPointeri_vEXT": 1582 } functions = [ diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index b7629bb1a96..e6cefabd386 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -1184,10 +1184,10 @@ const struct function common_desktop_functions_possible[] = { { "glDisableVertexArrayEXT", 30, -1 }, { "glEnableVertexArrayAttribEXT", 30, -1 }, { "glDisableVertexArrayAttribEXT", 30, -1 }, - //{ "glGetVertexArrayIntegervEXT", 30, -1 }, - //{ "glGetVertexArrayPointervEXT", 30, -1 }, - //{ "glGetVertexArrayIntegeri_vEXT", 30, -1 }, - //{ "glGetVertexArrayPointeri_vEXT", 30, -1 }, + { "glGetVertexArrayIntegervEXT", 30, -1 }, + { "glGetVertexArrayPointervEXT", 30, -1 }, + { "glGetVertexArrayIntegeri_vEXT", 30, -1 }, + { "glGetVertexArrayPointeri_vEXT", 30, -1 }, { "glMapNamedBufferRangeEXT", 30, -1 }, { "glFlushMappedNamedBufferRangeEXT", 30, -1 }, diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index 4b197dba826..ded559394dc 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -40,6 +40,7 @@ #include "mtypes.h" #include "varray.h" #include "arrayobj.h" +#include "get.h" #include "main/dispatch.h" @@ -3380,3 +3381,266 @@ _mesa_free_varray_data(struct gl_context *ctx) _mesa_HashDeleteAll(ctx->Array.Objects, delete_arrayobj_cb, ctx); _mesa_DeleteHashTable(ctx->Array.Objects); } + +void GLAPIENTRY +_mesa_GetVertexArrayIntegervEXT(GLuint vaobj, GLenum pname, GLint *param) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object* vao; + void* ptr; + + vao = _mesa_lookup_vao_err(ctx, vaobj, true, + "glGetVertexArrayIntegervEXT"); + if (!vao) + return; + + /* The EXT_direct_state_access spec says: + * + * "For GetVertexArrayIntegervEXT, pname must be one of the "Get value" tokens + * in tables 6.6, 6.7, 6.8, and 6.9 that use GetIntegerv, IsEnabled, or + * GetPointerv for their "Get command" (so excluding the VERTEX_ATTRIB_* + * tokens)." + */ + switch (pname) { + /* Tokens using GetIntegerv */ + case GL_CLIENT_ACTIVE_TEXTURE: + *param = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; + break; + case GL_VERTEX_ARRAY_SIZE: + *param = vao->VertexAttrib[VERT_ATTRIB_POS].Format.Size; + break; + case GL_VERTEX_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_POS].Format.Type; + break; + case GL_VERTEX_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_POS].Stride; + break; + case GL_VERTEX_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_POS].BufferObj->Name; + break; + case GL_COLOR_ARRAY_SIZE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR0].Format.Size; + break; + case GL_COLOR_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR0].Format.Type; + break; + case GL_COLOR_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR0].Stride; + break; + case GL_COLOR_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_COLOR0].BufferObj->Name; + break; + case GL_EDGE_FLAG_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Stride; + break; + case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_EDGEFLAG].BufferObj->Name; + break; + case GL_INDEX_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Format.Type; + break; + case GL_INDEX_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Stride; + break; + case GL_INDEX_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_COLOR_INDEX].BufferObj->Name; + break; + case GL_NORMAL_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_NORMAL].Format.Type; + break; + case GL_NORMAL_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_NORMAL].Stride; + break; + case GL_NORMAL_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_NORMAL].BufferObj->Name; + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Format.Size; + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Format.Type; + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Stride; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj->Name; + break; + case GL_FOG_COORD_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_FOG].Format.Type; + break; + case GL_FOG_COORD_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_FOG].Stride; + break; + case GL_FOG_COORD_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_FOG].BufferObj->Name; + break; + case GL_SECONDARY_COLOR_ARRAY_SIZE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR1].Format.Size; + break; + case GL_SECONDARY_COLOR_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR1].Format.Type; + break; + case GL_SECONDARY_COLOR_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_COLOR1].Stride; + break; + case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_COLOR1].BufferObj->Name; + break; + + /* Tokens using IsEnabled */ + case GL_VERTEX_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_POS); + break; + case GL_COLOR_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_COLOR0); + break; + case GL_EDGE_FLAG_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_EDGEFLAG); + break; + case GL_INDEX_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_COLOR_INDEX); + break; + case GL_NORMAL_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_NORMAL); + break; + case GL_TEXTURE_COORD_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_TEX(ctx->Array.ActiveTexture)); + break; + case GL_FOG_COORD_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_FOG); + break; + case GL_SECONDARY_COLOR_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_COLOR1); + break; + + /* Tokens using GetPointerv */ + case GL_VERTEX_ARRAY_POINTER: + case GL_COLOR_ARRAY_POINTER: + case GL_EDGE_FLAG_ARRAY_POINTER: + case GL_INDEX_ARRAY_POINTER: + case GL_NORMAL_ARRAY_POINTER: + case GL_TEXTURE_COORD_ARRAY_POINTER: + case GL_FOG_COORD_ARRAY_POINTER: + case GL_SECONDARY_COLOR_ARRAY_POINTER: + _get_vao_pointerv(pname, vao, &ptr, "glGetVertexArrayIntegervEXT"); + *param = (int) ((uint64_t) ptr & 0xFFFFFFFF); + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexArrayIntegervEXT(pname)"); + } +} + +void GLAPIENTRY +_mesa_GetVertexArrayPointervEXT(GLuint vaobj, GLenum pname, GLvoid** param) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object* vao; + + vao = _mesa_lookup_vao_err(ctx, vaobj, true, + "glGetVertexArrayPointervEXT"); + if (!vao) + return; + + /* The EXT_direct_state_access spec says: + * + * "For GetVertexArrayPointervEXT, pname must be a *_ARRAY_POINTER token from + * tables 6.6, 6.7, and 6.8 excluding VERTEX_ATTRIB_ARRAY_POINT." + */ + switch (pname) { + case GL_VERTEX_ARRAY_POINTER: + case GL_COLOR_ARRAY_POINTER: + case GL_EDGE_FLAG_ARRAY_POINTER: + case GL_INDEX_ARRAY_POINTER: + case GL_NORMAL_ARRAY_POINTER: + case GL_TEXTURE_COORD_ARRAY_POINTER: + case GL_FOG_COORD_ARRAY_POINTER: + case GL_SECONDARY_COLOR_ARRAY_POINTER: + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexArrayPointervEXT(pname)"); + return; + } + + /* pname has been validated, we can now use the helper function */ + _get_vao_pointerv(pname, vao, param, "glGetVertexArrayPointervEXT"); +} + +void GLAPIENTRY +_mesa_GetVertexArrayIntegeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLint *param) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object* vao; + + vao = _mesa_lookup_vao_err(ctx, vaobj, true, + "glGetVertexArrayIntegeri_vEXT"); + if (!vao) + return; + + + /* The EXT_direct_state_access spec says: + * + * "For GetVertexArrayIntegeri_vEXT, pname must be one of the + * "Get value" tokens in tables 6.8 and 6.9 that use GetVertexAttribiv + * or GetVertexAttribPointerv (so allowing only the VERTEX_ATTRIB_* + * tokens) or a token of the form TEXTURE_COORD_ARRAY (the enable) or + * TEXTURE_COORD_ARRAY_*; index identifies the vertex attribute + * array to query or texture coordinate set index respectively." + */ + + switch (pname) { + case GL_TEXTURE_COORD_ARRAY: + *param = !!(vao->Enabled & VERT_BIT_TEX(index)); + break; + case GL_TEXTURE_COORD_ARRAY_SIZE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(index)].Format.Size; + break; + case GL_TEXTURE_COORD_ARRAY_TYPE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(index)].Format.Type; + break; + case GL_TEXTURE_COORD_ARRAY_STRIDE: + *param = vao->VertexAttrib[VERT_ATTRIB_TEX(index)].Stride; + break; + case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: + *param = vao->BufferBinding[VERT_ATTRIB_TEX(index)].BufferObj->Name; + break; + default: + *param = get_vertex_array_attrib(ctx, vao, index, pname, "glGetVertexArrayIntegeri_vEXT"); + } +} + +void GLAPIENTRY +_mesa_GetVertexArrayPointeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLvoid** param) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_vertex_array_object* vao; + + vao = _mesa_lookup_vao_err(ctx, vaobj, true, + "glGetVertexArrayPointeri_vEXT"); + if (!vao) + return; + + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexArrayPointeri_vEXT(index)"); + return; + } + + /* The EXT_direct_state_access spec says: + * + * "For GetVertexArrayPointeri_vEXT, pname must be VERTEX_ATTRIB_ARRAY_POINTER + * or TEXTURE_COORD_ARRAY_POINTER with the index parameter indicating the vertex + * attribute or texture coordindate set index." + */ + switch(pname) { + case GL_VERTEX_ATTRIB_ARRAY_POINTER: + *param = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr; + break; + case GL_TEXTURE_COORD_ARRAY_POINTER: + *param = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_TEX(index)].Ptr; + break; + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexArrayPointeri_vEXT(pname)"); + } +} diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h index 2955e8bd03f..ecb463f42d3 100644 --- a/src/mesa/main/varray.h +++ b/src/mesa/main/varray.h @@ -494,5 +494,16 @@ extern void GLAPIENTRY _mesa_VertexArrayVertexAttribIOffsetEXT(GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +extern void GLAPIENTRY +_mesa_GetVertexArrayIntegervEXT(GLuint vaobj, GLenum pname, GLint *param); + +extern void GLAPIENTRY +_mesa_GetVertexArrayPointervEXT(GLuint vaobj, GLenum pname, GLvoid** param); + +extern void GLAPIENTRY +_mesa_GetVertexArrayIntegeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLint *param); + +extern void GLAPIENTRY +_mesa_GetVertexArrayPointeri_vEXT(GLuint vaobj, GLuint index, GLenum pname, GLvoid** param); #endif -- 2.30.2