@@ -159,23 +159,6 @@ of 3D USM images.
159
159
```cpp
160
160
namespace sycl::ext::oneapi::experimental {
161
161
162
- enum class image_channel_order : /* unspecified */ {
163
- a,
164
- r,
165
- rx,
166
- rg,
167
- rgx,
168
- ra,
169
- rgb,
170
- rgbx,
171
- rgba,
172
- argb,
173
- bgra,
174
- intensity,
175
- luminance,
176
- abgr,
177
- };
178
-
179
162
enum class image_channel_type : /* unspecified */ {
180
163
snorm_int8,
181
164
snorm_int16,
@@ -202,25 +185,25 @@ struct image_descriptor {
202
185
size_t width{0};
203
186
size_t height{0};
204
187
size_t depth{0};
205
- image_channel_order channel_order{image_channel_order::rgba };
188
+ unsigned int num_channels{4 };
206
189
image_channel_type channel_type{image_channel_type::fp32};
207
190
image_type type{image_type::standard};
208
191
unsigned int num_levels{1};
209
192
unsigned int array_size{1};
210
193
211
194
image_descriptor() = default;
212
195
213
- image_descriptor(sycl::range<1> dims, image_channel_order channel_order ,
196
+ image_descriptor(sycl::range<1> dims, unsigned int num_channels ,
214
197
image_channel_type channel_type,
215
198
image_type type = image_type::standard,
216
199
unsigned int num_levels = 1, unsigned int array_size = 1);
217
200
218
- image_descriptor(sycl::range<2> dims, image_channel_order channel_order ,
201
+ image_descriptor(sycl::range<2> dims, unsigned int num_channels ,
219
202
image_channel_type channel_type,
220
203
image_type type = image_type::standard,
221
204
unsigned int num_levels = 1, unsigned int array_size = 1);
222
205
223
- image_descriptor(sycl::range<3> dims, image_channel_order channel_order ,
206
+ image_descriptor(sycl::range<3> dims, unsigned int num_channels ,
224
207
image_channel_type channel_type,
225
208
image_type type = image_type::standard,
226
209
unsigned int num_levels = 1, unsigned int array_size = 1);
@@ -233,9 +216,9 @@ struct image_descriptor {
233
216
}
234
217
```
235
218
236
- The image descriptor represents the image dimensions, channel type , and channel
237
- order . An `image_type` member is also present to allow for implementation of
238
- mipmapped, image array, and cubemapped images.
219
+ The image descriptor represents the image dimensions, number of channels , and
220
+ channel type . An `image_type` member is also present to allow for implementation
221
+ of mipmapped, image array, and cubemapped images.
239
222
240
223
The `image_descriptor` shall be default constructible and follow by-value
241
224
semantics.
@@ -256,6 +239,8 @@ descriptor against the limitations outlined below. If the given descriptor is
256
239
deemed invalid, then a `sycl::exception` will be thrown with error code
257
240
`sycl::errc::invalid`.
258
241
242
+ For all image types, the value of `num_channels` must be `1`, `2`, or `4`.
243
+
259
244
For the `standard` image type, the value of `num_levels` and `array_size` must
260
245
both be `1`.
261
246
@@ -311,9 +296,8 @@ public:
311
296
sycl::context get_context() const;
312
297
313
298
sycl::range<3> get_range() const;
314
- sycl::image_channel_type get_image_channel_type() const;
315
- sycl::image_channel_type get_image_channel_order() const;
316
- unsigned int get_image_num_channels() const;
299
+ sycl::image_channel_type get_channel_type() const;
300
+ unsigned int get_num_channels() const;
317
301
image_type get_type() const;
318
302
319
303
image_mem_handle get_mip_level_mem_handle(unsigned int level) const;
@@ -394,7 +378,7 @@ using the `image_mem_alloc` function. These are similar to the member functions
394
378
provided by `image_mem`. However, since the `image_mem_handle` is a minimal
395
379
struct representing just the opaque handle the underlying memory object, there
396
380
is some information that we cannot retrieve from it, namely the `image_type`,
397
- `image_channel_order `, the `sycl::context` or `sycl::device` the memory was
381
+ `num_channels `, the `sycl::context` or `sycl::device` the memory was
398
382
allocated in, and the `image_descriptor` used to allocate the memory.
399
383
400
384
```cpp
@@ -1072,13 +1056,13 @@ void write_image(unsampled_image_handle ImageHandle,
1072
1056
```
1073
1057
1074
1058
Inside a kernel, it's possible to retrieve data from an image via `fetch_image`
1075
- or `sample_image`, passing the appropirate image handle. The `fetch_image` API
1059
+ or `sample_image`, passing the appropriate image handle. The `fetch_image` API
1076
1060
is applicable to sampled and unsampled images, and the data will be fetched
1077
1061
exactly as is in device memory. The `sample_image` API is only applicable to
1078
1062
sampled images, the image data will be sampled according to the
1079
1063
`bindless_image_sampler` that was passed to the image upon construction.
1080
1064
1081
- When fetching from a sampled image handle, data exatly as is in memory, no
1065
+ When fetching from a sampled image handle, data exactly as is in memory, no
1082
1066
sampling operations will be performed, and the `bindless_image_sampler` passed
1083
1067
to the image upon creation has no effect on the returned image data. Note that
1084
1068
not all devices may support fetching of sampled image data depending on the
@@ -1669,7 +1653,7 @@ When calling `create_image` with an `image_mem_handle` mapped from an external
1669
1653
memory object, the user must ensure that the image descriptor they pass to
1670
1654
`create_image` has members that match or map to those of the external API.
1671
1655
A mismatch between any of the `width`, `height`, `depth`, `image_channel_type`,
1672
- or `image_channel_order ` members will result in undefined behavior.
1656
+ or `num_channels ` members will result in undefined behavior.
1673
1657
1674
1658
Additionally, the `image_type` describing the image must match to the image of
1675
1659
the external API. The current supported importable image types are `standard`
@@ -1851,7 +1835,7 @@ for (int i = 0; i < width; i++) {
1851
1835
1852
1836
// Image descriptor - can use the same for both images
1853
1837
sycl::ext::oneapi::experimental::image_descriptor desc(
1854
- sycl::range{width}, sycl::ext::oneapi::experimental::image_channel_order::r ,
1838
+ sycl::range{width}, 1 ,
1855
1839
sycl::ext::oneapi::experimental::image_channel_type::fp32);
1856
1840
1857
1841
try {
@@ -1930,7 +1914,7 @@ for (int i = 0; i < width; i++) {
1930
1914
1931
1915
// Image descriptor - can use the same for all images
1932
1916
sycl::ext::oneapi::experimental::image_descriptor desc(
1933
- {width, height}, sycl::ext::oneapi::experimental::image_channel_order::r ,
1917
+ {width, height}, 1 ,
1934
1918
sycl::ext::oneapi::experimental::image_channel_type::fp32);
1935
1919
1936
1920
try {
@@ -2030,7 +2014,7 @@ try {
2030
2014
2031
2015
// Image descriptor -- number of levels
2032
2016
sycl::ext::oneapi::experimental::image_descriptor desc(
2033
- {width}, sycl::ext::oneapi::experimental::image_channel_order::r,
2017
+ {width}, 1,
2034
2018
sycl::ext::oneapi::experimental::image_channel_type::fp32,
2035
2019
sycl::ext::oneapi::experimental::image_type::mipmap, num_levels);
2036
2020
@@ -2130,7 +2114,7 @@ for (int i = 0; i < width; i++) {
2130
2114
try {
2131
2115
// Extension: image descriptor -- number of layers
2132
2116
sycl::ext::oneapi::experimental::image_descriptor desc(
2133
- {width}, sycl::image_channel_order::rgba , sycl::image_channel_type::fp32,
2117
+ {width}, 4 , sycl::image_channel_type::fp32,
2134
2118
sycl::ext::oneapi::experimental::image_type::array, 1, array_size);
2135
2119
2136
2120
// Extension: allocate image array memory on device
@@ -2259,7 +2243,7 @@ int main() {
2259
2243
2260
2244
// Extension: image descriptor - Cubemap
2261
2245
syclexp::image_descriptor desc(
2262
- {width, height}, sycl::image_channel_order::rgba ,
2246
+ {width, height}, 4 ,
2263
2247
sycl::image_channel_type::fp32, syclexp::image_type::cubemap, 1, 6);
2264
2248
2265
2249
syclexp::bindless_image_sampler samp(
@@ -2362,17 +2346,17 @@ sycl::context context = queue.get_context();
2362
2346
size_t width = /* passed from external API */;
2363
2347
size_t height = /* passed from external API */;
2364
2348
2365
- sycl::ext::oneapi::experimental::image_channel_order channel_order =
2349
+ unsigned int num_channels = 1;
2366
2350
/* mapped from external API */
2367
- /* we assume sycl::image_channel_order::r */;
2351
+ /* we assume there is one channel */;
2368
2352
2369
2353
sycl::ext::oneapi::experimental::image_channel_type channel_type =
2370
2354
/* mapped from external API */
2371
2355
/* we assume sycl::image_channel_type::unsigned_int32 */;
2372
2356
2373
2357
// Image descriptor - mapped to external API image layout
2374
2358
sycl::ext::oneapi::experimental::image_descriptor desc(
2375
- {width, height}, channel_order , channel_type);
2359
+ {width, height}, num_channels , channel_type);
2376
2360
2377
2361
size_t img_size_in_bytes = width * height * sizeof(uint32_t);
2378
2362
@@ -2689,4 +2673,13 @@ These features still need to be handled:
2689
2673
|5.8|2024-05-09| - Add missing cubemap `HintT` template parameter to
2690
2674
`fetch_cubemap` and `sample_cubemap`.
2691
2675
|5.9|2024-05-14| - Default constructor for `image_descriptor`.
2676
+ |5.10|2024-05-20| - Replaced `channel_order` field in `image_descriptor` with
2677
+ `num_channels`.
2678
+ - Renamed `image_mem` functions `get_image_channel_type()`
2679
+ to `get_channel_type()` and `get_image_num_channels()` to
2680
+ `get_num_channels()`.
2681
+ - Removed `get_channel_order()` function from `image_mem`.
2682
+ This function is redundant since images don't have a notion
2683
+ of channel order, only the channel size. Use
2684
+ `get_num_channels()` instead.
2692
2685
|======================
0 commit comments