From 2b44ca779b6532302b73398cc01b9daabef215a4 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Mon, 28 Oct 2019 15:31:02 +0100 Subject: [PATCH] mesa: extract helper function from _mesa_GetPointerv MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Will be used by EXT_dsa gllGetVertexArrayPointervEXT implementation. Reviewed-by: Marek Olšák --- src/mesa/main/get.h | 6 ++++ src/mesa/main/getstring.c | 70 +++++++++++++++++++++++---------------- 2 files changed, 47 insertions(+), 29 deletions(-) diff --git a/src/mesa/main/get.h b/src/mesa/main/get.h index 898fb49cdb3..de9b2a27e72 100644 --- a/src/mesa/main/get.h +++ b/src/mesa/main/get.h @@ -93,4 +93,10 @@ _mesa_GetError( void ); extern GLenum GLAPIENTRY _mesa_GetGraphicsResetStatusARB( void ); +struct gl_vertex_array_object; + +extern void +_get_vao_pointerv(GLenum pname, struct gl_vertex_array_object* vao, + GLvoid **params, const char* callerstr); + #endif diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 4db08f15e28..57299f37d45 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -230,29 +230,12 @@ _mesa_GetStringi(GLenum name, GLuint index) } - -/** - * Return pointer-valued state, such as a vertex array pointer. - * - * \param pname names state to be queried - * \param params returns the pointer value - * - * \sa glGetPointerv(). - * - * Tries to get the specified pointer via dd_function_table::GetPointerv, - * otherwise gets the specified pointer from the current context. - */ -void GLAPIENTRY -_mesa_GetPointerv( GLenum pname, GLvoid **params ) +void +_get_vao_pointerv(GLenum pname, struct gl_vertex_array_object* vao, + GLvoid **params, const char* callerstr ) { GET_CURRENT_CONTEXT(ctx); const GLuint clientUnit = ctx->Array.ActiveTexture; - const char *callerstr; - - if (_mesa_is_desktop_gl(ctx)) - callerstr = "glGetPointerv"; - else - callerstr = "glGetPointervKHR"; if (!params) return; @@ -264,42 +247,42 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) case GL_VERTEX_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POS].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_POS].Ptr; break; case GL_NORMAL_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_NORMAL].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_NORMAL].Ptr; break; case GL_COLOR_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR0].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR0].Ptr; break; case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR1].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR1].Ptr; break; case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_FOG].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_FOG].Ptr; break; case GL_INDEX_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Ptr; break; case GL_TEXTURE_COORD_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_TEX(clientUnit)].Ptr; break; case GL_EDGE_FLAG_ARRAY_POINTER: if (ctx->API != API_OPENGL_COMPAT) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Ptr; break; case GL_FEEDBACK_BUFFER_POINTER: if (ctx->API != API_OPENGL_COMPAT) @@ -314,7 +297,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) case GL_POINT_SIZE_ARRAY_POINTER_OES: if (ctx->API != API_OPENGLES) goto invalid_pname; - *params = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr; + *params = (GLvoid *) vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Ptr; break; case GL_DEBUG_CALLBACK_FUNCTION_ARB: case GL_DEBUG_CALLBACK_USER_PARAM_ARB: @@ -332,6 +315,35 @@ invalid_pname: } +/** + * Return pointer-valued state, such as a vertex array pointer. + * + * \param pname names state to be queried + * \param params returns the pointer value + * + * \sa glGetPointerv(). + * + * Tries to get the specified pointer via dd_function_table::GetPointerv, + * otherwise gets the specified pointer from the current context. + */ +void GLAPIENTRY +_mesa_GetPointerv( GLenum pname, GLvoid **params ) +{ + GET_CURRENT_CONTEXT(ctx); + const char *callerstr; + + if (_mesa_is_desktop_gl(ctx)) + callerstr = "glGetPointerv"; + else + callerstr = "glGetPointervKHR"; + + if (!params) + return; + + _get_vao_pointerv(pname, ctx->Array.VAO, params, callerstr); +} + + void GLAPIENTRY _mesa_GetPointerIndexedvEXT( GLenum pname, GLuint index, GLvoid **params ) { -- 2.30.2