Browse Source

MeshTools,Shaders: update test image comparison thresholds for NVidia.

pull/419/merge
Vladimír Vondruš 2 years ago
parent
commit
0a027b4469
  1. 20
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  2. 5
      src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp
  3. 62
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  4. 43
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  5. 24
      src/Magnum/Shaders/Test/VertexColorGLTest.cpp

20
src/Magnum/MeshTools/Test/CompileGLTest.cpp

@ -968,8 +968,9 @@ template<class T> void CompileGLTest::threeDimensions() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f}));
/* SwiftShader has some minor off-by-one precision differences,
NVidia as well */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.029f}));
}
/* Check generated flat / smooth normals with the phong shader. If smooth
@ -988,8 +989,9 @@ template<class T> void CompileGLTest::threeDimensions() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-flat.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.012f}));
/* SwiftShader has some minor off-by-one precision differences,
NVidia as well */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.020f}));
} else if(data.flags & Flag::GeneratedSmoothNormals) {
_framebuffer.clear(GL::FramebufferClear::Color);
_phong
@ -1003,8 +1005,9 @@ template<class T> void CompileGLTest::threeDimensions() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong-smooth.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.0088f}));
/* SwiftShader has some minor off-by-one precision differences,
NVidia as well */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.037f}));
}
/* Check with the colored shader, if we have colors */
@ -1237,8 +1240,9 @@ void CompileGLTest::packedAttributes() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Path::join(MESHTOOLS_TEST_DIR, "CompileTestFiles/phong.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.013f}));
/* SwiftShader has some minor off-by-one precision differences.
NVidia as well, more on ES2 */
(DebugTools::CompareImageToFile{_manager, 0.5f, 0.029f}));
/* Check colors */
_framebuffer.clear(GL::FramebufferClear::Color);

5
src/Magnum/MeshTools/Test/FullScreenTriangleGLTest.cpp

