mesa: extract helper function from _mesa_GetPointerv

Will be used by EXT_dsa gllGetVertexArrayPointervEXT implementation.
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
parent 5adeff80
......@@ -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
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment