diff --git a/src/Magnum/Implementation/vertexFormatMapping.hpp b/src/Magnum/Implementation/vertexFormatMapping.hpp index 2b2dc2b45..4832bcb0c 100644 --- a/src/Magnum/Implementation/vertexFormatMapping.hpp +++ b/src/Magnum/Implementation/vertexFormatMapping.hpp @@ -77,4 +77,61 @@ _c(Vector4s) _c(Vector4sNormalized) _c(Vector4ui) _c(Vector4i) +_c(Matrix2x2) +_c(Matrix2x2h) +_c(Matrix2x2d) +_c(Matrix2x2bNormalized) +_c(Matrix2x2sNormalized) +_c(Matrix2x3) +_c(Matrix2x3h) +_c(Matrix2x3d) +_c(Matrix2x3bNormalized) +_c(Matrix2x3sNormalized) +_c(Matrix2x4) +_c(Matrix2x4h) +_c(Matrix2x4d) +_c(Matrix2x4bNormalized) +_c(Matrix2x4sNormalized) +_c(Matrix2x2bNormalizedAligned) +_c(Matrix2x3hAligned) +_c(Matrix2x3bNormalizedAligned) +_c(Matrix2x3sNormalizedAligned) +_c(Matrix3x2) +_c(Matrix3x2h) +_c(Matrix3x2d) +_c(Matrix3x2bNormalized) +_c(Matrix3x2sNormalized) +_c(Matrix3x3) +_c(Matrix3x3h) +_c(Matrix3x3d) +_c(Matrix3x3bNormalized) +_c(Matrix3x3sNormalized) +_c(Matrix3x4) +_c(Matrix3x4h) +_c(Matrix3x4d) +_c(Matrix3x4bNormalized) +_c(Matrix3x4sNormalized) +_c(Matrix3x2bNormalizedAligned) +_c(Matrix3x3hAligned) +_c(Matrix3x3bNormalizedAligned) +_c(Matrix3x3sNormalizedAligned) +_c(Matrix4x2) +_c(Matrix4x2h) +_c(Matrix4x2d) +_c(Matrix4x2bNormalized) +_c(Matrix4x2sNormalized) +_c(Matrix4x3) +_c(Matrix4x3h) +_c(Matrix4x3d) +_c(Matrix4x3bNormalized) +_c(Matrix4x3sNormalized) +_c(Matrix4x4) +_c(Matrix4x4h) +_c(Matrix4x4d) +_c(Matrix4x4bNormalized) +_c(Matrix4x4sNormalized) +_c(Matrix4x2bNormalizedAligned) +_c(Matrix4x3hAligned) +_c(Matrix4x3bNormalizedAligned) +_c(Matrix4x3sNormalizedAligned) #endif diff --git a/src/Magnum/Test/VertexFormatTest.cpp b/src/Magnum/Test/VertexFormatTest.cpp index d145f4eb1..71c6669a8 100644 --- a/src/Magnum/Test/VertexFormatTest.cpp +++ b/src/Magnum/Test/VertexFormatTest.cpp @@ -25,11 +25,13 @@ #include #include +#include #include #include #include "Magnum/VertexFormat.h" -#include "Magnum/Math/Vector4.h" +#include "Magnum/Math/Half.h" +#include "Magnum/Math/Matrix4.h" namespace Magnum { namespace Test { namespace { @@ -52,6 +54,12 @@ struct VertexFormatTest: TestSuite::Tester { void componentFormat(); void componentFormatInvalid(); void componentFormatImplementationSpecific(); + void vectorCount(); + void vectorCountInvalid(); + void vectorCountImplementationSpecific(); + void vectorStride(); + void vectorStrideInvalid(); + void vectorStrideImplementationSpecific(); void isNormalized(); void isNormalizedInvalid(); void isNormalizedImplementationSpecific(); @@ -62,6 +70,12 @@ struct VertexFormatTest: TestSuite::Tester { void assembleInvalidComponentCount(); void assembleImplementationSpecific(); + void assembleMatrix(); + void assembleMatrixRoundtrip(); + void assembleMatrixInvalidType(); + void assembleMatrixInvalidCount(); + void assembleMatrixImplementationSpecific(); + void debug(); void debugImplementationSpecific(); void configuration(); @@ -85,6 +99,32 @@ constexpr struct { {VertexFormat::Int, false} }; +constexpr struct { + VertexFormat componentType; + UnsignedInt componentCount; + bool aligned; +} AssembleMatrixRoundtripData[]{ + {VertexFormat::Float, 2, true}, + {VertexFormat::Float, 3, true}, + {VertexFormat::Float, 4, true}, + {VertexFormat::Half, 2, false}, + {VertexFormat::Half, 3, false}, + {VertexFormat::Half, 3, true}, + {VertexFormat::Half, 4, false}, + {VertexFormat::Double, 2, true}, + {VertexFormat::Double, 3, true}, + {VertexFormat::Double, 4, true}, + {VertexFormat::Byte, 2, false}, + {VertexFormat::Byte, 2, true}, + {VertexFormat::Byte, 3, false}, + {VertexFormat::Byte, 3, true}, + {VertexFormat::Byte, 4, false}, + {VertexFormat::Short, 2, false}, + {VertexFormat::Short, 3, false}, + {VertexFormat::Short, 3, true}, + {VertexFormat::Short, 4, false} +}; + VertexFormatTest::VertexFormatTest() { addTests({&VertexFormatTest::mapping, @@ -102,6 +142,12 @@ VertexFormatTest::VertexFormatTest() { &VertexFormatTest::componentFormat, &VertexFormatTest::componentFormatInvalid, &VertexFormatTest::componentFormatImplementationSpecific, + &VertexFormatTest::vectorCount, + &VertexFormatTest::vectorCountInvalid, + &VertexFormatTest::vectorCountImplementationSpecific, + &VertexFormatTest::vectorStride, + &VertexFormatTest::vectorStrideInvalid, + &VertexFormatTest::vectorStrideImplementationSpecific, &VertexFormatTest::isNormalized, &VertexFormatTest::isNormalizedInvalid, &VertexFormatTest::isNormalizedImplementationSpecific, @@ -115,6 +161,15 @@ VertexFormatTest::VertexFormatTest() { &VertexFormatTest::assembleInvalidComponentCount, &VertexFormatTest::assembleImplementationSpecific, + &VertexFormatTest::assembleMatrix}); + + addRepeatedInstancedTests({&VertexFormatTest::assembleMatrixRoundtrip}, 3, + Containers::arraySize(AssembleMatrixRoundtripData)); + + addTests({&VertexFormatTest::assembleMatrixInvalidType, + &VertexFormatTest::assembleMatrixInvalidCount, + &VertexFormatTest::assembleMatrixImplementationSpecific, + &VertexFormatTest::debug, &VertexFormatTest::debugImplementationSpecific, &VertexFormatTest::configuration}); @@ -198,6 +253,13 @@ void VertexFormatTest::size() { CORRADE_COMPARE(vertexFormatSize(VertexFormat::Vector2), sizeof(Vector2)); CORRADE_COMPARE(vertexFormatSize(VertexFormat::Vector3), sizeof(Vector3)); CORRADE_COMPARE(vertexFormatSize(VertexFormat::Vector4), sizeof(Vector4)); + + CORRADE_COMPARE(vertexFormatSize(VertexFormat::Matrix2x3), sizeof(Matrix2x3)); + CORRADE_COMPARE(vertexFormatSize(VertexFormat::Matrix4x3h), sizeof(Matrix4x3h)); + + /* Aligned types */ + CORRADE_COMPARE(vertexFormatSize(VertexFormat::Matrix2x2bNormalized), sizeof(Matrix2x2b)); + CORRADE_COMPARE(vertexFormatSize(VertexFormat::Matrix2x2bNormalizedAligned), sizeof(Matrix2x4b)); } void VertexFormatTest::sizeInvalid() { @@ -224,6 +286,13 @@ void VertexFormatTest::componentCount() { CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Vector2us), 2); CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Vector3bNormalized), 3); CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Vector4), 4); + + CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Matrix4x3), 3); + CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Matrix2x4sNormalized), 4); + + /* Aligned types return used component count, w/o padding */ + CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Matrix2x3sNormalized), 3); + CORRADE_COMPARE(vertexFormatComponentCount(VertexFormat::Matrix2x3sNormalizedAligned), 3); } void VertexFormatTest::componentCountInvalid() { @@ -257,6 +326,14 @@ void VertexFormatTest::componentFormat() { CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Vector2sNormalized), VertexFormat::Short); CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Vector2ui), VertexFormat::UnsignedInt); CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Vector3i), VertexFormat::Int); + + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix3x4), VertexFormat::Float); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix2x3h), VertexFormat::Half); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix2x2d), VertexFormat::Double); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix4x2bNormalized), VertexFormat::Byte); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix4x2bNormalizedAligned), VertexFormat::Byte); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix2x3sNormalized), VertexFormat::Short); + CORRADE_COMPARE(vertexFormatComponentFormat(VertexFormat::Matrix2x3sNormalizedAligned), VertexFormat::Short); } void VertexFormatTest::componentFormatInvalid() { @@ -279,11 +356,80 @@ void VertexFormatTest::componentFormatImplementationSpecific() { "vertexFormatComponentFormat(): can't determine component format of an implementation-specific format 0xdead\n"); } +void VertexFormatTest::vectorCount() { + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::UnsignedByteNormalized), 1); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Vector2us), 1); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Vector3bNormalized), 1); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Vector4), 1); + + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Matrix2x4sNormalized), 2); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Matrix3x2bNormalized), 3); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Matrix3x2bNormalizedAligned), 3); + CORRADE_COMPARE(vertexFormatVectorCount(VertexFormat::Matrix4x3), 4); +} + +void VertexFormatTest::vectorCountInvalid() { + std::ostringstream out; + Error redirectError{&out}; + + vertexFormatVectorCount(VertexFormat{}); + vertexFormatVectorCount(VertexFormat(0xdead)); + + CORRADE_COMPARE(out.str(), + "vertexFormatVectorCount(): invalid format VertexFormat(0x0)\n" + "vertexFormatVectorCount(): invalid format VertexFormat(0xdead)\n"); +} + +void VertexFormatTest::vectorCountImplementationSpecific() { + std::ostringstream out; + Error redirectError{&out}; + vertexFormatVectorCount(vertexFormatWrap(0xdead)); + CORRADE_COMPARE(out.str(), + "vertexFormatVectorCount(): can't determine vector count of an implementation-specific format 0xdead\n"); +} + +void VertexFormatTest::vectorStride() { + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::UnsignedByteNormalized), 1); + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Vector3bNormalized), 3); + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Vector2us), 4); + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Vector4), 16); + + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Matrix2x4sNormalized), 8); + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Matrix4x3), 12); + + /* Aligned formats */ + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Matrix3x2bNormalized), 2); + CORRADE_COMPARE(vertexFormatVectorStride(VertexFormat::Matrix3x2bNormalizedAligned), 4); +} + +void VertexFormatTest::vectorStrideInvalid() { + std::ostringstream out; + Error redirectError{&out}; + + vertexFormatVectorStride(VertexFormat{}); + vertexFormatVectorStride(VertexFormat(0xdead)); + + CORRADE_COMPARE(out.str(), + "vertexFormatVectorStride(): invalid format VertexFormat(0x0)\n" + "vertexFormatVectorStride(): invalid format VertexFormat(0xdead)\n"); +} + +void VertexFormatTest::vectorStrideImplementationSpecific() { + std::ostringstream out; + Error redirectError{&out}; + vertexFormatVectorStride(vertexFormatWrap(0xdead)); + CORRADE_COMPARE(out.str(), + "vertexFormatVectorStride(): can't determine vector count of an implementation-specific format 0xdead\n"); +} + void VertexFormatTest::isNormalized() { CORRADE_VERIFY(isVertexFormatNormalized(VertexFormat::UnsignedByteNormalized)); CORRADE_VERIFY(!isVertexFormatNormalized(VertexFormat::Vector2us)); CORRADE_VERIFY(isVertexFormatNormalized(VertexFormat::Vector3bNormalized)); CORRADE_VERIFY(!isVertexFormatNormalized(VertexFormat::Vector4)); + + CORRADE_VERIFY(!isVertexFormatNormalized(VertexFormat::Matrix2x2h)); + CORRADE_VERIFY(isVertexFormatNormalized(VertexFormat::Matrix2x3bNormalized)); } void VertexFormatTest::isNormalizedInvalid() { @@ -336,8 +482,11 @@ void VertexFormatTest::assembleRoundtrip() { setTestCaseDescription(out.str()); VertexFormat result = vertexFormat(data.componentType, testCaseRepeatId() + 1, data.normalized); + CORRADE_COMPARE(vertexFormat(result, testCaseRepeatId() + 1, data.normalized), result); CORRADE_COMPARE(vertexFormatComponentFormat(result), data.componentType); CORRADE_COMPARE(vertexFormatComponentCount(result), testCaseRepeatId() + 1); + CORRADE_COMPARE(vertexFormatVectorCount(result), 1); + CORRADE_COMPARE(vertexFormatVectorStride(result), vertexFormatSize(result)); CORRADE_COMPARE(isVertexFormatNormalized(result), data.normalized); } @@ -365,6 +514,83 @@ void VertexFormatTest::assembleImplementationSpecific() { "vertexFormat(): can't assemble a format out of an implementation-specific format 0xdead\n"); } +void VertexFormatTest::assembleMatrix() { + CORRADE_COMPARE(vertexFormat(VertexFormat::Byte, 3, 2, false), + VertexFormat::Matrix3x2bNormalized); + CORRADE_COMPARE(vertexFormat(VertexFormat::Short, 2, 3, true), + VertexFormat::Matrix2x3sNormalizedAligned); + CORRADE_COMPARE(vertexFormat(VertexFormat::Float, 4, 2, true), + VertexFormat::Matrix4x2); + CORRADE_COMPARE(vertexFormat(VertexFormat::Half, 2, 4, false), + VertexFormat::Matrix2x4h); + CORRADE_COMPARE(vertexFormat(VertexFormat::Double, 4, 4, true), + VertexFormat::Matrix4x4d); + + /* Non-scalar types allowed too, as that makes the internal checking + much simpler than when requiring the type to be scalar non-normalized */ + CORRADE_COMPARE(vertexFormat(VertexFormat::Vector4bNormalized, 2, 2, false), + VertexFormat::Matrix2x2bNormalized); + CORRADE_COMPARE(vertexFormat(VertexFormat::Vector3h, 3, 3, true), + VertexFormat::Matrix3x3hAligned); +} + +void VertexFormatTest::assembleMatrixRoundtrip() { + auto&& data = AssembleMatrixRoundtripData[testCaseInstanceId()]; + + std::ostringstream out; + { + Debug d{&out, Debug::Flag::NoNewlineAtTheEnd}; + d << data.componentType << Debug::nospace << "," << data.componentCount; + if(data.aligned) d << Debug::nospace << ", aligned"; + } + setTestCaseDescription(out.str()); + + VertexFormat result = vertexFormat(data.componentType, testCaseRepeatId() + 2, data.componentCount, data.aligned); + CORRADE_COMPARE(vertexFormat(result, testCaseRepeatId() + 2, data.componentCount, data.aligned), result); + CORRADE_COMPARE(vertexFormatComponentFormat(result), data.componentType); + CORRADE_COMPARE(vertexFormatComponentCount(result), data.componentCount); + CORRADE_COMPARE(vertexFormatVectorCount(result), testCaseRepeatId() + 2); + CORRADE_COMPARE(vertexFormatVectorStride(result), vertexFormatSize(result)/(testCaseRepeatId() + 2)); + if(data.aligned) + CORRADE_COMPARE_AS(vertexFormatVectorStride(result), 4, TestSuite::Compare::Divisible); +} + +void VertexFormatTest::assembleMatrixInvalidType() { + std::ostringstream out; + Error redirectError{&out}; + vertexFormat(VertexFormat::UnsignedByte, 3, 2, false); + vertexFormat(VertexFormat::UnsignedShort, 3, 2, false); + vertexFormat(VertexFormat::UnsignedInt, 2, 3, false); + vertexFormat(VertexFormat::Int, 2, 3, false); + CORRADE_COMPARE(out.str(), + "vertexFormat(): invalid matrix component type VertexFormat::UnsignedByte, only floating-point or 8-/16-bit signed integer types are supported\n" + "vertexFormat(): invalid matrix component type VertexFormat::UnsignedShort, only floating-point or 8-/16-bit signed integer types are supported\n" + "vertexFormat(): invalid matrix component type VertexFormat::UnsignedInt, only floating-point or 8-/16-bit signed integer types are supported\n" + "vertexFormat(): invalid matrix component type VertexFormat::Int, only floating-point or 8-/16-bit signed integer types are supported\n"); +} + +void VertexFormatTest::assembleMatrixInvalidCount() { + std::ostringstream out; + Error redirectError{&out}; + vertexFormat(VertexFormat::Vector3, 2, 1, false); + vertexFormat(VertexFormat::Vector3, 2, 5, false); + vertexFormat(VertexFormat::Vector3, 5, 2, false); + vertexFormat(VertexFormat::Vector3, 1, 2, false); + CORRADE_COMPARE(out.str(), + "vertexFormat(): invalid component count 1\n" + "vertexFormat(): invalid component count 5\n" + "vertexFormat(): invalid vector count 5\n" + "vertexFormat(): invalid vector count 1\n"); +} + +void VertexFormatTest::assembleMatrixImplementationSpecific() { + std::ostringstream out; + Error redirectError{&out}; + vertexFormat(vertexFormatWrap(0xdead), 2, 2, true); + CORRADE_COMPARE(out.str(), + "vertexFormat(): can't assemble a format out of an implementation-specific format 0xdead\n"); +} + void VertexFormatTest::debug() { std::ostringstream o; Debug(&o) << VertexFormat::Vector4 << VertexFormat(0xdead); diff --git a/src/Magnum/VertexFormat.cpp b/src/Magnum/VertexFormat.cpp index ff96f53ef..38b07a039 100644 --- a/src/Magnum/VertexFormat.cpp +++ b/src/Magnum/VertexFormat.cpp @@ -69,12 +69,15 @@ UnsignedInt vertexFormatSize(const VertexFormat format) { case VertexFormat::Vector4ubNormalized: case VertexFormat::Vector4b: case VertexFormat::Vector4bNormalized: + case VertexFormat::Matrix2x2bNormalized: return 4; case VertexFormat::Vector3h: case VertexFormat::Vector3us: case VertexFormat::Vector3usNormalized: case VertexFormat::Vector3s: case VertexFormat::Vector3sNormalized: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix3x2bNormalized: return 6; case VertexFormat::Double: case VertexFormat::Vector2: @@ -85,20 +88,82 @@ UnsignedInt vertexFormatSize(const VertexFormat format) { case VertexFormat::Vector4usNormalized: case VertexFormat::Vector4s: case VertexFormat::Vector4sNormalized: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix4x2bNormalized: return 8; + case VertexFormat::Matrix3x3bNormalized: + return 9; case VertexFormat::Vector3: case VertexFormat::Vector3ui: case VertexFormat::Vector3i: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix4x3bNormalized: return 12; case VertexFormat::Vector2d: case VertexFormat::Vector4: case VertexFormat::Vector4ui: case VertexFormat::Vector4i: + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix2x4sNormalized: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix4x2sNormalized: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix4x2bNormalizedAligned: + case VertexFormat::Matrix4x3bNormalizedAligned: return 16; + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix3x3sNormalized: + return 18; case VertexFormat::Vector3d: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix3x4sNormalized: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix4x3sNormalized: return 24; case VertexFormat::Vector4d: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix4x4sNormalized: + case VertexFormat::Matrix4x3hAligned: + case VertexFormat::Matrix4x3sNormalizedAligned: return 32; + case VertexFormat::Matrix3x3: + return 36; + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix4x3: + return 48; + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix4x2d: + case VertexFormat::Matrix4x4: + return 64; + case VertexFormat::Matrix3x3d: + return 72; + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix4x3d: + return 96; + case VertexFormat::Matrix4x4d: + return 128; } CORRADE_ASSERT(false, "vertexFormatSize(): invalid format" << format, {}); @@ -137,6 +202,24 @@ UnsignedInt vertexFormatComponentCount(const VertexFormat format) { case VertexFormat::Vector2sNormalized: case VertexFormat::Vector2ui: case VertexFormat::Vector2i: + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix2x2bNormalized: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix3x2bNormalized: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix4x2d: + case VertexFormat::Matrix4x2bNormalized: + case VertexFormat::Matrix4x2sNormalized: + case VertexFormat::Matrix4x2bNormalizedAligned: return 2; case VertexFormat::Vector3: @@ -152,6 +235,30 @@ UnsignedInt vertexFormatComponentCount(const VertexFormat format) { case VertexFormat::Vector3sNormalized: case VertexFormat::Vector3ui: case VertexFormat::Vector3i: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix3x3: + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix3x3d: + case VertexFormat::Matrix3x3bNormalized: + case VertexFormat::Matrix3x3sNormalized: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix4x3: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix4x3d: + case VertexFormat::Matrix4x3bNormalized: + case VertexFormat::Matrix4x3sNormalized: + case VertexFormat::Matrix4x3bNormalizedAligned: + case VertexFormat::Matrix4x3hAligned: + case VertexFormat::Matrix4x3sNormalizedAligned: return 3; case VertexFormat::Vector4: @@ -167,6 +274,21 @@ UnsignedInt vertexFormatComponentCount(const VertexFormat format) { case VertexFormat::Vector4sNormalized: case VertexFormat::Vector4ui: case VertexFormat::Vector4i: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix2x4sNormalized: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix3x4sNormalized: + case VertexFormat::Matrix4x4: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix4x4d: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix4x4sNormalized: return 4; } @@ -182,18 +304,48 @@ VertexFormat vertexFormatComponentFormat(const VertexFormat format) { case VertexFormat::Vector2: case VertexFormat::Vector3: case VertexFormat::Vector4: + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix3x3: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix4x3: + case VertexFormat::Matrix4x4: return VertexFormat::Float; case VertexFormat::Half: case VertexFormat::Vector2h: case VertexFormat::Vector3h: case VertexFormat::Vector4h: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix4x3hAligned: return VertexFormat::Half; case VertexFormat::Double: case VertexFormat::Vector2d: case VertexFormat::Vector3d: case VertexFormat::Vector4d: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix3x3d: + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix4x2d: + case VertexFormat::Matrix4x3d: + case VertexFormat::Matrix4x4d: return VertexFormat::Double; case VertexFormat::UnsignedByte: @@ -214,6 +366,21 @@ VertexFormat vertexFormatComponentFormat(const VertexFormat format) { case VertexFormat::Vector3bNormalized: case VertexFormat::Vector4b: case VertexFormat::Vector4bNormalized: + case VertexFormat::Matrix2x2bNormalized: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix3x2bNormalized: + case VertexFormat::Matrix3x3bNormalized: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix4x2bNormalized: + case VertexFormat::Matrix4x3bNormalized: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix4x2bNormalizedAligned: + case VertexFormat::Matrix4x3bNormalizedAligned: return VertexFormat::Byte; case VertexFormat::UnsignedShort: @@ -234,6 +401,18 @@ VertexFormat vertexFormatComponentFormat(const VertexFormat format) { case VertexFormat::Vector3sNormalized: case VertexFormat::Vector4s: case VertexFormat::Vector4sNormalized: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix2x4sNormalized: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix3x3sNormalized: + case VertexFormat::Matrix3x4sNormalized: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix4x2sNormalized: + case VertexFormat::Matrix4x3sNormalized: + case VertexFormat::Matrix4x4sNormalized: + case VertexFormat::Matrix4x3sNormalizedAligned: return VertexFormat::Short; case VertexFormat::UnsignedInt: @@ -252,6 +431,261 @@ VertexFormat vertexFormatComponentFormat(const VertexFormat format) { CORRADE_ASSERT(false, "vertexFormatComponentType(): invalid format" << format, {}); } +UnsignedInt vertexFormatVectorCount(const VertexFormat format) { + CORRADE_ASSERT(!isVertexFormatImplementationSpecific(format), + "vertexFormatVectorCount(): can't determine vector count of an implementation-specific format" << reinterpret_cast(vertexFormatUnwrap(format)), {}); + + switch(format) { + case VertexFormat::Float: + case VertexFormat::Half: + case VertexFormat::Double: + case VertexFormat::UnsignedByte: + case VertexFormat::UnsignedByteNormalized: + case VertexFormat::Byte: + case VertexFormat::ByteNormalized: + case VertexFormat::UnsignedShort: + case VertexFormat::UnsignedShortNormalized: + case VertexFormat::Short: + case VertexFormat::ShortNormalized: + case VertexFormat::UnsignedInt: + case VertexFormat::Int: + case VertexFormat::Vector2: + case VertexFormat::Vector2h: + case VertexFormat::Vector2d: + case VertexFormat::Vector2ub: + case VertexFormat::Vector2ubNormalized: + case VertexFormat::Vector2b: + case VertexFormat::Vector2bNormalized: + case VertexFormat::Vector2us: + case VertexFormat::Vector2usNormalized: + case VertexFormat::Vector2s: + case VertexFormat::Vector2sNormalized: + case VertexFormat::Vector2ui: + case VertexFormat::Vector2i: + case VertexFormat::Vector3: + case VertexFormat::Vector3h: + case VertexFormat::Vector3d: + case VertexFormat::Vector3ub: + case VertexFormat::Vector3ubNormalized: + case VertexFormat::Vector3b: + case VertexFormat::Vector3bNormalized: + case VertexFormat::Vector3us: + case VertexFormat::Vector3usNormalized: + case VertexFormat::Vector3s: + case VertexFormat::Vector3sNormalized: + case VertexFormat::Vector3ui: + case VertexFormat::Vector3i: + case VertexFormat::Vector4: + case VertexFormat::Vector4h: + case VertexFormat::Vector4d: + case VertexFormat::Vector4ub: + case VertexFormat::Vector4ubNormalized: + case VertexFormat::Vector4b: + case VertexFormat::Vector4bNormalized: + case VertexFormat::Vector4us: + case VertexFormat::Vector4usNormalized: + case VertexFormat::Vector4s: + case VertexFormat::Vector4sNormalized: + case VertexFormat::Vector4ui: + case VertexFormat::Vector4i: + return 1; + + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix2x2bNormalized: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix2x4sNormalized: + return 2; + + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix3x2bNormalized: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix3x3: + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix3x3d: + case VertexFormat::Matrix3x3bNormalized: + case VertexFormat::Matrix3x3sNormalized: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix3x4sNormalized: + return 3; + + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix4x2d: + case VertexFormat::Matrix4x2bNormalized: + case VertexFormat::Matrix4x2sNormalized: + case VertexFormat::Matrix4x2bNormalizedAligned: + case VertexFormat::Matrix4x3: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix4x3d: + case VertexFormat::Matrix4x3bNormalized: + case VertexFormat::Matrix4x3sNormalized: + case VertexFormat::Matrix4x3bNormalizedAligned: + case VertexFormat::Matrix4x3hAligned: + case VertexFormat::Matrix4x3sNormalizedAligned: + case VertexFormat::Matrix4x4: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix4x4d: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix4x4sNormalized: + return 4; + } + + CORRADE_ASSERT(false, "vertexFormatVectorCount(): invalid format" << format, {}); +} + +UnsignedInt vertexFormatVectorStride(const VertexFormat format) { + CORRADE_ASSERT(!isVertexFormatImplementationSpecific(format), + "vertexFormatVectorStride(): can't determine vector count of an implementation-specific format" << reinterpret_cast(vertexFormatUnwrap(format)), {}); + + switch(format) { + case VertexFormat::UnsignedByte: + case VertexFormat::UnsignedByteNormalized: + case VertexFormat::Byte: + case VertexFormat::ByteNormalized: + return 1; + case VertexFormat::Half: + case VertexFormat::UnsignedShort: + case VertexFormat::UnsignedShortNormalized: + case VertexFormat::Short: + case VertexFormat::ShortNormalized: + case VertexFormat::Vector2ub: + case VertexFormat::Vector2ubNormalized: + case VertexFormat::Vector2b: + case VertexFormat::Vector2bNormalized: + case VertexFormat::Matrix2x2bNormalized: + case VertexFormat::Matrix3x2bNormalized: + case VertexFormat::Matrix4x2bNormalized: + return 2; + case VertexFormat::Vector3ub: + case VertexFormat::Vector3ubNormalized: + case VertexFormat::Vector3b: + case VertexFormat::Vector3bNormalized: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix3x3bNormalized: + case VertexFormat::Matrix4x3bNormalized: + return 3; + case VertexFormat::Float: + case VertexFormat::UnsignedInt: + case VertexFormat::Int: + case VertexFormat::Vector2h: + case VertexFormat::Vector2us: + case VertexFormat::Vector2usNormalized: + case VertexFormat::Vector2s: + case VertexFormat::Vector2sNormalized: + case VertexFormat::Vector4ub: + case VertexFormat::Vector4ubNormalized: + case VertexFormat::Vector4b: + case VertexFormat::Vector4bNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix4x2bNormalizedAligned: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix4x3bNormalizedAligned: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix4x2sNormalized: + return 4; + case VertexFormat::Vector3h: + case VertexFormat::Vector3us: + case VertexFormat::Vector3usNormalized: + case VertexFormat::Vector3s: + case VertexFormat::Vector3sNormalized: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix3x3sNormalized: + case VertexFormat::Matrix4x3sNormalized: + return 6; + case VertexFormat::Double: + case VertexFormat::Vector2: + case VertexFormat::Vector2ui: + case VertexFormat::Vector2i: + case VertexFormat::Vector4h: + case VertexFormat::Vector4us: + case VertexFormat::Vector4usNormalized: + case VertexFormat::Vector4s: + case VertexFormat::Vector4sNormalized: + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix2x4sNormalized: + case VertexFormat::Matrix3x4sNormalized: + case VertexFormat::Matrix4x4sNormalized: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix4x3hAligned: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix4x3sNormalizedAligned: + return 8; + case VertexFormat::Vector3: + case VertexFormat::Vector3ui: + case VertexFormat::Vector3i: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix3x3: + case VertexFormat::Matrix4x3: + return 12; + case VertexFormat::Vector2d: + case VertexFormat::Vector4: + case VertexFormat::Vector4ui: + case VertexFormat::Vector4i: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix4x4: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix4x2d: + return 16; + case VertexFormat::Vector3d: + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix3x3d: + case VertexFormat::Matrix4x3d: + return 24; + case VertexFormat::Vector4d: + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix4x4d: + return 32; + } + + CORRADE_ASSERT(false, "vertexFormatVectorStride(): invalid format" << format, {}); +} + bool isVertexFormatNormalized(const VertexFormat format) { CORRADE_ASSERT(!isVertexFormatImplementationSpecific(format), "isVertexFormatNormalized(): can't determine normalization of an implementation-specific format" << reinterpret_cast(vertexFormatUnwrap(format)), {}); @@ -293,6 +727,36 @@ bool isVertexFormatNormalized(const VertexFormat format) { case VertexFormat::Vector4s: case VertexFormat::Vector4ui: case VertexFormat::Vector4i: + case VertexFormat::Matrix2x2: + case VertexFormat::Matrix2x2h: + case VertexFormat::Matrix2x2d: + case VertexFormat::Matrix2x3: + case VertexFormat::Matrix2x3h: + case VertexFormat::Matrix2x3d: + case VertexFormat::Matrix2x4: + case VertexFormat::Matrix2x4h: + case VertexFormat::Matrix2x4d: + case VertexFormat::Matrix2x3hAligned: + case VertexFormat::Matrix3x2: + case VertexFormat::Matrix3x2h: + case VertexFormat::Matrix3x2d: + case VertexFormat::Matrix3x3: + case VertexFormat::Matrix3x3h: + case VertexFormat::Matrix3x3d: + case VertexFormat::Matrix3x4: + case VertexFormat::Matrix3x4h: + case VertexFormat::Matrix3x4d: + case VertexFormat::Matrix3x3hAligned: + case VertexFormat::Matrix4x2: + case VertexFormat::Matrix4x2h: + case VertexFormat::Matrix4x2d: + case VertexFormat::Matrix4x3: + case VertexFormat::Matrix4x3h: + case VertexFormat::Matrix4x3d: + case VertexFormat::Matrix4x4: + case VertexFormat::Matrix4x4h: + case VertexFormat::Matrix4x4d: + case VertexFormat::Matrix4x3hAligned: return false; case VertexFormat::UnsignedByteNormalized: @@ -311,6 +775,33 @@ bool isVertexFormatNormalized(const VertexFormat format) { case VertexFormat::Vector4bNormalized: case VertexFormat::Vector4usNormalized: case VertexFormat::Vector4sNormalized: + case VertexFormat::Matrix2x2bNormalized: + case VertexFormat::Matrix2x2sNormalized: + case VertexFormat::Matrix2x3bNormalized: + case VertexFormat::Matrix2x3sNormalized: + case VertexFormat::Matrix2x4bNormalized: + case VertexFormat::Matrix2x4sNormalized: + case VertexFormat::Matrix2x2bNormalizedAligned: + case VertexFormat::Matrix2x3bNormalizedAligned: + case VertexFormat::Matrix2x3sNormalizedAligned: + case VertexFormat::Matrix3x2bNormalized: + case VertexFormat::Matrix3x2sNormalized: + case VertexFormat::Matrix3x3bNormalized: + case VertexFormat::Matrix3x3sNormalized: + case VertexFormat::Matrix3x4bNormalized: + case VertexFormat::Matrix3x4sNormalized: + case VertexFormat::Matrix3x2bNormalizedAligned: + case VertexFormat::Matrix3x3bNormalizedAligned: + case VertexFormat::Matrix3x3sNormalizedAligned: + case VertexFormat::Matrix4x2bNormalized: + case VertexFormat::Matrix4x2sNormalized: + case VertexFormat::Matrix4x3bNormalized: + case VertexFormat::Matrix4x3sNormalized: + case VertexFormat::Matrix4x4bNormalized: + case VertexFormat::Matrix4x4sNormalized: + case VertexFormat::Matrix4x2bNormalizedAligned: + case VertexFormat::Matrix4x3bNormalizedAligned: + case VertexFormat::Matrix4x3sNormalizedAligned: return true; } @@ -362,6 +853,57 @@ VertexFormat vertexFormat(const VertexFormat format, const UnsignedInt component CORRADE_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ } +VertexFormat vertexFormat(const VertexFormat format, const UnsignedInt vectorCount, UnsignedInt componentCount, const bool aligned) { + CORRADE_ASSERT(!isVertexFormatImplementationSpecific(format), + "vertexFormat(): can't assemble a format out of an implementation-specific format" << reinterpret_cast(vertexFormatUnwrap(format)), {}); + CORRADE_ASSERT(vectorCount >= 2 && vectorCount <= 4, + "vertexFormat(): invalid vector count" << vectorCount, {}); + CORRADE_ASSERT(componentCount >= 2 && componentCount <= 4, + "vertexFormat(): invalid component count" << componentCount, {}); + + const VertexFormat componentFormat = vertexFormatComponentFormat(format); + const UnsignedInt vectorDistance = (vectorCount - 2)*( + UnsignedInt(VertexFormat::Matrix3x2) - + UnsignedInt(VertexFormat::Matrix2x2)); + const UnsignedInt componentDistance = (componentCount - 2)*( + UnsignedInt(VertexFormat::Matrix2x3) - + UnsignedInt(VertexFormat::Matrix2x2)); + + UnsignedInt out; + switch(componentFormat) { + case VertexFormat::Float: + out = UnsignedInt(VertexFormat::Matrix2x2) + componentDistance; + break; + case VertexFormat::Half: + if(aligned && componentCount == 3) + out = UnsignedInt(VertexFormat::Matrix2x3hAligned); + else + out = UnsignedInt(VertexFormat::Matrix2x2h) + componentDistance; + break; + case VertexFormat::Double: + out = UnsignedInt(VertexFormat::Matrix2x2d) + componentDistance; + break; + case VertexFormat::Byte: + if(aligned && componentCount == 2) + out = UnsignedInt(VertexFormat::Matrix2x2bNormalizedAligned); + else if(aligned && componentCount == 3) + out = UnsignedInt(VertexFormat::Matrix2x3bNormalizedAligned); + else + out = UnsignedInt(VertexFormat::Matrix2x2bNormalized) + componentDistance; + break; + case VertexFormat::Short: + if(aligned && componentCount == 3) + out = UnsignedInt(VertexFormat::Matrix2x3sNormalizedAligned); + else + out = UnsignedInt(VertexFormat::Matrix2x2sNormalized) + componentDistance; + break; + default: CORRADE_ASSERT(false, + "vertexFormat(): invalid matrix component type" << componentFormat << Debug::nospace << ", only floating-point or 8-/16-bit signed integer types are supported", {}); + } + + return VertexFormat(out + vectorDistance); +} + namespace { constexpr const char* VertexFormatNames[] { diff --git a/src/Magnum/VertexFormat.h b/src/Magnum/VertexFormat.h index ac04719e4..79c5c1805 100644 --- a/src/Magnum/VertexFormat.h +++ b/src/Magnum/VertexFormat.h @@ -26,7 +26,7 @@ */ /** @file - * @brief Enum @ref Magnum::VertexFormat, function @ref Magnum::isVertexFormatImplementationSpecific(), @ref Magnum::vertexFormatWrap(), @ref Magnum::vertexFormatUnwrap(), @ref Magnum::vertexFormatSize(), @ref Magnum::vertexFormatComponentCount(), @ref Magnum::vertexFormatComponentFormat(), @ref Magnum::isVertexFormatNormalized() + * @brief Enum @ref Magnum::VertexFormat, function @ref Magnum::isVertexFormatImplementationSpecific(), @ref Magnum::vertexFormatWrap(), @ref Magnum::vertexFormatUnwrap(), @ref Magnum::vertexFormatSize(), @ref Magnum::vertexFormatComponentFormat(), @ref Magnum::vertexFormatComponentCount(), @ref Magnum::vertexFormatVectorCount(), @ref Magnum::vertexFormatVectorStride(), @ref Magnum::isVertexFormatNormalized() */ #include @@ -776,7 +776,547 @@ enum class VertexFormat: UnsignedInt { * or @m_class{m-doc-external} [MTLVertexFormatInt4](https://developer.apple.com/documentation/metal/mtlvertexformat/mtlvertexformatint4?language=objc). * @m_keywords{DXGI_FORMAT_R32G32B32A32_SINT MTLVertexFormatInt4} */ - Vector4i + Vector4i, + + /** + * @ref Matrix2x2. + * + * Same as two @ref VertexFormat::Vector2 tightly following each other and + * bound to consecutive locations. + */ + Matrix2x2, + + /** + * @ref Matrix2x2h. + * + * Same as two @ref VertexFormat::Vector2h tightly following each other and + * bound to consecutive locations. + */ + Matrix2x2h, + + /** + * @ref Matrix2x2d. + * + * Same as two @ref VertexFormat::Vector2d tightly following each other and + * bound to consecutive locations. + */ + Matrix2x2d, + + /** + * @ref Matrix2x2b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector2bNormalized tightly following each + * other and bound to consecutive locations. Note that this type doesn't + * have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix2x2bNormalizedAligned instead. + */ + Matrix2x2bNormalized, + + /** + * @ref Matrix2x2s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector2sNormalized tightly following each + * other and bound to consecutive locations. + */ + Matrix2x2sNormalized, + + /** + * @ref Matrix2x3. + * + * Same as two @ref VertexFormat::Vector3 tightly following each other and + * bound to consecutive locations. + */ + Matrix2x3, + + /** + * @ref Matrix2x3h. + * + * Same as two @ref VertexFormat::Vector3h tightly following each other and + * bound to consecutive locations. Note that this type doesn't have the + * columns four-byte aligned, which may negatively affect performance on + * some APIs --- prefer to use @ref VertexFormat::Matrix2x3hAligned + * instead. + */ + Matrix2x3h, + + /** + * @ref Matrix2x3d. + * + * Same as two @ref VertexFormat::Vector3d tightly following each other and + * bound to consecutive locations. + */ + Matrix2x3d, + + /** + * @ref Matrix2x3b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector3bNormalized tightly following each + * other and bound to consecutive locations. Note that this type doesn't + * have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix2x3bNormalizedAligned instead. + */ + Matrix2x3bNormalized, + + /** + * @ref Matrix2x3s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector3sNormalized tightly following each + * other and bound to consecutive locations. Note that this type doesn't + * have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix2x3sNormalizedAligned instead. + */ + Matrix2x3sNormalized, + + /** + * @ref Matrix2x4. + * + * Same as two @ref VertexFormat::Vector4 tightly following each other and + * bound to consecutive locations. + */ + Matrix2x4, + + /** + * @ref Matrix2x4h. + * + * Same as two @ref VertexFormat::Vector4h tightly following each other and + * bound to consecutive locations. + */ + Matrix2x4h, + + /** + * @ref Matrix2x4d. + * + * Same as two @ref VertexFormat::Vector4d tightly following each other and + * bound to consecutive locations. + */ + Matrix2x4d, + + /** + * @ref Matrix2x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector4bNormalized tightly following each + * other and bound to consecutive locations. + */ + Matrix2x4bNormalized, + + /** + * @ref Matrix2x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as two @ref VertexFormat::Vector4sNormalized tightly following each + * other and bound to consecutive locations. + */ + Matrix2x4sNormalized, + + /** + * @ref Matrix2x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom two rows ignored. A variant of + * @ref VertexFormat::Matrix2x2bNormalized that has columns four-byte + * aligned. + * + * Same as two @ref VertexFormat::Vector2bNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix2x2bNormalizedAligned, + + /** + * @ref Matrix2x4h, with bottom row ignored. A variant of + * @ref VertexFormat::Matrix2x3h that has columns four-byte aligned. + * + * Same as two @ref VertexFormat::Vector3s following each other with a + * 2-byte gap in between, bound to consecutive locations. + */ + Matrix2x3hAligned, + + /** + * @ref Matrix2x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix2x3bNormalized that has columns four-byte + * aligned. + * + * Same as two @ref VertexFormat::Vector3bNormalized following each other + * with a 1-byte gap in between, bound to consecutive locations. + */ + Matrix2x3bNormalizedAligned, + + /** + * @ref Matrix2x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix2x3sNormalized that has columns four-byte + * aligned. + * + * Same as two @ref VertexFormat::Vector3sNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix2x3sNormalizedAligned, + + /** + * @ref Matrix3x2. + * + * Same as three @ref VertexFormat::Vector2 tightly following each other + * and bound to consecutive locations. + */ + Matrix3x2, + + /** + * @ref Matrix3x2h. + * + * Same as three @ref VertexFormat::Vector2h tightly following each other + * and bound to consecutive locations. + */ + Matrix3x2h, + + /** + * @ref Matrix3x2d. + * + * Same as three @ref VertexFormat::Vector2d tightly following each other + * and bound to consecutive locations. + */ + Matrix3x2d, + + /** + * @ref Matrix3x2b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector2bNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix3x2bNormalizedAligned instead. + */ + Matrix3x2bNormalized, + + /** + * @ref Matrix3x2s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector2sNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix3x2sNormalized, + + /** + * @ref Matrix3x3 or @ref Matrix3. + * + * Same as three @ref VertexFormat::Vector3 tightly following each other + * and bound to consecutive locations. + */ + Matrix3x3, + + /** + * @ref Matrix3x3h. + * + * Same as three @ref VertexFormat::Vector3h tightly following each other + * and bound to consecutive locations. Note that this type doesn't have the + * columns four-byte aligned, which may negatively affect performance on + * some APIs --- prefer to use @ref VertexFormat::Matrix3x3hAligned + * instead. + */ + Matrix3x3h, + + /** + * @ref Matrix3x3d or @ref Matrix3d. + * + * Same as three @ref VertexFormat::Vector3d tightly following each other + * and bound to consecutive locations. + */ + Matrix3x3d, + + /** + * @ref Matrix3x3b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector3bNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix3x3bNormalizedAligned instead. + */ + Matrix3x3bNormalized, + + /** + * @ref Matrix3x3s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector3sNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix3x3sNormalizedAligned instead. + */ + Matrix3x3sNormalized, + + /** + * @ref Matrix3x4. + * + * Same as three @ref VertexFormat::Vector4 tightly following each other + * and bound to consecutive locations. + */ + Matrix3x4, + + /** + * @ref Matrix3x4h. + * + * Same as three @ref VertexFormat::Vector4h tightly following each other + * and bound to consecutive locations. + */ + Matrix3x4h, + + /** + * @ref Matrix3x4d. + * + * Same as three @ref VertexFormat::Vector4d tightly following each other + * and bound to consecutive locations. + */ + Matrix3x4d, + + /** + * @ref Matrix3x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector4bNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix3x4bNormalized, + + /** + * @ref Matrix3x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as three @ref VertexFormat::Vector4sNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix3x4sNormalized, + + /** + * @ref Matrix3x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom two rows ignored. A variant of + * @ref VertexFormat::Matrix3x2bNormalized that has columns four-byte + * aligned. + * + * Same as three @ref VertexFormat::Vector2bNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix3x2bNormalizedAligned, + + /** + * @ref Matrix3x4h, with bottom row ignored. A variant of + * @ref VertexFormat::Matrix3x3h that has columns four-byte aligned. + * + * Same as three @ref VertexFormat::Vector3s following each other with a + * 2-byte gap in between, bound to consecutive locations. + */ + Matrix3x3hAligned, + + /** + * @ref Matrix3x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix3x3bNormalized that has columns four-byte + * aligned. + * + * Same as three @ref VertexFormat::Vector3bNormalized following each other + * with a 1-byte gap in between, bound to consecutive locations. + */ + Matrix3x3bNormalizedAligned, + + /** + * @ref Matrix3x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix3x3sNormalized that has columns four-byte + * aligned. + * + * Same as three @ref VertexFormat::Vector3sNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix3x3sNormalizedAligned, + + /** + * @ref Matrix4x2. + * + * Same as four @ref VertexFormat::Vector2 tightly following each other and + * bound to consecutive locations. + */ + Matrix4x2, + + /** + * @ref Matrix4x2h. + * + * Same as four @ref VertexFormat::Vector2h tightly following each other + * and bound to consecutive locations. + */ + Matrix4x2h, + + /** + * @ref Matrix4x2d. + * + * Same as four @ref VertexFormat::Vector2d tightly following each other + * and bound to consecutive locations. + */ + Matrix4x2d, + + /** + * @ref Matrix4x2b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector2bNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix4x2bNormalizedAligned instead. + */ + Matrix4x2bNormalized, + + /** + * @ref Matrix4x2s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector2sNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix4x2sNormalized, + + /** + * @ref Matrix4x3. + * + * Same as four @ref VertexFormat::Vector3 tightly following each other and + * bound to consecutive locations. + */ + Matrix4x3, + + /** + * @ref Matrix4x3h. + * + * Same as four @ref VertexFormat::Vector3h tightly following each other + * and bound to consecutive locations. Note that this type doesn't have the + * columns four-byte aligned, which may negatively affect performance on + * some APIs --- prefer to use @ref VertexFormat::Matrix4x3hAligned + * instead. + */ + Matrix4x3h, + + /** + * @ref Matrix4x3d. + * + * Same as four @ref VertexFormat::Vector3d tightly following each other + * and bound to consecutive locations. + */ + Matrix4x3d, + + /** + * @ref Matrix4x3b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector3bNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix4x3bNormalizedAligned instead. + */ + Matrix4x3bNormalized, + + /** + * @ref Matrix4x3s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector3sNormalized tightly following + * each other and bound to consecutive locations. Note that this type + * doesn't have the columns four-byte aligned, which may negatively affect + * performance --- prefer to use + * @ref VertexFormat::Matrix4x3sNormalizedAligned instead. + */ + Matrix4x3sNormalized, + + /** + * @ref Matrix4x4 or @ref Matrix4. + * + * Same as four @ref VertexFormat::Vector4 tightly following each other + * and bound to consecutive locations. + */ + Matrix4x4, + + /** + * @ref Matrix4x4h. + * + * Same as four @ref VertexFormat::Vector4h tightly following each other + * and bound to consecutive locations. + */ + Matrix4x4h, + + /** + * @ref Matrix4x4d. + * + * Same as four @ref VertexFormat::Vector4d tightly following each other + * and bound to consecutive locations. + */ + Matrix4x4d, + + /** + * @ref Matrix4x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector4bNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix4x4bNormalized, + + /** + * @ref Matrix4x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$. + * + * Same as four @ref VertexFormat::Vector4sNormalized tightly following + * each other and bound to consecutive locations. + */ + Matrix4x4sNormalized, + + /** + * @ref Matrix4x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom two rows ignored. A variant of + * @ref VertexFormat::Matrix4x2bNormalized that has columns four-byte + * aligned. + * + * Same as four @ref VertexFormat::Vector2bNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix4x2bNormalizedAligned, + + /** + * @ref Matrix4x4h, with bottom row ignored. A variant of + * @ref VertexFormat::Matrix3x3h that has columns four-byte aligned. + * + * Same as four @ref VertexFormat::Vector3s following each other with a + * 2-byte gap in between, bound to consecutive locations. + */ + Matrix4x3hAligned, + + /** + * @ref Matrix4x4b, with range @f$ [-127, 127] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix4x3bNormalized that has columns four-byte + * aligned. + * + * Same as four @ref VertexFormat::Vector3bNormalized following each other + * with a 1-byte gap in between, bound to consecutive locations. + */ + Matrix4x3bNormalizedAligned, + + /** + * @ref Matrix4x4s, with range @f$ [-32767, 32767] @f$ interpreted as + * @f$ [-1.0, 1.0] @f$ and bottom row ignored. A variant of + * @ref VertexFormat::Matrix4x3sNormalized that has columns four-byte + * aligned. + * + * Same as four @ref VertexFormat::Vector3sNormalized following each other + * with a 2-byte gap in between, bound to consecutive locations. + */ + Matrix4x3sNormalizedAligned }; /** @@ -863,6 +1403,25 @@ Returns @cpp 1 @ce for scalar types and e.g. @cpp 3 @ce for */ MAGNUM_EXPORT UnsignedInt vertexFormatComponentCount(VertexFormat format); +/** +@brief Vector count of given vertex format +@m_since_latest + +Returns @cpp 1 @ce for scalar and vector types and e.g. @cpp 3 @ce for +@ref VertexFormat::Matrix3x2d. +*/ +MAGNUM_EXPORT UnsignedInt vertexFormatVectorCount(VertexFormat format); + +/** +@brief Vector stride of given vertex format +@m_since_latest + +Returns type size for scalar and vector types and e.g. @cpp 8 @ce for +@ref VertexFormat::Matrix2x3hAligned (but @cpp 6 @ce for +@ref VertexFormat::Matrix2x3h). +*/ +MAGNUM_EXPORT UnsignedInt vertexFormatVectorStride(VertexFormat format); + /** @brief Component count of given vertex format @m_since_latest @@ -888,6 +1447,22 @@ normalization. Expects that @p componentCount is not larger than @cpp 4 @ce and */ MAGNUM_EXPORT VertexFormat vertexFormat(VertexFormat format, UnsignedInt componentCount, bool normalized); +/** +@brief Assemble a matrix vertex format from parts +@m_since_latest + +Converts @p format to a new format of desired component and vertex count and +normalization. Expects that both @p vectorCount and @p componentCount is either +@cpp 2 @ce, @cpp 3 @ce or @cpp 4 @ce, and @p format is floating-point or +8-/16-bit signed integer. +@see @ref vertexFormatComponentFormat(), + @ref vertexFormatComponentCount(), + @ref vertexFormatVectorCount(), + @ref vertexFormatVectorStride(), + @ref isVertexFormatNormalized() +*/ +MAGNUM_EXPORT VertexFormat vertexFormat(VertexFormat format, UnsignedInt vectorCount, UnsignedInt componentCount, bool aligned); + } namespace Corrade { namespace Utility { diff --git a/src/Magnum/Vk/Enums.h b/src/Magnum/Vk/Enums.h index 230fd0aae..8dc1c59b1 100644 --- a/src/Magnum/Vk/Enums.h +++ b/src/Magnum/Vk/Enums.h @@ -95,7 +95,10 @@ Some Vulkan targets don't support all generic vertex formats. Returns @cpp false @ce if current target can't support such format, @cpp true @ce otherwise. Moreover, returns @cpp true @ce also for all formats that are @ref isVertexFormatImplementationSpecific(). The @p format value is expected -to be valid. +to be valid. Note that for matrix formats the function only returns a +corresponding vector type, and the user is expected to bind the remaining +vectors to consecutive attribute locations based on what +@ref vertexFormatVectorCount() and @ref vertexFormatVectorStride() return. @note Support of some formats depends on presence of a particular Vulkan extension. Such check is outside of the scope of this function and you are diff --git a/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp b/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp index 2efe832bc..8e4ea054c 100644 --- a/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp +++ b/src/Magnum/Vk/Implementation/vertexFormatMapping.hpp @@ -77,4 +77,61 @@ _c(Vector4s, R16G16B16A16_SINT) _c(Vector4sNormalized, R16G16B16A16_SNORM) _c(Vector4ui, R32G32B32A32_UINT) _c(Vector4i, R32G32B32A32_SINT) +_c(Matrix2x2, R32G32_SFLOAT) +_c(Matrix2x2h, R16G16_SFLOAT) +_c(Matrix2x2d, R64G64_SFLOAT) +_c(Matrix2x2bNormalized, R8G8_SNORM) +_c(Matrix2x2sNormalized, R16G16_SNORM) +_c(Matrix2x3, R32G32B32_SFLOAT) +_c(Matrix2x3h, R16G16B16_SFLOAT) +_c(Matrix2x3d, R64G64B64_SFLOAT) +_c(Matrix2x3bNormalized, R8G8B8_SNORM) +_c(Matrix2x3sNormalized, R16G16B16_SNORM) +_c(Matrix2x4, R32G32B32A32_SFLOAT) +_c(Matrix2x4h, R16G16B16A16_SFLOAT) +_c(Matrix2x4d, R64G64B64A64_SFLOAT) +_c(Matrix2x4bNormalized, R8G8B8A8_SNORM) +_c(Matrix2x4sNormalized, R16G16B16A16_SNORM) +_c(Matrix2x2bNormalizedAligned, R8G8_SNORM) +_c(Matrix2x3hAligned, R16G16B16_SFLOAT) +_c(Matrix2x3bNormalizedAligned, R8G8B8_SNORM) +_c(Matrix2x3sNormalizedAligned, R16G16B16_SNORM) +_c(Matrix3x2, R32G32_SFLOAT) +_c(Matrix3x2h, R16G16_SFLOAT) +_c(Matrix3x2d, R64G64_SFLOAT) +_c(Matrix3x2bNormalized, R8G8_SNORM) +_c(Matrix3x2sNormalized, R16G16_SNORM) +_c(Matrix3x3, R32G32B32_SFLOAT) +_c(Matrix3x3h, R16G16B16_SFLOAT) +_c(Matrix3x3d, R64G64B64_SFLOAT) +_c(Matrix3x3bNormalized, R8G8B8_SNORM) +_c(Matrix3x3sNormalized, R16G16B16_SNORM) +_c(Matrix3x4, R32G32B32A32_SFLOAT) +_c(Matrix3x4h, R16G16B16A16_SFLOAT) +_c(Matrix3x4d, R64G64B64A64_SFLOAT) +_c(Matrix3x4bNormalized, R8G8B8A8_SNORM) +_c(Matrix3x4sNormalized, R16G16B16A16_SNORM) +_c(Matrix3x2bNormalizedAligned, R8G8_SNORM) +_c(Matrix3x3hAligned, R16G16B16_SFLOAT) +_c(Matrix3x3bNormalizedAligned, R8G8B8_SNORM) +_c(Matrix3x3sNormalizedAligned, R16G16B16_SNORM) +_c(Matrix4x2, R32G32_SFLOAT) +_c(Matrix4x2h, R16G16_SFLOAT) +_c(Matrix4x2d, R64G64_SFLOAT) +_c(Matrix4x2bNormalized, R8G8_SNORM) +_c(Matrix4x2sNormalized, R16G16_SNORM) +_c(Matrix4x3, R32G32B32_SFLOAT) +_c(Matrix4x3h, R16G16B16_SFLOAT) +_c(Matrix4x3d, R64G64B64_SFLOAT) +_c(Matrix4x3bNormalized, R8G8B8_SNORM) +_c(Matrix4x3sNormalized, R16G16B16_SNORM) +_c(Matrix4x4, R32G32B32A32_SFLOAT) +_c(Matrix4x4h, R16G16B16A16_SFLOAT) +_c(Matrix4x4d, R64G64B64A64_SFLOAT) +_c(Matrix4x4bNormalized, R8G8B8A8_SNORM) +_c(Matrix4x4sNormalized, R16G16B16A16_SNORM) +_c(Matrix4x2bNormalizedAligned, R8G8_SNORM) +_c(Matrix4x3hAligned, R16G16B16_SFLOAT) +_c(Matrix4x3bNormalizedAligned, R8G8B8_SNORM) +_c(Matrix4x3sNormalizedAligned, R16G16B16_SNORM) #endif diff --git a/src/Magnum/Vk/Test/EnumsTest.cpp b/src/Magnum/Vk/Test/EnumsTest.cpp index ee33252f9..e7a783b7c 100644 --- a/src/Magnum/Vk/Test/EnumsTest.cpp +++ b/src/Magnum/Vk/Test/EnumsTest.cpp @@ -251,6 +251,7 @@ void EnumsTest::mapVkFormatVertexFormat() { /* Touchstone verification */ CORRADE_VERIFY(hasVkFormat(Magnum::VertexFormat::Vector3us)); CORRADE_COMPARE(vkFormat(Magnum::VertexFormat::Vector3us), VK_FORMAT_R16G16B16_UINT); + CORRADE_COMPARE(vkFormat(Magnum::VertexFormat::Matrix2x3bNormalizedAligned), VK_FORMAT_R8G8B8_SNORM); /* This goes through the first 16 bits, which should be enough. Going through 32 bits takes 8 seconds, too much. */