]> git.tdb.fi Git - libs/gl.git/commitdiff
Rename some things in Program
authorMikko Rasa <tdb@tdb.fi>
Fri, 2 Apr 2021 09:09:01 +0000 (12:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 2 Apr 2021 11:02:10 +0000 (14:02 +0300)
source/core/program.cpp
source/core/program.h
source/core/uniformblock.cpp

index 9c2968497f302ccad397ea311be277da98d683e5..f28736bd9a63b7550ef712e0ab531d5a6b26b68d 100644 (file)
@@ -385,35 +385,35 @@ void Program::query_uniform_blocks(const vector<UniformInfo *> &uniforms_by_inde
                        uniforms_by_index[*j]->block = &info;
                }
 
-               vector<unsigned> indices2(indices.begin(), indices.end());
+               vector<unsigned> query_indices(indices.begin(), indices.end());
                vector<int> values(indices.size());
-               glGetActiveUniformsiv(id, indices.size(), &indices2[0], GL_UNIFORM_OFFSET, &values[0]);
+               glGetActiveUniformsiv(id, query_indices.size(), &query_indices[0], GL_UNIFORM_OFFSET, &values[0]);
                for(unsigned j=0; j<indices.size(); ++j)
-                       uniforms_by_index[indices[j]]->location = values[j];
+                       uniforms_by_index[indices[j]]->offset = values[j];
 
-               indices2.clear();
+               query_indices.clear();
                for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
                        if(uniforms_by_index[*j]->array_size>1)
-                               indices2.push_back(*j);
-               if(!indices2.empty())
+                               query_indices.push_back(*j);
+               if(!query_indices.empty())
                {
-                       glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
-                       for(unsigned j=0; j<indices2.size(); ++j)
-                               uniforms_by_index[indices2[j]]->array_stride = values[j];
+                       glGetActiveUniformsiv(id, query_indices.size(), &query_indices[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
+                       for(unsigned j=0; j<query_indices.size(); ++j)
+                               uniforms_by_index[query_indices[j]]->array_stride = values[j];
                }
 
-               indices2.clear();
+               query_indices.clear();
                for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
                {
                        DataType t = uniforms_by_index[*j]->type;
                        if(is_matrix(t))
-                               indices2.push_back(*j);
+                               query_indices.push_back(*j);
                }
-               if(!indices2.empty())
+               if(!query_indices.empty())
                {
-                       glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_MATRIX_STRIDE, &values[0]);
-                       for(unsigned j=0; j<indices2.size(); ++j)
-                               uniforms_by_index[indices2[j]]->matrix_stride = values[j];
+                       glGetActiveUniformsiv(id, query_indices.size(), &query_indices[0], GL_UNIFORM_MATRIX_STRIDE, &values[0]);
+                       for(unsigned j=0; j<query_indices.size(); ++j)
+                               uniforms_by_index[query_indices[j]]->matrix_stride = values[j];
                }
 
                sort(info.uniforms.begin(), info.uniforms.end(), uniform_location_compare);
@@ -511,7 +511,7 @@ void Program::collect_block_uniforms(UniformBlockInfo &block, const SpirVModule:
                        UniformInfo &info = uniforms[name];
                        info.name = name;
                        info.block = &block;
-                       info.location = i->offset;
+                       info.offset = i->offset;
                        info.array_size = i->array_size;
                        info.array_stride = i->array_stride;
                        info.matrix_stride = i->matrix_stride;
@@ -580,12 +580,12 @@ const Program::UniformInfo &Program::get_uniform_info(const string &name) const
        return get_item(uniforms, name);
 }
 
-int Program::get_uniform_location(const string &n) const
+int Program::get_uniform_location(const string &name) const
 {
-       if(n[n.size()-1]==']')
+       if(name[name.size()-1]==']')
                throw invalid_argument("Program::get_uniform_location");
 
-       UniformMap::const_iterator i = uniforms.find(n);
+       UniformMap::const_iterator i = uniforms.find(name);
        if(i==uniforms.end())
                return -1;
 
@@ -597,12 +597,12 @@ const Program::AttributeInfo &Program::get_attribute_info(const string &name) co
        return get_item(attributes, name);
 }
 
-int Program::get_attribute_location(const string &n) const
+int Program::get_attribute_location(const string &name) const
 {
-       if(n[n.size()-1]==']')
+       if(name[name.size()-1]==']')
                throw invalid_argument("Program::get_attribute_location");
 
-       AttributeMap::const_iterator i = attributes.find(n);
+       AttributeMap::const_iterator i = attributes.find(name);
        return i!=attributes.end() ? i->second.location : -1;
 }
 
@@ -628,7 +628,7 @@ void Program::unbind()
 
 Program::UniformInfo::UniformInfo():
        block(0),
-       location(0),
+       location(-1),
        array_size(0),
        array_stride(0),
        matrix_stride(0),
index 5ed61eaafb647654ba2f91ec8860340073f7645a..48c18d0f56333371130710942a4dbdc9076e9f45 100644 (file)
@@ -63,7 +63,11 @@ public:
        {
                std::string name;
                const UniformBlockInfo *block;
-               unsigned location;
+               union
+               {
+                       int location;
+                       unsigned offset;
+               };
                unsigned array_size;
                unsigned array_stride;
                unsigned matrix_stride;
index cc8945cf2093358d7df19ccebfe5e92ee9fffa61..6f63e385a7bbf6dad1791a3c7782dbf3c350abbd 100644 (file)
@@ -60,7 +60,7 @@ void UniformBlock::attach(const Program::UniformInfo &info, const Uniform &uni)
 {
        if(size)
        {
-               uni.store(info, &data[info.location]);
+               uni.store(info, &data[info.offset]);
                dirty = true;
        }
        else