@@ -986,39 +986,41 @@ listed above caused the failure.
986
986
namespace sycl::ext::oneapi::experimental {
987
987
988
988
template <typename DataT, typename HintT = DataT, typename CoordT>
989
- DataT read_image (const unsampled_image_handle &ImageHandle,
990
- const CoordT &Coords);
989
+ DataT fetch_image (const unsampled_image_handle &ImageHandle,
990
+ const CoordT &Coords);
991
991
template <typename DataT, typename HintT = DataT, typename CoordT>
992
- DataT read_image (const sampled_image_handle &ImageHandle,
993
- const CoordT &Coords);
992
+ DataT sample_image (const sampled_image_handle &ImageHandle,
993
+ const CoordT &Coords);
994
994
995
995
template <typename DataT, typename CoordT>
996
996
void write_image(unsampled_image_handle &ImageHandle,
997
997
const CoordT &Coords, const DataT &Color);
998
998
}
999
999
```
1000
1000
1001
- Inside a kernel, it's possible to read an image via `read_image`, passing
1002
- the image handle. For the form that takes `unsampled_image_handle`, image data
1003
- will be fetched exactly as is in device memory. For the form that takes a
1004
- `sampled_image_handle`, the image will be sampled according to the
1001
+ Inside a kernel, it's possible to retrieve data from an image via `fetch_image`
1002
+ or `sample_image`, passing the appropirate image handle. The `fetch_image` API
1003
+ is only applicable to unsampled images, and the data will be fetched exactly as
1004
+ is in device memory. The `sample_image` API is only applicable to sampled
1005
+ images, the image data will be sampled according to the
1005
1006
`bindless_image_sampler` that was passed to the image upon construction.
1006
1007
1007
1008
The user is required to pass a `DataT` template parameter, which specifies the
1008
- return type of the `read_image` function. If `DataT` is not a recognized
1009
- standard type, as defined in <<recognized_standard_types>>, and instead a
1010
- user-defined type, the user must provide a `HintT` template parameter to the
1011
- `read_image` function, to allow the backend to select the correct device
1012
- intrinsic to fetch or sample their data.
1009
+ return type of the `fetch_image` and `sample_image` functions. If `DataT` is
1010
+ not a recognized standard type, as defined in <<recognized_standard_types>>,
1011
+ and instead a user-defined type, the user must provide a `HintT` template
1012
+ parameter to the `fetch_image` and `sample_image` functions, to allow the
1013
+ backend to select the correct device intrinsic to fetch or sample their data.
1014
+
1013
1015
`HintT` must be one of the the <<recognized_standard_types>>, and must be the
1014
1016
same size as `DataT`.
1015
1017
If `DataT` is a recognized standard type, and `HintT` is also passed, `HintT`
1016
1018
will be ignored.
1017
1019
1018
- When reading a texture backed by a normalized integer channel type, either
1019
- `DataT` must be a 32-bit or 16-bit floating point value, a `sycl::vec` of
1020
- 32-bit or 16-bit floating point values, or, in the case `DataT` is not one of
1021
- the above, then `HintT` must be one of the above, and be of the same size as
1020
+ When fetching or sampling an image backed by a normalized integer channel type,
1021
+ either `DataT` must be a 32-bit or 16-bit floating point value, a `sycl::vec`
1022
+ of 32-bit or 16-bit floating point values, or, in the case `DataT` is not one
1023
+ of the above, then `HintT` must be one of the above, and be of the same size as
1022
1024
`DataT`.
1023
1025
1024
1026
It's possible to write to an unsampled image via `write_image` passing the
@@ -1029,8 +1031,8 @@ of the <<recognized_standard_types>>.
1029
1031
1030
1032
Sampled images cannot be written to using `write_image`.
1031
1033
1032
- For reading and writing of unsampled images, coordinates are specified by `int`,
1033
- `sycl::vec<int, 2>`, and `sycl::vec<int, 3>` for 1D, 2D, and 3D images,
1034
+ For fetching and writing of unsampled images, coordinates are specified by
1035
+ `int`, ` sycl::vec<int, 2>`, and `sycl::vec<int, 3>` for 1D, 2D, and 3D images,
1034
1036
respectively.
1035
1037
1036
1038
Sampled image reads take `float`, `sycl::vec<float, 2>`, and
@@ -1046,8 +1048,8 @@ kernel must be submitted for the written data to be accessible.
1046
1048
1047
1049
[NOTE]
1048
1050
====
1049
- Attempting to read an image with `read_mipmap ` or any other defined read
1050
- function will result in undefined behaviour.
1051
+ Attempting to sample a standard sampled image with `sample_mipmap ` or any other
1052
+ defined sampling function will result in undefined behaviour.
1051
1053
====
1052
1054
1053
1055
=== Recognized standard types [[recognized_standard_types]]
@@ -1057,7 +1059,8 @@ standard types.
1057
1059
1058
1060
* All POD types (`char`, `short`, `int`, `float`, etc.) excluding `double`
1059
1061
* `sycl::half`
1060
- * Variants of `sycl::vec<T, N>` where `T` is one of the above, and `N` is `1`, `2`, or `3`
1062
+ * Variants of `sycl::vec<T, N>` where `T` is one of the above, and `N` is `1`,
1063
+ `2`, or `3`
1061
1064
1062
1065
Any other types are classified as user-defined types.
1063
1066
@@ -1168,26 +1171,26 @@ level of a given top-level descriptor.
1168
1171
1169
1172
=== Reading a mipmap
1170
1173
1171
- Inside the kernel, it's possible to read a mipmap via `read_mipmap`, passing the
1172
- `sampled_image_handle`, the coordinates, and either the level or anisotropic
1173
- gradient values.
1174
+ Inside the kernel, it's possible to sample a mipmap via `sample_mipmap`,
1175
+ passing the `sampled_image_handle`, the coordinates, and either the level or
1176
+ anisotropic gradient values.
1174
1177
1175
- The method of sampling a mipmap is different based on which `read_mipmap `
1178
+ The method of sampling a mipmap is different based on which `sample_mipmap `
1176
1179
function is used, and the sampler attributes passed upon creation of the
1177
1180
mipmap.
1178
1181
1179
1182
```c++
1180
1183
// Nearest/linear filtering between mip levels
1181
1184
template <typename DataT, typename HintT = DataT, typename CoordT>
1182
- DataT read_mipmap (const sampled_image_handle &ImageHandle,
1183
- const CoordT &Coords,
1184
- const float Level);
1185
+ DataT sample_mipmap (const sampled_image_handle &ImageHandle,
1186
+ const CoordT &Coords,
1187
+ const float Level);
1185
1188
1186
1189
// Anisotropic filtering
1187
1190
template <typename DataT, typename HintT = DataT, typename CoordT>
1188
- DataT read_mipmap (const sampled_image_handle &ImageHandle,
1189
- const CoordT &Coords,
1190
- const CoordT &Dx, const CoordT &Dy);
1191
+ DataT sample_mipmap (const sampled_image_handle &ImageHandle,
1192
+ const CoordT &Coords,
1193
+ const CoordT &Dx, const CoordT &Dy);
1191
1194
```
1192
1195
1193
1196
Reading a mipmap follows the same restrictions on what coordinate types may be
@@ -1199,8 +1202,8 @@ the restrictions as laid out in <<reading_writing_inside_kernel>>.
1199
1202
1200
1203
[NOTE]
1201
1204
====
1202
- Attempting to read a mipmap with `read_image ` or any other defined read function
1203
- will result in undefined behaviour.
1205
+ Attempting to sample a mipmap with `sample_image ` or any other defined sample
1206
+ function will result in undefined behaviour.
1204
1207
====
1205
1208
1206
1209
== Interoperability
@@ -1544,7 +1547,7 @@ try {
1544
1547
1545
1548
cgh.parallel_for(width, [=](sycl::id<1> id) {
1546
1549
// Extension: read image data from handle
1547
- float pixel = sycl::ext::oneapi::experimental::read_image <float>(
1550
+ float pixel = sycl::ext::oneapi::experimental::fetch_image <float>(
1548
1551
imgIn, int(id[0]));
1549
1552
1550
1553
// Extension: write to image data using handle
@@ -1646,7 +1649,7 @@ try {
1646
1649
float sum = 0;
1647
1650
for (int i = 0; i < numImages; i++) {
1648
1651
// Extension: read image data from handle
1649
- sum += (sycl::ext::oneapi::experimental::read_image <float>(
1652
+ sum += (sycl::ext::oneapi::experimental::fetch_image <float>(
1650
1653
imgHandleAcc[i], sycl::vec<int, 2>(dim0, dim1)));
1651
1654
}
1652
1655
outAcc[sycl::id{dim1, dim0}] = sum;
@@ -1736,9 +1739,9 @@ try {
1736
1739
float x = (static_cast<float>(id[0]) + 0.5f) / static_cast<float>(width);
1737
1740
// Read mipmap level 0 with anisotropic filtering
1738
1741
// and level 1 with level filtering
1739
- float px1 = sycl::ext::oneapi::experimental::read_mipmap <float>(
1742
+ float px1 = sycl::ext::oneapi::experimental::sample_mipmap <float>(
1740
1743
mipHandle, x, 0.0f, 0.0f);
1741
- float px2 = sycl::ext::oneapi::experimental::read_mipmap <float>(
1744
+ float px2 = sycl::ext::oneapi::experimental::sample_mipmap <float>(
1742
1745
mipHandle, x, 1.0f);
1743
1746
1744
1747
sum = px1 + px2;
@@ -1874,7 +1877,7 @@ try {
1874
1877
1875
1878
// Extension: read image data from handle to imported image
1876
1879
uint32_t pixel =
1877
- sycl::ext::oneapi::experimental::read_image <uint32_t>(
1880
+ sycl::ext::oneapi::experimental::fetch_image <uint32_t>(
1878
1881
img_input, sycl::vec<int, 2>(dim0, dim1));
1879
1882
1880
1883
// Modify the data before writing back
@@ -2076,4 +2079,9 @@ These features still need to be handled:
2076
2079
user-defined type.
2077
2080
|5.1|2023-12-06| - Added unique addressing modes per dimension to the
2078
2081
`bindless_image_sampler`
2082
+ |5.2|2024-02-14| - Image read and write functions now accept 3-component
2083
+ coordinates for 3D reads, instead of 4-component coordinates.
2084
+ |5.3|2024-02-16| - Replace `read_image` and `read_mipmap` APIs in favor of more
2085
+ descriptive naming, with `fetch_image`, `sample_image`, and
2086
+ `sample_mipmap`.
2079
2087
|======================
0 commit comments