clCreateFromDX9MediaSurfaceKHR - Creates an OpenCL image object from a media surface.
Contents
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.
Errors
Returns CL_SUCCESS 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_CONTEXT if context is not a valid context.
• CL_INVALID_VALUE if values specified in flags are not valid or if plane is not a valid plane of
resource specified in surface_info..
• CL_INVALID_DX9_MEDIA_SURFACE_KHR if resource specified in surface_info is not a valid resource or is
not associated with adapter_type (e.g., adapter_type is set to CL_ADAPTER_D3D9_KHR and resource is
not a Direct3D 9 surface created in D3DPOOL_DEFAULT).
• CL_INVALID_DX9_MEDIA_SURFACE_KHR if shared_handle specified in surface_info is not NULL or a valid
handle value.
• CL_INVALID_IMAGE_FORMAT_DESCRIPTOR if the texture format of resource is not listed in tables 9.10.3
and 9.10.4.
• CL_INVALID_OPERATION if there are no devices in context that support adapter_type.
• CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation
on the device.
• CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL
implementation on the host.
Name
clCreateFromDX9MediaSurfaceKHR - Creates an OpenCL image object from a media surface.
cl_memclCreateFromDX9MediaSurfaceKHR(cl_contextcontext,cl_mem_flagsflags,cl_dx9_media_adapter_type_khradapter_type,void*surface_info,cl_uintplane,cl_int*errcode_ret);Notes
1. OpenCL Specification
page 89, section 9.10.7.2 Creating Media Resources as OpenCL Image Objects
The Khronos Group 11/18/2024 CLCREATEFROMDX9MEDIA(3clc)
Parameters
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 flags
for clCreateBuffer(3clc). Only CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY, and CL_MEM_READ_WRITE values
specified in the table of allowed values for flags for clCreateBuffer(3clc) can be used.
adapter_type
A value from enumeration of supported adapters described in the table of
cl_dx9_media_adapter_type_khr values for clGetDeviceIDsFromDX9MediaAdapterKHR(3clc). 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_D3D9EX_KHR, and CL_ADAPTER_DXVA_KHR.
If adapter_type is CL_ADAPTER_D3D9_KHR, CL_ADAPTER_D3D9EX_KHR, or CL_ADAPTER_DXVA_KHR, the
surface_info points to the following structure:
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_handle may be NULL and this may
result in sub-optimal performance.
surface_info
A pointer to one of the structures defined in the adapter_type description above passed in as a void
*.
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, plane must be 0.
errcode_ret
An appropriate error code. If errcode_ret is NULL, no error code is returned.
See Also
cl_khr_dx9_media_sharing(3clc), clGetDeviceIDsFromDX9MediaAdapterKHR(3clc), clEnqueueAcquireDX9MediaSurfacesKHR(3clc), clEnqueueReleaseDX9MediaSurfacesKHR(3clc)
Specification
OpenCLSpecification[1]
