USM Image Accessor
USM Image Accessor#
Description
USM Image accessor provides access to a USM image.
Include Files
oneapi/ipl.hpp
Domain Dependencies
Headers: oneapi/ipl.hpp
Libraries: oneipl.lib
Syntax
-
template<layouts Layout, typename DataT, sycl::access_mode AccessMode, typename AccessDataT>
class usm_image_accessor : public oneapi::ipl::usm_image_accessor_base<Layout, DataT, AccessMode># Provides access to a USM image.
- Template Parameters
Layout – the given layout of an image
DataT – the given type of a pixel component
AccessMode – the given acccess mode (sycl::access_mode)
AccessDataT – the given access type
Public Types
-
using data_t = typename usm_image_accessor_base_t::data_t#
Alias for the type of a pixel component.
-
template<typename SomeDataT>
using pixel_t = sycl::vec<SomeDataT, channel_count_v># Alias for the pixel type.
-
template<typename SomeDataT>
using pixel4_t = sycl::vec<SomeDataT, sycl_channel_count_v># Alias for the 4-component pixel type corresponding to RGBA images.
-
using native_pixel_t = pixel_t<data_t>#
Alias for the pixel type with the given type of a pixel component.
-
using native_pixel4_t = pixel4_t<data_t>#
Alias for the 4-component pixel type corresponding to RGBA images with the given type of a pixel component.
-
using access_data_t = AccessDataT#
Alias for the type of a pixel component for computations.
-
using access_pixel_t = pixel_t<access_data_t>#
Alias for the pixel type with the type of a pixel component for computations.
-
using access_pixel4_t = pixel4_t<access_data_t>#
Alias for the 4-component pixel type corresponding to RGBA images with the type of a pixel component for computations.
Public Functions
-
auto read(const sycl::int2 &coordinates) const -> access_pixel4_t#
Reads and returns an element of the image at the coordinates specified by
coordinates
.- Parameters
coordinates – [in] the given pixel coordinates
-
template<sycl::access_mode AccessMode2 = access_mode_v>
auto write(const sycl::int2 &coordinates, const access_pixel4_t &pixel) const -> void# Writes the value specified by
pixel
to the element of the image at the coordinates specified bycoordinates
.- Template Parameters
AccessMode2 – the given access mode (sycl::access_mode)
- Parameters
coordinates – [in] the given pixel coordinates
pixel – [in] the given pixel
-
std::size_t get_pitch() const noexcept#
Returns the image stride in bytes.
- Returns
the image stride in bytes
-
std::size_t get_count() const#
Returns the total number of pixels that this accessor may access.
- Returns
the total number of pixels that this accessor may access
-
sycl::range<2> get_range() const#
Returns a range object which represents the number of elements of DataT per dimension that this accessor may access.
- Returns
a range object which represents the number of elements of DataT per dimension that this accessor may access
Public Static Attributes
-
static constexpr int sycl_channel_count_v = {4}#
Alias for the number of channels corresponding to RGBA images.
-
static constexpr auto channel_count_v#
Alias for the number of image channels.
-
static constexpr auto access_mode_v#
Alias for the access mode.
-
static constexpr auto is_access_read_only_v = detail::is_access_read_only(AccessMode)#
The flag that shows whether the access mode is read-only.
-
static constexpr auto is_access_any_write_v = detail::is_access_any_write(AccessMode)#
The flag that shows whether the access mode is any write.
Supported values for AccessMode:
|
|
Supported values for AccessDataT:
|
|
|
|
|
|
|
The code example below demonstrates how shall be called
oneapi::ipl::usm_image_accessor
:
using namespace oneapi;
sycl::queue queue;
ipl::shared_usm_allocator_t allocator{ queue };
const sycl::range<2> image_size{ height, width };
const sycl::int2 coords2d{ 0, 0 };
// 3-channel image
ipl::image<ipl::layouts::channel3, std::uint8_t> usm_image{ queue, p_image_data, image_size, allocator };
// USM image accessor
const auto usm_image_accessor = usm_image.get_access<sycl::vec<float, 4>, sycl::access_mode::read>();
// Reading first pixel
const auto pixel = usm_image_accessor.read(coords2d);
std::cout << "Pixel: " << pixel[0] << " " << pixel[1] << " " << pixel[2] << std::endl;