Skip to content

Commit 99a7430

Browse files
committed
[Bindless][Exp][NFC] Deprecate read_image for more descriptive naming
- The `read_image` and `read_mipmap` APIs have been deprecated - They are replaced with the more descriptive `fetch_image`, `sample_image`, and `sample_mipmap` (for unsampled reads, sampled reads, and mipmap sampled reads, respectively). - This change is made in preperation for future functionality of fetching data from sampled images. - The reason behind this change is to avoid determining the underlying image read operation based on the coordinate type passed, and instead making it more transparent for the user which operation is performed based on the name of the function. - The extension document, bindless images headers, and all bindless images tests have all been updated. - The specification revision history has been updated to include a missed changelog entry for PR intel#12581
1 parent 1a98c4c commit 99a7430

29 files changed

+272
-193
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -986,39 +986,41 @@ listed above caused the failure.
986986
namespace sycl::ext::oneapi::experimental {
987987

988988
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);
991991
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);
994994

995995
template <typename DataT, typename CoordT>
996996
void write_image(unsampled_image_handle &ImageHandle,
997997
const CoordT &Coords, const DataT &Color);
998998
}
999999
```
10001000

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
10051006
`bindless_image_sampler` that was passed to the image upon construction.
10061007

10071008
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+
10131015
`HintT` must be one of the the <<recognized_standard_types>>, and must be the
10141016
same size as `DataT`.
10151017
If `DataT` is a recognized standard type, and `HintT` is also passed, `HintT`
10161018
will be ignored.
10171019

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
10221024
`DataT`.
10231025

10241026
It's possible to write to an unsampled image via `write_image` passing the
@@ -1029,8 +1031,8 @@ of the <<recognized_standard_types>>.
10291031

10301032
Sampled images cannot be written to using `write_image`.
10311033

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,
10341036
respectively.
10351037

10361038
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.
10461048

10471049
[NOTE]
10481050
====
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.
10511053
====
10521054

10531055
=== Recognized standard types [[recognized_standard_types]]
@@ -1057,7 +1059,8 @@ standard types.
10571059

10581060
* All POD types (`char`, `short`, `int`, `float`, etc.) excluding `double`
10591061
* `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`
10611064

10621065
Any other types are classified as user-defined types.
10631066

@@ -1168,26 +1171,26 @@ level of a given top-level descriptor.
11681171

11691172
=== Reading a mipmap
11701173

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.
11741177

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`
11761179
function is used, and the sampler attributes passed upon creation of the
11771180
mipmap.
11781181

11791182
```c++
11801183
// Nearest/linear filtering between mip levels
11811184
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);
11851188

11861189
// Anisotropic filtering
11871190
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);
11911194
```
11921195

11931196
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>>.
11991202

12001203
[NOTE]
12011204
====
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.
12041207
====
12051208

12061209
== Interoperability
@@ -1544,7 +1547,7 @@ try {
15441547

15451548
cgh.parallel_for(width, [=](sycl::id<1> id) {
15461549
// 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>(
15481551
imgIn, int(id[0]));
15491552

15501553
// Extension: write to image data using handle
@@ -1646,7 +1649,7 @@ try {
16461649
float sum = 0;
16471650
for (int i = 0; i < numImages; i++) {
16481651
// Extension: read image data from handle
1649-
sum += (sycl::ext::oneapi::experimental::read_image<float>(
1652+
sum += (sycl::ext::oneapi::experimental::fetch_image<float>(
16501653
imgHandleAcc[i], sycl::vec<int, 2>(dim0, dim1)));
16511654
}
16521655
outAcc[sycl::id{dim1, dim0}] = sum;
@@ -1736,9 +1739,9 @@ try {
17361739
float x = (static_cast<float>(id[0]) + 0.5f) / static_cast<float>(width);
17371740
// Read mipmap level 0 with anisotropic filtering
17381741
// 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>(
17401743
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>(
17421745
mipHandle, x, 1.0f);
17431746

17441747
sum = px1 + px2;
@@ -1874,7 +1877,7 @@ try {
18741877

18751878
// Extension: read image data from handle to imported image
18761879
uint32_t pixel =
1877-
sycl::ext::oneapi::experimental::read_image<uint32_t>(
1880+
sycl::ext::oneapi::experimental::fetch_image<uint32_t>(
18781881
img_input, sycl::vec<int, 2>(dim0, dim1));
18791882

18801883
// Modify the data before writing back
@@ -2076,4 +2079,9 @@ These features still need to be handled:
20762079
user-defined type.
20772080
|5.1|2023-12-06| - Added unique addressing modes per dimension to the
20782081
`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`.
20792087
|======================

0 commit comments

Comments
 (0)