CLGETSUPPORTEDIMAGEF(3clc)
β¨ NAME β¨
clGetSupportedImageFormats β bestie, this is your girl for finding out which image formats an OpenCL implementation actually supports π
Like, she will literally hand you the list. The whole guest list. Every format that made the cut π
This is the 3clc manual, part of the OpenCL Manual β yes we're fancy, we have our own manual section, iykyk π
Here's the whole signature, character for character, no cap:
cl_int clGetSupportedImageFormats(cl_context context,
cl_mem_flags flags,
cl_mem_object_type image_type,
cl_uint num_entries,
cl_image_format *image_formats,
cl_uint *num_image_formats);
Notice she returns a cl_int β that's your error code, so keep an eye on it later π«Ά
π PARAMETERS π
Okay so the parameters, one by one, no skipping, we don't do that here β¨
contextβ A valid OpenCL context on which the image object(s) will be created. Valid, okay?? Like actually valid, bestie, don't be out here passing nonsense π This is the context those image objects are gonna get born into, so it has to be the real deal.
okay that's the first chunk and there's more where that came from β the rest of these parameters are pulling up next πΈ
flags π
Okay bestie, flags is a bit-field that's used to specify allocation and usage information about the image memory object being created, and it's described in the table below. But we're doing bullets, because tables are not the vibe. β¨
Here's the cl_mem_flags lineup, no cap:
CL_MEM_READ_WRITEβ This flag specifies that the memory object will be read and written by a kernel. This is the default. πCL_MEM_WRITE_ONLYβ This flags specifies that the memory object will be written but not read by a kernel.
Reading from a buffer or image object created with CL_MEM_WRITE_ONLY inside a kernel is undefined. π«
CL_MEM_READ_WRITE and CL_MEM_WRITE_ONLY are mutually exclusive. π
CL_MEM_READ_ONLYβ This flag specifies that the memory object is a read-only memory object when used inside a kernel.
Writing to a buffer or image object created with CL_MEM_READ_ONLY inside a kernel is undefined. π
CL_MEM_READ_WRITE or CL_MEM_WRITE_ONLY and CL_MEM_READ_ONLY are mutually exclusive. π«
CL_MEM_USE_HOST_PTRβ This flag is valid only ifhost_ptris notNULL. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced byhost_ptras the storage bits for the memory object. π§
OpenCL implementations are allowed to cache the buffer contents pointed to by host_ptr in device memory. This cached copy can be used when kernels are executed on a device. β¨
The result of OpenCL commands that operate on multiple buffer objects created with the same host_ptr or overlapping host regions is considered to be undefined. π¨
Refer to the dataTypes(3clc) for host_ptr for memory objects (buffer and images) created using CL_MEM_USE_HOST_PTR. π
CL_MEM_ALLOC_HOST_PTRβ This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory. π
CL_MEM_ALLOC_HOST_PTR and CL_MEM_USE_HOST_PTR are mutually exclusive. π«
CL_MEM_COPY_HOST_PTRβ This flag is valid only ifhost_ptris notNULL. If specified, it indicates that the application wants the OpenCL implementation to allocate memory for the memory object and copy the data from memory referenced byhost_ptr. π
CL_MEM_COPY_HOST_PTR and CL_MEM_USE_HOST_PTR are mutually exclusive. π«
CL_MEM_COPY_HOST_PTR can be used with CL_MEM_ALLOC_HOST_PTR to initialize the contents of the cl_mem object allocated using host-accessible (e.g. PCIe) memory. πΎ
CL_MEM_HOST_WRITE_ONLYβ This flag specifies that the host will only write to the memory object (using OpenCL APIs that enqueue a write or a map for write). This can be used to optimize write access from the host (e.g. enable write combined allocations for memory objects for devices that communicate with the host over a system bus such as PCIe). β‘CL_MEM_HOST_READ_ONLYβ This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read). π
CL_MEM_HOST_WRITE_ONLY and CL_MEM_HOST_READ_ONLY are mutually exclusive. π«
CL_MEM_HOST_NO_ACCESSβ This flag specifies that the host will not read or write the memory object. π ββοΈ
CL_MEM_HOST_WRITE_ONLY or CL_MEM_HOST_READ_ONLY and CL_MEM_HOST_NO_ACCESS are mutually exclusive. π«
image_type πΌοΈ
Describes the image type and must be either CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE1D_BUFFER, CL_MEM_OBJECT_IMAGE2D, CL_MEM_OBJECT_IMAGE3D, CL_MEM_OBJECT_IMAGE1D_ARRAY or CL_MEM_OBJECT_IMAGE2D_ARRAY. β¨
num_entries π’
Specifies the number of entries that can be returned in the memory location given by image_formats. π
image_formatsβ a pointer to a memory location where the list of supported image formats are returned. Each entry describes acl_image_format(3clc)structure supported by the OpenCL implementation. Ifimage_formatsisNULL, it is ignored. πnum_image_formatsβ the actual number of supported image formats for a specific context and values specified byflags. Ifnum_image_formatsisNULL, it is ignored. π
π NOTES π
okay so clGetSupportedImageFormats can be used to get the list of image formats supported by an OpenCL implementation when the following information about an image memory object is specified:
- Context
- Image type - 1D, 2D, or 3D image, 1D image buffer, 1D or 2D image array.
- Image object allocation information
clGetSupportedImageFormats returns a union of image formats supported by all devices in the context. π«Ά
For 2D and 3D image objects, the mandated minimum list of image formats that must be supported by all devices (for reading and writing) that support images is described in the table below:
For image_num_channels = 4 and image_channel_order = CL_RGBA, the image_channel_data_type values are:
CL_UNORM_INT8CL_UNORM_INT16CL_SIGNED_INT8CL_SIGNED_INT16CL_SIGNED_INT32CL_UNSIGNED_INT8CL_UNSIGNED_INT16CL_UNSIGNED_INT32CL_HALF_FLOATCL_FLOAT
For image_num_channels = 4 and image_channel_order = CL_BGRA, the image_channel_data_type is:
CL_UNORM_INT8
If CL_DEVICE_IMAGE_SUPPORT specified in the table of OpenCL Device Queries for clGetDeviceInfo(3clc) is CL_TRUE, the values assigned to CL_DEVICE_MAX_READ_IMAGE_ARGS, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, CL_DEVICE_IMAGE2D_MAX_WIDTH, CL_DEVICE_IMAGE2D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_WIDTH, CL_DEVICE_IMAGE3D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_DEPTH, and CL_DEVICE_MAX_SAMPLERS by the implementation must be greater than or equal to the minimum values specified in the table of allowed values for param_name for clGetDeviceInfo(3clc). no cap π₯
π ERRORS π
Returns CL_SUCCESS if the function is executed successfully. Otherwise, it returns a NULL value with one of the following errors:
CL_INVALID_CONTEXTifcontextis not a valid context.CL_INVALID_VALUEifflagsorimage_typeare not valid, or ifnum_entriesis0andimage_formatsis notNULL.CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
ποΈ NOTES ποΈ
OpenCL Specificationpage 96, section 5.3.2 - Querying List of Supported Image Formats
and thatβs the tea! this page was brought to you by The Khronos Group, dated 01/14/2021, and itβs literally called CLGETSUPPORTEDIMAGEF(3clc). stay iconic bestie! πβ¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms