On 05/14/2014 05:28 PM, Kenneth Graunke wrote: > Tracking this will allow us to issue warnings when using a program that > hasn't yet been relinked, or when re-linking unnecessarily. > > The following functions cause changes that don't take effect until the > program has been re-linked: > > - glAttachShader > - glBindAttribLocation > - glBindFragDataLocation > - glBindFragDataLocationIndexed > - glTransformFeedbackVaryings > - glProgramParameteri (separable/binary retrievable hint) > - glUniformBlockBinding
And also glDetachShader, right? > OpenGL also allows the application to recompile shaders that have been > attached to programs and linked---at which point, they need relinking. > That case will be handled shortly. > > Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> > --- > src/mesa/main/mtypes.h | 1 + > src/mesa/main/shader_query.cpp | 3 ++- > src/mesa/main/shaderapi.c | 6 ++++++ > src/mesa/main/transformfeedback.c | 1 + > src/mesa/main/uniforms.c | 2 ++ > 5 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h > index 917d071..741f936 100644 > --- a/src/mesa/main/mtypes.h > +++ b/src/mesa/main/mtypes.h > @@ -2744,6 +2744,7 @@ struct gl_shader_program > struct gl_active_atomic_buffer *AtomicBuffers; > unsigned NumAtomicBuffers; > > + bool NeedsRelink; > GLboolean LinkStatus; /**< GL_LINK_STATUS */ > GLboolean Validated; > GLboolean _Used; /**< Ever used for drawing? */ > diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp > index 36d1d9c..db3be0c 100644 > --- a/src/mesa/main/shader_query.cpp > +++ b/src/mesa/main/shader_query.cpp > @@ -74,6 +74,7 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index, > * Note that this attribute binding won't go into effect until > * glLinkProgram is called again. > */ > + shProg->NeedsRelink = true; > } > > static bool > @@ -365,7 +366,7 @@ _mesa_BindFragDataLocationIndexed(GLuint program, GLuint > colorNumber, > * Note that this binding won't go into effect until > * glLinkProgram is called again. > */ > - > + shProg->NeedsRelink = true; > } > > GLint GLAPIENTRY > diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c > index 28739da..59d30ff 100644 > --- a/src/mesa/main/shaderapi.c > +++ b/src/mesa/main/shaderapi.c > @@ -284,6 +284,7 @@ attach_shader(struct gl_context *ctx, GLuint program, > GLuint shader) > shProg->Shaders[n] = NULL; /* since realloc() didn't zero the new space */ > _mesa_reference_shader(ctx, &shProg->Shaders[n], sh); > shProg->NumShaders++; > + shProg->NeedsRelink = true; > } > > > @@ -914,6 +915,9 @@ link_program(struct gl_context *ctx, GLuint program) > > _mesa_glsl_link_shader(ctx, shProg); > > + if (shProg->LinkStatus == GL_TRUE) > + shProg->NeedsRelink = false; > + > if (shProg->LinkStatus == GL_FALSE && > (ctx->_Shader->Flags & GLSL_REPORT_ERRORS)) { > _mesa_debug(ctx, "Error linking program %u:\n%s\n", > @@ -1770,6 +1774,7 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, > GLint value) > * is loaded again a recompile can be avoided." > */ > shProg->BinaryRetreivableHint = value; > + shProg->NeedsRelink = true; > return; > > case GL_PROGRAM_SEPARABLE: > @@ -1785,6 +1790,7 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, > GLint value) > return; > } > shProg->SeparateShader = value; > + shProg->NeedsRelink = true; > return; > > default: > diff --git a/src/mesa/main/transformfeedback.c > b/src/mesa/main/transformfeedback.c > index a737463..c037faa 100644 > --- a/src/mesa/main/transformfeedback.c > +++ b/src/mesa/main/transformfeedback.c > @@ -771,6 +771,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei > count, > /* No need to invoke FLUSH_VERTICES or flag NewTransformFeedback since > * the varyings won't be used until shader link time. > */ > + shProg->NeedsRelink = true; > } > > > diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c > index 1daade4..39a61f7 100644 > --- a/src/mesa/main/uniforms.c > +++ b/src/mesa/main/uniforms.c > @@ -1043,6 +1043,8 @@ _mesa_UniformBlockBinding(GLuint program, > sh->UniformBlocks[stage_index].Binding = uniformBlockBinding; > } > } > + > + shProg->NeedsRelink = true; > } > } > > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev