From ce66b22c427defa3db498d2d69ee615b3c913c5f Mon Sep 17 00:00:00 2001 From: mano-wii Date: Wed, 5 Jun 2019 13:06:11 -0300 Subject: Fix crash when editing shaders on Intel HD 4000. In the Intel HD 4000 driver a shader has to be deleted in the same context in which it is created. However, because you can't use a rendering context on different threads, to maintain the multithreaded compilation, the solution was to use the `GL_ARB_get_program_binary` and copy the binary generated for the shader and generate a shader on the main context using that binary. This solution is limited only to Intel HD 4000 and windows. Reviewers: fclem Reviewed By: fclem Differential Revision: https://developer.blender.org/D5019 --- source/blender/gpu/intern/gpu_material.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'source/blender/gpu/intern/gpu_material.c') diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index f3df10af518..6f1b8d2d0c6 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -733,23 +733,25 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene, void GPU_material_compile(GPUMaterial *mat) { - /* Only run once! */ + bool sucess; + BLI_assert(mat->status == GPU_MAT_QUEUED); BLI_assert(mat->pass); /* NOTE: The shader may have already been compiled here since we are * sharing GPUShader across GPUMaterials. In this case it's a no-op. */ #ifndef NDEBUG - GPU_pass_compile(mat->pass, mat->name); + sucess = GPU_pass_compile(mat->pass, mat->name); #else - GPU_pass_compile(mat->pass, __func__); + sucess = GPU_pass_compile(mat->pass, __func__); #endif - GPUShader *sh = GPU_pass_shader_get(mat->pass); - - if (sh != NULL) { - mat->status = GPU_MAT_SUCCESS; - GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes); + if (sucess) { + GPUShader *sh = GPU_pass_shader_get(mat->pass); + if (sh != NULL) { + mat->status = GPU_MAT_SUCCESS; + GPU_nodes_extract_dynamic_inputs(sh, &mat->inputs, &mat->nodes); + } } else { mat->status = GPU_MAT_FAILED; -- cgit v1.2.3