From c189535988b6406a74c600f98241a886e5e7c19f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 9 Apr 2022 14:39:37 +0300 Subject: [PATCH] Refactor SL::Features::from_api_version to take the actual API version Vulkan features now have a sensible GLSL version. --- source/glsl/features.cpp | 51 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/source/glsl/features.cpp b/source/glsl/features.cpp index 54fc6f4e..9382ce66 100644 --- a/source/glsl/features.cpp +++ b/source/glsl/features.cpp @@ -15,33 +15,46 @@ Features Features::from_api_version(GraphicsApi api, const Version &ver) switch(api) { case OPENGL: - features.arb_enhanced_layouts = (ver>=Version(4, 40)); - features.arb_explicit_attrib_location = (ver>=Version(3, 30)); - features.arb_explicit_uniform_location = (ver>=Version(4, 30)); + if(ver.major==2) + features.glsl_version = Version(1, (ver.minor+1)*10); + else if(ver.major==3 && ver.minor<3) + features.glsl_version = Version(1, (ver.minor+3)*10); + else + features.glsl_version = Version(ver.major, ver.minor*10); + + features.arb_enhanced_layouts = (ver>=Version(4, 4)); + features.arb_explicit_attrib_location = (ver>=Version(3, 3)); + features.arb_explicit_uniform_location = (ver>=Version(4, 3)); 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); + features.arb_separate_shader_objects = (ver>=Version(4, 1)); + features.arb_uniform_buffer_object = (ver>=Version(3, 2)); + features.ext_gpu_shader4 = (ver>=Version(2, 1)); + features.ext_texture_array = (ver>=Version(3, 0)); + features.uniform_binding_range = (ver>=Version(4, 3) ? 84 : ver>=Version(4, 0) ? 60 : + ver>=Version(3, 3) ? 36 : 24); + features.texture_binding_range = (ver>=Version(4, 3) ? 96 : ver>=Version(4, 0) ? 80 : + ver>=Version(3, 2) ? 48 : ver>=Version(1, 4) ? 32 : 16); break; case OPENGL_ES: - features.arb_enhanced_layouts = (ver>=Version(3, 20)); + if(ver.major==2) + features.glsl_version = Version(1, 0); + else + features.glsl_version = Version(ver.major, ver.minor*10); + + features.arb_enhanced_layouts = (ver>=Version(3, 2)); 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_explicit_uniform_location = (ver>=Version(3, 1)); + features.arb_gpu_shader5 = (ver>=Version(3, 2)); + features.arb_separate_shader_objects = (ver>=Version(3, 1)); 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 : + features.uniform_binding_range = (ver>=Version(3, 2) ? 72 : ver>=Version(3, 1) ? 36 : 24); + features.texture_binding_range = (ver>=Version(3, 2) ? 96 : ver>=Version(3, 1) ? 48 : ver>=Version(3, 0) ? 32 : 8); break; case VULKAN: + features.glsl_version = Version(4, 60); features.uniform_binding_range = 72; features.texture_binding_range = 96; break; @@ -56,9 +69,9 @@ Features Features::latest(GraphicsApi api) switch(api) { case OPENGL: - return from_api_version(api, Version(4, 60)); + return from_api_version(api, Version(4, 6)); case OPENGL_ES: - return from_api_version(api, Version(3, 20)); + return from_api_version(api, Version(3, 2)); case VULKAN: return from_api_version(api, Version(1, 2)); default: -- 2.45.2