Browse Source

GL: Cleanup std::string usage in Shader/AbstractShaderProgram

pull/608/head
Hugo Amiard 4 years ago
parent
commit
a0dc14452f
  1. 37
      src/Magnum/GL/AbstractShaderProgram.cpp
  2. 33
      src/Magnum/GL/AbstractShaderProgram.h
  3. 4
      src/Magnum/GL/Implementation/ShaderProgramState.h
  4. 4
      src/Magnum/GL/Implementation/ShaderState.h
  5. 58
      src/Magnum/GL/Shader.cpp
  6. 21
      src/Magnum/GL/Shader.h
  7. 11
      src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp
  8. 38
      src/Magnum/GL/Test/ShaderGLTest.cpp
  9. 10
      src/Magnum/GL/Test/TransformFeedbackGLTest.cpp
  10. 8
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  11. 8
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  12. 16
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  13. 8
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  14. 8
      src/Magnum/Shaders/Test/VectorGLTest.cpp
  15. 8
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp

37
src/Magnum/GL/AbstractShaderProgram.cpp

@ -29,12 +29,14 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
#include <Corrade/Containers/String.h> #include <Corrade/Containers/String.h>
#endif #endif
#include <Corrade/Containers/StringStl.h> /** @todo remove once <string>-free */ #include <Corrade/Containers/StringStl.h> /** @todo remove once <string>-free */
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/DebugStl.h> #include <Corrade/Utility/DebugStl.h>
#include "Magnum/GL/Context.h" #include "Magnum/GL/Context.h"
@ -340,7 +342,7 @@ AbstractShaderProgram& AbstractShaderProgram::setLabel(const Containers::StringV
} }
#endif #endif
std::pair<bool, std::string> AbstractShaderProgram::validate() { Containers::Pair<bool, Containers::String> AbstractShaderProgram::validate() {
glValidateProgram(_id); glValidateProgram(_id);
/* Check validation status */ /* Check validation status */
@ -350,12 +352,11 @@ std::pair<bool, std::string> AbstractShaderProgram::validate() {
/* Error or warning message. The string is returned null-terminated, scrap /* Error or warning message. The string is returned null-terminated, scrap
the \0 at the end afterwards */ the \0 at the end afterwards */
std::string message(logLength, '\n'); Containers::String message(ValueInit, Math::max(logLength, 1)-1);
if(message.size() > 1) if(message.size() > 1)
glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]); glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(Math::max(logLength, 1)-1);
return {success, std::move(message)}; return {bool(success), std::move(message)};
} }
AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh) { AbstractShaderProgram& AbstractShaderProgram::draw(Mesh& mesh) {
@ -554,32 +555,35 @@ void AbstractShaderProgram::bindFragmentDataLocationIndexedInternal(const Unsign
#endif #endif
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void AbstractShaderProgram::setTransformFeedbackOutputs(const Containers::ArrayView<const std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::setTransformFeedbackOutputs(const Containers::ArrayView<const Containers::String> outputs, const TransformFeedbackBufferMode bufferMode) {
(this->*Context::current().state().shaderProgram.transformFeedbackVaryingsImplementation)(outputs, bufferMode); (this->*Context::current().state().shaderProgram.transformFeedbackVaryingsImplementation)(outputs, bufferMode);
} }
void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list<std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::setTransformFeedbackOutputs(const std::initializer_list<Containers::String> outputs, const TransformFeedbackBufferMode bufferMode) {
setTransformFeedbackOutputs(Containers::arrayView(outputs), bufferMode); setTransformFeedbackOutputs(Containers::arrayView(outputs), bufferMode);
} }
void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const Containers::ArrayView<const std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::transformFeedbackVaryingsImplementationDefault(const Containers::ArrayView<const Containers::String> outputs, const TransformFeedbackBufferMode bufferMode) {
/** @todo VLAs */ /** @todo VLAs */
Containers::Array<const char*> names{outputs.size()}; Containers::Array<const char*> names{outputs.size()};
Int i = 0; Int i = 0;
for(const std::string& output: outputs) names[i++] = output.data(); for(const Containers::String& output: outputs) names[i++] = output.data();
glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode)); glTransformFeedbackVaryings(_id, outputs.size(), names, GLenum(bufferMode));
} }
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorkaround(const Containers::ArrayView<const std::string> outputs, const TransformFeedbackBufferMode bufferMode) { void AbstractShaderProgram::transformFeedbackVaryingsImplementationDanglingWorkaround(const Containers::ArrayView<const Containers::String> outputs, const TransformFeedbackBufferMode bufferMode) {
/* NVidia on Windows doesn't copy the names when calling /* NVidia on Windows doesn't copy the names when calling
glTransformFeedbackVaryings() so it then fails at link time because the glTransformFeedbackVaryings() so it then fails at link time because the
char* are dangling. We have to do the copy on the engine side and keep char* are dangling. We have to do the copy on the engine side and keep
the values until link time (which can happen any time and multiple the values until link time (which can happen any time and multiple
times, so basically for the remaining lifetime of the shader program) */ times, so basically for the remaining lifetime of the shader program) */
_transformFeedbackVaryingNames.assign(outputs.begin(), outputs.end()); _transformFeedbackVaryingNames =
Containers::Array<Containers::String>{ValueInit, outputs.size()};
for(size_t i = 0; i < outputs.size(); ++i)
_transformFeedbackVaryingNames[i] = outputs[i];
transformFeedbackVaryingsImplementationDefault({_transformFeedbackVaryingNames.data(), _transformFeedbackVaryingNames.size()}, bufferMode); transformFeedbackVaryingsImplementationDefault({_transformFeedbackVaryingNames.data(), _transformFeedbackVaryingNames.size()}, bufferMode);
} }
@ -608,10 +612,9 @@ bool AbstractShaderProgram::checkLink(const Containers::Iterable<Shader>& shader
/* Error or warning message. The string is returned null-terminated, /* Error or warning message. The string is returned null-terminated,
strip the \0 at the end afterwards. */ strip the \0 at the end afterwards. */
std::string message(logLength, '\n'); Containers::String message(ValueInit, Math::max(logLength, 1)-1);
if(message.size() > 1) if(message.size() > 1)
glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]); glGetProgramInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(Math::max(logLength, 1)-1);
/* Some drivers are chatty and can't keep shut when there's nothing to /* Some drivers are chatty and can't keep shut when there's nothing to
be said, handle that as well. */ be said, handle that as well. */
@ -655,16 +658,16 @@ bool AbstractShaderProgram::isLinkFinished() {
return success == GL_TRUE; return success == GL_TRUE;
} }
void AbstractShaderProgram::cleanLogImplementationNoOp(std::string&) {} void AbstractShaderProgram::cleanLogImplementationNoOp(Containers::String&) {}
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES)
void AbstractShaderProgram::cleanLogImplementationIntelWindows(std::string& message) { void AbstractShaderProgram::cleanLogImplementationIntelWindows(Containers::String& message) {
if(message == "No errors.\n") message = {}; if(message == "No errors.\n") message = {};
} }
#endif #endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
void AbstractShaderProgram::cleanLogImplementationAngle(std::string& message) { void AbstractShaderProgram::cleanLogImplementationAngle(Containers::String& message) {
if(message == "\n") message = {}; if(message == "\n") message = {};
} }
#endif #endif
@ -676,7 +679,7 @@ void AbstractShaderProgram::completionStatusImplementationFallback(GLuint, GLenu
Int AbstractShaderProgram::uniformLocationInternal(const Containers::ArrayView<const char> name) { Int AbstractShaderProgram::uniformLocationInternal(const Containers::ArrayView<const char> name) {
const GLint location = glGetUniformLocation(_id, name); const GLint location = glGetUniformLocation(_id, name);
if(location == -1) if(location == -1)
Warning{} << "GL::AbstractShaderProgram: location of uniform \'" << Debug::nospace << std::string{name, name.size()} << Debug::nospace << "\' cannot be retrieved"; Warning{} << "GL::AbstractShaderProgram: location of uniform \'" << Debug::nospace << Containers::String{name, name.size()} << Debug::nospace << "\' cannot be retrieved";
return location; return location;
} }
@ -684,7 +687,7 @@ Int AbstractShaderProgram::uniformLocationInternal(const Containers::ArrayView<c
UnsignedInt AbstractShaderProgram::uniformBlockIndexInternal(const Containers::ArrayView<const char> name) { UnsignedInt AbstractShaderProgram::uniformBlockIndexInternal(const Containers::ArrayView<const char> name) {
const GLuint index = glGetUniformBlockIndex(_id, name); const GLuint index = glGetUniformBlockIndex(_id, name);
if(index == GL_INVALID_INDEX) if(index == GL_INVALID_INDEX)
Warning{} << "GL::AbstractShaderProgram: index of uniform block \'" << Debug::nospace << std::string{name, name.size()} << Debug::nospace << "\' cannot be retrieved"; Warning{} << "GL::AbstractShaderProgram: index of uniform block \'" << Debug::nospace << Containers::String{name, name.size()} << Debug::nospace << "\' cannot be retrieved";
return index; return index;
} }
#endif #endif

33
src/Magnum/GL/AbstractShaderProgram.h

@ -31,8 +31,9 @@
* @brief Class @ref Magnum::GL::AbstractShaderProgram, macro @ref MAGNUM_GL_ABSTRACTSHADERPROGRAM_SUBCLASS_DRAW_IMPLEMENTATION(), @ref MAGNUM_GL_ABSTRACTSHADERPROGRAM_SUBCLASS_DISPATCH_IMPLEMENTATION() * @brief Class @ref Magnum::GL::AbstractShaderProgram, macro @ref MAGNUM_GL_ABSTRACTSHADERPROGRAM_SUBCLASS_DRAW_IMPLEMENTATION(), @ref MAGNUM_GL_ABSTRACTSHADERPROGRAM_SUBCLASS_DISPATCH_IMPLEMENTATION()
*/ */
#include <string>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "Magnum/Tags.h" #include "Magnum/Tags.h"
#include "Magnum/GL/AbstractObject.h" #include "Magnum/GL/AbstractObject.h"
@ -40,7 +41,7 @@
#include "Magnum/GL/GL.h" #include "Magnum/GL/GL.h"
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES2) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES2)
#include <vector> #include <Corrade/Containers/Array.h>
#endif #endif
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
@ -832,7 +833,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @def_gl{VALIDATE_STATUS}, @def_gl{INFO_LOG_LENGTH}, * @def_gl{VALIDATE_STATUS}, @def_gl{INFO_LOG_LENGTH},
* @fn_gl_keyword{GetProgramInfoLog} * @fn_gl_keyword{GetProgramInfoLog}
*/ */
std::pair<bool, std::string> validate(); Containers::Pair<bool, Containers::String> validate();
/** /**
* @brief Draw a mesh * @brief Draw a mesh
@ -1433,7 +1434,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @ref GL-AbstractShaderProgram-attribute-location "class documentation" * @ref GL-AbstractShaderProgram-attribute-location "class documentation"
* for more information. * for more information.
*/ */
void bindAttributeLocation(UnsignedInt location, const std::string& name) { void bindAttributeLocation(UnsignedInt location, Containers::StringView name) {
bindAttributeLocationInternal(location, {name.data(), name.size()}); bindAttributeLocationInternal(location, {name.data(), name.size()});
} }
@ -1462,7 +1463,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @requires_gl Multiple blend function inputs are not available in * @requires_gl Multiple blend function inputs are not available in
* OpenGL ES or WebGL. * OpenGL ES or WebGL.
*/ */
void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, const std::string& name) { void bindFragmentDataLocationIndexed(UnsignedInt location, UnsignedInt index, Containers::StringView name) {
bindFragmentDataLocationIndexedInternal(location, index, {name.data(), name.size()}); bindFragmentDataLocationIndexedInternal(location, index, {name.data(), name.size()});
} }
@ -1489,7 +1490,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* in OpenGL ES 2.0 and @webgl_extension{WEBGL,draw_buffers} in * in OpenGL ES 2.0 and @webgl_extension{WEBGL,draw_buffers} in
* WebGL 1.0. * WebGL 1.0.
*/ */
void bindFragmentDataLocation(UnsignedInt location, const std::string& name) { void bindFragmentDataLocation(UnsignedInt location, Containers::StringView name) {
bindFragmentDataLocationInternal(location, {name.data(), name.size()}); bindFragmentDataLocationInternal(location, {name.data(), name.size()});
} }
@ -1532,8 +1533,8 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @requires_gl Special output names `gl_NextBuffer` and * @requires_gl Special output names `gl_NextBuffer` and
* `gl_SkipComponents#` are not available in OpenGL ES or WebGL. * `gl_SkipComponents#` are not available in OpenGL ES or WebGL.
*/ */
void setTransformFeedbackOutputs(Containers::ArrayView<const std::string> outputs, TransformFeedbackBufferMode bufferMode); void setTransformFeedbackOutputs(Containers::ArrayView<const Containers::String> outputs, TransformFeedbackBufferMode bufferMode);
void setTransformFeedbackOutputs(std::initializer_list<std::string> outputs, TransformFeedbackBufferMode bufferMode); /**< @overload */ void setTransformFeedbackOutputs(std::initializer_list<Containers::String> outputs, TransformFeedbackBufferMode bufferMode); /**< @overload */
#endif #endif
/** /**
@ -1601,7 +1602,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @ref GL-AbstractShaderProgram-uniform-location "class documentation" * @ref GL-AbstractShaderProgram-uniform-location "class documentation"
* for more information. * for more information.
*/ */
Int uniformLocation(const std::string& name) { Int uniformLocation(Containers::StringView name) {
return uniformLocationInternal({name.data(), name.size()}); return uniformLocationInternal({name.data(), name.size()});
} }
@ -1627,7 +1628,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
* @ref GL-AbstractShaderProgram-uniform-block-binding "class documentation" * @ref GL-AbstractShaderProgram-uniform-block-binding "class documentation"
* for more information. * for more information.
*/ */
UnsignedInt uniformBlockIndex(const std::string& name) { UnsignedInt uniformBlockIndex(Containers::StringView name) {
return uniformBlockIndexInternal({name.data(), name.size()}); return uniformBlockIndexInternal({name.data(), name.size()});
} }
@ -1920,18 +1921,18 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
UnsignedInt uniformBlockIndexInternal(Containers::ArrayView<const char> name); UnsignedInt uniformBlockIndexInternal(Containers::ArrayView<const char> name);
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDefault(Containers::ArrayView<const std::string> outputs, TransformFeedbackBufferMode bufferMode); void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDefault(Containers::ArrayView<const Containers::String> outputs, TransformFeedbackBufferMode bufferMode);
#ifdef CORRADE_TARGET_WINDOWS #ifdef CORRADE_TARGET_WINDOWS
void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDanglingWorkaround(Containers::ArrayView<const std::string> outputs, TransformFeedbackBufferMode bufferMode); void MAGNUM_GL_LOCAL transformFeedbackVaryingsImplementationDanglingWorkaround(Containers::ArrayView<const Containers::String> outputs, TransformFeedbackBufferMode bufferMode);
#endif #endif
#endif #endif
static MAGNUM_GL_LOCAL void cleanLogImplementationNoOp(std::string& message); static MAGNUM_GL_LOCAL void cleanLogImplementationNoOp(Containers::String& message);
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES)
static MAGNUM_GL_LOCAL void cleanLogImplementationIntelWindows(std::string& message); static MAGNUM_GL_LOCAL void cleanLogImplementationIntelWindows(Containers::String& message);
#endif #endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL) #if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
static MAGNUM_GL_LOCAL void cleanLogImplementationAngle(std::string& message); static MAGNUM_GL_LOCAL void cleanLogImplementationAngle(Containers::String& message);
#endif #endif
MAGNUM_GL_LOCAL static void APIENTRY completionStatusImplementationFallback(GLuint, GLenum, GLint*); MAGNUM_GL_LOCAL static void APIENTRY completionStatusImplementationFallback(GLuint, GLenum, GLint*);
@ -2009,7 +2010,7 @@ class MAGNUM_GL_EXPORT AbstractShaderProgram: public AbstractObject {
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES2) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES2)
/* Needed for the nv-windows-dangling-transform-feedback-varying-names /* Needed for the nv-windows-dangling-transform-feedback-varying-names
workaround */ workaround */
std::vector<std::string> _transformFeedbackVaryingNames; Containers::Array<Containers::String> _transformFeedbackVaryingNames;
#endif #endif
}; };

