From dfde6f3568c1a840232cf860f4a260a987a1433b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 3 Apr 2021 18:39:26 +0300 Subject: [PATCH] Store constant id limit as range, not max value --- source/glsl/features.cpp | 2 +- source/glsl/features.h | 2 +- source/glsl/generate.cpp | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/glsl/features.cpp b/source/glsl/features.cpp index 1c19c0b0..d2030783 100644 --- a/source/glsl/features.cpp +++ b/source/glsl/features.cpp @@ -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() diff --git a/source/glsl/features.h b/source/glsl/features.h index c18efe05..36220eb3 100644 --- a/source/glsl/features.h +++ b/source/glsl/features.h @@ -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(); diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index 92d172c5..33876672 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -13,12 +13,11 @@ void ConstantIdAssigner::apply(Module &module, const Features &features) for(list::iterator i=module.stages.begin(); i!=module.stages.end(); ++i) i->content.visit(*this); - unsigned max_id = features.max_constant_id; for(vector::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 &qualifiers = (*i)->layout->qualifiers; for(vector::iterator j=qualifiers.begin(); j!=qualifiers.end(); ++j) -- 2.45.2