From 0fdc229b8b43f1897de4611672ac65b4db954be0 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 1 Oct 2022 23:05:45 +0300 Subject: [PATCH] Hack to work around an issue with the flat interpolation qualifier 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 | 6 +++++- source/glsl/finalize.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/glsl/finalize.cpp b/source/glsl/finalize.cpp index d840648b..469cb92d 100644 --- a/source/glsl/finalize.cpp +++ b/source/glsl/finalize.cpp @@ -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 &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 unbound_textures; std::vector unbound_blocks; + /* Dirty hack to work around an issue where vertex attributes prevent the + flat qualifier from working on the same location. */ + std::set used_vertex_attribs; + public: void apply(Module &, const Features &, bool = true); private: -- 2.45.2