4
src/Magnum/GL/Implementation/ShaderProgramState.h

@ -46,9 +46,9 @@ struct ShaderProgramState {
void reset(); void reset();
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
void(AbstractShaderProgram::*transformFeedbackVaryingsImplementation)(Containers::ArrayView<const std::string>, AbstractShaderProgram::TransformFeedbackBufferMode); void(AbstractShaderProgram::*transformFeedbackVaryingsImplementation)(Containers::ArrayView<const Containers::String>, AbstractShaderProgram::TransformFeedbackBufferMode);
#endif #endif
void(*cleanLogImplementation)(std::string&); void(*cleanLogImplementation)(Containers::String&);
/* This is a direct pointer to a GL function, so needs a __stdcall on /* This is a direct pointer to a GL function, so needs a __stdcall on
Windows to compile properly on 32 bits */ Windows to compile properly on 32 bits */
void(APIENTRY *completionStatusImplementation)(GLuint, GLenum, GLint* value); void(APIENTRY *completionStatusImplementation)(GLuint, GLenum, GLint* value);

4
src/Magnum/GL/Implementation/ShaderState.h

@ -52,8 +52,8 @@ struct ShaderState {
#endif #endif
}; };
void(Shader::*addSourceImplementation)(std::string); void(Shader::*addSourceImplementation)(Containers::StringView);
void(*cleanLogImplementation)(std::string&); void(*cleanLogImplementation)(Containers::String&);
/* This is a direct pointer to a GL function, so needs a __stdcall on /* This is a direct pointer to a GL function, so needs a __stdcall on
Windows to compile properly on 32 bits */ Windows to compile properly on 32 bits */
void(APIENTRY *completionStatusImplementation)(GLuint, GLenum, GLint* value); void(APIENTRY *completionStatusImplementation)(GLuint, GLenum, GLint* value);

