]> git.tdb.fi Git - libs/gl.git/commitdiff
Hack to work around an issue with the flat interpolation qualifier
authorMikko Rasa <tdb@tdb.fi>
Sat, 1 Oct 2022 20:05:45 +0000 (23:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 1 Oct 2022 20:05:45 +0000 (23:05 +0300)
It appears that at least on my current system (GeForce 980 Ti, driver
460.91.03) vertex attributes somehow block the flat qualifier from
working on the same location.  It feels like a driver bug but that
remains to be confirmed.

source/glsl/finalize.cpp
source/glsl/finalize.h

index d840648bbc3ec0135bbb02b4dc47350cf753f03f..469cb92daba088493168f82f55e47a4b5938dccd 100644 (file)
@@ -91,6 +91,8 @@ void LocationAllocator::apply(Stage &stage)
        stage.content.visit(*this);
 
        allocate_locations("in");
+       if(stage.type==Stage::VERTEX)
+               swap(used_locations["in"], used_vertex_attribs);
        allocate_locations("out");
 }
 
@@ -121,6 +123,8 @@ void LocationAllocator::allocate_locations(const string &iface)
                if(!alloc_new)
                        continue;
 
+               bool flat = ((*i)->interpolation=="flat" || ((*i)->linked_declaration && (*i)->linked_declaration->interpolation=="flat"));
+
                set<unsigned> &used = used_locations[(*i)->interface];
 
                unsigned size = LocationCounter().apply(**i);
@@ -128,7 +132,7 @@ void LocationAllocator::allocate_locations(const string &iface)
                {
                        int blocking = -1;
                        for(unsigned j=0; j<size; ++j)
-                               if(used.count(next+j))
+                               if(used.count(next+j) || (flat && used_vertex_attribs.count(next+j)))
                                        blocking = next+j;
                        if(blocking<0)
                                break;
index ec5f459ae53b59f1db6371dedcc2928e6d75cd36..4fc2e1b00c42806768e0aca28b9166eb2284939b 100644 (file)
@@ -43,6 +43,10 @@ private:
        std::vector<VariableDeclaration *> unbound_textures;
        std::vector<VariableDeclaration *> unbound_blocks;
 
+       /* Dirty hack to work around an issue where vertex attributes prevent the
+       flat qualifier from working on the same location. */
+       std::set<unsigned> used_vertex_attribs;
+
 public:
        void apply(Module &, const Features &, bool = true);
 private: