Browse Source

GL: make it possible to describe matrix attributes with DynamicAttribute.

Not sure why this wasn't done when originally implementing those.
pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
e983a2a168
  1. 3
      doc/changelog.dox
  2. 49
      src/Magnum/GL/Attribute.cpp
  3. 49
      src/Magnum/GL/Attribute.h
  4. 17
      src/Magnum/GL/Mesh.cpp
  5. 52
      src/Magnum/GL/Test/AttributeTest.cpp
  6. 56
      src/Magnum/GL/Test/MeshGLTest.cpp

3
doc/changelog.dox

@ -253,6 +253,9 @@ See also:
@ref GL::BufferTexture::resetBuffer() "resetBuffer()" @ref GL::BufferTexture::resetBuffer() "resetBuffer()"
- Matrix @ref GL::Attribute instances can now specify custom stride between - Matrix @ref GL::Attribute instances can now specify custom stride between
column vectors in order to control alignment in packed 8- and 16-bit types column vectors in order to control alignment in packed 8- and 16-bit types
- @ref GL::DynamicAttribute can now describe matrix attributes similarly to
@ref GL::Attribute, previously this was possible only by specifying each
column vector separately
@subsubsection changelog-latest-changes-math Math library @subsubsection changelog-latest-changes-math Math library

49
src/Magnum/GL/Attribute.cpp

