]> git.tdb.fi Git - libs/gl.git/commitdiff
Store constant id limit as range, not max value
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 15:39:26 +0000 (18:39 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 16:40:27 +0000 (19:40 +0300)
source/glsl/features.cpp
source/glsl/features.h
source/glsl/generate.cpp

index 1c19c0b0fa73294298b5303c3bb7c2c41c0c3544..d2030783403e8be9c790dc4c23ae13635b540179 100644 (file)
@@ -22,7 +22,7 @@ Features::Features():
        arb_uniform_buffer_object(false),
        ext_gpu_shader4(false),
        ext_texture_array(false),
-       max_constant_id(0x7FFFFFFF)
+       constant_id_range(0x80000000U)
 { }
 
 Features Features::from_context()
index c18efe05088e9c53b8d89ad7e3e2266e705a6980..36220eb352fc0e097dfa1a2ddcae378a10e6073f 100644 (file)
@@ -19,7 +19,7 @@ struct Features
        bool arb_uniform_buffer_object;
        bool ext_gpu_shader4;
        bool ext_texture_array;
-       unsigned max_constant_id;
+       unsigned constant_id_range;
 
        Features();
 
index 92d172c586469f78cd17c5d338700fc68e503c00..3387667283b425c4f9fdb74245b1da577c2b9d5b 100644 (file)
@@ -13,12 +13,11 @@ void ConstantIdAssigner::apply(Module &module, const Features &features)
        for(list<Stage>::iterator i=module.stages.begin(); i!=module.stages.end(); ++i)
                i->content.visit(*this);
 
-       unsigned max_id = features.max_constant_id;
        for(vector<VariableDeclaration *>::iterator i=auto_constants.begin(); i!=auto_constants.end(); ++i)
        {
-               unsigned id = hash32((*i)->name)%(max_id+1);
+               unsigned id = hash32((*i)->name)%features.constant_id_range;
                while(used_ids.count(id))
-                       ++id;
+                       id = (id+1)%features.constant_id_range;
 
                vector<Layout::Qualifier> &qualifiers = (*i)->layout->qualifiers;
                for(vector<Layout::Qualifier>::iterator j=qualifiers.begin(); j!=qualifiers.end(); ++j)