From: Mikko Rasa Date: Sat, 25 Aug 2012 19:28:05 +0000 (+0300) Subject: Don't query array/matrix stride for uniforms which are not arrays/matrices X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=5767702aa5456b6f52273b9667aebc4ec02961e3 Don't query array/matrix stride for uniforms which are not arrays/matrices --- diff --git a/source/program.cpp b/source/program.cpp index ffcc4a6c..a2688507 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -297,9 +297,12 @@ void Program::link() for(vector::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; jarray_stride = values[j]; + if(!indices2.empty()) + { + glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]); + for(unsigned j=0; jarray_stride = values[j]; + } indices2.clear(); for(vector::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; jmatrix_stride = values[j]; + if(!indices2.empty()) + { + glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_MATRIX_STRIDE, &values[0]); + for(unsigned j=0; jmatrix_stride = values[j]; + } info.layout_hash = compute_layout_hash(info.uniforms); info.bind_point = info.layout_hash%BufferRange::get_n_uniform_buffer_bindings();