From: Mikko Rasa Date: Sat, 9 Apr 2022 11:43:49 +0000 (+0300) Subject: Make it possible to specify a target API for GLSL test cases X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=4b9c9f565bb0335034dc8c2c7ad833ee42251d5d Make it possible to specify a target API for GLSL test cases --- diff --git a/tests/glsl/glslcompiler.cpp b/tests/glsl/glslcompiler.cpp index 51664272..7deeb1f3 100644 --- a/tests/glsl/glslcompiler.cpp +++ b/tests/glsl/glslcompiler.cpp @@ -15,6 +15,7 @@ protected: { std::string name; std::string source; + Msp::GL::GraphicsApi target_api; Msp::GL::SL::Compiler::Mode compile_mode; std::map spec_values; std::map expected_output; @@ -91,6 +92,7 @@ const GlslCompilerHelper::TestCase &GlslCompilerHelper::load_test_case(const str IO::BufferedFile file(fn); TestCase test_case; test_case.name = FS::basename(fn); + test_case.target_api = GL::OPENGL; test_case.compile_mode = GL::SL::Compiler::PROGRAM; string *target = &test_case.source; while(!file.eof()) @@ -127,6 +129,21 @@ const GlslCompilerHelper::TestCase &GlslCompilerHelper::load_test_case(const str continue; } + pos = line.find("Target API:"); + if(pos!=string::npos) + { + string api = strip(line.substr(pos+11)); + if(api=="OpenGL") + test_case.target_api = GL::OPENGL; + else if(api=="OpenGL ES") + test_case.target_api = GL::OPENGL_ES; + else if(api=="Vulkan") + test_case.target_api = GL::VULKAN; + else + throw runtime_error("Unknown API "+api); + continue; + } + pos = line.find("Compile mode:"); if(pos!=string::npos) { @@ -251,7 +268,7 @@ GlslCompilerTest::GlslCompilerTest() void GlslCompilerTest::run_test_case(const TestCase *test_case) { - GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL)); + GL::SL::Compiler compiler(GL::SL::Features::latest(test_case->target_api)); try { compiler.set_source(test_case->source, ""); @@ -308,13 +325,13 @@ GlslCompilerIdempotence::GlslCompilerIdempotence() void GlslCompilerIdempotence::run_test_case(const TestCase *test_case) { - GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL)); + GL::SL::Compiler compiler(GL::SL::Features::latest(test_case->target_api)); 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::latest(GL::OPENGL)); + GL::SL::Compiler compiler2(GL::SL::Features::latest(test_case->target_api)); compiler2.set_source(compiler.get_combined_glsl(), ""); compiler2.compile(test_case->compile_mode); @@ -351,7 +368,7 @@ GlslCompilerSpirV::GlslCompilerSpirV(): void GlslCompilerSpirV::run_test_case(const TestCase *test_case) { - GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL)); + GL::SL::Compiler compiler(GL::SL::Features::latest(test_case->target_api)); compiler.set_source(test_case->source, ""); compiler.compile(GL::SL::Compiler::SPIRV);