22 inline namespace _V1 {
23 namespace ext::oneapi::experimental {
62 : descriptor(desc), syclDevice(syclDevice), syclContext(syclContext) {
76 std::make_shared<detail::image_mem_impl>(desc, syclDevice, syclContext);
84 auto desc = impl->get_descriptor();
85 return {desc.width, desc.height, desc.depth};
89 return impl->get_descriptor().channel_type;
93 return impl->get_descriptor().channel_order;
98 impl->get_descriptor().channel_order);
102 return impl->get_descriptor().type;
108 impl->get_handle(),
level, impl->get_device(), impl->get_context());
114 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
117 std::shared_ptr<sycl::detail::device_impl> DevImpl =
119 pi_device Device = DevImpl->getHandleRef();
123 Plugin->call<sycl::errc::runtime,
125 C, Device, piImageHandle);
137 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
140 std::shared_ptr<sycl::detail::device_impl> DevImpl =
142 pi_device Device = DevImpl->getHandleRef();
146 Plugin->call<sycl::errc::runtime,
148 C, Device, piImageHandle);
157 __SYCL_EXPORT image_mem_handle
162 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
165 std::shared_ptr<sycl::detail::device_impl> DevImpl =
167 pi_device Device = DevImpl->getHandleRef();
177 Plugin->call<sycl::errc::memory_allocation,
179 C, Device, &piFormat, &piDesc, &retHandle.
raw_handle);
189 __SYCL_EXPORT_DEPRECATED(
"Distinct mipmap allocs are deprecated. "
190 "Instead use alloc_image_mem().")
196 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
199 std::shared_ptr<sycl::detail::device_impl> DevImpl =
201 pi_device Device = DevImpl->getHandleRef();
210 Plugin->call<sycl::errc::memory_allocation,
212 C, Device, &piFormat, &piDesc, &retHandle.
raw_handle);
217 __SYCL_EXPORT_DEPRECATED(
"Distinct mipmap allocs are deprecated. "
218 "Instead use alloc_image_mem().")
222 syclQueue.get_context());
229 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
232 std::shared_ptr<sycl::detail::device_impl> DevImpl =
234 pi_device Device = DevImpl->getHandleRef();
239 Plugin->call<sycl::errc::runtime,
243 return individual_image;
246 __SYCL_EXPORT image_mem_handle
257 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
260 std::shared_ptr<sycl::detail::device_impl> DevImpl =
262 pi_device Device = DevImpl->getHandleRef();
267 Plugin->call<sycl::errc::memory_allocation,
273 Plugin->call<sycl::errc::memory_allocation,
278 "Invalid image type to free");
290 __SYCL_EXPORT_DEPRECATED(
"Distinct image frees are deprecated. "
291 "Instead use overload that accepts image_type.")
298 __SYCL_EXPORT_DEPRECATED(
"Distinct image frees are deprecated. "
299 "Instead use overload that accepts image_type.")
301 free_image_mem(memHandle, syclQueue.get_device(), syclQueue.get_context());
304 __SYCL_EXPORT_DEPRECATED(
305 "Distinct mipmap frees are deprecated. "
306 "Instead use free_image_mem() that accepts image_type.")
310 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
313 std::shared_ptr<sycl::detail::device_impl> DevImpl =
315 pi_device Device = DevImpl->getHandleRef();
318 Plugin->call<sycl::errc::memory_allocation,
320 C, Device, memoryHandle.raw_handle);
323 __SYCL_EXPORT_DEPRECATED(
324 "Distinct mipmap frees are deprecated. "
325 "Instead use free_image_mem() that accepts image_type.")
329 syclQueue.get_context());
332 __SYCL_EXPORT unsampled_image_handle
338 __SYCL_EXPORT unsampled_image_handle
345 __SYCL_EXPORT unsampled_image_handle
350 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
353 std::shared_ptr<sycl::detail::device_impl> DevImpl =
355 pi_device Device = DevImpl->getHandleRef();
365 Plugin->call<sycl::errc::runtime,
367 C, Device, memHandle.
raw_handle, &piFormat, &piDesc, &piImage,
373 __SYCL_EXPORT unsampled_image_handle
380 __SYCL_EXPORT sampled_image_handle
385 syclDevice, syclContext);
388 __SYCL_EXPORT sampled_image_handle
395 __SYCL_EXPORT sampled_image_handle
400 desc, syclDevice, syclContext);
403 __SYCL_EXPORT sampled_image_handle
410 __SYCL_EXPORT sampled_image_handle
416 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
419 std::shared_ptr<sycl::detail::device_impl> DevImpl =
421 pi_device Device = DevImpl->getHandleRef();
442 Plugin->call<sycl::errc::runtime,
454 Plugin->call<sycl::errc::runtime,
456 C, Device, devPtr, &piFormat, &piDesc, piSampler, &piImage,
462 __SYCL_EXPORT sampled_image_handle
473 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
476 std::shared_ptr<sycl::detail::device_impl> DevImpl =
478 pi_device Device = DevImpl->getHandleRef();
482 Plugin->call<sycl::errc::invalid,
499 __SYCL_EXPORT_DEPRECATED(
500 "import_external_memory templated by external_mem_fd is deprecated."
501 "Template with resource_fd instead.")
508 externalMem.external_resource.file_descriptor;
514 __SYCL_EXPORT_DEPRECATED(
515 "import_external_memory templated by external_mem_fd is deprecated."
516 "Template with resource_fd instead.")
521 externalMem, syclQueue.get_device(), syclQueue.get_context());
531 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
534 std::shared_ptr<sycl::detail::device_impl> DevImpl =
536 pi_device Device = DevImpl->getHandleRef();
546 Plugin->call<sycl::errc::invalid,
548 C, Device, &piFormat, &piDesc, piInteropMem, &retHandle.
raw_handle);
561 __SYCL_EXPORT_DEPRECATED(
"map_external_memory_array is deprecated."
562 "use map_external_image_memory")
570 __SYCL_EXPORT_DEPRECATED(
"map_external_memory_array is deprecated."
571 "use map_external_image_memory")
576 syclQueue.get_context());
582 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
585 std::shared_ptr<sycl::detail::device_impl> DevImpl =
587 pi_device Device = DevImpl->getHandleRef();
590 Plugin->call<sycl::errc::invalid,
605 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
609 std::shared_ptr<sycl::detail::device_impl> DevImpl =
611 pi_device Device = DevImpl->getHandleRef();
615 Plugin->call<sycl::errc::invalid,
618 &piInteropSemaphore);
632 __SYCL_EXPORT_DEPRECATED(
"import_external_semaphore templated by "
633 "external_semaphore_fd is deprecated."
634 "Template with resource_fd instead.")
641 externalSemaphoreDesc.external_resource.file_descriptor;
642 return import_external_semaphore<resource_fd>(extSem, syclDevice,
647 __SYCL_EXPORT_DEPRECATED(
"import_external_semaphore templated by "
648 "external_semaphore_fd is deprecated."
649 "Template with resource_fd instead.")
654 externalSemaphoreDesc, syclQueue.get_device(), syclQueue.get_context());
661 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
665 std::shared_ptr<sycl::detail::device_impl> DevImpl =
667 pi_device Device = DevImpl->getHandleRef();
669 Plugin->call<sycl::errc::invalid,
684 std::ignore = syclDevice;
685 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
689 size_t Width, Height, Depth;
691 Plugin->call<sycl::errc::invalid,
695 Plugin->call<sycl::errc::invalid,
699 Plugin->call<sycl::errc::invalid,
703 return {Width, Height, Depth};
716 std::ignore = syclDevice;
717 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
723 Plugin->call<sycl::errc::invalid,
741 size_t widthInBytes,
size_t height,
742 unsigned int elementSizeBytes,
745 void *RetVal =
nullptr;
746 if (widthInBytes == 0 || height == 0 || elementSizeBytes == 0) {
748 "Cannot allocate pitched memory with zero size!");
751 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
753 if (CtxImpl->is_host()) {
755 "Cannot allocate pitched memory on host!");
764 Plugin->call<sycl::errc::memory_allocation,
773 size_t widthInBytes,
size_t height,
774 unsigned int elementSizeBytes,
792 uint8_t numChannels =
794 unsigned int elementSizeBytes =
797 size_t widthInBytes = desc.
width * elementSizeBytes;
798 size_t height = desc.
height;
801 elementSizeBytes, syclDevice, syclContext);
804 __SYCL_EXPORT
unsigned int
808 std::ignore = syclDevice;
810 std::shared_ptr<sycl::detail::context_impl> CtxImpl =
815 Plugin->call<sycl::errc::runtime,
825 __SYCL_EXPORT
unsigned int
The context class represents a SYCL context on which kernel functions may be executed.
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
image_mem_impl(const image_descriptor &desc, const device &syclDevice, const context &syclContext)
A class that represents image memory.
sycl::image_channel_type get_channel_type() const
raw_handle_type get_handle() const
sycl::image_channel_order get_channel_order() const
unsigned int get_num_channels() const
image_type get_type() const
sycl::range< 3 > get_range() const
raw_handle_type get_mip_level_mem_handle(const unsigned int level) const
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
device get_device() const
context get_context() const
Defines the iteration domain of either a single work-group in a parallel dispatch,...
uint8_t getImageElementSize(uint8_t NumChannels, image_channel_type Type)
sycl::detail::pi::PiMemImageChannelOrder convertChannelOrder(image_channel_order Order)
decltype(Obj::impl) getSyclObjImpl(const Obj &SyclObject)
std::shared_ptr< plugin > PluginPtr
sycl::detail::pi::PiMemImageChannelType convertChannelType(image_channel_type Type)
uint8_t getImageNumberChannels(image_channel_order Order)
void populate_pi_structs(const image_descriptor &desc, pi_image_desc &piDesc, pi_image_format &piFormat, size_t pitch=0)
image_mem_handle map_external_image_memory(interop_mem_handle memHandle, const image_descriptor &desc, const sycl::device &syclDevice, const sycl::context &syclContext)
Maps an interop memory handle to an image memory handle (which may have a device optimized memory lay...
sycl::range< 3 > get_image_range(const image_mem_handle memHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Get the range that describes the image's dimensions.
unsigned int get_image_num_channels(const image_mem_handle memHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Get the number of channels that describes the image memory.
interop_mem_handle import_external_memory< resource_fd >(external_mem_descriptor< resource_fd > externalMem, const sycl::device &syclDevice, const sycl::context &syclContext)
const CoordT const float level
void free_image_mem(image_mem_handle handle, const sycl::device &syclDevice, const sycl::context &syclContext)
[Deprecated] Free image memory
interop_mem_handle import_external_memory(external_mem_descriptor< ExternalMemHandleType > externalMem, const sycl::device &syclDevice, const sycl::context &syclContext)
Import external memory taking an external memory handle (the type of which is dependent on the OS & e...
unsampled_image_handle create_image(image_mem &memHandle, const image_descriptor &desc, const sycl::device &syclDevice, const sycl::context &syclContext)
Create an image and return the device image handle.
void * pitched_alloc_device(size_t *resultPitch, size_t widthInBytes, size_t height, unsigned int elementSizeBytes, const sycl::queue &syclQueue)
Allocate pitched USM image memory.
image_mem_handle map_external_memory_array(interop_mem_handle memHandle, const image_descriptor &desc, const sycl::device &syclDevice, const sycl::context &syclContext)
[Deprecated] Maps an interop memory handle to an image memory handle (which may have a device optimiz...
image_mem_handle alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice, const sycl::context &syclContext)
Allocate image memory based on image_descriptor.
interop_mem_handle import_external_memory< external_mem_fd >(external_mem_descriptor< external_mem_fd > externalMem, const sycl::device &syclDevice, const sycl::context &syclContext)
void release_external_memory(interop_mem_handle interopHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Release external memory.
void destroy_external_semaphore(interop_semaphore_handle semaphoreHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Destroy the external semaphore handle.
image_mem_handle get_mip_level_mem_handle(const image_mem_handle mipMem, const unsigned int level, const sycl::device &syclDevice, const sycl::context &syclContext)
Retrieve the memory handle to an individual mipmap image.
void free_mipmap_mem(image_mem_handle handle, const sycl::device &syclDevice, const sycl::context &syclContext)
[Deprecated] Free mipmap memory
interop_semaphore_handle import_external_semaphore(external_semaphore_descriptor< ExternalSemaphoreHandleType > externalSemaphoreDesc, const sycl::device &syclDevice, const sycl::context &syclContext)
Import external semaphore taking an external semaphore handle (the type of which is dependent on the ...
void destroy_image_handle(unsampled_image_handle &imageHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Destroy an unsampled image handle.
image_type
image type enum
sycl::image_channel_type get_image_channel_type(const image_mem_handle memHandle, const sycl::device &syclDevice, const sycl::context &syclContext)
Get the channel type that describes the image memory.
image_mem_handle alloc_mipmap_mem(const image_descriptor &desc, const sycl::device &syclDevice, const sycl::context &syclContext)
[Deprecated] Allocate mipmap memory based on image_descriptor
std::error_code make_error_code(sycl::errc E) noexcept
Constructs an error code using e and sycl_category()
static device_ext & get_device(unsigned int id)
Util function to get a device by id.
constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_NORMALIZED_COORDS
constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_ADDRESSING_MODE
pi_result piextMemImageAllocate(pi_context context, pi_device device, pi_image_format *image_format, pi_image_desc *image_desc, pi_image_mem_handle *ret_mem)
API to allocate memory for bindless images.
pi_result piextMemImportOpaqueFD(pi_context context, pi_device device, size_t size, int file_descriptor, pi_interop_mem_handle *ret_handle)
API to import external memory in the form of a file descriptor.
pi_uint64 pi_image_handle
pi_result piextMemMapExternalArray(pi_context context, pi_device device, pi_image_format *image_format, pi_image_desc *image_desc, pi_interop_mem_handle mem_handle, pi_image_mem_handle *ret_mem)
API to map an interop memory handle to an image memory handle.
pi_result piextMemSampledImageCreate(pi_context context, pi_device device, pi_image_mem_handle img_mem, pi_image_format *image_format, pi_image_desc *image_desc, pi_sampler sampler, pi_mem *ret_mem, pi_image_handle *ret_handle)
API to create sampled bindless image handles.
pi_result piextDestroyExternalSemaphore(pi_context context, pi_device device, pi_interop_semaphore_handle sem_handle)
API to destroy the external semaphore handle.
pi_bitfield pi_sampler_properties
pi_result piextMemImageFree(pi_context context, pi_device device, pi_image_mem_handle memory_handle)
API to free memory for bindless images.
pi_result piextMemUnsampledImageCreate(pi_context context, pi_device device, pi_image_mem_handle img_mem, pi_image_format *image_format, pi_image_desc *image_desc, pi_mem *ret_mem, pi_image_handle *ret_handle)
API to create bindless image handles.
pi_result piextMemSampledImageHandleDestroy(pi_context context, pi_device device, pi_image_handle handle)
API to destroy bindless sampled image handles.
@ PI_MEM_TYPE_IMAGE_CUBEMAP
@ PI_MEM_TYPE_IMAGE1D_ARRAY
@ PI_MEM_TYPE_IMAGE2D_ARRAY
pi_result piextMemUnsampledImageHandleDestroy(pi_context context, pi_device device, pi_image_handle handle)
API to destroy bindless unsampled image handles.
pi_result piextMemMipmapFree(pi_context context, pi_device device, pi_image_mem_handle memory_handle)
API to free mipmap memory for bindless images.
pi_result piextMemMipmapGetLevel(pi_context context, pi_device device, pi_image_mem_handle mip_mem, unsigned int level, pi_image_mem_handle *ret_mem)
API to retrieve individual image from mipmap.
constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_FILTER_MODE
constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_CUBEMAP_FILTER_MODE
pi_result piextMemReleaseInterop(pi_context context, pi_device device, pi_interop_mem_handle memory_handle)
API to destroy interop memory.
pi_result piextBindlessImageSamplerCreate(pi_context context, const pi_sampler_properties *sampler_properties, float min_mipmap_level_clamp, float max_mipmap_level_clamp, float max_anisotropy, pi_sampler *result_sampler)
API to create samplers for bindless images.
pi_result piextImportExternalSemaphoreOpaqueFD(pi_context context, pi_device device, int file_descriptor, pi_interop_semaphore_handle *ret_handle)
API to import an external semaphore in the form of a file descriptor.
pi_result piextMemImageGetInfo(const pi_image_mem_handle mem_handle, pi_image_info param_name, void *param_value, size_t *param_value_size_ret)
API to query an image memory handle for specific properties.
constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_MIP_FILTER_MODE
pi_result piextUSMPitchedAlloc(void **result_ptr, size_t *result_pitch, pi_context context, pi_device device, pi_usm_mem_properties *properties, size_t width_in_bytes, size_t height, unsigned int element_size_bytes)
Allocates memory accessible on device.
pi_uint64 pi_interop_semaphore_handle
pi_uint64 pi_interop_mem_handle
C++ wrapper of extern "C" PI interfaces.
sycl::filtering_mode mipmap_filtering
cubemap_filtering_mode cubemap_filtering
sycl::coordinate_normalization_mode coordinate
float max_mipmap_level_clamp
float min_mipmap_level_clamp
sycl::filtering_mode filtering
sycl::addressing_mode addressing[3]
Opaque external memory descriptor type.
ResourceType external_resource
EVERYTHING BELOW IS DEPRECATED.
ResourceType external_resource
External semaphore file descriptor type.
A struct to describe the properties of an image.
image_channel_order channel_order
image_channel_type channel_type
Opaque image memory handle type.
Opaque interop memory handle type.
raw_handle_type raw_handle
Opaque interop semaphore handle type.
raw_handle_type raw_handle
Opaque sampled image handle type.
raw_image_handle_type raw_handle
Opaque unsampled image handle type.
raw_image_handle_type raw_handle