--- /dev/null
+extension ARB_enhanced_layouts
--- /dev/null
+extension ARB_explicit_uniform_location
--- /dev/null
+extension ARB_separate_shader_objects
+# Also defined in ARB_geometry_shader4
+ignore glProgramParameteri
+#include <msp/gl/extensions/arb_enhanced_layouts.h>
#include <msp/gl/extensions/arb_explicit_attrib_location.h>
+#include <msp/gl/extensions/arb_explicit_uniform_location.h>
#include <msp/gl/extensions/arb_gpu_shader5.h>
+#include <msp/gl/extensions/arb_separate_shader_objects.h>
#include <msp/gl/extensions/arb_uniform_buffer_object.h>
#include <msp/gl/extensions/ext_gpu_shader4.h>
#include <msp/gl/extensions/ext_texture_array.h>
Features::Features():
gl_api(OPENGL),
+ arb_enhanced_layouts(false),
arb_explicit_attrib_location(false),
+ arb_explicit_uniform_location(false),
arb_gpu_shader5(false),
+ arb_separate_shader_objects(false),
arb_uniform_buffer_object(false),
ext_gpu_shader4(false),
ext_texture_array(false),
Features features;
features.gl_api = get_gl_api();
features.glsl_version = get_glsl_version();
+ features.arb_enhanced_layouts = ARB_enhanced_layouts;
features.arb_explicit_attrib_location = ARB_explicit_attrib_location;
+ features.arb_explicit_uniform_location = ARB_explicit_uniform_location;
features.arb_gpu_shader5 = ARB_gpu_shader5;
- //features.arb_texture_cube_map_array = ARB_texture_cube_map_array;
+ features.arb_separate_shader_objects = ARB_separate_shader_objects;
features.arb_uniform_buffer_object = ARB_uniform_buffer_object;
features.ext_gpu_shader4 = EXT_gpu_shader4;
features.ext_texture_array = EXT_texture_array;
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;
{
GLApi gl_api;
Version glsl_version;
+ bool arb_enhanced_layouts;
bool arb_explicit_attrib_location;
+ bool arb_explicit_uniform_location;
bool arb_gpu_shader5;
+ bool arb_separate_shader_objects;
bool arb_uniform_buffer_object;
bool ext_gpu_shader4;
bool ext_texture_array;
return false;
}
+bool LegacyConverter::supports_stage_interface_layouts() const
+{
+ if(features.gl_api==OPENGL_ES2)
+ return check_version(Version(3, 10));
+ else if(check_version(Version(4, 10)))
+ return true;
+ else
+ return check_extension(&Features::arb_separate_shader_objects);
+}
+
bool LegacyConverter::supports_centroid_sampling() const
{
if(features.gl_api==OPENGL_ES2)
return check_extension(&Features::arb_gpu_shader5);
}
+bool LegacyConverter::supports_uniform_location() const
+{
+ if(features.gl_api==OPENGL_ES2)
+ return check_version(Version(3, 10));
+ else if(check_version(Version(4, 30)))
+ return true;
+ else
+ return check_extension(&Features::arb_explicit_uniform_location);
+}
+
void LegacyConverter::visit(VariableDeclaration &var)
{
if(var.layout)
{
for(vector<Layout::Qualifier>::const_iterator i=var.layout->qualifiers.begin(); i!=var.layout->qualifiers.end(); )
{
- if(i->name=="location" && !supports_interface_layouts())
+ if(i->name=="location")
{
- if(stage->type==Stage::VERTEX && var.interface=="in")
- stage->locations[var.name] = i->value;
- else if(stage->type==Stage::FRAGMENT && var.interface=="out")
+ bool supported = true;
+ bool external = false;
+ if(var.interface=="in")
{
- if(check_extension(&Features::ext_gpu_shader4))
- stage->locations[var.name] = i->value;
- else if(i->value!=0)
- unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs");
+ external = (stage->type==Stage::VERTEX);
+ supported = (external ? supports_interface_layouts() : supports_stage_interface_layouts());
}
+ else if(var.interface=="out")
+ {
+ external = (stage->type==Stage::FRAGMENT);
+ supported = (external ? supports_interface_layouts() : supports_stage_interface_layouts());
+ if(external && !supported && !check_extension(&Features::ext_gpu_shader4))
+ {
+ external = false;
+ if(i->value!=0)
+ unsupported("EXT_gpu_shader4 required for multiple fragment shader outputs");
+ }
+ }
+ else if(var.interface=="uniform")
+ supported = supports_uniform_location();
- i = var.layout->qualifiers.erase(i);
+ if(!supported)
+ {
+ if(external)
+ stage->locations[var.name] = i->value;
+ i = var.layout->qualifiers.erase(i);
+ }
+ else
+ ++i;
}
else
++i;
return false;
}
+bool LegacyConverter::supports_interface_block_location() const
+{
+ if(features.gl_api==OPENGL_ES2)
+ return check_version(Version(3, 20));
+ else if(check_version(Version(4, 40)))
+ return true;
+ else
+ return check_extension(&Features::arb_enhanced_layouts);
+}
+
void LegacyConverter::visit(InterfaceBlock &iface)
{
+ if(iface.layout)
+ {
+ for(vector<Layout::Qualifier>::const_iterator i=iface.layout->qualifiers.begin(); i!=iface.layout->qualifiers.end(); )
+ {
+ if(i->name=="location" && !supports_interface_block_location())
+ i = iface.layout->qualifiers.erase(i);
+ else
+ ++i;
+ }
+
+ if(iface.layout->qualifiers.empty())
+ iface.layout = 0;
+ }
+
if(!supports_interface_blocks(iface.interface) && iface.type_declaration)
{
if(!iface.instance_name.empty())
bool supports_unified_sampling_functions() const;
virtual void visit(FunctionCall &);
bool supports_interface_layouts() const;
+ bool supports_stage_interface_layouts() const;
bool supports_centroid_sampling() const;
bool supports_sample_sampling() const;
+ bool supports_uniform_location() const;
virtual void visit(VariableDeclaration &);
bool supports_interface_blocks(const std::string &) const;
+ bool supports_interface_block_location() const;
virtual void visit(InterfaceBlock &);
};
formatted += '\n';
}
+ if(s.required_features.arb_enhanced_layouts)
+ append("#extension GL_ARB_enhanced_layouts: require\n");
if(s.required_features.arb_explicit_attrib_location)
append("#extension GL_ARB_explicit_attrib_location: require\n");
+ if(s.required_features.arb_explicit_uniform_location)
+ append("#extension GL_ARB_explicit_uniform_location: require\n");
if(s.required_features.arb_gpu_shader5)
append("#extension GL_ARB_gpu_shader5: require\n");
+ if(s.required_features.arb_separate_shader_objects)
+ append("#extension GL_ARB_separate_shader_objects: require\n");
if(s.required_features.arb_uniform_buffer_object)
append("#extension GL_ARB_uniform_buffer_object: require\n");
if(s.required_features.ext_gpu_shader4)