diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_context.cc | 52 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_context_private.hh | 13 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_backend.hh | 11 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_context.cc | 10 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_context.hh | 12 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_drawlist.cc | 5 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_index_buffer.cc | 4 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_texture.cc | 2 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_uniform_buffer.cc | 2 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_vertex_buffer.cc | 4 |
10 files changed, 24 insertions, 91 deletions
diff --git a/source/blender/gpu/intern/gpu_context.cc b/source/blender/gpu/intern/gpu_context.cc index 85e7dffe3e7..8ebd49a658e 100644 --- a/source/blender/gpu/intern/gpu_context.cc +++ b/source/blender/gpu/intern/gpu_context.cc @@ -126,58 +126,6 @@ GPUContext *GPU_context_active_get(void) return active_ctx; } -GLuint GPU_vao_alloc(void) -{ - GLuint new_vao_id = 0; - glGenVertexArrays(1, &new_vao_id); - return new_vao_id; -} - -GLuint GPU_fbo_alloc(void) -{ - GLuint new_fbo_id = 0; - glGenFramebuffers(1, &new_fbo_id); - return new_fbo_id; -} - -GLuint GPU_buf_alloc(void) -{ - GLuint new_buffer_id = 0; - glGenBuffers(1, &new_buffer_id); - return new_buffer_id; -} - -GLuint GPU_tex_alloc(void) -{ - GLuint new_texture_id = 0; - glGenTextures(1, &new_texture_id); - return new_texture_id; -} - -void GPU_vao_free(GLuint vao_id, GPUContext *ctx) -{ - static_cast<GLContext *>(ctx)->vao_free(vao_id); -} - -void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx) -{ - static_cast<GLContext *>(ctx)->fbo_free(fbo_id); -} - -void GPU_buf_free(GLuint buf_id) -{ - /* TODO avoid using backend */ - GPUBackend *backend = GPUBackend::get(); - static_cast<GLBackend *>(backend)->buf_free(buf_id); -} - -void GPU_tex_free(GLuint tex_id) -{ - /* TODO avoid using backend */ - GPUBackend *backend = GPUBackend::get(); - static_cast<GLBackend *>(backend)->tex_free(tex_id); -} - struct GPUMatrixState *gpu_context_active_matrix_state_get() { BLI_assert(active_ctx); diff --git a/source/blender/gpu/intern/gpu_context_private.hh b/source/blender/gpu/intern/gpu_context_private.hh index 5643eec1aa6..3d92b4eb587 100644 --- a/source/blender/gpu/intern/gpu_context_private.hh +++ b/source/blender/gpu/intern/gpu_context_private.hh @@ -83,19 +83,6 @@ struct GPUContext { MEM_CXX_CLASS_ALLOC_FUNCS("GPUContext") }; -/* These require a OpenGL ctx bound. */ -GLuint GPU_buf_alloc(void); -GLuint GPU_tex_alloc(void); -GLuint GPU_vao_alloc(void); -GLuint GPU_fbo_alloc(void); - -/* These can be called any threads even without OpenGL ctx. */ -void GPU_buf_free(GLuint buf_id); -void GPU_tex_free(GLuint tex_id); -/* These two need the ctx the id was created with. */ -void GPU_vao_free(GLuint vao_id, GPUContext *ctx); -void GPU_fbo_free(GLuint fbo_id, GPUContext *ctx); - void gpu_context_active_framebuffer_set(GPUContext *ctx, struct GPUFrameBuffer *fb); struct GPUFrameBuffer *gpu_context_active_framebuffer_get(GPUContext *ctx); 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_; } |