'\" t .\" Title: clCreateImage .\" Author: The Khronos Group .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 02/03/2019 .\" Manual: OpenCL Manual .\" Source: The Khronos Group .\" Language: English .\" .TH "CLCREATEIMAGE" "3clc" "02/03/2019" "The Khronos Group" "OpenCL Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" clCreateImage \- Creates a 1D image, 1D image buffer, 1D image array, 2D image, 2D image array or 3D image object\&. .SH "" .HP \w'cl_mem\ clCreateImage('u .BI "cl_mem clCreateImage(cl_context\ " "context" ", cl_mem_flags\ " "flags" ", const\ cl_image_format\ *" "image_format" ", const\ cl_image_desc\ *" "image_desc" ", void\ *" "host_ptr" ", cl_int\ *" "errcode_ret" ");" .SH "PARAMETERS" .PP \fI context \fR .RS 4 A valid OpenCL context on which the image object is to be created\&. .RE .PP \fI flags \fR .RS 4 A bit\-field that is used to specify allocation and usage information about the image memory object being created and is described in the table below\&. .sp For all image types except \fBCL_MEM_OBJECT_IMAGE1D_BUFFER\fR, if value specified for \fIflags\fR is 0, the default is used which is \fBCL_MEM_READ_WRITE\fR\&. .sp For \fBCL_MEM_OBJECT_IMAGE1D_BUFFER\fR image type, if the \fBCL_MEM_READ_WRITE\fR, \fBCL_MEM_READ_ONLY\fR or \fBCL_MEM_WRITE_ONLY\fR values are not specified in \fIflags\fR, they are inherited from the corresponding memory access qualifers associated with \fIbuffer\fR\&. The \fBCL_MEM_USE_HOST_PTR\fR, \fBCL_MEM_ALLOC_HOST_PTR\fR and \fBCL_MEM_COPY_HOST_PTR\fR values cannot be specified in \fIflags\fR but are inherited from the corresponding memory access qualifiers associated with \fIbuffer\fR\&. If \fBCL_MEM_COPY_HOST_PTR\fR is specified in the memory access qualifier values associated with \fIbuffer\fR it does not imply any additional copies when the sub\-buffer is created from \fIbuffer\fR\&. If the \fBCL_MEM_HOST_WRITE_ONLY\fR, \fBCL_MEM_HOST_READ_ONLY\fR or \fBCL_MEM_HOST_NO_ACCESS\fR values are not specified in \fIflags\fR, they are inherited from the corresponding memory access qualifiers associated with \fIbuffer\fR\&. .TS allbox tab(:); lB lB. T{ cl_mem_flags T}:T{ Description T} .T& l l l l l l l l l l l l l l l l l l. T{ \fBCL_MEM_READ_WRITE\fR T}:T{ This flag specifies that the memory object will be read and written by a kernel\&. This is the default\&. T} T{ \fBCL_MEM_WRITE_ONLY\fR T}:T{ This flags specifies that the memory object will be written but not read by a kernel\&. .sp Reading from a buffer or image object created with \fBCL_MEM_WRITE_ONLY\fR inside a kernel is undefined\&. .sp \fBCL_MEM_READ_WRITE\fR and \fBCL_MEM_WRITE_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_READ_ONLY\fR T}:T{ This flag specifies that the memory object is a read\-only memory object when used inside a kernel\&. .sp Writing to a buffer or image object created with \fBCL_MEM_READ_ONLY\fR inside a kernel is undefined\&. .sp \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_WRITE_ONLY\fR and \fBCL_MEM_READ_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_USE_HOST_PTR\fR T}:T{ This flag is valid only if \fIhost_ptr\fR is not NULL\&. If specified, it indicates that the application wants the OpenCL implementation to use memory referenced by \fIhost_ptr\fR as the storage bits for the memory object\&. .sp OpenCL implementations are allowed to cache the buffer contents pointed to by \fIhost_ptr\fR in device memory\&. This cached copy can be used when kernels are executed on a device\&. .sp The result of OpenCL commands that operate on multiple buffer objects created with the same \fIhost_ptr\fR or overlapping host regions is considered to be undefined\&. .sp Refer to the \fBdataTypes\fR(3clc) for \fIhost_ptr\fR for memory objects (buffer and images) created using \fBCL_MEM_USE_HOST_PTR\fR\&. T} T{ \fBCL_MEM_ALLOC_HOST_PTR\fR T}:T{ This flag specifies that the application wants the OpenCL implementation to allocate memory from host accessible memory\&. .sp \fBCL_MEM_ALLOC_HOST_PTR\fR and \fBCL_MEM_USE_HOST_PTR\fR are mutually exclusive\&. T} T{ \fBCL_MEM_COPY_HOST_PTR\fR T}:T{ This flag is valid only if \fIhost_ptr\fR is not NULL\&. 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 by \fIhost_ptr\fR\&. .sp \fBCL_MEM_COPY_HOST_PTR\fR and \fBCL_MEM_USE_HOST_PTR\fR are mutually exclusive\&. .sp \fBCL_MEM_COPY_HOST_PTR\fR can be used with \fBCL_MEM_ALLOC_HOST_PTR\fR to initialize the contents of the \fBcl_mem\fR object allocated using host\-accessible (e\&.g\&. PCIe) memory\&. T} T{ \fBCL_MEM_HOST_WRITE_ONLY\fR T}:T{ 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)\&. T} T{ \fBCL_MEM_HOST_READ_ONLY\fR T}:T{ This flag specifies that the host will only read the memory object (using OpenCL APIs that enqueue a read or a map for read)\&. .sp \fBCL_MEM_HOST_WRITE_ONLY\fR and \fBCL_MEM_HOST_READ_ONLY\fR are mutually exclusive\&. T} T{ \fBCL_MEM_HOST_NO_ACCESS\fR T}:T{ This flag specifies that the host will not read or write the memory object\&. .sp \fBCL_MEM_HOST_WRITE_ONLY\fR or \fBCL_MEM_HOST_READ_ONLY\fR and \fBCL_MEM_HOST_NO_ACCESS\fR are mutually exclusive\&. T} .TE .sp 1 .RE .PP \fI image_format \fR .RS 4 A pointer to a structure that describes format properties of the image to be allocated\&. See \fBcl_image_format\fR(3clc) for a detailed description of the image format descriptor\&. .RE .PP \fI image_desc \fR .RS 4 A pointer to a structure that describes type and dimensions of the image to be allocated\&. See \fBimageDescriptor\fR(3clc) for more information\&. .RE .PP \fI host_ptr \fR .RS 4 A pointer to the image data that may already be allocated by the application\&. Refer to table below for a description of how large the buffer that \fIhost_ptr\fR points to must be\&. .TS allbox tab(:); lB lB. T{ Image Type T}:T{ Size of buffer that \fIhost_ptr\fR points to T} .T& l l l l l l l l l l l l. T{ \fBCL_MEM_OBJECT_IMAGE1D\fR T}:T{ \fB≥ image_row_pitch\fR T} T{ \fBCL_MEM_OBJECT_IMAGE1D_BUFFER\fR T}:T{ \fB≥ image_row_pitch\fR T} T{ \fBCL_MEM_OBJECT_IMAGE2D\fR T}:T{ \fB≥ image_row_pitch * image_height\fR T} T{ \fBCL_MEM_OBJECT_IMAGE3D\fR T}:T{ \fB≥ image_slice_pitch * image_depth\fR T} T{ \fBCL_MEM_OBJECT_IMAGE1D_ARRAY\fR T}:T{ \fB≥ image_slice_pitch * image_array_size\fR T} T{ \fBCL_MEM_OBJECT_IMAGE2D_ARRAY\fR T}:T{ \fB≥ image_slice_pitch * image_array_size\fR T} .TE .sp 1 For a 3D image or 2D image array, the image data specified by \fIhost_ptr\fR is stored as a linear sequence of adjacent 2D image slices or 2D images respectively\&. Each 2D image is a linear sequence of adjacent scanlines\&. Each scanline is a linear sequence of image elements\&. .sp For a 2D image, the image data specified by \fIhost_ptr\fR is stored as a linear sequence of adjacent scanlines\&. Each scanline is a linear sequence of image elements\&. .sp For a 1D image array, the image data specified by \fIhost_ptr\fR is stored as a linear sequence of adjacent 1D images respectively\&. Each 1D image or 1D image buffer is a single scanline which is a linear sequence of adjacent elements\&. .RE .PP \fI errcode_ret \fR .RS 4 Will return an appropriate error code\&. If \fIerrcode_ret\fR is NULL, no error code is returned\&. .RE .SH "ERRORS" .PP \fBclCreateImage\fR returns a valid non\-zero image object and \fIerrcode_ret\fR is set to CL_SUCCESS if the image object is created successfully\&. Otherwise, it returns a NULL value with one of the following error values returned in \fIerrcode_ret\fR: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_CONTEXT if \fIcontext\fR is not a valid context\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if values specified in \fIflags\fR are not valid\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_IMAGE_FORMAT_DESCRIPTOR if values specified in \fIimage_format\fR are not valid or if \fIimage_format\fR is NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_IMAGE_DESCRIPTOR if values specified in \fIimage_desc\fR are not valid or if \fIimage_desc\fR is NULL\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_IMAGE_SIZE if image dimensions specified in \fIimage_desc\fR exceed the minimum maximum image dimensions described in the table of allowed values for \fIparam_name\fR for \fBclGetDeviceInfo\fR(3clc) for all devices in \fIcontext\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_HOST_PTR if \fIhost_ptr\fR in \fIimage_desc\fR is NULL and \fBCL_MEM_USE_HOST_PTR\fR or \fBCL_MEM_COPY_HOST_PTR\fR are set in \fIflags\fR or if \fIhost_ptr\fR is not NULL but \fBCL_MEM_COPY_HOST_PTR\fR or \fBCL_MEM_USE_HOST_PTR\fR are not set in \fIflags\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if a 1D image buffer is being created and the buffer object was created with \fBCL_MEM_WRITE_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_READ_ONLY\fR, or if the buffer object was created with \fBCL_MEM_READ_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_READ_WRITE\fR or \fBCL_MEM_WRITE_ONLY\fR, or if \fIflags\fR specifies \fBCL_MEM_USE_HOST_PTR\fR or \fBCL_MEM_ALLOC_HOST_PTR\fR or \fBCL_MEM_COPY_HOST_PTR\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_VALUE if a 1D image buffer is being created and the buffer object was created with \fBCL_MEM_HOST_WRITE_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_HOST_READ_ONLY\fR, or if the buffer object was created with \fBCL_MEM_HOST_READ_ONLY\fR and \fIflags\fR specifies \fBCL_MEM_HOST_WRITE_ONLY\fR, or if the buffer object was created with \fBCL_MEM_HOST_NO_ACCESS\fR and \fIflags\fR specifies \fBCL_MEM_HOST_READ_ONLY\fR or \fBCL_MEM_HOST_WRITE_ONLY\fR\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_IMAGE_FORMAT_NOT_SUPPORTED if the \fIimage_format\fR is not supported\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_MEM_OBJECT_ALLOCATION_FAILURE if there is a failure to allocate memory for image object\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_INVALID_OPERATION if there are no devices in \fIcontext\fR that support images (i\&.e\&. \fBCL_DEVICE_IMAGE_SUPPORT\fR (specified in the table of OpenCL Device Queries for \fBclGetDeviceInfo\fR(3clc)) is \fBCL_FALSE\fR)\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host\&. .RE .SH "SPECIFICATION" .PP \m[blue]\fBOpenCL Specification\fR\m[]\&\s-2\u[1]\d\s+2 .SH "SEE ALSO" .PP \fBimageDescriptor\fR(3clc), \fBcl_image_format\fR(3clc), \fBclassDiagram\fR(3clc) .SH "AUTHORS" .PP \fBThe Khronos Group\fR .SH "COPYRIGHT" .br Copyright \(co 2007-2011 The Khronos Group Inc. .br 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. .sp .SH "NOTES" .IP " 1." 4 OpenCL Specification .RS 4 \%page 90, section 5.3.1 - Creating Image Objects .RE