Mesa (master): mesa: don't always set _NEW_PROGRAM when linking
Timothy Arceri
tarceri at kemper.freedesktop.org
Thu Jan 19 04:55:13 UTC 2017
Module: Mesa
Branch: master
Commit: 3fe8d04a6d69fad98228be647ba9b250ea0e3a8b
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3fe8d04a6d69fad98228be647ba9b250ea0e3a8b
Author: Timothy Arceri <timothy.arceri at collabora.com>
Date: Mon Jan 9 16:13:27 2017 +1100
mesa: don't always set _NEW_PROGRAM when linking
We only need to set it when linking was successful and the program
being linked is currently active.
The programs_in_use mask is just used as a flag for now but in
a future change we will use it to update the CurrentProgram array.
V2: make sure to flush vertices before linking (suggested by Marek)
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/main/shaderapi.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 4ee71dc..00577dc 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1097,10 +1097,31 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
return;
}
- FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ unsigned programs_in_use = 0;
+ if (ctx->_Shader)
+ for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
+ if (ctx->_Shader->CurrentProgram[stage] == shProg) {
+ programs_in_use |= 1 << stage;
+ }
+ }
+ FLUSH_VERTICES(ctx, 0);
_mesa_glsl_link_shader(ctx, shProg);
+ /* From section 7.3 (Program Objects) of the OpenGL 4.5 spec:
+ *
+ * "If LinkProgram or ProgramBinary successfully re-links a program
+ * object that is active for any shader stage, then the newly generated
+ * executable code will be installed as part of the current rendering
+ * state for all shader stages where the program is active.
+ * Additionally, the newly generated executable code is made part of
+ * the state of any program pipeline for all stages where the program
+ * is attached."
+ */
+ if (shProg->data->LinkStatus && programs_in_use) {
+ ctx->NewState |= _NEW_PROGRAM;
+ }
+
/* Capture .shader_test files. */
const char *capture_path = _mesa_get_shader_capture_path();
if (shProg->Name != 0 && shProg->Name != ~0 && capture_path != NULL) {
More information about the mesa-commit
mailing list