58
src/Magnum/GL/Shader.cpp

@ -27,6 +27,7 @@
#include "Shader.h" #include "Shader.h"
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/GrowableArray.h>
#ifdef MAGNUM_BUILD_DEPRECATED #ifdef MAGNUM_BUILD_DEPRECATED
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#endif #endif
@ -57,7 +58,7 @@ namespace Magnum { namespace GL {
namespace { namespace {
std::string shaderName(const Shader::Type type) { Containers::String shaderName(const Shader::Type type) {
switch(type) { switch(type) {
case Shader::Type::Vertex: return "vertex"; case Shader::Type::Vertex: return "vertex";
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
@ -661,25 +662,25 @@ Shader::Shader(const Version version, const Type type): _type{type}, _flags{Obje
switch(version) { switch(version) {
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
case Version::GL210: _sources.emplace_back("#version 120\n"); return; case Version::GL210: Containers::arrayAppend(_sources, "#version 120\n"); return;
case Version::GL300: _sources.emplace_back("#version 130\n"); return; case Version::GL300: Containers::arrayAppend(_sources, "#version 130\n"); return;
case Version::GL310: _sources.emplace_back("#version 140\n"); return; case Version::GL310: Containers::arrayAppend(_sources, "#version 140\n"); return;
case Version::GL320: _sources.emplace_back("#version 150\n"); return; case Version::GL320: Containers::arrayAppend(_sources, "#version 150\n"); return;
case Version::GL330: _sources.emplace_back("#version 330\n"); return; case Version::GL330: Containers::arrayAppend(_sources, "#version 330\n"); return;
case Version::GL400: _sources.emplace_back("#version 400\n"); return; case Version::GL400: Containers::arrayAppend(_sources, "#version 400\n"); return;
case Version::GL410: _sources.emplace_back("#version 410\n"); return; case Version::GL410: Containers::arrayAppend(_sources, "#version 410\n"); return;
case Version::GL420: _sources.emplace_back("#version 420\n"); return; case Version::GL420: Containers::arrayAppend(_sources, "#version 420\n"); return;
case Version::GL430: _sources.emplace_back("#version 430\n"); return; case Version::GL430: Containers::arrayAppend(_sources, "#version 430\n"); return;
case Version::GL440: _sources.emplace_back("#version 440\n"); return; case Version::GL440: Containers::arrayAppend(_sources, "#version 440\n"); return;
case Version::GL450: _sources.emplace_back("#version 450\n"); return; case Version::GL450: Containers::arrayAppend(_sources, "#version 450\n"); return;
case Version::GL460: _sources.emplace_back("#version 460\n"); return; case Version::GL460: Containers::arrayAppend(_sources, "#version 460\n"); return;
#endif #endif
/* `#version 100` really is GLSL ES 1.00 and *not* GLSL 1.00. What a mess. */ /* `#version 100` really is GLSL ES 1.00 and *not* GLSL 1.00. What a mess. */
case Version::GLES200: _sources.emplace_back("#version 100\n"); return; case Version::GLES200: Containers::arrayAppend(_sources, "#version 100\n"); return;
case Version::GLES300: _sources.emplace_back("#version 300 es\n"); return; case Version::GLES300: Containers::arrayAppend(_sources, "#version 300 es\n"); return;
#ifndef MAGNUM_TARGET_WEBGL #ifndef MAGNUM_TARGET_WEBGL
case Version::GLES310: _sources.emplace_back("#version 310 es\n"); return; case Version::GLES310: Containers::arrayAppend(_sources, "#version 310 es\n"); return;
case Version::GLES320: _sources.emplace_back("#version 320 es\n"); return; case Version::GLES320: Containers::arrayAppend(_sources, "#version 320 es\n"); return;
#endif #endif
/* The user is responsible for (not) adding #version directive */ /* The user is responsible for (not) adding #version directive */
@ -721,10 +722,10 @@ Shader& Shader::setLabel(const Containers::StringView label) {
} }
#endif #endif
std::vector<std::string> Shader::sources() const { return _sources; } const Containers::Array<Containers::String>& Shader::sources() const { return _sources; }
Shader& Shader::addSource(std::string source) { Shader& Shader::addSource(Containers::StringView source) {
if(!source.empty()) { if(!source.isEmpty()) {
auto addSource = Context::current().state().shader.addSourceImplementation; auto addSource = Context::current().state().shader.addSourceImplementation;
/* Fix line numbers, so line 41 of third added file is marked as 3(41) /* Fix line numbers, so line 41 of third added file is marked as 3(41)
@ -738,7 +739,7 @@ Shader& Shader::addSource(std::string source) {
order to avoid complex logic in compile() where we assert for at order to avoid complex logic in compile() where we assert for at
least some user-provided source, an empty string is added here least some user-provided source, an empty string is added here
instead. */ instead. */
if(!_sources.empty()) (this->*addSource)( if(!_sources.isEmpty()) (this->*addSource)(
/* GLSL < 330 interprets #line 0 as the next line being line 1, /* GLSL < 330 interprets #line 0 as the next line being line 1,
while GLSL >= 330 which interprets #line 1 as next line being while GLSL >= 330 which interprets #line 1 as next line being
line 1; the latter is consistent with the C preprocessor. GLSL ES line 1; the latter is consistent with the C preprocessor. GLSL ES
@ -757,12 +758,12 @@ Shader& Shader::addSource(std::string source) {
return *this; return *this;
} }
void Shader::addSourceImplementationDefault(std::string source) { void Shader::addSourceImplementationDefault(Containers::StringView source) {
_sources.push_back(std::move(source)); Containers::arrayAppend(_sources, source);
} }
#if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__) #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__)
void Shader::addSourceImplementationEmscriptenPthread(std::string source) { void Shader::addSourceImplementationEmscriptenPthread(Containers::String source) {
/* See the "emscripten-pthreads-broken-unicode-shader-sources" /* See the "emscripten-pthreads-broken-unicode-shader-sources"
workaround description for details */ workaround description for details */
for(char& c: source) if(c < 0) c = ' '; for(char& c: source) if(c < 0) c = ' ';
@ -770,7 +771,7 @@ void Shader::addSourceImplementationEmscriptenPthread(std::string source) {
} }
#endif #endif
Shader& Shader::addFile(const std::string& filename) { Shader& Shader::addFile(Containers::StringView filename) {
const Containers::Optional<Containers::String> string = Utility::Path::readString(filename); const Containers::Optional<Containers::String> string = Utility::Path::readString(filename);
CORRADE_ASSERT(string, "GL::Shader::addFile(): can't read" << filename, *this); CORRADE_ASSERT(string, "GL::Shader::addFile(): can't read" << filename, *this);
addSource(*string); addSource(*string);
@ -806,10 +807,9 @@ bool Shader::checkCompile() {
/* Error or warning message. The string is returned null-terminated, /* Error or warning message. The string is returned null-terminated,
strip the \0 at the end afterwards. */ strip the \0 at the end afterwards. */
std::string message(logLength, '\0'); Containers::String message(ValueInit, Math::max(logLength, 1) - 1);
if(message.size() > 1) if(message.size() > 1)
glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]); glGetShaderInfoLog(_id, message.size(), nullptr, &message[0]);
message.resize(Math::max(logLength, 1)-1);
/* Some drivers are chatty and can't keep shut when there's nothing to /* Some drivers are chatty and can't keep shut when there's nothing to
be said, handle that as well. */ be said, handle that as well. */
@ -856,10 +856,10 @@ bool Shader::isCompileFinished() {
return success == GL_TRUE; return success == GL_TRUE;
} }
void Shader::cleanLogImplementationNoOp(std::string&) {} void Shader::cleanLogImplementationNoOp(Containers::String&) {}
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES)
void Shader::cleanLogImplementationIntelWindows(std::string& message) { void Shader::cleanLogImplementationIntelWindows(Containers::String& message) {
if(message == "No errors.\n") message = {}; if(message == "No errors.\n") message = {};
} }
#endif #endif

21
src/Magnum/GL/Shader.h

@ -30,9 +30,10 @@
* @brief Class @ref Magnum::GL::Shader * @brief Class @ref Magnum::GL::Shader
*/ */
#include <string> #include <Corrade/Containers/Array.h>
#include <vector>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "Magnum/Tags.h" #include "Magnum/Tags.h"
#include "Magnum/GL/AbstractObject.h" #include "Magnum/GL/AbstractObject.h"
@ -646,7 +647,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
Type type() const { return _type; } Type type() const { return _type; }
/** @brief Shader sources */ /** @brief Shader sources */
std::vector<std::string> sources() const; const Containers::Array<Containers::String>& sources() const;
/** /**
* @brief Add shader source * @brief Add shader source
@ -658,7 +659,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* @ref GL-Shader-errors "compilation error reporting". * @ref GL-Shader-errors "compilation error reporting".
* @see @ref addFile() * @see @ref addFile()
*/ */
Shader& addSource(std::string source); Shader& addSource(Containers::StringView source);
/** /**
* @brief Add shader source file * @brief Add shader source file
@ -668,7 +669,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
* The file must exist and must be readable. Calls @ref addSource() * The file must exist and must be readable. Calls @ref addSource()
* with the contents. * with the contents.
*/ */
Shader& addFile(const std::string& filename); Shader& addFile(Containers::StringView filename);
/** /**
* @brief Compile the shader * @brief Compile the shader
@ -745,14 +746,14 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
private: private:
explicit Shader(Type type, GLuint id, ObjectFlags flags) noexcept; explicit Shader(Type type, GLuint id, ObjectFlags flags) noexcept;
void MAGNUM_GL_LOCAL addSourceImplementationDefault(std::string source); void MAGNUM_GL_LOCAL addSourceImplementationDefault(Containers::StringView source);
#if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__) #if defined(CORRADE_TARGET_EMSCRIPTEN) && defined(__EMSCRIPTEN_PTHREADS__)
void MAGNUM_GL_LOCAL addSourceImplementationEmscriptenPthread(std::string source); void MAGNUM_GL_LOCAL addSourceImplementationEmscriptenPthread(Containers::StringView source);
#endif #endif
static MAGNUM_GL_LOCAL void cleanLogImplementationNoOp(std::string& message); static MAGNUM_GL_LOCAL void cleanLogImplementationNoOp(Containers::String& message);
#if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_TARGET_GLES)
static MAGNUM_GL_LOCAL void cleanLogImplementationIntelWindows(std::string& message); static MAGNUM_GL_LOCAL void cleanLogImplementationIntelWindows(Containers::String& message);
#endif #endif
MAGNUM_GL_LOCAL static void APIENTRY completionStatusImplementationFallback(GLuint, GLenum, GLint*); MAGNUM_GL_LOCAL static void APIENTRY completionStatusImplementationFallback(GLuint, GLenum, GLint*);
@ -765,7 +766,7 @@ class MAGNUM_GL_EXPORT Shader: public AbstractObject {
bool _offsetLineByOneOnOldGlsl; bool _offsetLineByOneOnOldGlsl;
#endif #endif
std::vector<std::string> _sources; Containers::Array<Containers::String> _sources;
}; };
/** @debugoperatorclassenum{Shader,Shader::Type} */ /** @debugoperatorclassenum{Shader,Shader::Type} */

11
src/Magnum/GL/Test/AbstractShaderProgramGLTest.cpp

@ -25,6 +25,7 @@
#include <sstream> #include <sstream>
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/StridedArrayView.h> #include <Corrade/Containers/StridedArrayView.h>
#include <Corrade/Containers/StringStl.h> /** @todo remove when Shader is <string>-free */ #include <Corrade/Containers/StringStl.h> /** @todo remove when Shader is <string>-free */
@ -281,7 +282,7 @@ void AbstractShaderProgramGLTest::create() {
program.bindAttributeLocation(0, "position"); program.bindAttributeLocation(0, "position");
const bool linked = program.link(); const bool linked = program.link();
const bool valid = program.validate().first; const bool valid = program.validate().first();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(linked); CORRADE_VERIFY(linked);
@ -356,7 +357,7 @@ void AbstractShaderProgramGLTest::createAsync() {
CORRADE_VERIFY(program.checkLink({vert, frag})); CORRADE_VERIFY(program.checkLink({vert, frag}));
CORRADE_VERIFY(program.isLinkFinished()); CORRADE_VERIFY(program.isLinkFinished());
const bool valid = program.validate().first; const bool valid = program.validate().first();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
{ {
@ -418,7 +419,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputs() {
program.bindFragmentDataLocation(0, "first"); program.bindFragmentDataLocation(0, "first");
program.bindFragmentDataLocation(1, "second"); program.bindFragmentDataLocation(1, "second");
const bool linked = program.link(); const bool linked = program.link();
const bool valid = program.validate().first; const bool valid = program.validate().first();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(linked); CORRADE_VERIFY(linked);
@ -477,7 +478,7 @@ void AbstractShaderProgramGLTest::createMultipleOutputsIndexed() {
program.bindFragmentDataLocationIndexed(0, 0, "first"); program.bindFragmentDataLocationIndexed(0, 0, "first");
program.bindFragmentDataLocationIndexed(0, 1, "second"); program.bindFragmentDataLocationIndexed(0, 1, "second");
const bool linked = program.link(); const bool linked = program.link();
const bool valid = program.validate().first; const bool valid = program.validate().first();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(linked); CORRADE_VERIFY(linked);
@ -921,7 +922,7 @@ void AbstractShaderProgramGLTest::createUniformBlocks() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
const bool linked = program.link(); const bool linked = program.link();
const bool valid = program.validate().first; const bool valid = program.validate().first();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_VERIFY(linked); CORRADE_VERIFY(linked);

38
src/Magnum/GL/Test/ShaderGLTest.cpp

@ -123,9 +123,9 @@ void ShaderGLTest::construct() {
CORRADE_VERIFY(shader.id() > 0); CORRADE_VERIFY(shader.id() > 0);
CORRADE_COMPARE(shader.type(), Shader::Type::Fragment); CORRADE_COMPARE(shader.type(), Shader::Type::Fragment);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(shader.sources(), std::vector<std::string>{"#version 130\n"}); CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 130\n"}}));
#else #else
CORRADE_COMPARE(shader.sources(), std::vector<std::string>{"#version 300 es\n"}); CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 300 es\n"})});
#endif #endif
} }
@ -134,7 +134,7 @@ void ShaderGLTest::construct() {
void ShaderGLTest::constructNoVersion() { void ShaderGLTest::constructNoVersion() {
const Shader shader(Version::None, Shader::Type::Fragment); const Shader shader(Version::None, Shader::Type::Fragment);
CORRADE_VERIFY(shader.sources().empty()); CORRADE_VERIFY(shader.sources().isEmpty());
} }
void ShaderGLTest::constructMove() { void ShaderGLTest::constructMove() {
@ -154,9 +154,9 @@ void ShaderGLTest::constructMove() {
CORRADE_COMPARE(b.id(), id); CORRADE_COMPARE(b.id(), id);
CORRADE_COMPARE(b.type(), Shader::Type::Fragment); CORRADE_COMPARE(b.type(), Shader::Type::Fragment);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(b.sources(), std::vector<std::string>{"#version 130\n"}); CORRADE_COMPARE(b.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 130\n"}}));
#else #else
CORRADE_COMPARE(b.sources(), std::vector<std::string>{"#version 300 es\n"}); CORRADE_COMPARE(b.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 300 es\n"}}));
#endif #endif
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
@ -173,9 +173,9 @@ void ShaderGLTest::constructMove() {
CORRADE_COMPARE(c.id(), id); CORRADE_COMPARE(c.id(), id);
CORRADE_COMPARE(c.type(), Shader::Type::Fragment); CORRADE_COMPARE(c.type(), Shader::Type::Fragment);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(c.sources(), std::vector<std::string>{"#version 130\n"}); CORRADE_COMPARE(c.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 130\n"}}));
#else #else
CORRADE_COMPARE(c.sources(), std::vector<std::string>{"#version 300 es\n"}); CORRADE_COMPARE(c.sources(), (Containers::Array<Containers::String>{InPlaceInit, {"#version 300 es\n"}}));
#endif #endif
CORRADE_VERIFY(std::is_nothrow_move_constructible<Shader>::value); CORRADE_VERIFY(std::is_nothrow_move_constructible<Shader>::value);
@ -232,7 +232,7 @@ void ShaderGLTest::addSource() {
.addSource("void main() {}\n"); .addSource("void main() {}\n");
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"#version 120\n", "#version 120\n",
/* On (desktop) GLSL < 330 the #line affect next line, not current /* On (desktop) GLSL < 330 the #line affect next line, not current
line; see compileFailure() for a correctness verification */ line; see compileFailure() for a correctness verification */
@ -240,15 +240,15 @@ void ShaderGLTest::addSource() {
"#define FOO BAR\n", "#define FOO BAR\n",
"#line 0 2\n", "#line 0 2\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#else #else
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"#version 100\n", "#version 100\n",
"#line 1 1\n", "#line 1 1\n",
"#define FOO BAR\n", "#define FOO BAR\n",
"#line 1 2\n", "#line 1 2\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#endif #endif
} }
@ -264,7 +264,7 @@ void ShaderGLTest::addSourceNoVersion() {
.addSource("void main() {}\n"); .addSource("void main() {}\n");
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"", "",
/* Here, even though there's #version 120 eventually added by the user, /* Here, even though there's #version 120 eventually added by the user,
it assumes the specified version was new GLSL, not old. Explicitly it assumes the specified version was new GLSL, not old. Explicitly
@ -275,16 +275,16 @@ void ShaderGLTest::addSourceNoVersion() {
"#define FOO BAR\n", "#define FOO BAR\n",
"#line 1 2\n", "#line 1 2\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#else #else
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"", "",
"#version 100\n", "#version 100\n",
"#line 1 1\n", "#line 1 1\n",
"#define FOO BAR\n", "#define FOO BAR\n",
"#line 1 2\n", "#line 1 2\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#endif #endif
} }
@ -298,19 +298,19 @@ void ShaderGLTest::addFile() {
shader.addFile(Utility::Path::join(SHADERGLTEST_FILES_DIR, "shader.glsl")); shader.addFile(Utility::Path::join(SHADERGLTEST_FILES_DIR, "shader.glsl"));
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"#version 120\n", "#version 120\n",
/* On (desktop) GLSL < 330 the #line affect next line, not current /* On (desktop) GLSL < 330 the #line affect next line, not current
line; see compileFailure() for a correctness verification */ line; see compileFailure() for a correctness verification */
"#line 0 1\n", "#line 0 1\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#else #else
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{ CORRADE_COMPARE(shader.sources(), (Containers::Array<Containers::String>{InPlaceInit, {
"#version 100\n", "#version 100\n",
"#line 1 1\n", "#line 1 1\n",
"void main() {}\n" "void main() {}\n"
})); }}));
#endif #endif
} }

10
src/Magnum/GL/Test/TransformFeedbackGLTest.cpp

@ -23,9 +23,11 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <string>
#include <Corrade/Containers/Iterable.h> #include <Corrade/Containers/Iterable.h>
#include <Corrade/Containers/Reference.h> #include <Corrade/Containers/Reference.h>
#include <Corrade/Containers/Triple.h> #include <Corrade/Containers/Triple.h>
#include <Corrade/Utility/Format.h>
#include "Magnum/Image.h" #include "Magnum/Image.h"
#include "Magnum/GL/AbstractShaderProgram.h" #include "Magnum/GL/AbstractShaderProgram.h"
@ -618,11 +620,11 @@ void TransformFeedbackGLTest::draw() {
" vertexOutput = vec2(0.3);\n" " vertexOutput = vec2(0.3);\n"
" gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n" " gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
"}\n"); "}\n");
if(stream) geom.addSource( if(stream) geom.addSource(Utility::format(
"#extension GL_ARB_gpu_shader5: require\n" "#extension GL_ARB_gpu_shader5: require\n"
"#define STREAM " + std::to_string(stream) + "\n" + "#define STREAM {}\n"
"layout(stream = 0) out mediump float otherOutput;\n" + "layout(stream = 0) out mediump float otherOutput;\n"
"layout(stream = STREAM) out mediump vec2 geomOutput;\n"); "layout(stream = STREAM) out mediump vec2 geomOutput;\n", stream));
else geom.addSource( else geom.addSource(
"out mediump vec2 geomOutput;\n"); "out mediump vec2 geomOutput;\n");
geom.addSource( geom.addSource(

8
src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp

@ -382,7 +382,7 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::construct() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -406,7 +406,7 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::constructAsync(
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -449,7 +449,7 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::constructUnifor
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -484,7 +484,7 @@ template<UnsignedInt dimensions> void DistanceFieldVectorGLTest::constructUnifor
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

8
src/Magnum/Shaders/Test/FlatGLTest.cpp

@ -861,7 +861,7 @@ template<UnsignedInt dimensions> void FlatGLTest::construct() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -885,7 +885,7 @@ template<UnsignedInt dimensions> void FlatGLTest::constructAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -932,7 +932,7 @@ template<UnsignedInt dimensions> void FlatGLTest::constructUniformBuffers() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -966,7 +966,7 @@ template<UnsignedInt dimensions> void FlatGLTest::constructUniformBuffersAsync()
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

16
src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp

@ -1411,7 +1411,7 @@ void MeshVisualizerGLTest::construct2D() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1434,7 +1434,7 @@ void MeshVisualizerGLTest::construct2DAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1515,7 +1515,7 @@ void MeshVisualizerGLTest::constructUniformBuffers2D() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1549,7 +1549,7 @@ void MeshVisualizerGLTest::constructUniformBuffers2DAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1611,7 +1611,7 @@ void MeshVisualizerGLTest::construct3D() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1633,7 +1633,7 @@ void MeshVisualizerGLTest::construct3DAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1714,7 +1714,7 @@ void MeshVisualizerGLTest::constructUniformBuffers3D() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1747,7 +1747,7 @@ void MeshVisualizerGLTest::constructUniformBuffers3DAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

8
src/Magnum/Shaders/Test/PhongGLTest.cpp

@ -1196,7 +1196,7 @@ void PhongGLTest::construct() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1221,7 +1221,7 @@ void PhongGLTest::constructAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1268,7 +1268,7 @@ void PhongGLTest::constructUniformBuffers() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1304,7 +1304,7 @@ void PhongGLTest::constructUniformBuffersAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

8
src/Magnum/Shaders/Test/VectorGLTest.cpp

@ -378,7 +378,7 @@ template<UnsignedInt dimensions> void VectorGLTest::construct() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -402,7 +402,7 @@ template<UnsignedInt dimensions> void VectorGLTest::constructAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -445,7 +445,7 @@ template<UnsignedInt dimensions> void VectorGLTest::constructUniformBuffers() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -480,7 +480,7 @@ template<UnsignedInt dimensions> void VectorGLTest::constructUniformBuffersAsync
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

8
src/Magnum/Shaders/Test/VertexColorGLTest.cpp

@ -314,7 +314,7 @@ template<UnsignedInt dimensions> void VertexColorGLTest::construct() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -335,7 +335,7 @@ template<UnsignedInt dimensions> void VertexColorGLTest::constructAsync() {
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -377,7 +377,7 @@ template<UnsignedInt dimensions> void VertexColorGLTest::constructUniformBuffers
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -409,7 +409,7 @@ template<UnsignedInt dimensions> void VertexColorGLTest::constructUniformBuffers
#if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES) #if defined(CORRADE_TARGET_APPLE) && !defined(MAGNUM_TARGET_GLES)
CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly."); CORRADE_EXPECT_FAIL("macOS drivers need insane amount of state to validate properly.");
#endif #endif
CORRADE_VERIFY(shader.validate().first); CORRADE_VERIFY(shader.validate().first());
} }
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

Loading…
Cancel
Save