Creates an OpenCL image object from a media surface.
cl_mem clCreateFromDX9MediaSurfaceKHR(cl_context context,
cl_mem_flags flags,
cl_dx9_media_adapter_type_khr adapter_type,
void *surface_info,
cl_uint plane,
cl_int *errcode_ret)context-
A valid OpenCL context created from a media adapter.
flags-
A bit-field that is used to specify usage information. Refer to the table of allowed values for
flagsforclCreateBuffer. OnlyCL_MEM_READ_ONLY,CL_MEM_WRITE_ONLY, andCL_MEM_READ_WRITEvalues specified in the table of allowed values forflagsforclCreateBuffercan be used. adapter_type-
A value from enumeration of supported adapters described in the table of
cl_dx9_media_adapter_type_khrvalues forclGetDeviceIDsFromDX9MediaAdapterKHR. The type ofsurface_infois determined by the adapter type. The implementation does not need to support all adapter types. This approach provides flexibility to support additional adapter types in the future. Supported adapter types areCL_ADAPTER_D3D9_KHR,CL_ADAPTER_D3D9EX_KHR, andCL_ADAPTER_DXVA_KHR.If
adapter_typeisCL_ADAPTER_D3D9_KHR,CL_ADAPTER_D3D9EX_KHR, orCL_ADAPTER_DXVA_KHR, thesurface_infopoints to the following structure:typedef struct _cl_dx9_surface_info_khr { IDirect3DSurface9 *resource; HANDLE shared_handle; } cl_dx9_surface_info_khr;For D3D9 surfaces, we need both the handle to the resource and the resource itself to have a sufficient amount of information to eliminate a copy of the surface for sharing in cases where this is possible. Elimination of the copy is driver dependent.
shared_handlemay be NULL and this may result in sub-optimal performance. surface_info-
A pointer to one of the structures defined in the
adapter_typedescription above passed in as avoid*. plane-
The plane of resource to share for planar surface formats. For planar formats, we use the plane parameter to obtain a handle to thie specific plane (Y, U or V for example). For nonplanar formats used by media,
planemust be 0. errcode_ret-
An appropriate error code. If
errcode_retis NULL, no error code is returned.
The width and height of the returned OpenCL 2D image object are determined by the width and height of the plane of resource. The channel type and order of the returned image object is determined by the format and plane of resource and are described in tables 9.10.3 and 9.10.4.
This call will increment the internal media surface count on resource.
The internal media surface reference count on resource will be decremented when the OpenCL reference count on the returned OpenCL memory object drops to zero.
Returns a valid non-zero 2D image object and errcode_ret is set to CL_SUCCESS if the 2D image object is created successfully.
Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
-
CL_INVALID_CONTEXTifcontextis not a valid context. -
CL_INVALID_VALUEif values specified inflagsare not valid or ifplaneis not a valid plane ofresourcespecified insurface_info. -
CL_INVALID_DX9_MEDIA_SURFACE_KHRifresourcespecified insurface_infois not a valid resource or is not associated withadapter_type(e.g.,adapter_typeis set toCL_ADAPTER_D3D9_KHRandresourceis not a Direct3D 9 surface created inD3DPOOL_DEFAULT). -
CL_INVALID_DX9_MEDIA_SURFACE_KHRifshared_handlespecified insurface_infois not NULL or a valid handle value. -
CL_INVALID_DX9_MEDIA_SURFACE_KHRifadapter_typeis set to a media adapter and thesurface_infodoes not reference a media surface of the required type, or ifadapter_typeis set to a media adapter type andsurface_infodoes not contain a valid reference to a media surface on that adapter, byclGetMemObjectInfowhenparam_nameis a surface or handle when the image was not created from an appropriate media surface, and fromclGetImageInfowhenparam_nameisCL_IMAGE_DX9_MEDIA_PLANE_KHRand image was not created from an appropriate media surface. -
CL_INVALID_IMAGE_FORMAT_DESCRIPTORif the texture format ofresourceis not listed in tables 9.10.3 and 9.10.4. -
CL_INVALID_OPERATIONif there are no devices incontextthat supportadapter_type. -
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.