[Bf-blender-cvs] [005084ef62b] master: GPU: Make the creation of opengl shaders more stable.

mano-wii noreply at git.blender.org
Mon Mar 11 16:30:38 CET 2019


Commit: 005084ef62b63645f9189c493f4cdd5b49e7c7d7
Author: mano-wii
Date:   Mon Mar 11 12:22:33 2019 -0300
Branches: master
https://developer.blender.org/rB005084ef62b63645f9189c493f4cdd5b49e7c7d7

GPU: Make the creation of opengl shaders more stable.

This commit possibly fixes the T58938.
The crash happens when a shader that is created in a rendering context is deleted and another shader with the same name/program of the deleted one is created in the same context and used in another context.

===================================================================

M	source/blender/gpu/intern/gpu_codegen.c

===================================================================

diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 63d875b07fd..8be4c178a75 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1254,8 +1254,6 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
 	if (!shader)
 		return;
 
-	GPU_shader_bind(shader);
-
 	for (node = nodes->first; node; node = node->next) {
 		int z = 0;
 		for (input = node->inputs.first; input; input = next, z++) {
@@ -1284,8 +1282,6 @@ void GPU_nodes_extract_dynamic_inputs(GPUShader *shader, ListBase *inputs, ListB
 			}
 		}
 	}
-
-	GPU_shader_unbind();
 }
 
 /* Node Link Functions */
@@ -1983,6 +1979,13 @@ void GPU_pass_compile(GPUPass *pass, const char *shname)
 			pass->shader = NULL;
 		}
 		pass->compiled = true;
+
+		if (!BLI_thread_is_main()) {
+			/* For some drivers, you must use the program at least once in the
+			 * rendering context that it is created. */
+			glUseProgram(GPU_shader_get_program(pass->shader));
+			glUseProgram(0);
+		}
 	}
 }



More information about the Bf-blender-cvs mailing list