@ -145,9 +145,10 @@ void main() {
0xff80ff80_rgba, 0xff80ff80_rgba, 0xff80ff80_rgba, 0xff80ff80_rgba
};
#ifndef MAGNUM_TARGET_GLES2
CORRADE_COMPARE_AS(image,
CORRADE_COMPARE_WITH(image,
(ImageView2D{PixelFormat::RGBA8Unorm, {4, 4}, expected}),
DebugTools::CompareImage);
/* Off-by-one difference in all pixels on NV */
(DebugTools::CompareImage{0.5f, 0.5f}));
#else
/* The RGBA4 format on ES2 causes rounding errors. On NV it's stable
off-by-one, 0x7f, on Mesa it's more (either 0x77 or 0x88 instead of

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

@ -1055,8 +1055,8 @@ const struct {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
{"wireframe", "instanced-wireframe2D.tga",
MeshVisualizerGL2D::Flag::Wireframe,
/* Minor differences on ARM Mali */
0.34f, 0.00625f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.012f},
#endif
{"wireframe w/o GS", "instanced-wireframe-nogeo2D.tga",
MeshVisualizerGL2D::Flag::Wireframe|MeshVisualizerGL2D::Flag::NoGeometryShader,
@ -1095,12 +1095,14 @@ const struct {
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
{"wireframe", "instanced-wireframe3D.tga",
MeshVisualizerGL3D::Flag::Wireframe,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0054f},
#endif
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
{"wireframe + TBN", "instanced-wireframe-tbn3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::TangentDirection|MeshVisualizerGL3D::Flag::BitangentFromTangentDirection|MeshVisualizerGL3D::Flag::NormalDirection,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0050f},
#endif
{"wireframe w/o GS", "instanced-wireframe-nogeo3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader,
@ -1176,7 +1178,8 @@ constexpr struct {
{"bind with offset, textured array object ID, shader storage", "multidraw-objectidtexture2D.tga",
MeshVisualizerGL2D::Flag::ShaderStorageBuffers|MeshVisualizerGL2D::Flag::TextureTransformation|MeshVisualizerGL2D::Flag::ObjectIdTexture|MeshVisualizerGL2D::Flag::TextureArrays,
0, 0, true, 16,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.056f},
#endif
#ifndef MAGNUM_TARGET_WEBGL
{"draw offset, wireframe", "multidraw-wireframe2D.tga",
@ -1214,7 +1217,8 @@ constexpr struct {
{"draw offset, textured array object ID, shader storage", "multidraw-objectidtexture2D.tga",
MeshVisualizerGL2D::Flag::ShaderStorageBuffers|MeshVisualizerGL2D::Flag::TextureTransformation|MeshVisualizerGL2D::Flag::ObjectIdTexture|MeshVisualizerGL2D::Flag::TextureArrays,
0, 0, false, 1,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.056f},
#endif
#ifndef MAGNUM_TARGET_WEBGL
{"multidraw, wireframe", "multidraw-wireframe2D.tga",
@ -1266,17 +1270,19 @@ constexpr struct {
{"bind with offset, wireframe", "multidraw-wireframe3D.tga",
MeshVisualizerGL3D::Flag::Wireframe,
1, 1, true, 16,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0055f},
{"bind with offset, wireframe + TBN", "multidraw-wireframe-tbn3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::TangentDirection|MeshVisualizerGL3D::Flag::BitangentFromTangentDirection|MeshVisualizerGL3D::Flag::NormalDirection,
1, 1, true, 16,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0054f},
#endif
{"bind with offset, wireframe w/o GS", "multidraw-wireframe-nogeo3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader,
1, 1, true, 16,
/* Minor differences on ARM Mali */
6.0f, 0.042f},
/* Minor differences on ARM Mali, NVidia */
11.34f, 0.068f},
{"bind with offset, vertex ID", "multidraw-vertexid3D.tga",
MeshVisualizerGL3D::Flag::VertexId,
1, 1, true, 16,
@ -1305,17 +1311,19 @@ constexpr struct {
{"draw offset, wireframe", "multidraw-wireframe3D.tga",
MeshVisualizerGL3D::Flag::Wireframe,
2, 3, false, 1,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0055f},
{"draw offset, wireframe + TBN", "multidraw-wireframe-tbn3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::TangentDirection|MeshVisualizerGL3D::Flag::BitangentFromTangentDirection|MeshVisualizerGL3D::Flag::NormalDirection,
2, 3, false, 1,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.0054f},
#endif
{"draw offset, wireframe w/o GS", "multidraw-wireframe-nogeo3D.tga",
MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader,
2, 3, false, 1,
/* Minor differences on ARM Mali */
6.0f, 0.042f},
/* Minor differences on ARM Mali, NVidia */
11.34f, 0.068f},
{"draw offset, vertex ID", "multidraw-vertexid3D.tga",
MeshVisualizerGL3D::Flag::VertexId,
2, 3, false, 1,
@ -1344,17 +1352,19 @@ constexpr struct {
{"multidraw, wireframe", "multidraw-wireframe3D.tga",
MeshVisualizerGL3D::Flag::MultiDraw|MeshVisualizerGL3D::Flag::Wireframe,
2, 3, false, 1,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.003f},
{"multidraw, wireframe + TBN", "multidraw-wireframe-tbn3D.tga",
MeshVisualizerGL3D::Flag::MultiDraw|MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::TangentDirection|MeshVisualizerGL3D::Flag::BitangentFromTangentDirection|MeshVisualizerGL3D::Flag::NormalDirection,
2, 3, false, 1,
0.0f, 0.0f},
/* Minor differences on NVidia */
0.667f, 0.003f},
#endif
{"multidraw, wireframe w/o GS", "multidraw-wireframe-nogeo3D.tga",
MeshVisualizerGL3D::Flag::MultiDraw|MeshVisualizerGL3D::Flag::Wireframe|MeshVisualizerGL3D::Flag::NoGeometryShader,
2, 3, false, 1,
/* Minor differences on ARM Mali */
6.0f, 0.04f},
/* Minor differences on ARM Mali, NVidia */
11.34f, 0.066f},
{"multidraw, vertex ID", "multidraw-vertexid3D.tga",
MeshVisualizerGL3D::Flag::MultiDraw|MeshVisualizerGL3D::Flag::VertexId,
2, 3, false, 1,
@ -3863,7 +3873,8 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefault
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid2D.tga"),
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.017f}));
/* Minor differences on NVidia */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.022f}));
}
template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefaultsVertexId3D() {
@ -3941,7 +3952,8 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderDefault
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Path::join(_testDir, "MeshVisualizerTestFiles/defaults-vertexid3D.tga"),
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.012f}));
/* Minor differences on NVidia */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.018f}));
}
template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderDefaultsPrimitiveId2D() {
@ -6381,8 +6393,9 @@ template<MeshVisualizerGL2D::Flag flag> void MeshVisualizerGLTest::renderInstanc
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Path::join(_testDir, "MeshVisualizerTestFiles/skinning-instanced.tga"),
/* SwiftShader has minor differences in the output, ARM Mali too */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.018f}));
/* SwiftShader has minor differences in the output, ARM Mali too,
NVidia as well */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.022f}));
}
template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderInstancedSkinningWireframe3D() {
@ -6542,8 +6555,9 @@ template<MeshVisualizerGL3D::Flag flag> void MeshVisualizerGLTest::renderInstanc
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Path::join(_testDir, "MeshVisualizerTestFiles/skinning-instanced.tga"),
/* SwiftShader has minor differences in the output, ARM Mali too */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.018f}));
/* SwiftShader has minor differences in the output, ARM Mali too,
NVidia as well */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.022f}));
}
#endif

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

