Browse Source

Shaders: use explicit texture location and binding on ES3.1+.

No reason not to, reduces the amount of unnecessary driver calls quite
significantly.
pull/617/head
Vladimír Vondruš 3 years ago
parent
commit
1847c7201d
  1. 8
      src/Magnum/Shaders/DistanceFieldVectorGL.cpp
  2. 6
      src/Magnum/Shaders/DistanceFieldVectorGL.h
  3. 8
      src/Magnum/Shaders/FlatGL.cpp
  4. 6
      src/Magnum/Shaders/FlatGL.h
  5. 10
      src/Magnum/Shaders/LineGL.cpp
  6. 6
      src/Magnum/Shaders/LineGL.h
  7. 12
      src/Magnum/Shaders/MeshVisualizerGL.cpp
  8. 12
      src/Magnum/Shaders/MeshVisualizerGL.h
  9. 8
      src/Magnum/Shaders/PhongGL.cpp
  10. 6
      src/Magnum/Shaders/PhongGL.h
  11. 8
      src/Magnum/Shaders/VectorGL.cpp
  12. 6
      src/Magnum/Shaders/VectorGL.h
  13. 8
      src/Magnum/Shaders/VertexColorGL.cpp
  14. 6
      src/Magnum/Shaders/VertexColorGL.h
  15. 13
      src/Magnum/Shaders/compatibility.glsl
  16. 6
      src/Magnum/TextureTools/DistanceField.cpp

8
src/Magnum/Shaders/DistanceFieldVectorGL.cpp

@ -103,7 +103,7 @@ template<UnsignedInt dimensions> typename DistanceFieldVectorGL<dimensions>::Com
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
@ -160,7 +160,7 @@ template<UnsignedInt dimensions> typename DistanceFieldVectorGL<dimensions>::Com
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -194,6 +194,8 @@ template<UnsignedInt dimensions> DistanceFieldVectorGL<dimensions>::DistanceFiel
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -214,6 +216,8 @@ template<UnsignedInt dimensions> DistanceFieldVectorGL<dimensions>::DistanceFiel
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
setUniform(uniformLocation("vectorTexture"_s), TextureUnit); setUniform(uniformLocation("vectorTexture"_s), TextureUnit);

6
src/Magnum/Shaders/DistanceFieldVectorGL.h

@ -755,17 +755,17 @@ template<UnsignedInt dimensions> class DistanceFieldVectorGL<dimensions>::Compil
explicit CompileState(NoCreateT): DistanceFieldVectorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): DistanceFieldVectorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(DistanceFieldVectorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(DistanceFieldVectorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): DistanceFieldVectorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): DistanceFieldVectorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

8
src/Magnum/Shaders/FlatGL.cpp

