OpenCL™规范 5.3.10. 从DirectX 9媒体资源创建OpenCL图像对象

5.3.10. Creating OpenCL Image Objects From DirectX 9 Media Resources
5.3.10. 从DirectX 9媒体资源创建OpenCL图像对象

To create an OpenCL image object from a media surface, call the function

要从媒体表面创建OpenCL图像对象,请调用函数

// 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.

clCreateFromDX9MediaSurfaceKHR由cl_khr_dx9_media_sharing扩展提供。

  • context is a valid OpenCL context created from a media adapter.

  • context是从媒体适配器创建的有效OpenCL上下文。

  • 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_ONLYCL_MEM_WRITE_ONLY and CL_MEM_READ_WRITE flags specified in that table can be used.

  • ​flags是一个用于指定使用信息的位字段。有关标志的描述,请参阅支持的内存标志值列表表。只能使用该表中指定的CL_MEM_READ_ONLY、CL_MEM_WRITE_ONLY和CL_MEM_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_KHRCL_ADAPTER_D3D9EX_KHR and CL_ADAPTER_DXVA_KHR.

  • ​adapter_type是cl_dx9_media_adapter_type_khr值表中描述的受支持适配器枚举中的一个值。surface_info的类型由适配器类型决定。该实现不需要支持所有适配器类型。这种方法提供了灵活性,可以在将来支持其他适配器类型。支持的适配器类型有CL_ADAPTER_D3D9_KHR、CL_ADAPPTER_D3D9EX_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 is CL_ADAPTER_D3D9_KHRCL_ADAPTER_D3D9EX_KHR and CL_ADAPTER_DXVA_KHRsurface_info points to a [cl_dx9_surface_info_khr] structure describing the surface.

  • ​surface_info是指向上面adapter_type描述中定义的结构之一的指针,以void*形式传入。如果adapter_type是CL_ADAPTER_D3D9_KHR、CL_ADAPER_D3D9EX_KHR和CL_ADAPPTER_DXVA_KHR,则surface_info指向描述该曲面的[CL_dx9_surface_info_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.

  • plane是平面曲面格式要共享的资源平面。对于平面格式,我们使用平面参数来获得特定平面(例如,Y、U或V)的控制柄。对于介质使用的非平面格式,plane必须为0。

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

  • errcode_ret将返回相应的错误代码。如果errcode_ret为NULL,则不会返回任何错误代码。

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.

​返回的OpenCL 2D图像对象的宽度和高度由资源的plane(surface_info→_resource_).返回图像对象的通道类型和顺序由资源的格式和平面决定,并在YUV FourCC代码和相应的OpenCL图像格式以及Direct3D 9格式和相应的OpenCL图像格式表中进行了描述。

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.

此调用将增加资源上的内部媒体表面计数。当返回的OpenCL内存对象上的OpenCL引用计数降至零时,资源上的内部媒体表面引用计数将递减。

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:

​clCreateFromDX9MediaSurfaceKHR返回有效的非零二维图像对象,如果成功创建二维图像对象则errcode_ret设置为CL_SUCCESS。否则,它将返回一个NULL值,并在errcode_ret中返回以下错误值之一:

  • CL_INVALID_CONTEXT if context is not a valid context.

  • CL_INVALID_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.

  • 如果标志中指定的值无效,或者plane不是surface_info中指定的资源的有效平面,则CL_INVALID_VALUE。

  • 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,如果surface_info中指定的资源不是有效资源或与adapter_type不关联(例如,adapter_type设置为CL_ADAPTER_D3D9_KHR,并且资源不是在D3DPOOL_DEFAULT中创建的Direct3D 9曲面)。

  • CL_INVALID_DX9_MEDIA_SURFACE_KHR if shared_handle specified in surface_info is not NULL or a valid handle value.

  • 如果surface_info中指定的shared_handle不是NULL或有效的句柄值,则CL_INVALID_DX9_MEDIA_SURFACE_KHR。

  • CL_INVALID_IMAGE_FORMAT_DESCRIPTOR 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.

  • CL_INVALID_IMAGE_FORMAT_DESCRIPTOR(如果YUV FourCC代码和相应的OpenCL图像格式或Direct3D 9格式和相应的OpenCL图像格式表中未列出资源的纹理格式)。

  • CL_INVALID_OPERATION if there are no devices in context that support adapter_type.

  • CL_INVALID_OPERATION(如果上下文中没有支持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_RESOURCES,如果在设备上分配OpenCL实现所需的资源失败。

  • CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

  • CL_OUT_OF_HOST_MEMORY,如果在主机上分配OpenCL实现所需的资源失败。

The cl_dx9_surface_info_khr structure is passed to clCreateFromDX9MediaSurfaceKHR to describe a DX9 surface, and is defined as:

cl_dx9_surface_info_khr结构传递给clCreateFromDX9MediaSurfaceKHR以描述dx9曲面,并定义为:

// Provided by cl_khr_dx9_media_sharing
typedef struct cl_dx9_surface_info_khr {
    IDirect3DSurface9*    resource;
    HANDLE                shared_handle;
} cl_dx9_surface_info_khr;
  • resource is a pointer to a IDirect3DSurface9 surface interface.

  • resource是指向IDirect3DSurface9曲面接口的指针。

  • shared_handle is a HANDLE to the resource.

  • shared_handle是resource的handle。

For DX9 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.

对于DX9曲面,我们需要资源的句柄和资源本身都有足够的信息来消除曲面的副本,以便在可能的情况下共享。复制的消除取决于驱动程序。shared_handle可能为NULL,这可能导致次优性能。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值