From 551311c6424ce6189283165841a7049d5bba160d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 26 Aug 2012 11:01:12 +0300 Subject: [PATCH] Sort the uniforms in Program::UniformBlockInfo by offset --- source/program.cpp | 6 ++++++ source/program.h | 1 + 2 files changed, 7 insertions(+) diff --git a/source/program.cpp b/source/program.cpp index a2688507..d9627519 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -320,6 +320,7 @@ void Program::link() uniforms_by_index[indices[j]]->matrix_stride = values[j]; } + 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(); glUniformBlockBinding(id, i, info.bind_point); @@ -345,6 +346,11 @@ unsigned Program::compute_layout_hash(const vector &uniform return hash32(layout_descriptor); } +bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInfo *uni2) +{ + return uni1->locationlocation; +} + string Program::get_info_log() const { GLsizei len = 0; diff --git a/source/program.h b/source/program.h index 132c21d5..21b38c25 100644 --- a/source/program.h +++ b/source/program.h @@ -109,6 +109,7 @@ public: void link(); private: static unsigned compute_layout_hash(const std::vector &); + static bool uniform_location_compare(const UniformInfo *, const UniformInfo *); public: bool is_linked() const { return linked; } std::string get_info_log() const; -- 2.45.2