@ -144,7 +144,7 @@ template<UnsignedInt dimensions> typename FlatGL<dimensions>::CompileState FlatG
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
FlatGL<dimensions> out{NoInit}; FlatGL<dimensions> out{NoInit};
@ -306,7 +306,7 @@ template<UnsignedInt dimensions> typename FlatGL<dimensions>::CompileState FlatG
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -340,6 +340,8 @@ template<UnsignedInt dimensions> FlatGL<dimensions>::FlatGL(CompileState&& state
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -373,6 +375,8 @@ template<UnsignedInt dimensions> FlatGL<dimensions>::FlatGL(CompileState&& state
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
if(_flags & Flag::Textured) setUniform(uniformLocation("textureData"_s), TextureUnit); if(_flags & Flag::Textured) setUniform(uniformLocation("textureData"_s), TextureUnit);

6
src/Magnum/Shaders/FlatGL.h

@ -1536,17 +1536,17 @@ template<UnsignedInt dimensions> class FlatGL<dimensions>::CompileState: public
explicit CompileState(NoCreateT): FlatGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): FlatGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(FlatGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(FlatGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): FlatGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): FlatGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

10
src/Magnum/Shaders/LineGL.cpp

@ -92,12 +92,12 @@ template<UnsignedInt dimensions> typename LineGL<dimensions>::CompileState LineG
#endif #endif
Utility::Resource rs{"MagnumShadersGL"_s}; Utility::Resource rs{"MagnumShadersGL"_s};
const GL::Context& context = GL::Context::current();
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current();
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
constexpr GL::Version version = GL::Version::GLES300; const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300});
#endif #endif
/* Cap and join style is needed by both the vertex and fragment shader, /* Cap and join style is needed by both the vertex and fragment shader,
@ -200,7 +200,7 @@ template<UnsignedInt dimensions> typename LineGL<dimensions>::CompileState LineG
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -218,6 +218,8 @@ template<UnsignedInt dimensions> LineGL<dimensions>::LineGL(CompileState&& state
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
_viewportSizeUniform = uniformLocation("viewportSize"_s); _viewportSizeUniform = uniformLocation("viewportSize"_s);
@ -239,6 +241,8 @@ template<UnsignedInt dimensions> LineGL<dimensions>::LineGL(CompileState&& state
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
if(_flags >= Flag::UniformBuffers) { if(_flags >= Flag::UniformBuffers) {

6
src/Magnum/Shaders/LineGL.h

@ -1104,17 +1104,17 @@ template<UnsignedInt dimensions> class LineGL<dimensions>::CompileState: public
explicit CompileState(NoCreateT): LineGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): LineGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(LineGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(LineGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): LineGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): LineGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

12
src/Magnum/Shaders/MeshVisualizerGL.cpp

@ -630,7 +630,7 @@ MeshVisualizerGL2D::CompileState MeshVisualizerGL2D::compile(const Configuration
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
, geom ? &*geom : nullptr , geom ? &*geom : nullptr
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -671,6 +671,8 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
/* This one is used also in the UBO case as it's usually a global /* This one is used also in the UBO case as it's usually a global
@ -723,6 +725,8 @@ MeshVisualizerGL2D::MeshVisualizerGL2D(CompileState&& state): MeshVisualizerGL2D
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(flags() && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(flags() && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) {
@ -1124,7 +1128,7 @@ MeshVisualizerGL3D::CompileState MeshVisualizerGL3D::compile(const Configuration
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
, geom ? &*geom : nullptr , geom ? &*geom : nullptr
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -1165,6 +1169,8 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
/* This one is used also in the UBO case as it's usually a global /* This one is used also in the UBO case as it's usually a global
@ -1235,6 +1241,8 @@ MeshVisualizerGL3D::MeshVisualizerGL3D(CompileState&& state): MeshVisualizerGL3D
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(flags() && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(flags() && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) { if(flags() & (Flag::ObjectId|Flag::VertexId|Flag::PrimitiveIdFromVertexId)) {

12
src/Magnum/Shaders/MeshVisualizerGL.h

@ -1339,11 +1339,11 @@ class MeshVisualizerGL2D::CompileState: public MeshVisualizerGL2D {
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
, GL::Shader* geom , GL::Shader* geom
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): MeshVisualizerGL2D{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): MeshVisualizerGL2D{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{ {
@ -1356,7 +1356,7 @@ class MeshVisualizerGL2D::CompileState: public MeshVisualizerGL2D {
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
Implementation::GLShaderWrapper _geom{NoCreate}; Implementation::GLShaderWrapper _geom{NoCreate};
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };
@ -3331,11 +3331,11 @@ class MeshVisualizerGL3D::CompileState: public MeshVisualizerGL3D {
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
, GL::Shader* geom , GL::Shader* geom
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): MeshVisualizerGL3D{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): MeshVisualizerGL3D{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{ {
@ -3348,7 +3348,7 @@ class MeshVisualizerGL3D::CompileState: public MeshVisualizerGL3D {
#if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2) #if !defined(MAGNUM_TARGET_WEBGL) && !defined(MAGNUM_TARGET_GLES2)
Implementation::GLShaderWrapper _geom{NoCreate}; Implementation::GLShaderWrapper _geom{NoCreate};
#endif #endif
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

8
src/Magnum/Shaders/PhongGL.cpp

@ -164,7 +164,7 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
PhongGL out{NoInit}; PhongGL out{NoInit};
@ -391,7 +391,7 @@ PhongGL::CompileState PhongGL::compile(const Configuration& configuration) {
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -431,6 +431,8 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast<PhongGL&&>(std::move
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -480,6 +482,8 @@ PhongGL::PhongGL(CompileState&& state): PhongGL{static_cast<PhongGL&&>(std::move
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(_flags && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(_flags && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
if(_flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"_s), AmbientTextureUnit); if(_flags & Flag::AmbientTexture) setUniform(uniformLocation("ambientTexture"_s), AmbientTextureUnit);

6
src/Magnum/Shaders/PhongGL.h

@ -2358,17 +2358,17 @@ class PhongGL::CompileState: public PhongGL {
explicit CompileState(NoCreateT): PhongGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): PhongGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(PhongGL&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(PhongGL&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): PhongGL{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): PhongGL{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

8
src/Magnum/Shaders/VectorGL.cpp

@ -103,7 +103,7 @@ template<UnsignedInt dimensions> typename VectorGL<dimensions>::CompileState Vec
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
@ -161,7 +161,7 @@ template<UnsignedInt dimensions> typename VectorGL<dimensions>::CompileState Vec
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -195,6 +195,8 @@ template<UnsignedInt dimensions> VectorGL<dimensions>::VectorGL(CompileState&& s
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -213,6 +215,8 @@ template<UnsignedInt dimensions> VectorGL<dimensions>::VectorGL(CompileState&& s
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
setUniform(uniformLocation("vectorTexture"_s), TextureUnit); setUniform(uniformLocation("vectorTexture"_s), TextureUnit);

6
src/Magnum/Shaders/VectorGL.h

@ -704,17 +704,17 @@ template<UnsignedInt dimensions> class VectorGL<dimensions>::CompileState: publi
explicit CompileState(NoCreateT): VectorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): VectorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(VectorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(VectorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): VectorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): VectorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

8
src/Magnum/Shaders/VertexColorGL.cpp

@ -94,7 +94,7 @@ template<UnsignedInt dimensions> typename VertexColorGL<dimensions>::CompileStat
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210}); const GL::Version version = context.supportedVersion({GL::Version::GL320, GL::Version::GL310, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version version = context.supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version version = context.supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex); GL::Shader vert = Implementation::createCompatibilityShader(rs, version, GL::Shader::Type::Vertex);
@ -139,7 +139,7 @@ template<UnsignedInt dimensions> typename VertexColorGL<dimensions>::CompileStat
out.submitLink(); out.submitLink();
return CompileState{std::move(out), std::move(vert), std::move(frag) return CompileState{std::move(out), std::move(vert), std::move(frag)
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, version , version
#endif #endif
}; };
@ -172,6 +172,8 @@ template<UnsignedInt dimensions> VertexColorGL<dimensions>::VertexColorGL(Compil
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Context& context = GL::Context::current(); const GL::Context& context = GL::Context::current();
if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version)) if(!context.isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>(state._version))
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(state._version < GL::Version::GLES310)
#endif #endif
{ {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
@ -188,6 +190,8 @@ template<UnsignedInt dimensions> VertexColorGL<dimensions>::VertexColorGL(Compil
if(_flags >= Flag::UniformBuffers if(_flags >= Flag::UniformBuffers
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
&& !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version) && !context.isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>(state._version)
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
&& state._version < GL::Version::GLES310
#endif #endif
) { ) {
setUniformBlockBinding(uniformBlockIndex("TransformationProjection"_s), TransformationProjectionBufferBinding); setUniformBlockBinding(uniformBlockIndex("TransformationProjection"_s), TransformationProjectionBufferBinding);

6
src/Magnum/Shaders/VertexColorGL.h

@ -517,17 +517,17 @@ template<UnsignedInt dimensions> class VertexColorGL<dimensions>::CompileState:
explicit CompileState(NoCreateT): VertexColorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {} explicit CompileState(NoCreateT): VertexColorGL{NoCreate}, _vert{NoCreate}, _frag{NoCreate} {}
explicit CompileState(VertexColorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag explicit CompileState(VertexColorGL<dimensions>&& shader, GL::Shader&& vert, GL::Shader&& frag
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, GL::Version version , GL::Version version
#endif #endif
): VertexColorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)} ): VertexColorGL<dimensions>{Utility::move(shader)}, _vert{Utility::move(vert)}, _frag{Utility::move(frag)}
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
, _version{version} , _version{version}
#endif #endif
{} {}
Implementation::GLShaderWrapper _vert, _frag; Implementation::GLShaderWrapper _vert, _frag;
#ifndef MAGNUM_TARGET_GLES #if !defined(MAGNUM_TARGET_GLES) || (!defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL))
GL::Version _version; GL::Version _version;
#endif #endif
}; };

13
src/Magnum/Shaders/compatibility.glsl

@ -43,10 +43,15 @@
#define EXPLICIT_UNIFORM_LOCATION #define EXPLICIT_UNIFORM_LOCATION
#endif #endif
#if defined(GL_ES) && __VERSION__ >= 300 #ifdef GL_ES
#define EXPLICIT_ATTRIB_LOCATION #if __VERSION__ >= 300
/* EXPLICIT_BINDING, EXPLICIT_UNIFORM_LOCATION and RUNTIME_CONST is not #define EXPLICIT_ATTRIB_LOCATION
available in OpenGL ES */ #endif
#if __VERSION__ >= 310
#define EXPLICIT_BINDING
#define EXPLICIT_UNIFORM_LOCATION
#endif
/* RUNTIME_CONST is not available in OpenGL ES */
#endif #endif
/* Precision qualifiers are not supported in GLSL 1.20 */ /* Precision qualifiers are not supported in GLSL 1.20 */

