Browse Source

Text: fix DistanceFieldGlyphCacheGLTest failing on recent Mesa.

Neither a driver bug nor something wrong with the code. It's just
that with a tight flush rectangle the target texture may have some random
garbage left around the edges, causing the comparison to fail, so it's
now explicitly cleared upfront.

Doesn't happen when running the offending test alone (because I suppose
the memory is coming fresh from the driver, being zeroed out for security
purposes), only when running after the others (where I suspect it's now
reusing previous partially-filled memory which it didn't before). Doesn't
happen on NVidia either.
pull/651/merge
Vladimír Vondruš 1 year ago
parent
commit
66a2ce87cd
  1. 14
      src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp

14
src/Magnum/Text/Test/DistanceFieldGlyphCacheGLTest.cpp

@ -230,6 +230,20 @@ void DistanceFieldGlyphCacheGLTest::setImage() {
CORRADE_COMPARE(inputImage->size(), (Vector2i{256, 256})); CORRADE_COMPARE(inputImage->size(), (Vector2i{256, 256}));
DistanceFieldGlyphCacheGL cache{data.sourceSize, data.size, 32}; DistanceFieldGlyphCacheGL cache{data.sourceSize, data.size, 32};
/* Clear the target texture to avoid random garbage getting in when the
data.flushRange isn't covering the whole output */
Containers::Array<char> zeros{ValueInit, data.size.product()*pixelFormatSize(cache.processedFormat())};
cache.texture().setSubImage(0, {},
/* On ES2, R8Unorm maps to Luminance, but here it's actually Red if
EXT_texture_rg is supported */
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
cache.processedFormat() == PixelFormat::R8Unorm ?
ImageView2D{GL::PixelFormat::Red, GL::PixelType::UnsignedByte, data.size, zeros} :
#endif
ImageView2D{cache.processedFormat(), data.size, zeros}
);
Containers::StridedArrayView3D<const char> src = inputImage->pixels(); Containers::StridedArrayView3D<const char> src = inputImage->pixels();
/* Test also uploading under an offset. The cache might be three-component /* Test also uploading under an offset. The cache might be three-component
in some cases, slice the destination view to just the first component */ in some cases, slice the destination view to just the first component */

Loading…
Cancel
Save