C Specification
To create an OpenCL image object from a media surface, call the function
// Provided by cl_khr_dx9_media_sharing
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);
clCreateFromDX9MediaSurfaceKHR is provided by the cl_khr_dx9_media_sharing extension.
|
Parameters
-
context is a valid OpenCL context created from a media adapter.
-
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 -
adapter_type is a value from enumeration of supported adapters described in the cl_dx9_media_adapter_type_khr values table. The type of surface_info is 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 are
CL_ADAPTER_,D3D9_ KHR CL_ADAPTER_andD3D9EX_ KHR CL_ADAPTER_.DXVA_ KHR -
surface_info is a pointer to one of the structures defined in the adapter_type description above, passed in as a
void *. If adapter_type isCL_ADAPTER_,D3D9_ KHR CL_ADAPTER_andD3D9EX_ KHR CL_ADAPTER_, surface_info points to a https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#cl_dx9_surface_info_khr structure describing the surface.DXVA_ KHR -
plane is 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 non-planar formats used by media, plane must be 0.
-
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 the plane of the resource (surface_info→_resource_). The channel type and order of the returned image object is determined by the format and plane of the resource, and are described in the YUV FourCC Codes and Corresponding OpenCL Image Formats and Direct3D 9 Formats and Corresponding OpenCL Image Formats tables.
This call will increment the internal media surface count on the resource. The internal media surface reference count on the resource will be decremented when the OpenCL reference count on the returned OpenCL memory object drops to zero.
clCreateFromDX9MediaSurfaceKHR 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_if context is not a valid context.CONTEXT -
CL_INVALID_if values specified in flags are not valid or if plane is not a valid plane of resource specified in surface_info.VALUE -
CL_INVALID_if resource specified in surface_info is not a valid resource or is not associated with adapter_type (e.g., adapter_type is set toDX9_ MEDIA_ SURFACE_ KHR CL_ADAPTER_and resource is not a Direct3D 9 surface created in D3DPOOL_DEFAULT).D3D9_ KHR -
CL_INVALID_if shared_handle specified in surface_info is notDX9_ MEDIA_ SURFACE_ KHR NULLor a valid handle value. -
CL_INVALID_if the texture format of resource is not listed in the YUV FourCC Codes and Corresponding OpenCL Image Formats or Direct3D 9 Formats and Corresponding OpenCL Image Formats tables.IMAGE_ FORMAT_ DESCRIPTOR -
CL_INVALID_if there are no devices in context that support adapter_type.OPERATION -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the device.OF_ RESOURCES -
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.