@ -1071,15 +1071,15 @@ constexpr struct {
"multidraw-textured.tga", {},
PhongGL::Flag::TextureTransformation|PhongGL::Flag::DiffuseTexture,
2, 2, 1, 1, true, 16,
/* Minor differences on ARM Mali */
4.67f, 0.02f},
/* Minor differences on ARM Mali, on NVidia */
7.0f, 0.02f},
{"bind with offset, texture array",
"multidraw-textured.tga", {},
PhongGL::Flag::TextureTransformation|PhongGL::Flag::DiffuseTexture|PhongGL::Flag::TextureArrays,
2, 2, 1, 1, true, 16,
/* Some difference at the UV edge (texture is wrapping in the 2D case
while the 2D array has a black area around) */
50.34f, 0.141f},
50.34f, 0.146f},
#ifndef MAGNUM_TARGET_WEBGL
{"bind with offset, texture array, shader storage",
"multidraw-textured.tga", {},
@ -1087,7 +1087,7 @@ constexpr struct {
0, 2, 0, 0, true, 16,
/* Some difference at the UV edge (texture is wrapping in the 2D case
while the 2D array has a black area around) */
50.34f, 0.131f},
50.34f, 0.146f},
#endif
{"draw offset, colored",
"multidraw.tga", {},
@ -1123,15 +1123,15 @@ constexpr struct {
"multidraw-textured.tga", {},
PhongGL::Flag::TextureTransformation|PhongGL::Flag::DiffuseTexture,
4, 4, 2, 3, false, 1,
/* Minor differences on ARM Mali */
4.67f, 0.02f},
/* Minor differences on ARM Mali, on NVidia */
7.0f, 0.02f},
{"draw offset, texture array",
"multidraw-textured.tga", {},
PhongGL::Flag::TextureTransformation|PhongGL::Flag::DiffuseTexture|PhongGL::Flag::TextureArrays,
4, 4, 2, 3, false, 1,
/* Some difference at the UV edge (texture is wrapping in the 2D case
while the 2D array has a black area around) */
50.34f, 0.141f},
50.34f, 0.146f},
#ifndef MAGNUM_TARGET_WEBGL
{"draw offset, texture array, shader storage",
"multidraw-textured.tga", {},
@ -1139,7 +1139,7 @@ constexpr struct {
0, 2, 0, 0, false, 1,
/* Some difference at the UV edge (texture is wrapping in the 2D case
while the 2D array has a black area around) */
50.34f, 0.141f},
50.34f, 0.146f},
#endif
{"multidraw, colored",
"multidraw.tga", {},
@ -2511,8 +2511,9 @@ template<PhongGL::Flag flag> void PhongGLTest::renderColored() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has some minor rounding differences (max = 1). ARM Mali G71
and Apple A8 has bigger rounding differences. */
const Float maxThreshold = 8.34f, meanThreshold = 0.100f;
and Apple A8 has bigger rounding differences. NVidia as well, more on
ES2. */
const Float maxThreshold = 12.67f, meanThreshold = 0.121f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 15.34f, meanThreshold = 3.33f;
@ -2733,8 +2734,9 @@ template<PhongGL::Flag flag> void PhongGLTest::renderSinglePixelTextured() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has some minor rounding differences (max = 1). ARM Mali G71
and Apple A8 has bigger rounding differences. */
const Float maxThreshold = 7.67f, meanThreshold = 0.100f;
and Apple A8 has bigger rounding differences. NVidia as well, more on
ES2. */
const Float maxThreshold = 12.67f, meanThreshold = 0.125f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 15.34f, meanThreshold = 3.33f;
@ -3901,8 +3903,8 @@ template<PhongGL::Flag flag> void PhongGLTest::renderObjectId() {
/* Color output should have no difference -- same as in colored() */
/* SwiftShader has some minor rounding differences (max = 1). ARM Mali G71
and Apple A8 has bigger rounding differences. */
const Float maxThreshold = 8.34f, meanThreshold = 0.100f;
and Apple A8 has bigger rounding differences. NVidia as well. */
const Float maxThreshold = 12.67f, meanThreshold = 0.113f;
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
@ -4051,17 +4053,12 @@ template<PhongGL::Flag flag> void PhongGLTest::renderLights() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImporter plugins not found.");
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
const Float maxThreshold = 3.0f, meanThreshold = 0.02f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 3.0f, meanThreshold = 0.02f;
#endif
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<const Color3ub>(image.pixels<Color4ub>()),
Utility::Path::join({_testDir, "PhongTestFiles", data.file}),
(DebugTools::CompareImageToFile{_manager, maxThreshold, meanThreshold}));
/* Minor differences on ES2 and on NVidia */
(DebugTools::CompareImageToFile{_manager, 3.0f, 0.27f}));
}
void PhongGLTest::renderLightsSetOneByOne() {
@ -4246,8 +4243,8 @@ void PhongGLTest::renderLightCulling() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has some minor rounding differences (max = 1). ARM Mali G71
and Apple A8 has bigger rounding differences. */
const Float maxThreshold = 8.34f, meanThreshold = 0.100f;
and Apple A8 has bigger rounding differences. NVidia as well. */
const Float maxThreshold = 12.67f, meanThreshold = 0.113f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 15.34f, meanThreshold = 3.33f;

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

@ -186,33 +186,33 @@ constexpr struct {
} RenderMultiData[] {
{"bind with offset", "multidraw2D.tga", "multidraw3D.tga",
{}, 1, true, 16,
/* Minor differences on ARM Mali */
0.34f, 0.01f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#ifndef MAGNUM_TARGET_WEBGL
{"bind with offset, shader storage", "multidraw2D.tga", "multidraw3D.tga",
VertexColorGL2D::Flag::ShaderStorageBuffers, 1, true, 16,
/* Minor differences on ARM Mali */
0.34f, 0.01f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#endif
{"draw offset", "multidraw2D.tga", "multidraw3D.tga",
{}, 3, false, 1,
/* Minor differences on ARM Mali */
0.34f, 0.01f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#ifndef MAGNUM_TARGET_WEBGL
{"draw offset, shader storage", "multidraw2D.tga", "multidraw3D.tga",
VertexColorGL2D::Flag::ShaderStorageBuffers, 3, false, 1,
/* Minor differences on ARM Mali */
0.34f, 0.01f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#endif
{"multidraw", "multidraw2D.tga", "multidraw3D.tga",
VertexColorGL2D::Flag::MultiDraw, 3, false, 1,
/* Minor differences on ARM Mali */
0.34f, 0.01f},
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#ifndef MAGNUM_TARGET_WEBGL
{"multidraw, shader storage", "multidraw2D.tga", "multidraw3D.tga",
VertexColorGL2D::Flag::ShaderStorageBuffers|VertexColorGL2D::Flag::MultiDraw, 0, false, 1,
/* Minor differences on ARM Mali */
0.34f, 0.01f}
/* Minor differences on ARM Mali, NVidia */
0.667f, 0.01f},
#endif
};
#endif

Loading…
Cancel
Save