Fix #104347: Loop Cut Tool becomes impressive with GPU Subdivision
When updating a mesh, the GPU Subdivision code makes calls to `GPU_indexbuf_bind_as_ssbo()`. This may cause the current VAO index buffer to change due to calls from `glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id_)` in `GPU_indexbuf_bind_as_ssbo()`. The solution is to unbind the VAO (by calling `glBindVertexArray(0)`) before creating the index buffer IBO. Co-authored-by: Germano Cavalcante <grmncv@gmail.com> Pull Request #104873
This commit is contained in:
@@ -41,7 +41,18 @@ void GLIndexBuf::bind()
|
||||
|
||||
void GLIndexBuf::bind_as_ssbo(uint binding)
|
||||
{
|
||||
bind();
|
||||
if (ibo_id_ == 0 || data_ != nullptr) {
|
||||
/* Calling `glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id_)` changes the index buffer
|
||||
* of the currently bound VAO.
|
||||
*
|
||||
* In the OpenGL backend, the VAO state persists even after `GLVertArray::update_bindings`
|
||||
* is called.
|
||||
*
|
||||
* NOTE: For safety, we could call `glBindVertexArray(0)` right after drawing a `GPUBatch`.
|
||||
* However, for performance reasons, we have chosen not to do so. */
|
||||
glBindVertexArray(0);
|
||||
bind();
|
||||
}
|
||||
BLI_assert(ibo_id_ != 0);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, ibo_id_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user