diff --git a/source/blender/gpu/opengl/gl_index_buffer.cc b/source/blender/gpu/opengl/gl_index_buffer.cc index c32634a5d1f..a2de6a99064 100644 --- a/source/blender/gpu/opengl/gl_index_buffer.cc +++ b/source/blender/gpu/opengl/gl_index_buffer.cc @@ -59,8 +59,27 @@ void GLIndexBuf::bind_as_ssbo(uint binding) glBindVertexArray(0); bind(); } - BLI_assert(ibo_id_ != 0); - glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, ibo_id_); + + if (!is_subrange_) { + BLI_assert(ibo_id_ != 0); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, ibo_id_); + } + else { + GLuint src_ibo_id = static_cast(src_)->ibo_id_; + BLI_assert(src_ibo_id != 0); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, src_ibo_id); +#if 0 + /* TODO(pragma37): Check with @fclem. + * I think this would be the correct behavior, but + * overlay::Prepass::use_material_slot_selection_ seems to rely on binding the full index + * buffer? */ + glBindBufferRange(GL_SHADER_STORAGE_BUFFER, + binding, + src_ibo_id, + index_start_, + index_len_ * to_bytesize(index_type_)); +#endif + } #ifndef NDEBUG BLI_assert(binding < 16);