]> git.tdb.fi Git - libs/gl.git/commitdiff
Sort the uniforms in Program::UniformBlockInfo by offset
authorMikko Rasa <tdb@tdb.fi>
Sun, 26 Aug 2012 08:01:12 +0000 (11:01 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 26 Aug 2012 08:01:12 +0000 (11:01 +0300)
source/program.cpp
source/program.h

index a268850762ef2a78bddd6347fc0de53a1e619eb6..d962751994d38fe1e7fd93550bb51a545eaec9f6 100644 (file)
@@ -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<const UniformInfo *> &uniform
        return hash32(layout_descriptor);
 }
 
+bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInfo *uni2)
+{
+       return uni1->location<uni2->location;
+}
+
 string Program::get_info_log() const
 {
        GLsizei len = 0;
index 132c21d5b126ec7d1dc3d2d9bb94ec1814747fb0..21b38c255e7262d77d01800c2204d27c75c7f0f8 100644 (file)
@@ -109,6 +109,7 @@ public:
        void link();
 private:
        static unsigned compute_layout_hash(const std::vector<const UniformInfo *> &);
+       static bool uniform_location_compare(const UniformInfo *, const UniformInfo *);
 public:
        bool is_linked() const { return linked; }
        std::string get_info_log() const;