12
12
namespace sycl {
13
13
inline namespace _V1 {
14
14
namespace detail {
15
- template <int Dim, typename T> struct IsValidCoordDataT ;
16
- template <typename T> struct IsValidCoordDataT <1 , T> {
17
- constexpr static bool value = detail::is_contained<
18
- T, detail::type_list<opencl::cl_int, opencl::cl_float>>::type::value;
15
+ template <int Dim, typename T, bool AllowFP = true > struct IsValidCoordDataT ;
16
+ template <typename T, bool AllowFP> struct IsValidCoordDataT <1 , T, AllowFP> {
17
+ constexpr static bool value =
18
+ std::is_same_v<T, opencl::cl_int> ||
19
+ (AllowFP && std::is_same_v<T, opencl::cl_float>);
19
20
};
20
- template <typename T> struct IsValidCoordDataT <2 , T> {
21
- constexpr static bool value = detail::is_contained<
22
- T, detail::type_list< vec<opencl::cl_int, 2 >,
23
- vec<opencl::cl_float, 2 >>>::type::value ;
21
+ template <typename T, bool AllowFP > struct IsValidCoordDataT <2 , T, AllowFP > {
22
+ constexpr static bool value =
23
+ std::is_same_v<T, vec<opencl::cl_int, 2 >> ||
24
+ (AllowFP && std::is_same_v<T, vec<opencl::cl_float, 2 >>) ;
24
25
};
25
- template <typename T> struct IsValidCoordDataT <3 , T> {
26
- constexpr static bool value = detail::is_contained<
27
- T, detail::type_list< vec<opencl::cl_int, 4 >,
28
- vec<opencl::cl_float, 4 >>>::type::value ;
26
+ template <typename T, bool AllowFP > struct IsValidCoordDataT <3 , T, AllowFP > {
27
+ constexpr static bool value =
28
+ std::is_same_v<T, vec<opencl::cl_int, 4 >> ||
29
+ (AllowFP && std::is_same_v<T, vec<opencl::cl_float, 4 >>) ;
29
30
};
30
31
31
32
template <int Dim, typename T> struct IsValidUnsampledCoord2020DataT ;
@@ -448,12 +449,12 @@ class image_accessor
448
449
// (accessTarget == access::target::image && accessMode == access::mode::read)
449
450
// || (accessTarget == access::target::host_image && ( accessMode ==
450
451
// access::mode::read || accessMode == access::mode::read_write))
451
- template <typename CoordT, int Dims = Dimensions,
452
- typename = std:: enable_if_t <
453
- (Dims > 0 ) && (IsValidCoordDataT<Dims, CoordT>::value) &&
454
- (detail::is_genint_v<CoordT> ) &&
455
- ((IsImageAcc && IsImageAccessReadOnly) ||
456
- (IsHostImageAcc && IsImageAccessAnyRead))>>
452
+ template <
453
+ typename CoordT, int Dims = Dimensions,
454
+ typename = std:: enable_if_t <
455
+ (IsValidCoordDataT<Dims, CoordT, /* AllowFP = */ false >::value ) &&
456
+ ((IsImageAcc && IsImageAccessReadOnly) ||
457
+ (IsHostImageAcc && IsImageAccessAnyRead))>>
457
458
DataT read (const CoordT &Coords) const {
458
459
#ifdef __SYCL_DEVICE_ONLY__
459
460
return __invoke__ImageRead<DataT, OCLImageTy, CoordT>(MImageObj, Coords);
@@ -470,7 +471,7 @@ class image_accessor
470
471
// access::mode::read || accessMode == access::mode::read_write))
471
472
template <typename CoordT, int Dims = Dimensions,
472
473
typename = std::enable_if_t <
473
- (Dims > 0 ) && ( IsValidCoordDataT<Dims, CoordT>::value) &&
474
+ (IsValidCoordDataT<Dims, CoordT>::value) &&
474
475
((IsImageAcc && IsImageAccessReadOnly) ||
475
476
(IsHostImageAcc && IsImageAccessAnyRead))>>
476
477
DataT read (const CoordT &Coords, const sampler &Smpl) const {
@@ -494,10 +495,10 @@ class image_accessor
494
495
// accessMode == access::mode::read_write))
495
496
template <
496
497
typename CoordT, int Dims = Dimensions,
497
- typename = std::enable_if_t <(Dims > 0 ) && (detail::is_genint_v<CoordT>) &&
498
- (IsValidCoordDataT<Dims, CoordT>::value) &&
499
- ((IsImageAcc && IsImageAccessWriteOnly) ||
500
- (IsHostImageAcc && IsImageAccessAnyWrite))>>
498
+ typename = std::enable_if_t <
499
+ (IsValidCoordDataT<Dims, CoordT, /* AllowFP = */ false >::value) &&
500
+ ((IsImageAcc && IsImageAccessWriteOnly) ||
501
+ (IsHostImageAcc && IsImageAccessAnyWrite))>>
501
502
void write (const CoordT &Coords, const DataT &Color) const {
502
503
#ifdef __SYCL_DEVICE_ONLY__
503
504
__invoke__ImageWrite<OCLImageTy, CoordT, DataT>(MImageObj, Coords, Color);
@@ -546,23 +547,21 @@ class __image_array_slice__ {
546
547
size_t Idx)
547
548
: MBaseAcc(BaseAcc), MIdx(Idx) {}
548
549
549
- template <typename CoordT, int Dims = Dimensions,
550
- typename = std:: enable_if_t <
551
- (Dims > 0 ) && (IsValidCoordDataT<Dims, CoordT>::value)>>
550
+ template <
551
+ typename CoordT, int Dims = Dimensions,
552
+ typename = std:: enable_if_t < (IsValidCoordDataT<Dims, CoordT>::value)>>
552
553
DataT read (const CoordT &Coords) const {
553
554
return MBaseAcc.read (getAdjustedCoords (Coords));
554
555
}
555
556
556
557
template <typename CoordT, int Dims = Dimensions,
557
- typename = std::enable_if_t <(Dims > 0 ) &&
558
- IsValidCoordDataT<Dims, CoordT>::value>>
558
+ typename = std::enable_if_t <IsValidCoordDataT<Dims, CoordT>::value>>
559
559
DataT read (const CoordT &Coords, const sampler &Smpl) const {
560
560
return MBaseAcc.read (getAdjustedCoords (Coords), Smpl);
561
561
}
562
562
563
563
template <typename CoordT, int Dims = Dimensions,
564
- typename = std::enable_if_t <(Dims > 0 ) &&
565
- IsValidCoordDataT<Dims, CoordT>::value>>
564
+ typename = std::enable_if_t <IsValidCoordDataT<Dims, CoordT>::value>>
566
565
void write (const CoordT &Coords, const DataT &Color) const {
567
566
return MBaseAcc.write (getAdjustedCoords (Coords), Color);
568
567
}
0 commit comments