Skip to content

[SYCL][Bindless] Add default constructor to bindless sampler #11895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,24 @@ struct bindless_image_sampler {
float minMipmapLevelClamp, float maxMipmapLevelClamp,
float maxAnisotropy);

sycl::addressing_mode addressing;
sycl::coordinate_normalization_mode coordinate;
sycl::filtering_mode filtering;
sycl::filtering_mode mipmap_filtering;
float min_mipmap_level_clamp;
float max_mipmap_level_clamp;
float max_anisotropy;
sycl::addressing_mode addressing = sycl::addressing_mode::none;
sycl::coordinate_normalization_mode coordinate =
sycl::coordinate_normalization_mode::unnormalized;
sycl::filtering_mode filtering = sycl::filtering_mode::nearest;
sycl::filtering_mode mipmap_filtering = sycl::filtering_mode::nearest;
float min_mipmap_level_clamp = 0.f;
float max_mipmap_level_clamp = 0.f;
float max_anisotropy = 0.f;
};

}
```

The `bindless_image_sampler` shall be default constructible and follow by-value
semantics. The value for the addressing mode, `addressing_mode::none`,
represents the backend's default addressing mode. On CUDA this is `Wrap`, i.e.
`addressing_mode::repeat`.

`mipmap_filtering` dictates the method in which sampling between mipmap
levels is performed.

Expand Down Expand Up @@ -1997,4 +2003,6 @@ These features still need to be handled:
restrictions on image types
|4.8|2023-10-25| - Change the name of `map_external_memory_array` to
`map_external_image_memory` to avoid CUDA terminology
|4.9|2023-11-13| - Add that the bindless sampler is default constructible
and follows by-value semantics
|======================
11 changes: 7 additions & 4 deletions sycl/include/sycl/ext/oneapi/bindless_images_sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ struct bindless_image_sampler {
max_mipmap_level_clamp(maxMipmapLevelClamp),
max_anisotropy(maxAnisotropy) {}

sycl::addressing_mode addressing;
sycl::coordinate_normalization_mode coordinate;
sycl::filtering_mode filtering;
sycl::filtering_mode mipmap_filtering;
bindless_image_sampler() = default;

sycl::addressing_mode addressing = sycl::addressing_mode::none;
sycl::coordinate_normalization_mode coordinate =
sycl::coordinate_normalization_mode::unnormalized;
sycl::filtering_mode filtering = sycl::filtering_mode::nearest;
sycl::filtering_mode mipmap_filtering = sycl::filtering_mode::nearest;
float min_mipmap_level_clamp = 0.f;
float max_mipmap_level_clamp = 0.f;
float max_anisotropy = 0.f;
Expand Down
9 changes: 8 additions & 1 deletion sycl/test-e2e/bindless_images/sampling_2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ int main() {
}

try {
sycl::ext::oneapi::experimental::bindless_image_sampler samp(
sycl::ext::oneapi::experimental::bindless_image_sampler tempSamp(
sycl::addressing_mode::repeat,
sycl::coordinate_normalization_mode::normalized,
sycl::filtering_mode::linear);

// Default constructible sampler
sycl::ext::oneapi::experimental::bindless_image_sampler samp;

// Sampler follows by-value semantics
sycl::ext::oneapi::experimental::bindless_image_sampler tempSamp2(tempSamp);
samp = tempSamp2;

// Extension: image descriptor -- can use the same for both images
sycl::ext::oneapi::experimental::image_descriptor desc(
{width, height}, sycl::image_channel_order::rgba,
Expand Down