Browse Source

MeshTools,Shaders: make the rendering tests pass on llvmpipe.

pull/427/merge
Vladimír Vondruš 6 years ago
parent
commit
97e3e2a8fe
  1. 15
      src/Magnum/MeshTools/Test/CompileGLTest.cpp
  2. 25
      src/Magnum/Shaders/Test/DistanceFieldVectorGLTest.cpp
  3. 9
      src/Magnum/Shaders/Test/FlatGLTest.cpp
  4. 8
      src/Magnum/Shaders/Test/MeshVisualizerGLTest.cpp
  5. 23
      src/Magnum/Shaders/Test/PhongGLTest.cpp
  6. 9
      src/Magnum/Shaders/Test/VectorGLTest.cpp

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

@ -500,8 +500,9 @@ template<class T> void CompileGLTest::twoDimensions() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(COMPILEGLTEST_TEST_DIR, "textured2D.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 0.75f, 0.0906f}));
/* SwiftShader has some minor off-by-one precision differences,
llvmpipe as well */
(DebugTools::CompareImageToFile{_manager, 1.75f, 0.22f}));
}
#ifndef MAGNUM_TARGET_GLES2
@ -787,8 +788,9 @@ template<class T> void CompileGLTest::threeDimensions() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(COMPILEGLTEST_TEST_DIR, "textured3D.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.0948f}));
/* SwiftShader has some minor off-by-one precision differences,
llvmpipe as well */
(DebugTools::CompareImageToFile{_manager, 2.0f, 0.256f}));
}
#ifndef MAGNUM_TARGET_GLES2
@ -1023,8 +1025,9 @@ void CompileGLTest::packedAttributes() {
CORRADE_COMPARE_WITH(
_framebuffer.read({{}, {32, 32}}, {PixelFormat::RGBA8Unorm}),
Utility::Directory::join(COMPILEGLTEST_TEST_DIR, "textured3D.tga"),
/* SwiftShader has some minor off-by-one precision differences */
(DebugTools::CompareImageToFile{_manager, 1.0f, 0.0948f}));
/* SwiftShader has some minor off-by-one precision differences,
llvmpipe more */
(DebugTools::CompareImageToFile{_manager, 2.0f, 0.259f}));
#ifndef MAGNUM_TARGET_GLES2
_framebuffer.clearColor(1, Vector4ui{27});

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

