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:
authorJeroen Bakker <jeroen@blender.org>2020-08-05 16:59:04 +0300
committerJeroen Bakker <jeroen@blender.org>2020-08-05 16:59:04 +0300
commit2ca006f6c179b77ad954d883d0a92d05011640f4 (patch)
treedbbc45bacfdcb099ea8a168cd5a078b0a09e3c8d /source/blender/gpu
parent43d41675a4e5f2621285c9eeac6737c83bf44923 (diff)
parent87062d4d670c01c9c0835057aaf4164aea971e00 (diff)
Merge branch 'blender-v2.90-release'
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_context.h8
-rw-r--r--source/blender/gpu/GPU_extensions.h2
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c15
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h5
-rw-r--r--source/blender/gpu/intern/gpu_context.cc11
-rw-r--r--source/blender/gpu/intern/gpu_extensions.cc10
6 files changed, 25 insertions, 26 deletions
diff --git a/source/blender/gpu/GPU_context.h b/source/blender/gpu/GPU_context.h
index 9876aa6998c..6af150b4660 100644
--- a/source/blender/gpu/GPU_context.h
+++ b/source/blender/gpu/GPU_context.h
@@ -42,6 +42,14 @@ void GPU_context_discard(GPUContext *);
void GPU_context_active_set(GPUContext *);
GPUContext *GPU_context_active_get(void);
+/* Legacy GPU (Intel HD4000 series) do not support sharing GPU objects between GPU
+ * contexts. EEVEE/Workbench can create different contexts for image/preview rendering, baking or
+ * compiling. When a legacy GPU is detected (`GPU_use_main_context_workaround()`) any worker
+ * threads should use the draw manager opengl context and make sure that they are the only one
+ * using it by locking the main context using these two functions. */
+void GPU_context_main_lock(void);
+void GPU_context_main_unlock(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 0d8954dc16c..0518108edf6 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -48,7 +48,7 @@ bool GPU_arb_texture_cube_map_array_is_supported(void);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
bool GPU_unused_fb_slot_workaround(void);
-bool GPU_context_local_shaders_workaround(void);
+bool GPU_use_main_context_workaround(void);
bool GPU_texture_copy_workaround(void);
bool GPU_crappy_amd_driver(void);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index e15e4e08159..8947365d666 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -992,21 +992,9 @@ bool GPU_pass_compile(GPUPass *pass, const char *shname)
shader = NULL;
}
}
- else if (!BLI_thread_is_main() && GPU_context_local_shaders_workaround()) {
- pass->binary.content = GPU_shader_get_binary(
- shader, &pass->binary.format, &pass->binary.len);
- GPU_shader_free(shader);
- shader = NULL;
- }
-
pass->shader = shader;
pass->compiled = true;
}
- else if (pass->binary.content && BLI_thread_is_main()) {
- pass->shader = GPU_shader_load_from_binary(
- pass->binary.content, pass->binary.format, pass->binary.len, shname);
- MEM_SAFE_FREE(pass->binary.content);
- }
return success;
}
@@ -1027,9 +1015,6 @@ static void gpu_pass_free(GPUPass *pass)
MEM_SAFE_FREE(pass->geometrycode);
MEM_SAFE_FREE(pass->vertexcode);
MEM_SAFE_FREE(pass->defines);
- if (pass->binary.content) {
- MEM_freeN(pass->binary.content);
- }
MEM_freeN(pass);
}
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 18ff4c3241d..c08ac663cef 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -47,11 +47,6 @@ typedef struct GPUPass {
char *defines;
uint refcount; /* Orphaned GPUPasses gets freed by the garbage collector. */
uint32_t hash; /* Identity hash generated from all GLSL code. */
- struct {
- char *content;
- uint format;
- int len;
- } binary;
bool compiled; /* Did we already tried to compile the attached GPUShader. */
} GPUPass;
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc
index 0b9104e5349..e6356580ea3 100644
--- a/source/blender/gpu/intern/gpu_context.cc
+++ b/source/blender/gpu/intern/gpu_context.cc
@@ -62,6 +62,7 @@ static std::vector<GLuint> orphaned_buffer_ids;
static std::vector<GLuint> orphaned_texture_ids;
static std::mutex orphans_mutex;
+static std::mutex main_context_mutex;
struct GPUContext {
GLuint default_vao;
@@ -345,3 +346,13 @@ struct GPUMatrixState *gpu_context_active_matrix_state_get()
BLI_assert(active_ctx);
return active_ctx->matrix_state;
}
+
+void GPU_context_main_lock(void)
+{
+ main_context_mutex.lock();
+}
+
+void GPU_context_main_unlock(void)
+{
+ main_context_mutex.unlock();
+}
diff --git a/source/blender/gpu/intern/gpu_extensions.cc b/source/blender/gpu/intern/gpu_extensions.cc
index 32c1bf6e2d3..35b70a18363 100644
--- a/source/blender/gpu/intern/gpu_extensions.cc
+++ b/source/blender/gpu/intern/gpu_extensions.cc
@@ -97,7 +97,7 @@ static struct GPUGlobal {
bool broken_amd_driver;
/* Some crappy Intel drivers don't work well with shaders created in different
* rendering contexts. */
- bool context_local_shaders_workaround;
+ bool use_main_context_workaround;
/* Intel drivers exhibit artifacts when using #glCopyImageSubData & workbench anti-aliasing.
* (see T76273) */
bool texture_copy_workaround;
@@ -225,9 +225,9 @@ bool GPU_unused_fb_slot_workaround(void)
return GG.unused_fb_slot_workaround;
}
-bool GPU_context_local_shaders_workaround(void)
+bool GPU_use_main_context_workaround(void)
{
- return GG.context_local_shaders_workaround;
+ return GG.use_main_context_workaround;
}
bool GPU_texture_copy_workaround(void)
@@ -391,12 +391,12 @@ void gpu_extensions_init(void)
/* Maybe not all of these drivers have problems with `GLEW_ARB_base_instance`.
* But it's hard to test each case. */
GG.glew_arb_base_instance_is_supported = false;
- GG.context_local_shaders_workaround = true;
+ GG.use_main_context_workaround = true;
}
if (strstr(version, "Build 20.19.15.4285")) {
/* Somehow fixes armature display issues (see T69743). */
- GG.context_local_shaders_workaround = true;
+ GG.use_main_context_workaround = true;
}
}
else if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE) &&