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:
authorClément Foucault <foucault.clem@gmail.com>2020-09-08 04:18:49 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-08 05:15:50 +0300
commitccc512cc619dc9f0e6fd79270a7a96ece34d23b5 (patch)
treeda728c4f3745fc352a5e223502ca8734c3c1f01b /source/blender/gpu
parentca8ffc523e3d08fc55c5cf000fa9fc3888950bf7 (diff)
GPUImmediate: Make activation / deactivation implicit
This avoids unecessary complexity. Also makes the GPUImmediate threadsafe by using a threadlocal imm variable.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_immediate.h6
-rw-r--r--source/blender/gpu/intern/gpu_immediate.cc12
-rw-r--r--source/blender/gpu/intern/gpu_immediate_private.hh5
-rw-r--r--source/blender/gpu/intern/gpu_init_exit.c8
-rw-r--r--source/blender/gpu/opengl/gl_context.cc4
5 files changed, 9 insertions, 26 deletions
diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h
index 6057770d2d9..edb7c9fe5b5 100644
--- a/source/blender/gpu/GPU_immediate.h
+++ b/source/blender/gpu/GPU_immediate.h
@@ -145,12 +145,6 @@ void immUniformThemeColorBlendShade(int color_id1, int color_id2, float fac, int
void immUniformThemeColorBlend(int color_id1, int color_id2, float fac);
void immThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset);
-/* These are called by the system -- not part of drawing API. */
-void immInit(void);
-void immActivate(void);
-void immDeactivate(void);
-void immDestroy(void);
-
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index dd3e5bea604..9fc5e03a796 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -39,12 +39,7 @@
using namespace blender::gpu;
-static Immediate *imm = NULL;
-
-void immInit(void)
-{
- /* TODO Remove */
-}
+static thread_local Immediate *imm = NULL;
void immActivate(void)
{
@@ -56,11 +51,6 @@ void immDeactivate(void)
imm = NULL;
}
-void immDestroy(void)
-{
- /* TODO Remove */
-}
-
GPUVertFormat *immVertexFormat(void)
{
GPU_vertformat_clear(&imm->vertex_format);
diff --git a/source/blender/gpu/intern/gpu_immediate_private.hh b/source/blender/gpu/intern/gpu_immediate_private.hh
index aa99fb9a438..38db8131942 100644
--- a/source/blender/gpu/intern/gpu_immediate_private.hh
+++ b/source/blender/gpu/intern/gpu_immediate_private.hh
@@ -63,4 +63,7 @@ class Immediate {
virtual void end(void) = 0;
};
-} // namespace blender::gpu \ No newline at end of file
+} // namespace blender::gpu
+
+void immActivate(void);
+void immDeactivate(void); \ No newline at end of file
diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c
index 129a66994b1..0eb2fe57c28 100644
--- a/source/blender/gpu/intern/gpu_init_exit.c
+++ b/source/blender/gpu/intern/gpu_init_exit.c
@@ -54,10 +54,6 @@ void GPU_init(void)
gpu_batch_init();
- if (!G.background) {
- immInit();
- }
-
#ifndef GPU_STANDALONE
gpu_pbvh_init();
#endif
@@ -69,10 +65,6 @@ void GPU_exit(void)
gpu_pbvh_exit();
#endif
- if (!G.background) {
- immDestroy();
- }
-
gpu_batch_exit();
gpu_material_library_exit();
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
index 1f7e191d394..30279ccade1 100644
--- a/source/blender/gpu/opengl/gl_context.cc
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -32,6 +32,7 @@
#include "GHOST_C-api.h"
#include "gpu_context_private.hh"
+#include "gpu_immediate_private.hh"
#include "gl_debug.hh"
#include "gl_immediate.hh"
@@ -151,10 +152,13 @@ void GLContext::activate(void)
/* Not really following the state but we should consider
* no ubo bound when activating a context. */
bound_ubo_slots = 0;
+
+ immActivate();
}
void GLContext::deactivate(void)
{
+ immDeactivate();
is_active_ = false;
}