@ -88,6 +88,7 @@ struct DistanceFieldVectorGLTest: GL::OpenGLTester {
- Mesa Intel
- Mesa AMD
- Mesa llvmpipe
- SwiftShader ES2/ES3
- ARM Mali (Huawei P10) ES2/ES3
- WebGL 1 / 2 (on Mesa Intel)
@ -305,12 +306,12 @@ void DistanceFieldVectorGLTest::renderDefaults2D() {
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 189.0f, 6.1f}));
(DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences on edges, ARM Mali off-by-one in
all channels. Apple A8 off-by-more. */
const Float maxThreshold = 4.0f, meanThreshold = 0.077f;
all channels. Apple A8 & llvmpipe off-by-more. */
const Float maxThreshold = 32.0f, meanThreshold = 0.583f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 0.480f;
@ -361,12 +362,12 @@ void DistanceFieldVectorGLTest::renderDefaults3D() {
/* Dropping the alpha channel, as it's always 1.0 */
Containers::arrayCast<Color3ub>(_framebuffer.read(_framebuffer.viewport(), {PixelFormat::RGBA8Unorm}).pixels<Color4ub>()),
Utility::Directory::join(_testDir, "VectorTestFiles/defaults.tga"),
(DebugTools::CompareImageToFile{_manager, 189.0f, 6.1f}));
(DebugTools::CompareImageToFile{_manager, 201.0f, 6.1f}));
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences on edges, ARM Mali off-by-one in
all channels. Apple A8 off-by-more. */
const Float maxThreshold = 4.0f, meanThreshold = 0.077f;
all channels. Apple A8 and llvmpipe off-by-more. */
const Float maxThreshold = 32.0f, meanThreshold = 0.583f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 0.480f;
@ -433,11 +434,11 @@ void DistanceFieldVectorGLTest::render2D() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences when smoothing, Apple A8 a bit
more. */
const Float maxThreshold = 6.0f, meanThreshold = 0.360f;
more, llvmpipe also */
const Float maxThreshold = 32.0f, meanThreshold = 0.942f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 2.386f;
const Float maxThreshold = 32.0f, meanThreshold = 2.386f;
#endif
CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file2D}),
@ -502,11 +503,11 @@ void DistanceFieldVectorGLTest::render3D() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences when smoothing plus a bunch of
different pixels on primitive edges, Apple A8 a bit more. */
const Float maxThreshold = 17.0f, meanThreshold = 0.204f;
different pixels on primitive edges, Apple A8 & llvmpipe a bit more. */
const Float maxThreshold = 32.0f, meanThreshold = 0.642f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 1.613f;
const Float maxThreshold = 32.0f, meanThreshold = 1.613f;
#endif
CORRADE_COMPARE_WITH(pixels,
Utility::Directory::join({_testDir, "VectorTestFiles", data.file3D}),

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

@ -124,6 +124,7 @@ struct FlatGLTest: GL::OpenGLTester {
- Mesa Intel
- Mesa AMD
- Mesa llvmpipe
- SwiftShader ES2/ES3
- ARM Mali (Huawei P10) ES2/ES3 (except instancing)
- WebGL 1 / 2 (on Mesa Intel) (except instancing)
@ -687,8 +688,8 @@ void FlatGLTest::renderTextured2D() {
if(data.flip) pixels = pixels.flipped<0>().flipped<1>();
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has minor rounding errors, Apple A8 slightly more */
const Float maxThreshold = 2.334f, meanThreshold = 0.023f;
/* SwiftShader has minor rounding errors, Apple A8 & llvmpipe a bit more */
const Float maxThreshold = 2.334f, meanThreshold = 0.032f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 15.667f, meanThreshold = 3.254f;
@ -982,8 +983,8 @@ void FlatGLTest::renderAlpha3D() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* Minor differences between opaque and diffuse, not sure why. SwiftShader
has 5 different pixels on the edges. */
const Float maxThreshold = 139.0f, meanThreshold = 0.280f;
has 5 different pixels on the edges, llvmpipe some off-by-one errors */
const Float maxThreshold = 139.0f, meanThreshold = 0.421f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 139.0f, meanThreshold = 4.587f;

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

@ -1552,11 +1552,11 @@ void MeshVisualizerGLTest::renderObjectPrimitiveId3D() {
!(_manager.loadState("TgaImporter") & PluginManager::LoadState::Loaded))
CORRADE_SKIP("AnyImageImporter / TgaImageImporter plugins not found.");
/* Release build has 1 pixel slightly off. Huh. AMD has additional
off-by-one errors compared to Intel. If
/* Release build has 1 pixel slightly off. Huh. AMD & llvmpipe has
additional off-by-one errors compared to Intel. If
GL_NV_shader_noperspective_interpolation is not supported, the artifacts
are bigger when wireframe is enabled. */
Float maxThreshold = 1.0f, meanThreshold = 0.026f;
Float maxThreshold = 10.7f, meanThreshold = 0.279f;
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
if(data.flags3D & MeshVisualizer3D::Flag::Wireframe && !GL::Context::current().isExtensionSupported<GL::Extensions::NV::shader_noperspective_interpolation>()) {
/* SwiftShader has a bit more rounding errors */
@ -1740,7 +1740,7 @@ void MeshVisualizerGLTest::renderTangentBitangentNormal() {
/* Slight rasterization differences on AMD. If
GL_NV_shader_noperspective_interpolation is not supported, the artifacts
are bigger. */
Float maxThreshold = 1.334f, meanThreshold = 0.008f;
Float maxThreshold = 1.334f, meanThreshold = 0.018f;
#ifdef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::NV::shader_noperspective_interpolation>()) {
maxThreshold = 39.0f;

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

@ -123,6 +123,7 @@ struct PhongGLTest: GL::OpenGLTester {
- Mesa Intel
- Mesa AMD
. Mesa llvmpipe
- SwiftShader ES2/ES3
- ARM Mali (Huawei P10) ES2/ES3 (except instancing)
- WebGL 1 / 2 (on Mesa Intel) (except instancing)
@ -307,8 +308,8 @@ constexpr struct {
},
{"diffuse + normal", "instanced-normal.tga", Phong::Flag::NormalTexture,
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* AMD has one off pixel */
94.0f, 0.132f,
/* AMD has one off pixel, llvmpipe more */
94.0f, 0.333f,
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage */
94.0f, 0.132f,
@ -952,8 +953,8 @@ void PhongGLTest::renderTexturedNormal() {
okay. Due to the density of the normal map, SwiftShader has an overally
consistent off-by-a-bit error. AMD macOS drivers have one pixel off
due to a rounding error on the edge. Apple A8 has a slightly larger
overall difference. */
const Float maxThreshold = 191.0f, meanThreshold = 0.438f;
overall difference; llvmpipe is off also. */
const Float maxThreshold = 191.0f, meanThreshold = 0.918f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 191.0f, meanThreshold = 3.017f;
@ -1067,19 +1068,21 @@ void PhongGLTest::renderShininess() {
#endif
#if defined(MAGNUM_TARGET_GLES) && !defined(MAGNUM_TARGET_WEBGL)
CORRADE_EXPECT_FAIL_IF(data.shininess <= 0.0011f && (GL::Context::current().detectedDriver() & GL::Context::DetectedDriver::SwiftShader),
"SwiftShader has a much larger ring for the owerflown shininess.");
"SwiftShader has a much larger ring for the overflown shininess.");
#endif
#if defined(CORRADE_TARGET_ANDROID) && defined(MAGNUM_TARGET_GLES2)
CORRADE_EXPECT_FAIL_IF(data.shininess == 0.0f && (GL::Context::current().detectedDriver() & GL::Context::DetectedDriver::ArmMali),
"ARM Mali has a much larger ring for the owerflown shininess when it's exactly 0.");
"ARM Mali has a much larger ring for the overflown shininess when it's exactly 0.");
#endif
#ifndef MAGNUM_TARGET_WEBGL
CORRADE_EXPECT_FAIL_IF(data.shininess == 0.0f && (GL::Context::current().detectedDriver() & GL::Context::DetectedDriver::Mesa) && GL::Context::current().rendererString().find("AMD") != std::string::npos,
"AMD Mesa drivers have a much larger ring for the owerflown shininess when it's exactly 0.");
"AMD Mesa drivers have a much larger ring for the overflown shininess when it's exactly 0.");
CORRADE_EXPECT_FAIL_IF(data.shininess <= 0.0011f && (GL::Context::current().detectedDriver() & GL::Context::DetectedDriver::Mesa) && GL::Context::current().rendererString().find("llvmpipe") != std::string::npos,
"Mesa llvmpipe drivers have a much larger ring for the overflown shininess.");
#endif
#if defined(CORRADE_TARGET_APPLE) && !defined(CORRADE_TARGET_IOS)
CORRADE_EXPECT_FAIL_IF(data.shininess == 0.0f && GL::Context::current().rendererString().find("AMD") != std::string::npos,
"AMD on macOS has a much larger ring for the owerflown shininess when it's exactly 0.");
"AMD on macOS has a much larger ring for the overflown shininess when it's exactly 0.");
#endif
CORRADE_COMPARE_WITH(
/* Dropping the alpha channel, as it's always 1.0 */
@ -1202,7 +1205,7 @@ void PhongGLTest::renderAlpha() {
That's okay, as we have only 8bit texture precision. SwiftShader has
additionally a few minor rounding errors at the edges, Apple A8 a bit
more. */
const Float maxThreshold = 172.667f, meanThreshold = 0.229f;
const Float maxThreshold = 172.667f, meanThreshold = 0.385f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 172.667f, meanThreshold = 4.736f;
@ -1372,7 +1375,7 @@ void PhongGLTest::renderZeroLights() {
pixels on the edges, caused by matrix multiplication being done in the
shader and not on the CPU side. Apple A8 sprinkles a bunch of tiny
differences here and there. */
const Float maxThreshold = 139.0f, meanThreshold = 0.140f;
const Float maxThreshold = 139.0f, meanThreshold = 0.421f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 139.0f, meanThreshold = 2.896f;

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

@ -88,6 +88,7 @@ struct VectorGLTest: GL::OpenGLTester {
- Mesa Intel
- Mesa AMD
- Mesa llvmpipe
- SwiftShader ES2/ES3
- ARM Mali (Huawei P10) ES2/ES3
- WebGL 1 / 2 (on Mesa Intel)
@ -295,8 +296,8 @@ void VectorGLTest::renderDefaults2D() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences on edges, ARM Mali a bit more of
them */
const Float maxThreshold = 1.0f, meanThreshold = 0.022f;
them, llvmpipe is off-by-two */
const Float maxThreshold = 2.0f, meanThreshold = 0.071f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 0.359f;
@ -342,8 +343,8 @@ void VectorGLTest::renderDefaults3D() {
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
/* SwiftShader has off-by-one differences on edges, ARM Mali a bit more of
them */
const Float maxThreshold = 1.0f, meanThreshold = 0.022f;
them; llvmpipe is off-by-two */
const Float maxThreshold = 2.0f, meanThreshold = 0.071f;
#else
/* WebGL 1 doesn't have 8bit renderbuffer storage, so it's way worse */
const Float maxThreshold = 17.0f, meanThreshold = 0.359f;

Loading…
Cancel
Save