From: Mikko Rasa Date: Sun, 26 Aug 2012 08:01:12 +0000 (+0300) Subject: Sort the uniforms in Program::UniformBlockInfo by offset X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=551311c6424ce6189283165841a7049d5bba160d;p=libs%2Fgl.git Sort the uniforms in Program::UniformBlockInfo by offset --- 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;