From 91d3eac06389c0bb0363f643790581403b5fca1b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Jul 2018 00:03:35 +0300 Subject: [PATCH] Support the sample sampling qualifier Also add a version check for the centroid qualifier. --- source/programcompiler.cpp | 27 +++++++++++++++++++++++++++ source/programcompiler.h | 2 ++ source/programparser.cpp | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 1ba898ec..1c84a96d 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -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") diff --git a/source/programcompiler.h b/source/programcompiler.h index 7e8d3373..56bf1d53 100644 --- a/source/programcompiler.h +++ b/source/programcompiler.h @@ -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 &); diff --git a/source/programparser.cpp b/source/programparser.cpp index b3a226fc..159c3147 100644 --- a/source/programparser.cpp +++ b/source/programparser.cpp @@ -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) -- 2.45.2