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-07 21:08:25 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-07 21:17:45 +0300
commit19f56cfe6c59e3a54aaf7499fd9072a8790171b7 (patch)
tree3db73ef6ceb2586175249344bf4564457ad2fbc5 /source/blender/gpu/opengl
parent58353834f441b8b4ca91dcd4ec94ac49bbbf5ab0 (diff)
Cleanup: GLBackend: Move buf_free and tex_free to GLContext
This makes it easier to follow. Also removes the GL related functions inside gpu_context.cc.
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r--source/blender/gpu/opengl/gl_backend.hh11
-rw-r--r--source/blender/gpu/opengl/gl_context.cc10
-rw-r--r--source/blender/gpu/opengl/gl_context.hh12
-rw-r--r--source/blender/gpu/opengl/gl_drawlist.cc5
-rw-r--r--source/blender/gpu/opengl/gl_index_buffer.cc4
-rw-r--r--source/blender/gpu/opengl/gl_texture.cc2
-rw-r--r--source/blender/gpu/opengl/gl_uniform_buffer.cc2
-rw-r--r--source/blender/gpu/opengl/gl_vertex_buffer.cc4
8 files changed, 24 insertions, 26 deletions
diff --git a/source/blender/gpu/opengl/gl_backend.hh b/source/blender/gpu/opengl/gl_backend.hh
index 25f3ff38d8b..0c759d2cd62 100644
--- a/source/blender/gpu/opengl/gl_backend.hh
+++ b/source/blender/gpu/opengl/gl_backend.hh
@@ -115,15 +115,10 @@ class GLBackend : public GPUBackend {
return new GLVertBuf();
};
- /* TODO remove */
- void buf_free(GLuint buf_id);
- void tex_free(GLuint tex_id);
- void orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, unsigned int id)
+ GLSharedOrphanLists &shared_orphan_list_get(void)
{
- list_mutex.lock();
- orphan_list.append(id);
- list_mutex.unlock();
- }
+ return shared_orphan_list_;
+ };
private:
static void platform_init(void);
diff --git a/source/blender/gpu/opengl/gl_context.cc b/source/blender/gpu/opengl/gl_context.cc
index ecf74a1993d..5633d28023a 100644
--- a/source/blender/gpu/opengl/gl_context.cc
+++ b/source/blender/gpu/opengl/gl_context.cc
@@ -230,25 +230,27 @@ void GLContext::fbo_free(GLuint fbo_id)
}
}
-void GLBackend::buf_free(GLuint buf_id)
+void GLContext::buf_free(GLuint buf_id)
{
/* Any context can free. */
if (GPU_context_active_get()) {
glDeleteBuffers(1, &buf_id);
}
else {
- orphans_add(shared_orphan_list_.buffers, shared_orphan_list_.lists_mutex, buf_id);
+ GLSharedOrphanLists &orphan_list = GLBackend::get()->shared_orphan_list_get();
+ orphans_add(orphan_list.buffers, orphan_list.lists_mutex, buf_id);
}
}
-void GLBackend::tex_free(GLuint tex_id)
+void GLContext::tex_free(GLuint tex_id)
{
/* Any context can free. */
if (GPU_context_active_get()) {
glDeleteTextures(1, &tex_id);
}
else {
- orphans_add(shared_orphan_list_.textures, shared_orphan_list_.lists_mutex, tex_id);
+ GLSharedOrphanLists &orphan_list = GLBackend::get()->shared_orphan_list_get();
+ orphans_add(orphan_list.textures, orphan_list.lists_mutex, tex_id);
}
}
diff --git a/source/blender/gpu/opengl/gl_context.hh b/source/blender/gpu/opengl/gl_context.hh
index 06e59724f4a..f05029c7075 100644
--- a/source/blender/gpu/opengl/gl_context.hh
+++ b/source/blender/gpu/opengl/gl_context.hh
@@ -105,13 +105,17 @@ class GLContext : public GPUContext {
return static_cast<GLStateManager *>(ctx->state_manager);
};
+ /* These need to be called with the context the id was created with. */
+ void vao_free(GLuint vao_id);
+ void fbo_free(GLuint fbo_id);
+ /* These can be called by any threads even without OpenGL ctx. Deletion will be delayed. */
+ static void buf_free(GLuint buf_id);
+ static void tex_free(GLuint tex_id);
+
/* TODO(fclem) these needs to become private. */
public:
- void orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, GLuint id);
+ static void orphans_add(Vector<GLuint> &orphan_list, std::mutex &list_mutex, GLuint id);
void orphans_clear(void);
-
- void vao_free(GLuint vao_id);
- void fbo_free(GLuint fbo_id);
void vao_cache_register(GLVaoCache *cache);
void vao_cache_unregister(GLVaoCache *cache);
};
diff --git a/source/blender/gpu/opengl/gl_drawlist.cc b/source/blender/gpu/opengl/gl_drawlist.cc
index 7cec6da7541..039ef18ad72 100644
--- a/source/blender/gpu/opengl/gl_drawlist.cc
+++ b/source/blender/gpu/opengl/gl_drawlist.cc
@@ -88,10 +88,7 @@ GLDrawList::GLDrawList(int length)
GLDrawList::~GLDrawList()
{
- /* TODO This ... */
- static_cast<GLBackend *>(GPUBackend::get())->buf_free(buffer_id_);
- /* ... should be this. */
- // context_->buf_free(buffer_id_)
+ GLContext::buf_free(buffer_id_);
}
void GLDrawList::init(void)
diff --git a/source/blender/gpu/opengl/gl_index_buffer.cc b/source/blender/gpu/opengl/gl_index_buffer.cc
index 03a9607a00b..d68953e6daa 100644
--- a/source/blender/gpu/opengl/gl_index_buffer.cc
+++ b/source/blender/gpu/opengl/gl_index_buffer.cc
@@ -21,7 +21,7 @@
* \ingroup gpu
*/
-#include "gl_backend.hh"
+#include "gl_context.hh"
#include "gl_debug.hh"
#include "gl_index_buffer.hh"
@@ -30,7 +30,7 @@ namespace blender::gpu {
GLIndexBuf::~GLIndexBuf()
{
- GLBackend::get()->buf_free(ibo_id_);
+ GLContext::buf_free(ibo_id_);
}
void GLIndexBuf::bind(void)
diff --git a/source/blender/gpu/opengl/gl_texture.cc b/source/blender/gpu/opengl/gl_texture.cc
index 2934865f4d1..b4a8e43c931 100644
--- a/source/blender/gpu/opengl/gl_texture.cc
+++ b/source/blender/gpu/opengl/gl_texture.cc
@@ -59,7 +59,7 @@ GLTexture::~GLTexture()
/* This avoid errors when the texture is still inside the bound texture array. */
ctx->state_manager->texture_unbind(this);
}
- GLBackend::get()->tex_free(tex_id_);
+ GLContext::tex_free(tex_id_);
}
/* Return true on success. */
diff --git a/source/blender/gpu/opengl/gl_uniform_buffer.cc b/source/blender/gpu/opengl/gl_uniform_buffer.cc
index 8c8fac44fdc..a06fadf4785 100644
--- a/source/blender/gpu/opengl/gl_uniform_buffer.cc
+++ b/source/blender/gpu/opengl/gl_uniform_buffer.cc
@@ -45,7 +45,7 @@ GLUniformBuf::GLUniformBuf(size_t size, const char *name) : UniformBuf(size, nam
GLUniformBuf::~GLUniformBuf()
{
- GLBackend::get()->buf_free(ubo_id_);
+ GLContext::buf_free(ubo_id_);
}
/** \} */
diff --git a/source/blender/gpu/opengl/gl_vertex_buffer.cc b/source/blender/gpu/opengl/gl_vertex_buffer.cc
index 66ff1f36cef..d56f5d1aa52 100644
--- a/source/blender/gpu/opengl/gl_vertex_buffer.cc
+++ b/source/blender/gpu/opengl/gl_vertex_buffer.cc
@@ -21,7 +21,7 @@
* \ingroup gpu
*/
-#include "gl_backend.hh"
+#include "gl_context.hh"
#include "gl_vertex_buffer.hh"
@@ -42,7 +42,7 @@ void GLVertBuf::resize_data(void)
void GLVertBuf::release_data(void)
{
if (vbo_id_ != 0) {
- GLBackend::get()->buf_free(vbo_id_);
+ GLContext::buf_free(vbo_id_);
vbo_id_ = 0;
memory_usage -= vbo_size_;
}