@ -500,7 +500,54 @@ bool hasVertexFormat(const VertexFormat format) {
} }
} }
DynamicAttribute::DynamicAttribute(const Kind kind, UnsignedInt location, const VertexFormat format, GLint maxComponents): _kind{kind}, _location{location}, _components{Components(vertexFormatComponentCount(format))} { namespace {
UnsignedInt attributeSize(DynamicAttribute::Components components, DynamicAttribute::DataType dataType) {
Int componentCount = GLint(components);
#ifndef MAGNUM_TARGET_GLES
if(components == DynamicAttribute::Components::BGRA) componentCount = 4;
#endif
switch(dataType) {
case DynamicAttribute::DataType::UnsignedByte:
case DynamicAttribute::DataType::Byte:
return componentCount;
case DynamicAttribute::DataType::UnsignedShort:
case DynamicAttribute::DataType::Short:
#if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
case DynamicAttribute::DataType::Half:
#endif
return 2*componentCount;
case DynamicAttribute::DataType::UnsignedInt:
case DynamicAttribute::DataType::Int:
case DynamicAttribute::DataType::Float:
return 4*componentCount;
#ifndef MAGNUM_TARGET_GLES
case DynamicAttribute::DataType::Double:
return 8*componentCount;
#endif
#ifndef MAGNUM_TARGET_GLES2
case DynamicAttribute::DataType::UnsignedInt2101010Rev:
case DynamicAttribute::DataType::Int2101010Rev:
CORRADE_INTERNAL_ASSERT(componentCount == 4);
return 4;
#endif
#ifndef MAGNUM_TARGET_GLES
case DynamicAttribute::DataType::UnsignedInt10f11f11fRev:
CORRADE_INTERNAL_ASSERT(componentCount == 3);
return 4;
#endif
}
CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
}
}
DynamicAttribute::DynamicAttribute(const Kind kind, const UnsignedInt location, const Components components, const UnsignedInt vectors, const DataType dataType): DynamicAttribute{kind, location, components, vectors, attributeSize(components, dataType), dataType} {}
DynamicAttribute::DynamicAttribute(const Kind kind, UnsignedInt location, const VertexFormat format, GLint maxComponents): _kind{kind}, _location{location}, _components{Components(vertexFormatComponentCount(format))}, _vectors{vertexFormatVectorCount(format)}, _vectorStride{vertexFormatVectorStride(format)} {
CORRADE_ASSERT(hasVertexFormat(format), CORRADE_ASSERT(hasVertexFormat(format),
"GL::DynamicAttribute:" << format << "isn't available on this target", ); "GL::DynamicAttribute:" << format << "isn't available on this target", );

49
src/Magnum/GL/Attribute.h

@ -591,8 +591,37 @@ class MAGNUM_GL_EXPORT DynamicAttribute {
* @param location Attribute location * @param location Attribute location
* @param components Component count * @param components Component count
* @param dataType Type of passed data * @param dataType Type of passed data
*
* Vector count is set to @cpp 1 @ce, vector stride to size of the data
* type times component count.
*/
explicit DynamicAttribute(Kind kind, UnsignedInt location, Components components, DataType dataType): DynamicAttribute{kind, location, components, 1, dataType} {}
/**
* @brief Construct a matrix attribute
* @param kind Attribute kind
* @param location Attribute location
* @param components Component count
* @param vectors Vector count
* @param dataType Type of passed data
* @m_since_latest
*
* Vector stride is set to size of the data type times component count.
*/ */
constexpr explicit DynamicAttribute(Kind kind, UnsignedInt location, Components components, DataType dataType): _kind{kind}, _location{location}, _components{components}, _dataType{dataType} {} explicit DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, DataType dataType);
/**
* @brief Construct a matrix attribute with custom vector stride
* @param kind Attribute kind
* @param location Attribute location
* @param components Component count
* @param vectors Vector count
* @param vectorStride Stride between consecutive matrix column
* vectors
* @param dataType Type of passed data
* @m_since_latest
*/
constexpr explicit DynamicAttribute(Kind kind, UnsignedInt location, Components components, UnsignedInt vectors, UnsignedInt vectorStride, DataType dataType): _kind{kind}, _location{location}, _components{components}, _vectors{vectors}, _vectorStride{vectorStride}, _dataType{dataType} {}
/** /**
* @brief Construct from a compile-time attribute * @brief Construct from a compile-time attribute
@ -635,6 +664,20 @@ class MAGNUM_GL_EXPORT DynamicAttribute {
/** @brief Component count */ /** @brief Component count */
constexpr Components components() const { return _components; } constexpr Components components() const { return _components; }
/**
* @brief Vector count
* @m_since_latest
*
* Returns @cpp 1 @ce for non-matrix attributes.
*/
constexpr UnsignedInt vectors() const { return _vectors; }
/**
* @brief Vector stride
* @m_since_latest
*/
constexpr UnsignedInt vectorStride() const { return _vectorStride; }
/** @brief Type of passed data */ /** @brief Type of passed data */
constexpr DataType dataType() const { return _dataType; } constexpr DataType dataType() const { return _dataType; }
@ -646,6 +689,8 @@ class MAGNUM_GL_EXPORT DynamicAttribute {
Kind _kind; Kind _kind;
UnsignedInt _location; UnsignedInt _location;
Components _components; Components _components;
UnsignedInt _vectors;
UnsignedInt _vectorStride;
DataType _dataType; DataType _dataType;
}; };
@ -1000,7 +1045,7 @@ template<class T> struct Attribute<Math::Matrix4<T>>: Attribute<Math::Matrix<4,
} }
template<UnsignedInt location_, class T> constexpr DynamicAttribute::DynamicAttribute(const Attribute<location_, T>& attribute): _kind{Implementation::kindFor<location_, T>(attribute.dataOptions())}, _location{location_}, _components{Components(GLint(attribute.components()))}, _dataType{DataType(GLenum(attribute.dataType()))} {} template<UnsignedInt location_, class T> constexpr DynamicAttribute::DynamicAttribute(const Attribute<location_, T>& attribute): _kind{Implementation::kindFor<location_, T>(attribute.dataOptions())}, _location{location_}, _components{Components(GLint(attribute.components()))}, _vectors{Attribute<location_, T>::Vectors}, _vectorStride{attribute.vectorStride()}, _dataType{DataType(GLenum(attribute.dataType()))} {}
template<UnsignedInt location_, class T> DynamicAttribute::DynamicAttribute(const Attribute<location_, T>& attribute, const VertexFormat format): DynamicAttribute{Implementation::kindFor<location_, T>(attribute.dataOptions()), location_, format, GLint(Implementation::Attribute<T>::DefaultComponents)} {} template<UnsignedInt location_, class T> DynamicAttribute::DynamicAttribute(const Attribute<location_, T>& attribute, const VertexFormat format): DynamicAttribute{Implementation::kindFor<location_, T>(attribute.dataOptions()), location_, format, GLint(Implementation::Attribute<T>::DefaultComponents)} {}

17
src/Magnum/GL/Mesh.cpp

