From fd67e42df1cdb5a5a621169a8d3b5cbb544ca333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 9 Aug 2019 18:53:19 +0200 Subject: [PATCH] Shaders: don't test for ES3 at runtime. This only generates code that will be never executed. Tested with Flat and Phong, the other shaders don't have rendering tests yet but since the change is the same, I assume it will work there as well. --- src/Magnum/Shaders/DistanceFieldVector.cpp | 5 +++-- src/Magnum/Shaders/Flat.cpp | 5 +++-- src/Magnum/Shaders/MeshVisualizer.cpp | 5 +++-- src/Magnum/Shaders/Phong.cpp | 5 +++-- src/Magnum/Shaders/Vector.cpp | 5 +++-- src/Magnum/Shaders/VertexColor.cpp | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Magnum/Shaders/DistanceFieldVector.cpp b/src/Magnum/Shaders/DistanceFieldVector.cpp index 9139f496d..df9da7d33 100644 --- a/src/Magnum/Shaders/DistanceFieldVector.cpp +++ b/src/Magnum/Shaders/DistanceFieldVector.cpp @@ -67,15 +67,16 @@ template DistanceFieldVector::DistanceFieldV GL::AbstractShaderProgram::attachShaders({vert, frag}); + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector::Position::Location, "position"); GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector::TextureCoordinates::Location, "textureCoordinates"); } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link()); diff --git a/src/Magnum/Shaders/Flat.cpp b/src/Magnum/Shaders/Flat.cpp index 65be491db..bb6c3cb3c 100644 --- a/src/Magnum/Shaders/Flat.cpp +++ b/src/Magnum/Shaders/Flat.cpp @@ -74,15 +74,16 @@ template Flat::Flat(const Flags flags): _fla attachShaders({vert, frag}); + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); if(flags & Flag::Textured) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates"); } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(link()); diff --git a/src/Magnum/Shaders/MeshVisualizer.cpp b/src/Magnum/Shaders/MeshVisualizer.cpp index b54f26893..5bac33b49 100644 --- a/src/Magnum/Shaders/MeshVisualizer.cpp +++ b/src/Magnum/Shaders/MeshVisualizer.cpp @@ -106,10 +106,10 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} { if(geom) attachShader(*geom); #endif + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -123,6 +123,7 @@ MeshVisualizer::MeshVisualizer(const Flags flags): _flags{flags} { } #endif } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(link()); diff --git a/src/Magnum/Shaders/Phong.cpp b/src/Magnum/Shaders/Phong.cpp index dc46a8bae..0c2e48b53 100644 --- a/src/Magnum/Shaders/Phong.cpp +++ b/src/Magnum/Shaders/Phong.cpp @@ -110,10 +110,10 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l attachShaders({vert, frag}); + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); @@ -123,6 +123,7 @@ Phong::Phong(const Flags flags, const UnsignedInt lightCount): _flags{flags}, _l if(flags & (Flag::AmbientTexture|Flag::DiffuseTexture|Flag::SpecularTexture)) bindAttributeLocation(TextureCoordinates::Location, "textureCoordinates"); } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(link()); diff --git a/src/Magnum/Shaders/Vector.cpp b/src/Magnum/Shaders/Vector.cpp index f1f334f52..6d1c2bdfa 100644 --- a/src/Magnum/Shaders/Vector.cpp +++ b/src/Magnum/Shaders/Vector.cpp @@ -67,15 +67,16 @@ template Vector::Vector() { GL::AbstractShaderProgram::attachShaders({vert, frag}); + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector::Position::Location, "position"); GL::AbstractShaderProgram::bindAttributeLocation(AbstractVector::TextureCoordinates::Location, "textureCoordinates"); } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(GL::AbstractShaderProgram::link()); diff --git a/src/Magnum/Shaders/VertexColor.cpp b/src/Magnum/Shaders/VertexColor.cpp index d4021187e..10f33e51f 100644 --- a/src/Magnum/Shaders/VertexColor.cpp +++ b/src/Magnum/Shaders/VertexColor.cpp @@ -67,15 +67,16 @@ template VertexColor::VertexColor() { attachShaders({vert, frag}); + /* ES3 has this done in the shader directly */ + #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!GL::Context::current().isExtensionSupported(version)) - #else - if(!GL::Context::current().isVersionSupported(GL::Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); bindAttributeLocation(Color3::Location, "color"); /* Color4 is the same */ } + #endif CORRADE_INTERNAL_ASSERT_OUTPUT(link());