Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/opengl/gl_uniform_buffer.cc
| Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | void GLUniformBuf::bind(int slot) | ||||
| glBindBufferBase(GL_UNIFORM_BUFFER, slot_, ubo_id_); | glBindBufferBase(GL_UNIFORM_BUFFER, slot_, ubo_id_); | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| BLI_assert(slot < 16); | BLI_assert(slot < 16); | ||||
| GLContext::get()->bound_ubo_slots |= 1 << slot; | GLContext::get()->bound_ubo_slots |= 1 << slot; | ||||
| #endif | #endif | ||||
| } | } | ||||
| void GLUniformBuf::bind_as_ssbo(int slot) | |||||
| { | |||||
| if (ubo_id_ == 0) { | |||||
| this->init(); | |||||
| } | |||||
| if (data_ != nullptr) { | |||||
| this->update(data_); | |||||
| MEM_SAFE_FREE(data_); | |||||
| } | |||||
| glBindBufferBase(GL_SHADER_STORAGE_BUFFER, slot, ubo_id_); | |||||
| } | |||||
| void GLUniformBuf::unbind() | void GLUniformBuf::unbind() | ||||
| { | { | ||||
| #ifdef DEBUG | #ifdef DEBUG | ||||
| /* NOTE: This only unbinds the last bound slot. */ | /* NOTE: This only unbinds the last bound slot. */ | ||||
| glBindBufferBase(GL_UNIFORM_BUFFER, slot_, 0); | glBindBufferBase(GL_UNIFORM_BUFFER, slot_, 0); | ||||
| /* Hope that the context did not change. */ | /* Hope that the context did not change. */ | ||||
| GLContext::get()->bound_ubo_slots &= ~(1 << slot_); | GLContext::get()->bound_ubo_slots &= ~(1 << slot_); | ||||
| #endif | #endif | ||||
| slot_ = 0; | slot_ = 0; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| } // namespace blender::gpu | } // namespace blender::gpu | ||||