@@ -812,6 +812,11 @@ template <int NDims>
812
812
using OCLImageArrayTyWrite = typename sycl::detail::opencl_image_type<
813
813
NDims, sycl::access::mode::write, sycl::access::target::image_array>::type;
814
814
815
+ template <int NDims>
816
+ using OCLSampledImageArrayTyRead =
817
+ typename sycl::detail::sampled_opencl_image_type<
818
+ detail::OCLImageArrayTyRead<NDims>>::type;
819
+
815
820
// Macros are required because it is not legal for a function to return
816
821
// a variable of type 'opencl_image_type'.
817
822
#if defined(__SPIR__)
@@ -823,34 +828,64 @@ using OCLImageArrayTyWrite = typename sycl::detail::opencl_image_type<
823
828
typename sycl::detail::sampled_opencl_image_type< \
824
829
detail::OCLImageTyRead<NDims>>::type>(raw_handle)
825
830
831
+ #define CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (raw_handle, NDims ) \
832
+ __spirv_ConvertHandleToSampledImageINTEL< \
833
+ typename sycl::detail::sampled_opencl_image_type< \
834
+ detail::OCLImageArrayTyRead<NDims>>::type>(raw_handle)
835
+
826
836
#define FETCH_UNSAMPLED_IMAGE (DataT, raw_handle, coords ) \
827
837
__invoke__ImageRead<DataT>(raw_handle, coords)
828
838
829
839
#define FETCH_SAMPLED_IMAGE (DataT, raw_handle, coords ) \
830
- __invoke__ImageRead<DataT>(raw_handle, coords)
840
+ __invoke__ImageReadLod<DataT>(raw_handle, coords, 0 .f)
841
+
842
+ #define SAMPLE_IMAGE_READ (DataT, raw_handle, coords ) \
843
+ __invoke__ImageReadLod<DataT>(raw_handle, coords, 0 .f)
831
844
832
845
#define FETCH_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, coordsLayer ) \
833
846
__invoke__ImageRead<DataT>(raw_handle, coordsLayer)
834
847
835
848
#define WRITE_IMAGE_ARRAY (raw_handle, coords, arrayLayer, coordsLayer, color ) \
836
849
__invoke__ImageWrite (raw_handle, coordsLayer, color)
837
850
851
+ #define FETCH_SAMPLED_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, \
852
+ coordsLayer) \
853
+ __invoke__ImageReadLod<DataT>(raw_handle, coordsLayer, 0 .f)
854
+
855
+ #define READ_SAMPLED_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, \
856
+ coordsLayer) \
857
+ __invoke__ImageReadLod<DataT>(raw_handle, coordsLayer, 0 .f)
858
+
838
859
#else
839
860
#define CONVERT_HANDLE_TO_IMAGE (raw_handle, ImageType ) raw_handle
840
861
841
862
#define CONVERT_HANDLE_TO_SAMPLED_IMAGE (raw_handle, NDims ) raw_handle
842
863
864
+ #define CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (raw_handle, NDims ) raw_handle
865
+
843
866
#define FETCH_UNSAMPLED_IMAGE (DataT, raw_handle, coords ) \
844
867
__invoke__ImageFetch<DataT>(raw_handle, coords)
845
868
846
869
#define FETCH_SAMPLED_IMAGE (DataT, raw_handle, coords ) \
847
870
__invoke__SampledImageFetch<DataT>(raw_handle, coords)
848
871
872
+ #define SAMPLE_IMAGE_READ (DataT, raw_handle, coords ) \
873
+ __invoke__ImageRead<DataT>(raw_handle, coords)
874
+
849
875
#define FETCH_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, coordsLayer ) \
850
876
__invoke__ImageArrayFetch<DataT>(raw_handle, coords, arrayLayer)
851
877
852
878
#define WRITE_IMAGE_ARRAY (raw_handle, coords, arrayLayer, coordsLayer, color ) \
853
879
__invoke__ImageArrayWrite (raw_handle, coords, arrayLayer, color)
880
+
881
+ #define FETCH_SAMPLED_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, \
882
+ coordsLayer) \
883
+ __invoke__SampledImageArrayFetch<DataT>(raw_handle, coords, arrayLayer)
884
+
885
+ #define READ_SAMPLED_IMAGE_ARRAY (DataT, raw_handle, coords, arrayLayer, \
886
+ coordsLayer) \
887
+ __invoke__ImageArrayRead<DataT>(raw_handle, coords, arrayLayer)
888
+
854
889
#endif
855
890
856
891
#endif // __SYCL_DEVICE_ONLY__
@@ -1030,11 +1065,13 @@ DataT sample_image(const sampled_image_handle &imageHandle [[maybe_unused]],
1030
1065
1031
1066
#ifdef __SYCL_DEVICE_ONLY__
1032
1067
if constexpr (detail::is_recognized_standard_type<DataT>()) {
1033
- return __invoke__ImageRead<DataT>(
1068
+ return SAMPLE_IMAGE_READ (
1069
+ DataT,
1034
1070
CONVERT_HANDLE_TO_SAMPLED_IMAGE (imageHandle.raw_handle , coordSize),
1035
1071
coords);
1036
1072
} else {
1037
- return sycl::bit_cast<DataT>(__invoke__ImageRead<HintT>(
1073
+ return sycl::bit_cast<DataT>(SAMPLE_IMAGE_READ (
1074
+ HintT,
1038
1075
CONVERT_HANDLE_TO_SAMPLED_IMAGE (imageHandle.raw_handle , coordSize),
1039
1076
coords));
1040
1077
}
@@ -1410,17 +1447,23 @@ DataT fetch_image_array(const sampled_image_handle &imageHandle
1410
1447
" and 2D images respectively." );
1411
1448
1412
1449
#ifdef __SYCL_DEVICE_ONLY__
1450
+ sycl::vec<int , coordSize + 1 > coordsLayer{coords, arrayLayer};
1413
1451
if constexpr (detail::is_recognized_standard_type<DataT>()) {
1414
- return __invoke__SampledImageArrayFetch<DataT>(imageHandle.raw_handle ,
1415
- coords, arrayLayer);
1452
+ return FETCH_SAMPLED_IMAGE_ARRAY (DataT,
1453
+ CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (
1454
+ imageHandle.raw_handle , coordSize),
1455
+ coords, arrayLayer, coordsLayer);
1416
1456
} else {
1417
1457
static_assert (sizeof (HintT) == sizeof (DataT),
1418
1458
" When trying to fetch a user-defined type, HintT must be of "
1419
1459
" the same size as the user-defined DataT." );
1420
1460
static_assert (detail::is_recognized_standard_type<HintT>(),
1421
1461
" HintT must always be a recognized standard type" );
1422
- return sycl::bit_cast<DataT>(__invoke__SampledImageArrayFetch<HintT>(
1423
- imageHandle.raw_handle , coords, arrayLayer));
1462
+ return sycl::bit_cast<DataT>(
1463
+ FETCH_SAMPLED_IMAGE_ARRAY (HintT,
1464
+ CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (
1465
+ imageHandle.raw_handle , coordSize),
1466
+ coords, arrayLayer, coordsLayer));
1424
1467
}
1425
1468
#else
1426
1469
assert (false ); // Bindless images not yet implemented on host.
@@ -1454,17 +1497,23 @@ DataT sample_image_array(const sampled_image_handle &imageHandle
1454
1497
" and 2D images respectively." );
1455
1498
1456
1499
#ifdef __SYCL_DEVICE_ONLY__
1500
+ sycl::vec<float , coordSize + 1 > coordsLayer{coords, arrayLayer};
1457
1501
if constexpr (detail::is_recognized_standard_type<DataT>()) {
1458
- return __invoke__ImageArrayRead<DataT>(imageHandle.raw_handle , coords,
1459
- arrayLayer);
1502
+ return READ_SAMPLED_IMAGE_ARRAY (DataT,
1503
+ CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (
1504
+ imageHandle.raw_handle , coordSize),
1505
+ coords, arrayLayer, coordsLayer);
1460
1506
} else {
1461
1507
static_assert (sizeof (HintT) == sizeof (DataT),
1462
1508
" When trying to fetch a user-defined type, HintT must be of "
1463
1509
" the same size as the user-defined DataT." );
1464
1510
static_assert (detail::is_recognized_standard_type<HintT>(),
1465
1511
" HintT must always be a recognized standard type" );
1466
- return sycl::bit_cast<DataT>(__invoke__ImageArrayRead<HintT>(
1467
- imageHandle.raw_handle , coords, arrayLayer));
1512
+ return sycl::bit_cast<DataT>(
1513
+ READ_SAMPLED_IMAGE_ARRAY (HintT,
1514
+ CONVERT_HANDLE_TO_SAMPLED_IMAGE_ARRAY (
1515
+ imageHandle.raw_handle , coordSize),
1516
+ coords, arrayLayer, coordsLayer));
1468
1517
}
1469
1518
#else
1470
1519
assert (false ); // Bindless images not yet implemented on host.
0 commit comments