From 34e5b39f37f6bd43676b3422b058c4df464c5ee7 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Mon, 26 Jun 2017 17:35:24 +0200 Subject: [PATCH] mesa: add bind_attrib_location() helper Signed-off-by: Samuel Pitoiset Reviewed-by: Timothy Arceri --- src/mesa/main/shader_query.cpp | 48 +++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp index 6efbc37..9086a90 100644 --- a/src/mesa/main/shader_query.cpp +++ b/src/mesa/main/shader_query.cpp @@ -62,30 +62,26 @@ DECL_RESOURCE_FUNC(XFV, gl_transform_feedback_varying_info); DECL_RESOURCE_FUNC(XFB, gl_transform_feedback_buffer); DECL_RESOURCE_FUNC(SUB, gl_subroutine_function); -void GLAPIENTRY -_mesa_BindAttribLocation(GLuint program, GLuint index, - const GLchar *name) +static void +bind_attrib_location(struct gl_context *ctx, + struct gl_shader_program *const shProg, GLuint index, + const GLchar *name, bool no_error) { - GET_CURRENT_CONTEXT(ctx); - - struct gl_shader_program *const shProg = - _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation"); - if (!shProg) - return; - if (!name) return; - if (strncmp(name, "gl_", 3) == 0) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glBindAttribLocation(illegal name)"); - return; - } + if (!no_error) { + if (strncmp(name, "gl_", 3) == 0) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glBindAttribLocation(illegal name)"); + return; + } - if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { - _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(%u >= %u)", - index, ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs); - return; + if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) { + _mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(%u >= %u)", + index, ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs); + return; + } } /* Replace the current value if it's already in the list. Add @@ -101,6 +97,20 @@ _mesa_BindAttribLocation(GLuint program, GLuint index, } void GLAPIENTRY +_mesa_BindAttribLocation(GLuint program, GLuint index, + const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + + struct gl_shader_program *const shProg = + _mesa_lookup_shader_program_err(ctx, program, "glBindAttribLocation"); + if (!shProg) + return; + + bind_attrib_location(ctx, shProg, index, name, false); +} + +void GLAPIENTRY _mesa_GetActiveAttrib(GLuint program, GLuint desired_index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLchar * name) -- 2.7.4