Skip to content

Commit e5dd111

Browse files
[Bindless][Exp] Add constructors to image handle structs (#11896)
- Constructors were added to the `sampled_image_handle` and `unsampled_image_handle` structs to allow creation of image handles from raw handles. - Removed `sampler_handle` member from `sampled_image_handle` struct, awaiting the LevelZero and SPIR-V extensions to become more mature before deciding whether we need a sampler handle. - Align naming of raw image handle members between specification and implementation.
1 parent 3b97561 commit e5dd111

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_bindless_images.asciidoc

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,16 +505,19 @@ namespace sycl::ext::oneapi::experimental {
505505
/// Opaque unsampled image handle type.
506506
struct unsampled_image_handle {
507507
using raw_image_handle_type = /* Implementation defined */;
508-
raw_image_handle_type image_handle;
508+
509+
unsampled_image_handle(raw_image_handle_type raw_handle);
510+
511+
raw_image_handle_type raw_handle;
509512
};
510513

511514
/// Opaque sampled image handle type.
512515
struct sampled_image_handle {
513516
using raw_image_handle_type = /* Implementation defined */;
514-
using raw_sampler_handle_type = /* Implementation defined */
515517

516-
raw_image_handle_type image_handle;
517-
raw_sampler_handle_type sampler_handle;
518+
sampled_image_handle(raw_image_handle_type raw_image_handle);
519+
520+
raw_image_handle_type raw_handle;
518521
};
519522

520523
// Creating an unsampled image from an `image_mem_handle`
@@ -617,6 +620,9 @@ with error code `sycl::errc::runtime`.
617620
The `unsampled_image_handle` and `sampled_image_handle` types shall be
618621
default-constructible, copy-constructible, and device-copyable.
619622

623+
The `unsampled_image_handle` and `sampled_image_handle` types have a
624+
constructor to allow creation of the types from a `raw_image_handle_type`
625+
620626
[NOTE]
621627
====
622628
In the DPC++ CUDA backend a sampled image will correspond to a CUDA texture,
@@ -973,9 +979,7 @@ Inside a kernel, it's possible to read an image via `read_image`, passing
973979
the image handle. For the form that takes `unsampled_image_handle`, image data
974980
will be fetched exactly as is in device memory. For the form that takes a
975981
`sampled_image_handle`, the image will be sampled according to the
976-
`bindless_image_sampler` that was passed to the image upon construction. The
977-
sampler handle is included in the `sampled_image_handle` as
978-
`sampled_image_handle::raw_sampler_handle`.
982+
`bindless_image_sampler` that was passed to the image upon construction.
979983

980984
The returned data will be of templated type `DataT`, which is specified by the
981985
user, and should map to the type that the image was created with (a combination
@@ -2005,4 +2009,12 @@ These features still need to be handled:
20052009
`map_external_image_memory` to avoid CUDA terminology
20062010
|4.9|2023-11-13| - Add that the bindless sampler is default constructible
20072011
and follows by-value semantics
2012+
|4.10|2023-11-15| - Added constructors for `sampled_image_handle` and
2013+
`unsampled_image_handle` structs.
2014+
- Removed `raw_sampler_handle` member from
2015+
`sampled_image_handle` struct. Awaiting LevelZero
2016+
and SPIR-V extensions to mature before before deciding
2017+
whether a `raw_sampler_handle` member is necessary.
2018+
- Renamed `image_handle` members in `sampled_image_handle` and
2019+
`unsampled_image_handle` structs to `raw_handle`.
20082020
|======================

sycl/include/sycl/ext/oneapi/bindless_images.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,22 @@ namespace ext::oneapi::experimental {
3030

3131
/// Opaque unsampled image handle type.
3232
struct unsampled_image_handle {
33-
using raw_handle_type = pi_uint64;
34-
raw_handle_type raw_handle;
33+
using raw_image_handle_type = pi_uint64;
34+
35+
unsampled_image_handle(raw_image_handle_type raw_image_handle)
36+
: raw_handle(raw_image_handle) {}
37+
38+
raw_image_handle_type raw_handle;
3539
};
40+
3641
/// Opaque sampled image handle type.
3742
struct sampled_image_handle {
38-
using raw_handle_type = pi_uint64;
39-
raw_handle_type raw_handle;
43+
using raw_image_handle_type = pi_uint64;
44+
45+
sampled_image_handle(raw_image_handle_type raw_image_handle)
46+
: raw_handle(raw_image_handle) {}
47+
48+
raw_image_handle_type raw_handle;
4049
};
4150

4251
/**

0 commit comments

Comments
 (0)