Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2019-06-05 19:06:11 +0300
committermano-wii <germano.costa@ig.com.br>2019-06-05 19:50:58 +0300
commitce66b22c427defa3db498d2d69ee615b3c913c5f (patch)
tree5b0b947f7c0cd22d100af33c23d3ad60eee2133c /source/blender/draw/intern/draw_manager_shader.c
parentdd81efa4a343ecbb7a208e06ea854ce673e20504 (diff)
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
Diffstat (limited to 'source/blender/draw/intern/draw_manager_shader.c')
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 186bbae5cad..bdb3d5958d6 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -63,7 +63,8 @@ typedef struct DRWDeferredShader {
} DRWDeferredShader;
typedef struct DRWShaderCompiler {
- ListBase queue; /* DRWDeferredShader */
+ ListBase queue; /* DRWDeferredShader */
+ ListBase queue_conclude; /* DRWDeferredShader */
SpinLock list_lock;
DRWDeferredShader *mat_compiling;
@@ -134,7 +135,12 @@ static void drw_deferred_shader_compilation_exec(void *custom_data,
BLI_mutex_unlock(&comp->compilation_lock);
BLI_spin_lock(&comp->list_lock);
- drw_deferred_shader_free(comp->mat_compiling);
+ if (GPU_material_status(comp->mat_compiling->mat) == GPU_MAT_QUEUED) {
+ BLI_addtail(&comp->queue_conclude, comp->mat_compiling);
+ }
+ else {
+ drw_deferred_shader_free(comp->mat_compiling);
+ }
comp->mat_compiling = NULL;
BLI_spin_unlock(&comp->list_lock);
}
@@ -148,6 +154,17 @@ static void drw_deferred_shader_compilation_free(void *custom_data)
drw_deferred_shader_queue_free(&comp->queue);
+ if (!BLI_listbase_is_empty(&comp->queue_conclude)) {
+ /* Compile the shaders in the context they will be deleted. */
+ DRW_opengl_context_enable_ex(false);
+ DRWDeferredShader *mat_conclude;
+ while (mat_conclude = BLI_poptail(&comp->queue_conclude)) {
+ GPU_material_compile(mat_conclude->mat);
+ drw_deferred_shader_free(mat_conclude);
+ }
+ DRW_opengl_context_disable_ex(true);
+ }
+
BLI_spin_end(&comp->list_lock);
BLI_mutex_end(&comp->compilation_lock);