diff --git a/tests/ImagePreprocessorGPUFusedTest.cpp b/tests/ImagePreprocessorGPUFusedTest.cpp index 0400591d..fcd122b8 100644 --- a/tests/ImagePreprocessorGPUFusedTest.cpp +++ b/tests/ImagePreprocessorGPUFusedTest.cpp @@ -69,10 +69,13 @@ void CheckFusedMatchesCPU(CompressedImageMode mode, T err_value, uint32_t seed) PixelMask mask(x); // Mask a deterministic scatter of pixels, so masked-vs-error-vs-saturated priority is exercised - // rather than assumed. - auto &m = const_cast &>(mask.GetMask()); - for (size_t i = 0; i < npixels; i += 997) m[i] = 1; - for (size_t i = 13; i < npixels; i += 4001) m[i] = 1; + // rather than assumed. It goes in through LoadUserMask because the mask derives the + // byte-per-pixel form the GPU preprocessor uploads: writing the bitfield behind its back leaves + // that form stale, and the device then works from a mask the CPU reference does not have. + std::vector user_mask(mask.GetMask().size(), 0); + for (size_t i = 0; i < npixels; i += 997) user_mask[i] = 1; + for (size_t i = 13; i < npixels; i += 4001) user_mask[i] = 1; + mask.LoadUserMask(x, user_mask); const auto img = MakeImage(npixels, err_value, seed); JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4); @@ -132,8 +135,9 @@ TEST_CASE("ImagePreprocessorGPU_FusedMatchesHostUpload", "[ImagePreprocessorGPU] DiffractionExperiment x = MakeExperiment(32000); const size_t npixels = x.GetPixelsNum(); PixelMask mask(x); - auto &m = const_cast &>(mask.GetMask()); - for (size_t i = 0; i < npixels; i += 1301) m[i] = 1; + std::vector user_mask(mask.GetMask().size(), 0); + for (size_t i = 0; i < npixels; i += 1301) user_mask[i] = 1; + mask.LoadUserMask(x, user_mask); const auto img = MakeImage(npixels, UINT32_MAX, 77); JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);