Browse Source

Shaders: properly test uniform struct trivial copyability.

Somehow this wasn't done for any of the types and then the lack of tests
got copied to the Ui library as well. Sigh.
pull/680/head
Vladimír Vondruš 9 months ago
parent
commit
43c552aa01
  1. 34
      src/Magnum/Shaders/Test/DistanceFieldVectorTest.cpp
  2. 38
      src/Magnum/Shaders/Test/FlatTest.cpp
  3. 79
      src/Magnum/Shaders/Test/GenericTest.cpp
  4. 36
      src/Magnum/Shaders/Test/LineTest.cpp
  5. 60
      src/Magnum/Shaders/Test/MeshVisualizerTest.cpp
  6. 60
      src/Magnum/Shaders/Test/PhongTest.cpp
  7. 34
      src/Magnum/Shaders/Test/VectorTest.cpp

34
src/Magnum/Shaders/Test/DistanceFieldVectorTest.cpp

@ -38,11 +38,13 @@ struct DistanceFieldVectorTest: TestSuite::Tester {
void drawUniformConstructDefault();
void drawUniformConstructNoInit();
void drawUniformConstructCopy();
void drawUniformSetters();
void drawUniformMaterialIdPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
};
@ -52,11 +54,13 @@ DistanceFieldVectorTest::DistanceFieldVectorTest() {
&DistanceFieldVectorTest::drawUniformConstructDefault,
&DistanceFieldVectorTest::drawUniformConstructNoInit,
&DistanceFieldVectorTest::drawUniformConstructCopy,
&DistanceFieldVectorTest::drawUniformSetters,
&DistanceFieldVectorTest::drawUniformMaterialIdPacking,
&DistanceFieldVectorTest::materialUniformConstructDefault,
&DistanceFieldVectorTest::materialUniformConstructNoInit,
&DistanceFieldVectorTest::materialUniformConstructCopy,
&DistanceFieldVectorTest::materialUniformSetters});
}
@ -124,6 +128,20 @@ void DistanceFieldVectorTest::drawUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, DistanceFieldVectorDrawUniform>::value);
}
void DistanceFieldVectorTest::drawUniformConstructCopy() {
/* Testing only some fields, should be enough */
DistanceFieldVectorDrawUniform a;
a.materialId = 76;
DistanceFieldVectorDrawUniform b = a;
CORRADE_COMPARE(b.materialId, 76);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<DistanceFieldVectorDrawUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<DistanceFieldVectorDrawUniform>::value);
#endif
}
void DistanceFieldVectorTest::drawUniformSetters() {
DistanceFieldVectorDrawUniform a;
a.setMaterialId(76);
@ -196,6 +214,22 @@ void DistanceFieldVectorTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, DistanceFieldVectorMaterialUniform>::value);
}
void DistanceFieldVectorTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
DistanceFieldVectorMaterialUniform a;
a.color = 0x354565fc_rgbaf;
a.outlineEnd = 0.37f;
DistanceFieldVectorMaterialUniform b = a;
CORRADE_COMPARE(b.color, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.outlineEnd, 0.37f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<DistanceFieldVectorMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<DistanceFieldVectorMaterialUniform>::value);
#endif
}
void DistanceFieldVectorTest::materialUniformSetters() {
DistanceFieldVectorMaterialUniform a;
a.setColor(0x354565fc_rgbaf)

38
src/Magnum/Shaders/Test/FlatTest.cpp

@ -38,11 +38,13 @@ struct FlatTest: TestSuite::Tester {
void drawUniformConstructDefault();
void drawUniformConstructNoInit();
void drawUniformConstructCopy();
void drawUniformSetters();
void drawUniformMaterialIdPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
};
@ -52,11 +54,13 @@ FlatTest::FlatTest() {
&FlatTest::drawUniformConstructDefault,
&FlatTest::drawUniformConstructNoInit,
&FlatTest::drawUniformConstructCopy,
&FlatTest::drawUniformSetters,
&FlatTest::drawUniformMaterialIdPacking,
&FlatTest::materialUniformConstructDefault,
&FlatTest::materialUniformConstructNoInit,
&FlatTest::materialUniformConstructCopy,
&FlatTest::materialUniformSetters});
}
@ -140,6 +144,24 @@ void FlatTest::drawUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, FlatDrawUniform>::value);
}
void FlatTest::drawUniformConstructCopy() {
/* Testing only some fields, should be enough */
FlatDrawUniform a;
a.materialId = 5;
a.objectId = 7;
a.perInstanceJointCount = 9;
FlatDrawUniform b = a;
CORRADE_COMPARE(b.materialId, 5);
CORRADE_COMPARE(b.objectId, 7);
CORRADE_COMPARE(b.perInstanceJointCount, 9);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<FlatDrawUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<FlatDrawUniform>::value);
#endif
}
void FlatTest::drawUniformSetters() {
FlatDrawUniform a;
a.setMaterialId(5)
@ -214,6 +236,22 @@ void FlatTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, FlatMaterialUniform>::value);
}
void FlatTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
FlatMaterialUniform a;
a.color = 0x354565fc_rgbaf;
a.alphaMask = 0.7f;
FlatMaterialUniform b = a;
CORRADE_COMPARE(b.color, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.alphaMask, 0.7f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<FlatMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<FlatMaterialUniform>::value);
#endif
}
void FlatTest::materialUniformSetters() {
FlatMaterialUniform a;
a.setColor(0x354565fc_rgbaf)

79
src/Magnum/Shaders/Test/GenericTest.cpp

@ -38,22 +38,27 @@ struct GenericTest: TestSuite::Tester {
void projectionUniform2DConstructDefault();
void projectionUniform2DConstructNoInit();
void projectionUniform2DConstructCopy();
void projectionUniform2DSetters();
void projectionUniform3DConstructDefault();
void projectionUniform3DConstructNoInit();
void projectionUniform3DConstructCopy();
void projectionUniform3DSetters();
void transformationUniform2DConstructDefault();
void transformationUniform2DConstructNoInit();
void transformationUniform2DConstructCopy();
void transformationUniform2DSetters();
void transformationUniform3DConstructDefault();
void transformationUniform3DConstructNoInit();
void transformationUniform3DConstructCopy();
void transformationUniform3DSetters();
void textureTransformationUniformConstructDefault();
void textureTransformationUniformConstructNoInit();
void textureTransformationUniformConstructCopy();
void textureTransformationUniformSetters();
};
@ -66,22 +71,27 @@ GenericTest::GenericTest() {
&GenericTest::projectionUniform2DConstructDefault,
&GenericTest::projectionUniform2DConstructNoInit,
&GenericTest::projectionUniform2DConstructCopy,
&GenericTest::projectionUniform2DSetters,
&GenericTest::projectionUniform3DConstructDefault,
&GenericTest::projectionUniform3DConstructNoInit,
&GenericTest::projectionUniform3DConstructCopy,
&GenericTest::projectionUniform3DSetters,
&GenericTest::transformationUniform2DConstructDefault,
&GenericTest::transformationUniform2DConstructNoInit,
&GenericTest::transformationUniform2DConstructCopy,
&GenericTest::transformationUniform2DSetters,
&GenericTest::transformationUniform3DConstructDefault,
&GenericTest::transformationUniform3DConstructNoInit,
&GenericTest::transformationUniform3DConstructCopy,
&GenericTest::transformationUniform3DSetters,
&GenericTest::textureTransformationUniformConstructDefault,
&GenericTest::textureTransformationUniformConstructNoInit,
&GenericTest::textureTransformationUniformConstructCopy,
&GenericTest::textureTransformationUniformSetters});
}
@ -173,6 +183,19 @@ void GenericTest::projectionUniform2DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, ProjectionUniform2D>::value);
}
void GenericTest::projectionUniform2DConstructCopy() {
ProjectionUniform2D a;
a.projectionMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
ProjectionUniform2D b = a;
CORRADE_COMPARE(b.projectionMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<ProjectionUniform2D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<ProjectionUniform2D>::value);
#endif
}
void GenericTest::projectionUniform2DSetters() {
ProjectionUniform2D a;
a.setProjectionMatrix(Matrix3::projection({2.5f, 3.0f}));
@ -242,6 +265,19 @@ void GenericTest::projectionUniform3DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, ProjectionUniform3D>::value);
}
void GenericTest::projectionUniform3DConstructCopy() {
ProjectionUniform3D a;
a.projectionMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
ProjectionUniform3D b = a;
CORRADE_COMPARE(b.projectionMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<ProjectionUniform3D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<ProjectionUniform3D>::value);
#endif
}
void GenericTest::projectionUniform3DSetters() {
ProjectionUniform3D a;
a.setProjectionMatrix(Matrix4::perspectiveProjection(35.0_degf, 1.5f, 0.1f, 100.0f));
@ -303,6 +339,19 @@ void GenericTest::transformationUniform2DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, TransformationUniform2D>::value);
}
void GenericTest::transformationUniform2DConstructCopy() {
TransformationUniform2D a;
a.transformationMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
TransformationUniform2D b = a;
CORRADE_COMPARE(b.transformationMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<TransformationUniform2D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<TransformationUniform2D>::value);
#endif
}
void GenericTest::transformationUniform2DSetters() {
TransformationUniform2D a;
a.setTransformationMatrix(Matrix3::translation({2.5f, 3.0f}));
@ -372,6 +421,19 @@ void GenericTest::transformationUniform3DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, TransformationUniform3D>::value);
}
void GenericTest::transformationUniform3DConstructCopy() {
TransformationUniform3D a;
a.transformationMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
TransformationUniform3D b = a;
CORRADE_COMPARE(b.transformationMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<TransformationUniform3D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<TransformationUniform3D>::value);
#endif
}
void GenericTest::transformationUniform3DSetters() {
TransformationUniform3D a;
a.setTransformationMatrix(Matrix4::translation({3.5f, 2.0f, -1.0f}));
@ -441,6 +503,23 @@ void GenericTest::textureTransformationUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, TextureTransformationUniform>::value);
}
void GenericTest::textureTransformationUniformConstructCopy() {
TextureTransformationUniform a;
a.rotationScaling[1] = {2.5f, -3.0f};
a.offset = {2.7f, 0.3f};
a.layer = 37;
TextureTransformationUniform b = a;
CORRADE_COMPARE(b.rotationScaling[1], (Vector2{2.5f, -3.0f}));
CORRADE_COMPARE(b.offset, (Vector2{2.7f, 0.3f}));
CORRADE_COMPARE(b.layer, 37);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<TextureTransformationUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<TextureTransformationUniform>::value);
#endif
}
void GenericTest::textureTransformationUniformSetters() {
TextureTransformationUniform a;
a.setTextureMatrix(Matrix3::translation({2.6f, 0.3f})*

36
src/Magnum/Shaders/Test/LineTest.cpp

@ -42,11 +42,13 @@ struct LineTest: TestSuite::Tester {
void drawUniformConstructDefault();
void drawUniformConstructNoInit();
void drawUniformConstructCopy();
void drawUniformSetters();
void drawUniformMaterialIdPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
/* Miter limit tests are copied verbatim between the Shaders and Ui
@ -93,11 +95,13 @@ LineTest::LineTest() {
&LineTest::drawUniformConstructDefault,
&LineTest::drawUniformConstructNoInit,
&LineTest::drawUniformConstructCopy,
&LineTest::drawUniformSetters,
&LineTest::drawUniformMaterialIdPacking,
&LineTest::materialUniformConstructDefault,
&LineTest::materialUniformConstructNoInit,
&LineTest::materialUniformConstructCopy,
&LineTest::materialUniformSetters,
&LineTest::materialUniformMiterLimit});
@ -184,6 +188,22 @@ void LineTest::drawUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, LineDrawUniform>::value);
}
void LineTest::drawUniformConstructCopy() {
/* Testing only some fields, should be enough */
LineDrawUniform a;
a.materialId = 5;
a.objectId = 7;
LineDrawUniform b = a;
CORRADE_COMPARE(b.materialId, 5);
CORRADE_COMPARE(b.objectId, 7);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<LineDrawUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<LineDrawUniform>::value);
#endif
}
void LineTest::drawUniformSetters() {
LineDrawUniform a;
a.setMaterialId(5)
@ -258,6 +278,22 @@ void LineTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, LineMaterialUniform>::value);
}
void LineTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
LineMaterialUniform a;
a.color = 0x354565fc_rgbaf;
a.smoothness = 7.0f;
LineMaterialUniform b = a;
CORRADE_COMPARE(b.color, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.smoothness, 7.0f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<LineMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<LineMaterialUniform>::value);
#endif
}
void LineTest::materialUniformSetters() {
LineMaterialUniform a;
a.setBackgroundColor(0x01020304_rgbaf)

60
src/Magnum/Shaders/Test/MeshVisualizerTest.cpp

@ -39,16 +39,19 @@ struct MeshVisualizerTest: TestSuite::Tester {
void drawUniform2DConstructDefault();
void drawUniform2DConstructNoInit();
void drawUniform2DConstructCopy();
void drawUniform2DSetters();
void drawUniform2DMaterialIdPacking();
void drawUniform3DConstructDefault();
void drawUniform3DConstructNoInit();
void drawUniform3DConstructCopy();
void drawUniform3DSetters();
void drawUniform3DMaterialIdPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
};
@ -59,16 +62,19 @@ MeshVisualizerTest::MeshVisualizerTest() {
&MeshVisualizerTest::drawUniform2DConstructDefault,
&MeshVisualizerTest::drawUniform2DConstructNoInit,
&MeshVisualizerTest::drawUniform2DConstructCopy,
&MeshVisualizerTest::drawUniform2DSetters,
&MeshVisualizerTest::drawUniform2DMaterialIdPacking,
&MeshVisualizerTest::drawUniform3DConstructDefault,
&MeshVisualizerTest::drawUniform3DConstructNoInit,
&MeshVisualizerTest::drawUniform3DConstructCopy,
&MeshVisualizerTest::drawUniform3DSetters,
&MeshVisualizerTest::drawUniform3DMaterialIdPacking,
&MeshVisualizerTest::materialUniformConstructDefault,
&MeshVisualizerTest::materialUniformConstructNoInit,
&MeshVisualizerTest::materialUniformConstructCopy,
&MeshVisualizerTest::materialUniformSetters});
}
@ -155,6 +161,24 @@ void MeshVisualizerTest::drawUniform2DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, MeshVisualizerDrawUniform2D>::value);
}
void MeshVisualizerTest::drawUniform2DConstructCopy() {
/* Testing only some fields, should be enough */
MeshVisualizerDrawUniform2D a;
a.materialId = 73;
a.objectId = 7;
a.perInstanceJointCount = 9;
MeshVisualizerDrawUniform2D b = a;
CORRADE_COMPARE(b.materialId, 73);
CORRADE_COMPARE(b.objectId, 7);
CORRADE_COMPARE(b.perInstanceJointCount, 9);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<MeshVisualizerDrawUniform2D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<MeshVisualizerDrawUniform2D>::value);
#endif
}
void MeshVisualizerTest::drawUniform2DSetters() {
MeshVisualizerDrawUniform2D a;
a.setMaterialId(73)
@ -261,6 +285,26 @@ void MeshVisualizerTest::drawUniform3DConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, MeshVisualizerDrawUniform3D>::value);
}
void MeshVisualizerTest::drawUniform3DConstructCopy() {
/* Testing only some fields, should be enough */
MeshVisualizerDrawUniform3D a;
a.normalMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
a.materialId = 5;
a.objectId = 7;
a.perInstanceJointCount = 9;
MeshVisualizerDrawUniform3D b = a;
CORRADE_COMPARE(b.normalMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
CORRADE_COMPARE(b.materialId, 5);
CORRADE_COMPARE(b.objectId, 7);
CORRADE_COMPARE(b.perInstanceJointCount, 9);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<MeshVisualizerDrawUniform3D>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<MeshVisualizerDrawUniform3D>::value);
#endif
}
void MeshVisualizerTest::drawUniform3DSetters() {
MeshVisualizerDrawUniform3D a;
a.setNormalMatrix(Matrix4::rotationX(90.0_degf).normalMatrix())
@ -365,6 +409,22 @@ void MeshVisualizerTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, MeshVisualizerMaterialUniform>::value);
}
void MeshVisualizerTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
MeshVisualizerMaterialUniform a;
a.color = 0x354565fc_rgbaf;
a.lineWidth = 0.765f;
MeshVisualizerMaterialUniform b = a;
CORRADE_COMPARE(b.color, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.lineWidth, 0.765f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<MeshVisualizerMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<MeshVisualizerMaterialUniform>::value);
#endif
}
void MeshVisualizerTest::materialUniformSetters() {
MeshVisualizerMaterialUniform a;
a.setColor(0x354565fc_rgbaf)

60
src/Magnum/Shaders/Test/PhongTest.cpp

@ -39,15 +39,18 @@ struct PhongTest: TestSuite::Tester {
void drawUniformConstructDefault();
void drawUniformConstructNoInit();
void drawUniformConstructCopy();
void drawUniformSetters();
void drawUniformPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
void lightUniformConstructDefault();
void lightUniformConstructNoInit();
void lightUniformConstructCopy();
void lightUniformSetters();
};
@ -58,15 +61,18 @@ PhongTest::PhongTest() {
&PhongTest::drawUniformConstructDefault,
&PhongTest::drawUniformConstructNoInit,
&PhongTest::drawUniformConstructCopy,
&PhongTest::drawUniformSetters,
&PhongTest::drawUniformPacking,
&PhongTest::materialUniformConstructDefault,
&PhongTest::materialUniformConstructNoInit,
&PhongTest::materialUniformConstructCopy,
&PhongTest::materialUniformSetters,
&PhongTest::lightUniformConstructDefault,
&PhongTest::lightUniformConstructNoInit,
&PhongTest::lightUniformConstructCopy,
&PhongTest::lightUniformSetters});
}
@ -183,6 +189,26 @@ void PhongTest::drawUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, PhongDrawUniform>::value);
}
void PhongTest::drawUniformConstructCopy() {
/* Testing only some fields, should be enough */
PhongDrawUniform a;
a.normalMatrix[2] = {1.5f, 0.3f, 3.1f, 0.5f};
a.materialId = 5;
a.lightCount = 7;
a.perInstanceJointCount = 9;
PhongDrawUniform b = a;
CORRADE_COMPARE(b.normalMatrix[2], (Vector4{1.5f, 0.3f, 3.1f, 0.5f}));
CORRADE_COMPARE(b.materialId, 5);
CORRADE_COMPARE(b.lightCount, 7);
CORRADE_COMPARE(b.perInstanceJointCount, 9);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<PhongDrawUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<PhongDrawUniform>::value);
#endif
}
void PhongTest::drawUniformSetters() {
PhongDrawUniform a;
a.setNormalMatrix(Matrix4::rotationX(90.0_degf).normalMatrix())
@ -290,6 +316,24 @@ void PhongTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, PhongMaterialUniform>::value);
}
void PhongTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
PhongMaterialUniform a;
a.diffuseColor = 0x354565fc_rgbaf;
a.normalTextureScale = 0.4f;
a.alphaMask = 7.0f;
PhongMaterialUniform b = a;
CORRADE_COMPARE(b.diffuseColor, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.normalTextureScale, 0.4f);
CORRADE_COMPARE(b.alphaMask, 7.0f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<PhongMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<PhongMaterialUniform>::value);
#endif
}
void PhongTest::materialUniformSetters() {
PhongMaterialUniform a;
a.setAmbientColor(0xff3366cc_rgbaf)
@ -360,6 +404,22 @@ void PhongTest::lightUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, PhongLightUniform>::value);
}
void PhongTest::lightUniformConstructCopy() {
/* Testing only some fields, should be enough */
PhongLightUniform a;
a.color = 0x354565_rgbf;
a.range = 7.0f;
PhongLightUniform b = a;
CORRADE_COMPARE(b.color, 0x354565_rgbf);
CORRADE_COMPARE(b.range, 7.0f);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<PhongLightUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<PhongLightUniform>::value);
#endif
}
void PhongTest::lightUniformSetters() {
PhongLightUniform a;
a.setPosition({2.5f, 3.6f, 0.7f, 1.1f})

34
src/Magnum/Shaders/Test/VectorTest.cpp

@ -38,11 +38,13 @@ struct VectorTest: TestSuite::Tester {
void drawUniformConstructDefault();
void drawUniformConstructNoInit();
void drawUniformConstructCopy();
void drawUniformSetters();
void drawUniformMaterialIdPacking();
void materialUniformConstructDefault();
void materialUniformConstructNoInit();
void materialUniformConstructCopy();
void materialUniformSetters();
};
@ -52,11 +54,13 @@ VectorTest::VectorTest() {
&VectorTest::drawUniformConstructDefault,
&VectorTest::drawUniformConstructNoInit,
&VectorTest::drawUniformConstructCopy,
&VectorTest::drawUniformSetters,
&VectorTest::drawUniformMaterialIdPacking,
&VectorTest::materialUniformConstructDefault,
&VectorTest::materialUniformConstructNoInit,
&VectorTest::materialUniformConstructCopy,
&VectorTest::materialUniformSetters});
}
@ -124,6 +128,20 @@ void VectorTest::drawUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, VectorDrawUniform>::value);
}
void VectorTest::drawUniformConstructCopy() {
/* Testing only some fields, should be enough */
VectorDrawUniform a;
a.materialId = 5;
VectorDrawUniform b = a;
CORRADE_COMPARE(b.materialId, 5);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<VectorDrawUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<VectorDrawUniform>::value);
#endif
}
void VectorTest::drawUniformSetters() {
VectorDrawUniform a;
a.setMaterialId(5);
@ -184,6 +202,22 @@ void VectorTest::materialUniformConstructNoInit() {
CORRADE_VERIFY(!std::is_convertible<NoInitT, VectorMaterialUniform>::value);
}
void VectorTest::materialUniformConstructCopy() {
/* Testing only some fields, should be enough */
VectorMaterialUniform a;
a.color = 0x354565fc_rgbaf;
a.backgroundColor = 0x98769fac_rgbaf;
VectorMaterialUniform b = a;
CORRADE_COMPARE(b.color, 0x354565fc_rgbaf);
CORRADE_COMPARE(b.backgroundColor, 0x98769fac_rgbaf);
#ifndef CORRADE_NO_STD_IS_TRIVIALLY_TRAITS
CORRADE_VERIFY(std::is_trivially_copy_constructible<VectorMaterialUniform>::value);
CORRADE_VERIFY(std::is_trivially_copy_assignable<VectorMaterialUniform>::value);
#endif
}
void VectorTest::materialUniformSetters() {
VectorMaterialUniform a;
a.setColor(0x354565fc_rgbaf)

Loading…
Cancel
Save