5.2.5. Creating OpenCL Buffer Objects From Direct3D 10 Buffer Resources
5.2.5. 从Direct3D 10缓冲区资源创建OpenCL缓冲区对象
To create an OpenCL buffer object from a Direct3D 10 buffer, call the function
要从Direct3D 10缓冲区创建OpenCL缓冲区对象,请调用函数
// Provided by cl_khr_d3d10_sharing
cl_mem clCreateFromD3D10BufferKHR(
cl_context context,
cl_mem_flags flags,
ID3D10Buffer* resource,
cl_int* errcode_ret);
clCreateFromD3D10BufferKHR is provided by the clCreateFromD3D10BufferKHR由cl_khr_d3d10_shareing扩展提供。 |
-
context is a valid OpenCL context created from a Direct3D 10 device.
-
上下文是从Direct3D10设备创建的有效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_ONLY, CL_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标志。
-
resource is a pointer to the Direct3D 10 buffer to share.
-
resource是指向要共享的Direct3D 10缓冲区的指针。
-
errcode_ret will return an appropriate error code. If errcode_ret is
NULL
, no error code is returned. -
errcode_ret将返回相应的错误代码。如果errcode_ret为NULL,则不会返回任何错误代码。
The size of the returned OpenCL buffer object is the same as the size of resource. 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.
返回的OpenCL缓冲区对象的大小与资源的大小相同。此调用将增加资源上的内部Direct3D 10引用计数。当返回的OpenCL内存对象上的OpenCL引用计数降至零时,资源上的内部Direct3D 10引用计数将递减。
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. |
clCreateFromD3D10BufferKHR returns a valid non-zero OpenCL buffer object and errcode_ret is set to CL_SUCCESS if the buffer object is created successfully. Otherwise, it returns a NULL
value with one of the following error values returned in errcode_ret:
clCreateFromD3D10BufferKHR返回有效的非零OpenCL缓冲区对象,如果缓冲区对象创建成功,则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.
-
CL_INVALID_VALUE(如果标志中指定的值无效)。
-
CL_INVALID_D3D10_RESOURCE_KHR if resource is not a Direct3D 10 buffer resource, if resource was created with the D3D10_USAGE flag D3D10_USAGE_IMMUTABLE, if a
cl_mem
from resource has already been created using clCreateFromD3D10BufferKHR, or if context was not created against the same Direct3D 10 device from which resource was created. -
CL_INVALID_D3D10_RESOURCE_KHR如果资源不是Direct3D 10缓冲区资源,如果资源是使用D3D10_USAGE标志D3D10_USAGE_IMUTABLE创建的,如果已经使用clCreateFromD3D10BufferKHR创建了来自资源的cl_mem,或者如果上下文不是针对创建资源的同一Direct3D 10设备创建的。
-
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实现所需的资源失败。