Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_uniform_buffer.cc
| Show All 19 Lines | |||||
| /** \file | /** \file | ||||
| * \ingroup gpu | * \ingroup gpu | ||||
| */ | */ | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "GPU_extensions.h" | |||||
| #include "gpu_backend.hh" | #include "gpu_backend.hh" | ||||
| #include "gpu_context_private.hh" | #include "gpu_context_private.hh" | ||||
| #include "gl_backend.hh" | #include "gl_backend.hh" | ||||
| #include "gl_uniform_buffer.hh" | #include "gl_uniform_buffer.hh" | ||||
| namespace blender::gpu { | namespace blender::gpu { | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Creation & Deletion | /** \name Creation & Deletion | ||||
| * \{ */ | * \{ */ | ||||
| GLUniformBuf::GLUniformBuf(size_t size, const char *name) : UniformBuf(size, name) | GLUniformBuf::GLUniformBuf(size_t size, const char *name) : UniformBuf(size, name) | ||||
| { | { | ||||
| /* Do not create ubo GL buffer here to allow allocation from any thread. */ | /* Do not create ubo GL buffer here to allow allocation from any thread. */ | ||||
| BLI_assert(size <= GLContext::max_ubo_size); | |||||
| } | } | ||||
| GLUniformBuf::~GLUniformBuf() | GLUniformBuf::~GLUniformBuf() | ||||
| { | { | ||||
| GLBackend::get()->buf_free(ubo_id_); | GLContext::buf_free(ubo_id_); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Data upload / update | /** \name Data upload / update | ||||
| * \{ */ | * \{ */ | ||||
| Show All 27 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Usage | /** \name Usage | ||||
| * \{ */ | * \{ */ | ||||
| void GLUniformBuf::bind(int slot) | void GLUniformBuf::bind(int slot) | ||||
| { | { | ||||
| if (slot >= GPU_max_ubo_binds()) { | if (slot >= GLContext::max_ubo_binds) { | ||||
| fprintf(stderr, | fprintf(stderr, | ||||
| "Error: Trying to bind \"%s\" ubo to slot %d which is above the reported limit of %d.", | "Error: Trying to bind \"%s\" ubo to slot %d which is above the reported limit of %d.", | ||||
| name_, | name_, | ||||
| slot, | slot, | ||||
| GPU_max_ubo_binds()); | GLContext::max_ubo_binds); | ||||
| return; | return; | ||||
| } | } | ||||
| if (ubo_id_ == 0) { | if (ubo_id_ == 0) { | ||||
| this->init(); | this->init(); | ||||
| } | } | ||||
| if (data_ != NULL) { | if (data_ != NULL) { | ||||
| Show All 19 Lines | #ifdef DEBUG | ||||
| static_cast<GLContext *>(GPU_context_active_get())->bound_ubo_slots &= ~(1 << slot_); | static_cast<GLContext *>(GPU_context_active_get())->bound_ubo_slots &= ~(1 << slot_); | ||||
| #endif | #endif | ||||
| slot_ = 0; | slot_ = 0; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| } // namespace blender::gpu | } // namespace blender::gpu | ||||
| No newline at end of file | No newline at end of file | ||||