From 3f7b09b2e12830eb439889b300f0d6591c4952ac Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 25 Aug 2012 00:46:24 +0300 Subject: [PATCH] Store block pointer in uniform info It greatly simplifies figuring out which uniforms are not in blocks. --- source/program.cpp | 22 ++++++---------------- source/program.h | 3 +++ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/source/program.cpp b/source/program.cpp index 40a38819..8892bcf1 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -251,6 +251,7 @@ void Program::link() if(len && strncmp(name, "gl_", 3)) { UniformInfo &info = uniforms[name]; + info.block = 0; info.name = name; info.size = size; info.type = type; @@ -258,13 +259,10 @@ void Program::link() } } - vector blockless_uniforms; - if(is_supported("GL_ARB_uniform_buffer_object")) { glGetObjectParameterivARB(id, GL_ACTIVE_UNIFORM_BLOCKS, &value); count = value; - vector uniforms_in_blocks(uniforms_by_index.size()); for(unsigned i=0; iblock = &info; } vector indices2(indices.begin(), indices.end()); @@ -318,23 +316,15 @@ void Program::link() info.bind_point = info.layout_hash%BufferRange::get_n_uniform_buffer_bindings(); glUniformBlockBinding(id, i, info.bind_point); } - - for(unsigned i=0; ilocation = glGetUniformLocationARB(id, info->name.c_str()); - blockless_uniforms.push_back(info); - } } - else - { - for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) + + vector blockless_uniforms; + for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) + if(!i->second.block) { i->second.location = glGetUniformLocationARB(id, i->second.name.c_str()); blockless_uniforms.push_back(&i->second); } - } uniform_layout_hash = compute_layout_hash(blockless_uniforms); } diff --git a/source/program.h b/source/program.h index 40a7a33b..132c21d5 100644 --- a/source/program.h +++ b/source/program.h @@ -51,9 +51,12 @@ public: std::string create_flags() const; }; + struct UniformBlockInfo; + struct UniformInfo { std::string name; + const UniformBlockInfo *block; unsigned location; unsigned size; unsigned array_stride; -- 2.45.2