Fix and enable failed gradient signal tests on Linux

* Fix failure reason for PerlinGradientComponent_GoldenTest: non-standard behavior of std::shuffle producing different results across platforms
* Fix failure reason for GradientImageAssetConversionU8SingleScale: Undefined behavior when float casts to a uint8 has overflow

Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
This commit is contained in:
Steve Pham
2021-12-08 14:28:45 -08:00
committed by GitHub
parent fc71f3f81d
commit 9b480f252e
7 changed files with 37 additions and 9 deletions
@@ -111,7 +111,10 @@ namespace
constexpr auto numChannels = 1;
constexpr auto bytesPerPixel = numChannels * sizeof(AZ::u8);
constexpr auto outputSize = imageDimensions * imageDimensions;
constexpr auto scaling = 25;
// Adjust the test scale so that none of the input data overflows the cast to AZ::u8.
// The overflow behavior when casting from float to uint8 is undefined so we want to
// avoid that consistently across all platforms
constexpr auto scaling = 255.0f / aznumeric_cast<float>(imageDimensions * imageDimensions);
auto inputData = Detail::GenerateInput<AZ::u8, imageDimensions, numChannels>(scaling);