diff options
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 151 |
1 files changed, 95 insertions, 56 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index e6c7f7aa3f8..030236e7350 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -404,6 +404,14 @@ bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index, } +static void +bind_frag_data_location(struct gl_context *ctx, GLuint program, + GLuint colorNumber, const GLchar *name) +{ + _mesa_problem(ctx, "bind_frag_data_location() not implemented yet"); +} + + static GLuint create_shader(struct gl_context *ctx, GLenum type) { @@ -605,6 +613,16 @@ get_attached_shaders(struct gl_context *ctx, GLuint program, GLsizei maxCount, } +static GLint +get_frag_data_location(struct gl_context *ctx, GLuint program, + const GLchar *name) +{ + _mesa_problem(ctx, "get_frag_data_location() not implemented yet"); + return -1; +} + + + /** * glGetHandleARB() - return ID/name of currently bound shader program. */ @@ -918,9 +936,9 @@ print_shader_info(const struct gl_shader_program *shProg) /** * Use the named shader program for subsequent glUniform calls */ -static void -active_program(struct gl_context *ctx, struct gl_shader_program *shProg, - const char *caller) +void +_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, + const char *caller) { if ((shProg != NULL) && !shProg->LinkStatus) { _mesa_error(ctx, GL_INVALID_OPERATION, @@ -974,6 +992,7 @@ use_shader_program(struct gl_context *ctx, GLenum type, } if (*target != shProg) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); _mesa_reference_shader_program(ctx, target, shProg); return true; } @@ -985,49 +1004,12 @@ use_shader_program(struct gl_context *ctx, GLenum type, * Use the named shader program for subsequent rendering. */ void -_mesa_use_program(struct gl_context *ctx, GLuint program) +_mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg) { - struct gl_shader_program *shProg; - struct gl_transform_feedback_object *obj = - ctx->TransformFeedback.CurrentObject; - bool changed = false; - - if (obj->Active) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(transform feedback active)"); - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); - if (!shProg) { - return; - } - if (!shProg->LinkStatus) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(program %u not linked)", program); - return; - } - - /* debug code */ - if (ctx->Shader.Flags & GLSL_USE_PROG) { - print_shader_info(shProg); - } - } - else { - shProg = NULL; - } - - changed = use_shader_program(ctx, GL_VERTEX_SHADER, shProg); - changed = use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg) - || changed; - changed = use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg) - || changed; - active_program(ctx, shProg, "glUseProgram"); - - if (changed) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - } + use_shader_program(ctx, GL_VERTEX_SHADER, shProg); + use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg); + use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg); + _mesa_active_program(ctx, shProg, "glUseProgram"); if (ctx->Driver.UseProgram) ctx->Driver.UseProgram(ctx, shProg); @@ -1185,6 +1167,16 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint index, } +/* GL_EXT_gpu_shader4, GL3 */ +void GLAPIENTRY +_mesa_BindFragDataLocation(GLuint program, GLuint colorNumber, + const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + bind_frag_data_location(ctx, program, colorNumber, name); +} + + void GLAPIENTRY _mesa_CompileShaderARB(GLhandleARB shaderObj) { @@ -1315,6 +1307,16 @@ _mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name) } +/* GL_EXT_gpu_shader4, GL3 */ +GLint GLAPIENTRY +_mesa_GetFragDataLocation(GLuint program, const GLchar *name) +{ + GET_CURRENT_CONTEXT(ctx); + return get_frag_data_location(ctx, program, name); +} + + + void GLAPIENTRY _mesa_GetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog) @@ -1576,8 +1578,37 @@ void GLAPIENTRY _mesa_UseProgramObjectARB(GLhandleARB program) { GET_CURRENT_CONTEXT(ctx); - FLUSH_VERTICES(ctx, _NEW_PROGRAM); - _mesa_use_program(ctx, program); + struct gl_shader_program *shProg; + struct gl_transform_feedback_object *obj = + ctx->TransformFeedback.CurrentObject; + + if (obj->Active) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(transform feedback active)"); + return; + } + + if (program) { + shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); + if (!shProg) { + return; + } + if (!shProg->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(program %u not linked)", program); + return; + } + + /* debug code */ + if (ctx->Shader.Flags & GLSL_USE_PROG) { + print_shader_info(shProg); + } + } + else { + shProg = NULL; + } + + _mesa_use_program(ctx, shProg); } @@ -1693,12 +1724,21 @@ _mesa_ProgramParameteriARB(GLuint program, GLenum pname, #endif +void +_mesa_use_shader_program(struct gl_context *ctx, GLenum type, + struct gl_shader_program *shProg) +{ + use_shader_program(ctx, type, shProg); + + if (ctx->Driver.UseProgram) + ctx->Driver.UseProgram(ctx, shProg); +} + void GLAPIENTRY _mesa_UseShaderProgramEXT(GLenum type, GLuint program) { GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *shProg = NULL; - bool changed = false; if (!validate_shader_target(ctx, type)) { _mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)"); @@ -1724,13 +1764,7 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program) } } - changed = use_shader_program(ctx, type, shProg); - if (changed) - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - - if (ctx->Driver.UseProgram) - ctx->Driver.UseProgram(ctx, shProg); - return; + _mesa_use_shader_program(ctx, type, shProg); } void GLAPIENTRY @@ -1741,7 +1775,7 @@ _mesa_ActiveProgramEXT(GLuint program) ? _mesa_lookup_shader_program_err(ctx, program, "glActiveProgramEXT") : NULL; - active_program(ctx, shProg, "glActiveProgramEXT"); + _mesa_active_program(ctx, shProg, "glActiveProgramEXT"); return; } @@ -1842,6 +1876,11 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec) SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT); SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT); SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT); + + /* GL_EXT_gpu_shader4 / GL 3.0 */ + SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation); + SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation); + #endif /* FEATURE_GL */ } |