+#include <stdexcept>
#include "features.h"
+using namespace std;
+
namespace Msp {
namespace GL {
namespace SL {
-Features Features::from_opengl_version(const Version &ver)
+Features Features::from_api_version(GraphicsApi api, const Version &ver)
{
Features features;
- features.target_api = OPENGL;
+ features.target_api = api;
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);
+ switch(api)
+ {
+ case OPENGL:
+ 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);
+ break;
+ case OPENGL_ES:
+ features.arb_enhanced_layouts = (ver>=Version(3, 20));
+ features.arb_explicit_attrib_location = (ver>=Version(3, 0));
+ features.arb_explicit_uniform_location = (ver>=Version(3, 10));
+ features.arb_gpu_shader5 = (ver>=Version(3, 20));
+ features.arb_separate_shader_objects = (ver>=Version(3, 10));
+ features.arb_uniform_buffer_object = (ver>=Version(3, 0));
+ features.ext_gpu_shader4 = (ver>=Version(3, 0));
+ features.ext_texture_array = (ver>=Version(3, 0));
+ features.uniform_binding_range = (ver>=Version(3, 20) ? 72 : ver>=Version(3, 10) ? 36 : 24);
+ features.texture_binding_range = (ver>=Version(3, 20) ? 96 : ver>=Version(3, 10) ? 48 :
+ ver>=Version(3, 0) ? 32 : 8);
+ break;
+ default:
+ throw invalid_argument("Features::from_api_version");
+ }
return features;
}
-Features Features::opengl_latest()
+Features Features::latest(GraphicsApi api)
{
- return from_opengl_version(Version(4, 60));
+ switch(api)
+ {
+ case OPENGL:
+ return from_api_version(api, Version(4, 60));
+ case OPENGL_ES:
+ return from_api_version(api, Version(3, 20));
+ default:
+ throw invalid_argument("Features::latest");
+ }
}
} // namespace SL
void GlslCompilerTest::run_test_case(const TestCase *test_case)
{
- GL::SL::Compiler compiler(GL::SL::Features::opengl_latest());
+ GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL));
try
{
compiler.set_source(test_case->source, "<test>");
void GlslCompilerIdempotence::run_test_case(const TestCase *test_case)
{
- GL::SL::Compiler compiler(GL::SL::Features::opengl_latest());
+ GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL));
compiler.set_source(test_case->source, "<test>");
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::opengl_latest());
+ GL::SL::Compiler compiler2(GL::SL::Features::latest(GL::OPENGL));
compiler2.set_source(compiler.get_combined_glsl(), "<loopback>");
compiler2.compile(test_case->compile_mode);
void GlslCompilerSpirV::run_test_case(const TestCase *test_case)
{
- GL::SL::Compiler compiler(GL::SL::Features::opengl_latest());
+ GL::SL::Compiler compiler(GL::SL::Features::latest(GL::OPENGL));
compiler.set_source(test_case->source, "<test>");
compiler.compile(GL::SL::Compiler::SPIRV);