6
src/Magnum/TextureTools/DistanceField.cpp

@ -96,7 +96,7 @@ DistanceFieldShader::DistanceFieldShader(const UnsignedInt radius) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
const GL::Version v = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL300, GL::Version::GL210}); const GL::Version v = GL::Context::current().supportedVersion({GL::Version::GL320, GL::Version::GL300, GL::Version::GL210});
#else #else
const GL::Version v = GL::Context::current().supportedVersion({GL::Version::GLES300, GL::Version::GLES200}); const GL::Version v = GL::Context::current().supportedVersion({GL::Version::GLES310, GL::Version::GLES300, GL::Version::GLES200});
#endif #endif
GL::Shader vert = Shaders::Implementation::createCompatibilityShader(rs, v, GL::Shader::Type::Vertex); GL::Shader vert = Shaders::Implementation::createCompatibilityShader(rs, v, GL::Shader::Type::Vertex);
@ -122,6 +122,8 @@ DistanceFieldShader::DistanceFieldShader(const UnsignedInt radius) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>()) if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::explicit_uniform_location>())
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(v < GL::Version::GLES310)
#endif #endif
{ {
scalingUniform = uniformLocation("scaling"_s); scalingUniform = uniformLocation("scaling"_s);
@ -138,6 +140,8 @@ DistanceFieldShader::DistanceFieldShader(const UnsignedInt radius) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>()) if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::shading_language_420pack>())
#elif !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
if(v < GL::Version::GLES310)
#endif #endif
{ {
setUniform(uniformLocation("textureData"_s), TextureUnit); setUniform(uniformLocation("textureData"_s), TextureUnit);

Loading…
Cancel
Save