]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't query array/matrix stride for uniforms which are not arrays/matrices
authorMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 19:28:05 +0000 (22:28 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 25 Aug 2012 19:28:05 +0000 (22:28 +0300)
source/program.cpp

index ffcc4a6c81bd3db1f3aa4c0315676dd1c5e6d1e2..a268850762ef2a78bddd6347fc0de53a1e619eb6 100644 (file)
@@ -297,9 +297,12 @@ void Program::link()
                        for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
                                if(uniforms_by_index[*j]->size>1)
                                        indices2.push_back(*j);
-                       glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
-                       for(unsigned j=0; j<indices2.size(); ++j)
-                               uniforms_by_index[indices[j]]->array_stride = values[j];
+                       if(!indices2.empty())
+                       {
+                               glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
+                               for(unsigned j=0; j<indices2.size(); ++j)
+                                       uniforms_by_index[indices[j]]->array_stride = values[j];
+                       }
 
                        indices2.clear();
                        for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
@@ -310,9 +313,12 @@ void Program::link()
                                        t==GL_FLOAT_MAT3x4 || t==GL_FLOAT_MAT4x2 || t==GL_FLOAT_MAT4x3)
                                        indices2.push_back(*j);
                        }
-                       glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_MATRIX_STRIDE, &values[0]);
-                       for(unsigned j=0; j<indices2.size(); ++j)
-                               uniforms_by_index[indices[j]]->matrix_stride = values[j];
+                       if(!indices2.empty())
+                       {
+                               glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_MATRIX_STRIDE, &values[0]);
+                               for(unsigned j=0; j<indices2.size(); ++j)
+                                       uniforms_by_index[indices[j]]->matrix_stride = values[j];
+                       }
 
                        info.layout_hash = compute_layout_hash(info.uniforms);
                        info.bind_point = info.layout_hash%BufferRange::get_n_uniform_buffer_bindings();