Skip to content

Commit 2a91372

Browse files
[SYCL][E2E] Fix max color value in image test (#10064)
This commit fixes an issue where the maximum value for a new color in the image write tests would cause a conversion to an invalid value, which in turn would cause written and read values to differ. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 0bb7221 commit 2a91372

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sycl/test-e2e/Basic/sycl_2020_images/common.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,20 +329,18 @@ ApplyAddressingMode(CoordT<ImageType::Sampled, Dims> Coord,
329329
}
330330
}
331331

332-
template <image_format Format> static constexpr size_t getMaxInt() {
333-
using rep_elem_type = typename FormatTraits<Format>::rep_elem_type;
334-
return static_cast<size_t>(std::numeric_limits<rep_elem_type>::max());
335-
}
336-
337332
template <image_format Format>
338333
typename FormatTraits<Format>::pixel_type PickNewColor(size_t I,
339334
size_t AccSize) {
335+
using RepElemT = typename FormatTraits<Format>::rep_elem_type;
340336
using PixelType = typename FormatTraits<Format>::pixel_type;
337+
341338
size_t Idx = I * 4;
342339

343340
// Pick a new color. Make sure it isn't too big for the data type.
344341
PixelType NewColor{Idx, Idx + 1, Idx + 2, Idx + 3};
345-
NewColor = sycl::min(NewColor, PixelType{getMaxInt<Format>()});
342+
PixelType MaxPixelVal{std::numeric_limits<RepElemT>::max()};
343+
NewColor = sycl::min(NewColor, MaxPixelVal);
346344
if constexpr (FormatTraits<Format>::Normalized)
347345
NewColor /= AccSize * 4;
348346
return NewColor;

0 commit comments

Comments
 (0)