@ -358,14 +358,15 @@ UnsignedInt Mesh::indexTypeSize() const {
} }
Mesh& Mesh::addVertexBufferInstanced(Buffer& buffer, const UnsignedInt divisor, const GLintptr offset, const GLsizei stride, const DynamicAttribute& attribute) { Mesh& Mesh::addVertexBufferInstanced(Buffer& buffer, const UnsignedInt divisor, const GLintptr offset, const GLsizei stride, const DynamicAttribute& attribute) {
attributePointerInternal(AttributeLayout{buffer, for(UnsignedInt i = 0; i != attribute.vectors(); ++i)
attribute.location(), attributePointerInternal(AttributeLayout{buffer,
GLint(attribute.components()), attribute.location() + i,
GLenum(attribute.dataType()), GLint(attribute.components()),
attribute.kind(), GLenum(attribute.dataType()),
offset, attribute.kind(),
stride, GLintptr(offset + i*attribute.vectorStride()),
divisor}); stride,
divisor});
return *this; return *this;
} }

52
src/Magnum/GL/Test/AttributeTest.cpp

@ -183,6 +183,8 @@ void AttributeTest::attributeScalar() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(da.vectorStride(), 4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
/* Options */ /* Options */
@ -194,6 +196,8 @@ void AttributeTest::attributeScalar() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::GenericNormalized); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::GenericNormalized);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(db.vectorStride(), 2);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedShort); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedShort);
} }
@ -211,6 +215,8 @@ void AttributeTest::attributeScalarInt() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(da.location(), 2); CORRADE_COMPARE(da.location(), 2);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(da.vectorStride(), 4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Int); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Int);
/* Options */ /* Options */
@ -221,6 +227,8 @@ void AttributeTest::attributeScalarInt() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(db.location(), 2); CORRADE_COMPARE(db.location(), 2);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(db.vectorStride(), 2);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Short); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Short);
#else #else
CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2.");
@ -241,6 +249,8 @@ void AttributeTest::attributeScalarUnsignedInt() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(da.vectorStride(), 4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt);
/* Options */ /* Options */
@ -251,6 +261,8 @@ void AttributeTest::attributeScalarUnsignedInt() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(db.vectorStride(), 1);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedByte); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedByte);
#else #else
CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2.");
@ -271,6 +283,8 @@ void AttributeTest::attributeScalarDouble() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(da.vectorStride(), 8);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double);
#else #else
CORRADE_SKIP("Double attributes are not available in OpenGL ES."); CORRADE_SKIP("Double attributes are not available in OpenGL ES.");
@ -292,6 +306,8 @@ void AttributeTest::attributeVector() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three);
CORRADE_COMPARE(da.vectorStride(), 3*4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
/* Options */ /* Options */
@ -304,6 +320,8 @@ void AttributeTest::attributeVector() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Two); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Two);
CORRADE_COMPARE(db.vectorStride(), 2*8);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Double);
#else #else
Attribute b(Attribute::Components::Two, Attribute::DataType::Float); Attribute b(Attribute::Components::Two, Attribute::DataType::Float);
@ -314,6 +332,8 @@ void AttributeTest::attributeVector() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Two); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Two);
CORRADE_COMPARE(db.vectorStride(), 2*4);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Float);
#endif #endif
} }
@ -334,6 +354,8 @@ void AttributeTest::attributeVectorInt() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two);
CORRADE_COMPARE(da.vectorStride(), 2*4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Int); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Int);
/* Options */ /* Options */
@ -344,6 +366,8 @@ void AttributeTest::attributeVectorInt() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(db.vectorStride(), 4);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Int); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Int);
#else #else
CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2.");
@ -366,6 +390,8 @@ void AttributeTest::attributeVectorUnsignedInt() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 4*4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt);
/* Options */ /* Options */
@ -376,6 +402,8 @@ void AttributeTest::attributeVectorUnsignedInt() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Integral);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Three); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Three);
CORRADE_COMPARE(db.vectorStride(), 3*2);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedShort); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::UnsignedShort);
#else #else
CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2."); CORRADE_SKIP("Integer attributes are not available in OpenGL ES 2.");
@ -398,6 +426,8 @@ void AttributeTest::attributeVectorDouble() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two);
CORRADE_COMPARE(da.vectorStride(), 2*8);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double);
/* Options */ /* Options */
@ -408,6 +438,8 @@ void AttributeTest::attributeVectorDouble() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Long); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Long);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::One);
CORRADE_COMPARE(db.vectorStride(), 8);
CORRADE_COMPARE(db.vectors(), 1);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Double);
#else #else
CORRADE_SKIP("Double attributes are not available in OpenGL ES."); CORRADE_SKIP("Double attributes are not available in OpenGL ES.");
@ -428,6 +460,8 @@ void AttributeTest::attributeVector4() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt2101010Rev); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::UnsignedInt2101010Rev);
#elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) #elif !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2))
Attribute a(Attribute::DataType::Half); Attribute a(Attribute::DataType::Half);
@ -437,6 +471,8 @@ void AttributeTest::attributeVector4() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 8);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Half); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Half);
#else #else
Attribute a(Attribute::DataType::Float); Attribute a(Attribute::DataType::Float);
@ -446,6 +482,8 @@ void AttributeTest::attributeVector4() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 16);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
#endif #endif
} }
@ -464,6 +502,8 @@ void AttributeTest::attributeVectorBGRA() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::BGRA); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::BGRA);
CORRADE_COMPARE(da.vectorStride(), 4*4);
CORRADE_COMPARE(da.vectors(), 1);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
#else #else
CORRADE_SKIP("BGRA attribute component ordering is not available in OpenGL ES."); CORRADE_SKIP("BGRA attribute component ordering is not available in OpenGL ES.");
@ -485,6 +525,8 @@ void AttributeTest::attributeMatrixNxN() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three);
CORRADE_COMPARE(da.vectorStride(), 3*4);
CORRADE_COMPARE(da.vectors(), 3);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
} }
@ -503,6 +545,8 @@ void AttributeTest::attributeMatrixNxNCustomStride() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Three);
CORRADE_COMPARE(da.vectorStride(), 6);
CORRADE_COMPARE(da.vectors(), 3);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Short); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Short);
/* Custom stride */ /* Custom stride */
@ -515,6 +559,8 @@ void AttributeTest::attributeMatrixNxNCustomStride() {
CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(db.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(db.location(), 3); CORRADE_COMPARE(db.location(), 3);
CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Three); CORRADE_COMPARE(db.components(), DynamicAttribute::Components::Three);
CORRADE_COMPARE(db.vectorStride(), 8);
CORRADE_COMPARE(db.vectors(), 3);
CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Short); CORRADE_COMPARE(db.dataType(), DynamicAttribute::DataType::Short);
} }
@ -534,6 +580,8 @@ void AttributeTest::attributeMatrixMxN() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Generic);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 4*4);
CORRADE_COMPARE(da.vectors(), 3);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Float);
} }
#endif #endif
@ -554,6 +602,8 @@ void AttributeTest::attributeMatrixNxNd() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Four);
CORRADE_COMPARE(da.vectorStride(), 4*8);
CORRADE_COMPARE(da.vectors(), 4);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double);
#else #else
CORRADE_SKIP("Double attributes are not available in OpenGL ES."); CORRADE_SKIP("Double attributes are not available in OpenGL ES.");
@ -576,6 +626,8 @@ void AttributeTest::attributeMatrixMxNd() {
CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long); CORRADE_COMPARE(da.kind(), DynamicAttribute::Kind::Long);
CORRADE_COMPARE(da.location(), 3); CORRADE_COMPARE(da.location(), 3);
CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two); CORRADE_COMPARE(da.components(), DynamicAttribute::Components::Two);
CORRADE_COMPARE(da.vectorStride(), 2*8);
CORRADE_COMPARE(da.vectors(), 4);
CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double); CORRADE_COMPARE(da.dataType(), DynamicAttribute::DataType::Double);
#else #else
CORRADE_SKIP("Double attributes are not available in OpenGL ES."); CORRADE_SKIP("Double attributes are not available in OpenGL ES.");

