C Specification
To create an OpenCL 2D image object from a subresource of a Direct3D 10 2D texture, call the function
// Provided by cl_khr_d3d10_sharing
cl_mem clCreateFromD3D10Texture2DKHR(
cl_context context,
cl_mem_flags flags,
ID3D10Texture2D* resource,
UINT subresource,
cl_int* errcode_ret);
clCreateFromD3D10Texture2DKHR is provided by the cl_khr_d3d10_sharing extension.
|
Parameters
-
context is a valid OpenCL context created from a Direct3D 10 device.
-
flags is a bit-field that is used to specify usage information. Refer to the List of supported memory flag values table for a description of flags. Only the
CL_MEM_,READ_ ONLY CL_MEM_andWRITE_ ONLY CL_MEM_flags specified in that table can be used.READ_ WRITE -
resource is a pointer to the Direct3D 10 2D texture to share.
-
subresource is the subresource of resource to share.
-
errcode_ret will return an appropriate error code. If errcode_ret is
NULL, no error code is returned.
Description
The width and height of the returned OpenCL 2D image object are determined by the width and height of subresource subresource of resource. The channel type and order of the returned OpenCL 2D image object is determined by the format of resource and the DXGI Formats and Corresponding OpenCL Image Formats table.
This call will increment the internal Direct3D 10 reference count on resource. The internal Direct3D 10 reference count on resource will be decremented when the OpenCL reference count on the returned OpenCL memory object drops to zero.
| Refer to the Lifetime of Shared Direct3D Memory Objects and Acquiring, Releasing, and Synchronizing Access to Shared OpenCL/OpenGL Memory Objects sections for more information. |
clCreateFromD3D10Texture2DKHR returns a valid non-zero OpenCL image object
and errcode_ret 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 errcode_ret:
-
CL_INVALID_if context is not a valid context.CONTEXT -
CL_INVALID_if values specified in flags are not valid or if subresource is not a valid subresource index for resource.VALUE -
CL_INVALID_if resource is not a Direct3D 10 texture resource, if resource was created with the D3D10_USAGE flag D3D10_USAGE_IMMUTABLE, if resource is a multisampled texture, if aD3D10_ RESOURCE_ KHR cl_memfrom subresource subresource of resource has already been created using clCreateFromD3D10Texture2DKHR, or if context was not created against the same Direct3D 10 device from which resource was created. -
CL_INVALID_if the Direct3D 10 texture format of resource is not listed in the DXGI Formats and Corresponding OpenCL Image Formats table or if the Direct3D 10 texture format of resource does not map to a supported OpenCL image format.IMAGE_ FORMAT_ DESCRIPTOR -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the host.OF_ HOST_ MEMORY
Document Notes
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.