]> git.tdb.fi Git - libs/gl.git/commitdiff
Support the sample sampling qualifier
authorMikko Rasa <tdb@tdb.fi>
Thu, 5 Jul 2018 21:03:35 +0000 (00:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 5 Jul 2018 21:03:35 +0000 (00:03 +0300)
Also add a version check for the centroid qualifier.

source/programcompiler.cpp
source/programcompiler.h
source/programparser.cpp

index 1ba898ec4d373f63e019610206dcce5762248063..1c84a96dc925f18095368d63aa13aaaf19a7d88d 100644 (file)
@@ -1765,6 +1765,22 @@ bool ProgramCompiler::LegacyConverter::supports_interface_layouts() const
                return check_version(Version(3, 30));
 }
 
+bool ProgramCompiler::LegacyConverter::supports_centroid_sampling() const
+{
+       if(target_api==OPENGL_ES2)
+               return check_version(Version(3, 0));
+       else
+               return check_version(Version(1, 20));
+}
+
+bool ProgramCompiler::LegacyConverter::supports_sample_sampling() const
+{
+       if(target_api==OPENGL_ES2)
+               return check_version(Version(3, 20));
+       else
+               return check_version(Version(4, 0));
+}
+
 void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var)
 {
        if(var.layout && !supports_interface_layouts())
@@ -1792,6 +1808,17 @@ void ProgramCompiler::LegacyConverter::visit(VariableDeclaration &var)
                }
        }
 
+       if(var.sampling=="centroid")
+       {
+               if(!supports_centroid_sampling())
+                       var.sampling = string();
+       }
+       else if(var.sampling=="sample")
+       {
+               if(!supports_sample_sampling())
+                       var.sampling = string();
+       }
+
        if((var.interface=="in" || var.interface=="out") && !supports_unified_interface_syntax())
        {
                if(stage->type==FRAGMENT && var.interface=="out")
index 7e8d3373a53e4ffcf028a218d99e420d1a9cd5a7..56bf1d538fc1be3069f1ed816547fbbc20638585 100644 (file)
@@ -361,6 +361,8 @@ private:
                bool supports_unified_sampling_functions() const;
                virtual void visit(ProgramSyntax::FunctionCall &);
                bool supports_interface_layouts() const;
+               bool supports_centroid_sampling() const;
+               bool supports_sample_sampling() const;
                virtual void visit(ProgramSyntax::VariableDeclaration &);
                bool supports_interface_blocks(const std::string &) const;
                virtual void visit(ProgramSyntax::InterfaceBlock &);
index b3a226fc98c55d2d9ceed2f39e9e498b4c68a71a..159c314777ecf092f3ad634204f4c2c169b0187d 100644 (file)
@@ -315,7 +315,7 @@ bool ProgramParser::is_interface_qualifier(const string &token)
 
 bool ProgramParser::is_sampling_qualifier(const string &token)
 {
-       return token=="centroid";
+       return (token=="centroid" || token=="sample");
 }
 
 bool ProgramParser::is_interpolation_qualifier(const string &token)