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-08-07 18:00:28 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-08 02:16:40 +0300
commit1dd737759639c63d3279be774202585de778dac5 (patch)
treeb0b666aa69477ee7eb0cc2b5a379522bd75d1a62 /source/blender/gpu/intern/gpu_context_private.h
parent0ccf3f89d2e2389d433d1ab682ad04310a9b19ae (diff)
GPUBackend: Add new GPUBackend object to manage GL object allocations
This just set a global object responsible for allocating new objects in a thread safe way without needing any GPUContext bound to this thread. This also introduce the GLContext which will contain all the GL related functions for the current context.
Diffstat (limited to 'source/blender/gpu/intern/gpu_context_private.h')
-rw-r--r--source/blender/gpu/intern/gpu_context_private.h44
1 files changed, 42 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_context_private.h b/source/blender/gpu/intern/gpu_context_private.h
index 08fbefe3b3f..374a05bc25f 100644
--- a/source/blender/gpu/intern/gpu_context_private.h
+++ b/source/blender/gpu/intern/gpu_context_private.h
@@ -27,12 +27,52 @@
#include "GPU_context.h"
+/* TODO cleanup this ifdef */
#ifdef __cplusplus
-extern "C" {
-#endif
+
+# include <mutex>
+# include <pthread.h>
+# include <string.h>
+# include <unordered_set>
+# include <vector>
struct GPUFrameBuffer;
+struct GPUContext {
+ GLuint default_vao;
+ GLuint default_framebuffer;
+ GPUFrameBuffer *current_fbo;
+ std::unordered_set<GPUBatch *> batches; /* Batches that have VAOs from this context */
+# ifdef DEBUG
+ std::unordered_set<GPUFrameBuffer *>
+ framebuffers; /* Framebuffers that have FBO from this context */
+# endif
+ struct GPUMatrixState *matrix_state;
+ std::vector<GLuint> orphaned_vertarray_ids;
+ std::vector<GLuint> orphaned_framebuffer_ids;
+ std::mutex orphans_mutex; /* todo: try spinlock instead */
+# if TRUST_NO_ONE
+ pthread_t thread; /* Thread on which this context is active. */
+ bool thread_is_used;
+# endif
+
+ GPUContext()
+ {
+# if TRUST_NO_ONE
+ thread_is_used = false;
+# endif
+ current_fbo = 0;
+ };
+
+ virtual ~GPUContext(){};
+};
+
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
GLuint GPU_vao_default(void);
GLuint GPU_framebuffer_default(void);