From: Mikko Rasa Date: Sat, 3 Apr 2021 16:53:55 +0000 (+0300) Subject: Better way to request features for different GLSL versions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1401e69c17d06034af53f6e55e735be065b75c7b;p=libs%2Fgl.git Better way to request features for different GLSL versions --- diff --git a/source/glsl/features.cpp b/source/glsl/features.cpp index 73c95b0f..0b5b438b 100644 --- a/source/glsl/features.cpp +++ b/source/glsl/features.cpp @@ -46,22 +46,31 @@ Features Features::from_context() return features; } -Features Features::all() +Features Features::from_version(const Version &ver) { Features features; features.gl_api = OPENGL; - features.glsl_version = Version(4, 60); - features.arb_enhanced_layouts = true; - features.arb_explicit_attrib_location = true; - features.arb_explicit_uniform_location = true; - features.arb_gpu_shader5 = true; - features.arb_separate_shader_objects = true; - features.arb_uniform_buffer_object = true; - features.ext_gpu_shader4 = true; - features.ext_texture_array = true; + features.glsl_version = ver; + features.arb_enhanced_layouts = (ver>=Version(4, 40)); + features.arb_explicit_attrib_location = (ver>=Version(1, 30)); + features.arb_explicit_uniform_location = (ver>=Version(4, 30)); + features.arb_gpu_shader5 = (ver>=Version(4, 0)); + features.arb_separate_shader_objects = (ver>=Version(4, 10)); + features.arb_uniform_buffer_object = (ver>=Version(1, 50)); + features.ext_gpu_shader4 = (ver>=Version(1, 20)); + features.ext_texture_array = (ver>=Version(1, 30)); + features.uniform_binding_range = (ver>=Version(4, 30) ? 84 : ver>=Version(4, 0) ? 60 : + ver>=Version(3, 30) ? 36 : 24); + features.texture_binding_range = (ver>=Version(4, 30) ? 96 : ver>=Version(4, 0) ? 80 : + ver>=Version(1, 50) ? 48 : ver>=Version(1, 40) ? 32 : 16); return features; } +Features Features::latest() +{ + return from_version(Version(4, 60)); +} + } // namespace SL } // namespace GL } // namespace Msp diff --git a/source/glsl/features.h b/source/glsl/features.h index 31825c02..f8be0131 100644 --- a/source/glsl/features.h +++ b/source/glsl/features.h @@ -26,7 +26,8 @@ struct Features Features(); static Features from_context(); - static Features all(); + static Features from_version(const Version &); + static Features latest(); }; } // namespace SL diff --git a/tests/glsl/glslcompiler.cpp b/tests/glsl/glslcompiler.cpp index 371df6cc..8d3fe532 100644 --- a/tests/glsl/glslcompiler.cpp +++ b/tests/glsl/glslcompiler.cpp @@ -228,7 +228,7 @@ GlslCompilerTest::GlslCompilerTest() void GlslCompilerTest::run_test_case(const TestCase *test_case) { - GL::SL::Compiler compiler(GL::SL::Features::all()); + GL::SL::Compiler compiler(GL::SL::Features::latest()); try { compiler.set_source(test_case->source, ""); @@ -283,13 +283,13 @@ GlslCompilerIdempotence::GlslCompilerIdempotence() void GlslCompilerIdempotence::run_test_case(const TestCase *test_case) { - GL::SL::Compiler compiler(GL::SL::Features::all()); + GL::SL::Compiler compiler(GL::SL::Features::latest()); compiler.set_source(test_case->source, ""); if(test_case->compile_mode==GL::SL::Compiler::PROGRAM) compiler.specialize(test_case->spec_values); compiler.compile(test_case->compile_mode); - GL::SL::Compiler compiler2(GL::SL::Features::all()); + GL::SL::Compiler compiler2(GL::SL::Features::latest()); compiler2.set_source(compiler.get_combined_glsl(), ""); compiler2.compile(test_case->compile_mode); diff --git a/tools/glslcompiler.cpp b/tools/glslcompiler.cpp index 5d8362d4..c6fe8bcd 100644 --- a/tools/glslcompiler.cpp +++ b/tools/glslcompiler.cpp @@ -83,7 +83,7 @@ GlslCompiler::GlslCompiler(int argc, char **argv): int GlslCompiler::main() { - GL::SL::Compiler compiler(GL::SL::Features::all()); + GL::SL::Compiler compiler(GL::SL::Features::latest()); IO::File file(source_fn); compiler.load_source(file, source_fn); if(compile_mode==GL::SL::Compiler::PROGRAM)