]> git.tdb.fi Git - libs/gl.git/commitdiff
Add flat interpolation qualifier for integer inputs in fragment shader
authorMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 14:49:15 +0000 (17:49 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 17:21:57 +0000 (20:21 +0300)
source/glsl/generate.cpp

index cc427d05c30c3f9d66a32556d4ee2c5aa8d042d5..635d9f15dcec1b6720a13df6285d83a6e329c3aa 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/core/hash.h>
 #include <msp/core/raii.h>
 #include "generate.h"
+#include "reflect.h"
 
 using namespace std;
 
@@ -105,6 +106,11 @@ VariableDeclaration *InterfaceGenerator::generate_interface(VariableDeclaration
 
        VariableDeclaration* iface_var = new VariableDeclaration;
        iface_var->sampling = var.sampling;
+       if(stage->type==Stage::FRAGMENT && iface=="in")
+               if(BasicTypeDeclaration *basic = dynamic_cast<BasicTypeDeclaration *>(var.type_declaration))
+                       if(BasicTypeDeclaration *elem = get_element_type(*basic))
+                               if(elem->kind==BasicTypeDeclaration::INT)
+                                       iface_var->interpolation = "flat";
        iface_var->interface = iface;
        iface_var->type = var.type;
        iface_var->name = name;