#include <algorithm>
#include <cstring>
+#include <set>
#include <msp/core/hash.h>
#include <msp/core/maputils.h>
#include <msp/gl/extensions/arb_shader_objects.h>
if(ARB_uniform_buffer_object)
{
+ std::set<unsigned> used_bind_points;
count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS);
for(unsigned i=0; i<count; ++i)
{
sort(info.uniforms.begin(), info.uniforms.end(), uniform_location_compare);
info.layout_hash = compute_layout_hash(info.uniforms);
- info.bind_point = info.layout_hash%BufferRange::get_n_uniform_buffer_bindings();
+ unsigned n_bindings = BufferRange::get_n_uniform_buffer_bindings();
+ info.bind_point = info.layout_hash%n_bindings;
+ while(used_bind_points.count(info.bind_point))
+ info.bind_point = (info.bind_point+1)%n_bindings;
glUniformBlockBinding(id, i, info.bind_point);
+ used_bind_points.insert(info.bind_point);
}
}