Skip to content

Commit cd6529f

Browse files
[SYCL] Fix Host Device sampler coordinate conversion (#3226)
The None and Clamp sampler are incorrectly calculating isOutOfRange predicate when the image dimensions are less than 3. This is because the shorthand float conversion used for the samplers uses 0 for the missing dimensions. But that isn't correct, when linearly sampling, the pixel center is at 0.5. Setting it to 0 then leads to an 'out of bounds' for those undefined dimensions. This fix is to use 0.5 for missing dimension. Signed-off-by: Chris Perkins <[email protected]>
1 parent d0a678c commit cd6529f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sycl/include/CL/sycl/detail/image_accessor_util.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,19 @@ UnnormalizeCoordinates(const vec<T, 4> &Coords, const range<3> &Range) {
5252
}
5353

5454
// Converts the Coordinates from any dimensions into float4.
55+
// valid but unused coordinates are written as 0.5 so the Int_uvwsubhalf
56+
// calculation won't pass 0.
5557
// Non-valid coordinates are written as 0.
5658
template <typename T>
5759
detail::enable_if_t<IsValidCoordType<T>::value, cl_float4>
5860
convertToFloat4(T Coords) {
59-
return {static_cast<float>(Coords), 0.f, 0.f, 0.f};
61+
return {static_cast<float>(Coords), 0.5f, 0.5f, 0.f};
6062
}
6163

6264
template <typename T>
6365
detail::enable_if_t<IsValidCoordType<T>::value, cl_float4>
6466
convertToFloat4(vec<T, 2> Coords) {
65-
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()), 0.f,
67+
return {static_cast<float>(Coords.x()), static_cast<float>(Coords.y()), 0.5f,
6668
0.f};
6769
}
6870

0 commit comments

Comments
 (0)