56
src/Magnum/GL/Test/MeshGLTest.cpp

@ -995,17 +995,9 @@ void MeshGLTest::addVertexBufferMatrixNxN() {
} else if(testCaseInstanceId() == 1) { } else if(testCaseInstanceId() == 1) {
setTestCaseDescription("DynamicAttribute"); setTestCaseDescription("DynamicAttribute");
mesh.addVertexBuffer(buffer, 3*3*4, 3*3*4, DynamicAttribute{ mesh.addVertexBuffer(buffer, 3*3*4, 3*3*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 0, DynamicAttribute::Kind::Generic, 0,
DynamicAttribute::Components::Three, DynamicAttribute::Components::Three, 3,
DynamicAttribute::DataType::Float}) DynamicAttribute::DataType::Float});
.addVertexBuffer(buffer, 3*3*4 + 3*4, 3*3*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 1,
DynamicAttribute::Components::Three,
DynamicAttribute::DataType::Float})
.addVertexBuffer(buffer, 3*3*4 + 6*4, 3*3*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 2,
DynamicAttribute::Components::Three,
DynamicAttribute::DataType::Float});
} else CORRADE_ASSERT_UNREACHABLE(); } else CORRADE_ASSERT_UNREACHABLE();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1049,17 +1041,9 @@ void MeshGLTest::addVertexBufferMatrixNxNd() {
} else if(testCaseInstanceId() == 1) { } else if(testCaseInstanceId() == 1) {
setTestCaseDescription("DynamicAttribute"); setTestCaseDescription("DynamicAttribute");
mesh.addVertexBuffer(buffer, 3*3*8, 3*3*8, DynamicAttribute{ mesh.addVertexBuffer(buffer, 3*3*8, 3*3*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 0, DynamicAttribute::Kind::Long, 0,
DynamicAttribute::Components::Three, DynamicAttribute::Components::Three, 3,
DynamicAttribute::DataType::Double}) DynamicAttribute::DataType::Double});
.addVertexBuffer(buffer, 3*3*8 + 3*8, 3*3*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 1,
DynamicAttribute::Components::Three,
DynamicAttribute::DataType::Double})
.addVertexBuffer(buffer, 3*3*8 + 6*8, 3*3*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 2,
DynamicAttribute::Components::Three,
DynamicAttribute::DataType::Double});
} else CORRADE_ASSERT_UNREACHABLE(); } else CORRADE_ASSERT_UNREACHABLE();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1103,17 +1087,9 @@ void MeshGLTest::addVertexBufferMatrixMxN() {
} else if(testCaseInstanceId() == 1) { } else if(testCaseInstanceId() == 1) {
setTestCaseDescription("DynamicAttribute"); setTestCaseDescription("DynamicAttribute");
mesh.addVertexBuffer(buffer, 3*4*4, 3*4*4, DynamicAttribute{ mesh.addVertexBuffer(buffer, 3*4*4, 3*4*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 0, DynamicAttribute::Kind::Generic, 0,
DynamicAttribute::Components::Four, DynamicAttribute::Components::Four, 3,
DynamicAttribute::DataType::Float}) DynamicAttribute::DataType::Float});
.addVertexBuffer(buffer, 3*4*4 + 4*4, 3*4*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 1,
DynamicAttribute::Components::Four,
DynamicAttribute::DataType::Float})
.addVertexBuffer(buffer, 3*4*4 + 8*4, 3*4*4, DynamicAttribute{
DynamicAttribute::Kind::Generic, 2,
DynamicAttribute::Components::Four,
DynamicAttribute::DataType::Float});
} else CORRADE_ASSERT_UNREACHABLE(); } else CORRADE_ASSERT_UNREACHABLE();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -1149,17 +1125,9 @@ void MeshGLTest::addVertexBufferMatrixMxNd() {
} else if(testCaseInstanceId() == 1) { } else if(testCaseInstanceId() == 1) {
setTestCaseDescription("DynamicAttribute"); setTestCaseDescription("DynamicAttribute");
mesh.addVertexBuffer(buffer, 3*4*8, 3*4*8, DynamicAttribute{ mesh.addVertexBuffer(buffer, 3*4*8, 3*4*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 0, DynamicAttribute::Kind::Long, 0,
DynamicAttribute::Components::Four, DynamicAttribute::Components::Four, 3,
DynamicAttribute::DataType::Double}) DynamicAttribute::DataType::Double});
.addVertexBuffer(buffer, 3*4*8 + 4*8, 3*4*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 1,
DynamicAttribute::Components::Four,
DynamicAttribute::DataType::Double})
.addVertexBuffer(buffer, 3*4*8 + 8*8, 3*4*8, DynamicAttribute{
DynamicAttribute::Kind::Long, 2,
DynamicAttribute::Components::Four,
DynamicAttribute::DataType::Double});
} else CORRADE_ASSERT_UNREACHABLE(); } else CORRADE_ASSERT_UNREACHABLE();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();

Loading…
Cancel
Save