Hi I have coded some example trying to see how d3d interop works..
I see up to three APIs one is
KB91 - Additional Header File Required For Preview Feature: ATI Stream SDK v2.01 Support for OpenCL™ / Microsoft® DirectX® 9 & 10 Interoperability
wich shows in cl_amd.hpp clEnqueueReleaseExternalObjects similar to clEnqueueReleaseGLObjects for gl interop..
this seems to be the correct way according to KB but I can't find clEnqueueReleaseExternalObjects with clGetExtensionFunctionAddress so I also
in cl_d3d9.h I see
clEnqueueAcquireD3D9ObjectsKHR which is another way..
this is found by clGetExtensionFunctionAddress
then for buffer interop similarly we found two functions:
clCreateFromD3D9BufferKHR
and then below is
"//
// Legacy AMD CL-D3D9 interop extension
//"
with
clCreateFromD3D9Buffer
function.
With clGetExtensionFunctionAddress I found clCreateFromD3D9BufferKHR which is the correct I think.
also I'm asking for correct texture interop(yeah I know is image support required but I'm talking having correct/stable source code here not testing)
I must use this clCreateFromD3D9TextureKHR?
For testing I create context with
cl_context_properties cps[6] =
{
CL_CONTEXT_PLATFORM,
(cl_context_properties)platform,
CL_CONTEXT_D3D9_DEVICE,
(cl_context_properties)g_pd3dDevice,
0
};
with a D3d device created and then use
CL_API_ENTRY cl_mem (CL_API_CALL
*myclCreateFromD3D9TextureKHR)(
cl_context /* context */,
cl_mem_flags /* flags */,
IDirect3DTexture9 * /* texture */,
HANDLE /* shared_handle */,
UINT /* miplevel */,
cl_int * /* errcode_ret */);
myclCreateFromD3D9TextureKHR=(P2)clGetExtensionFunctionAddress("clCreateFromD3D9TextureKHR")
as clCreateFromD3D9TextureKHR is defined already in header.
then calling
myclCreateFromD3D9TextureKHR(context,CL_MEM_READ_WRITE,g_inputTex,g_handle,0,&status);
where g_inputTex is created and g_handle is the last parameter returned by CreateTexture. Is this correct?
In this way I get runtime error after enabling images with "set GPU_IMAGES_SUPPORT=1"
setting the Handle shader parameter to NULL
myclCreateFromD3D9TextureKHR(context,CL_MEM_READ_WRITE,g_inputTex,NULL,0,&status);
returns an CL_INVALID_D3D_OBJECT
What's the correct API? Is that stable?
Is there any sample showing interop?
is d3d11 interop coming? as nvidia has one d3d11 extension published in khronos registry?..
Thanks Micah,
for being fair I have tested Nvidia d3d10 interop (Nvidia APis seem final and are very similar)(d3d10 are the only current entry poins found) and they are reporting initialization issues so no go..
I hope you implement d3d texture interop sooner than ogl as CAL has cal-d3d interop example with texture interop working..
oscar,
With SDK 2.01, you dont require cl_amd.hpp. Including cl_d3d9.h is enough.
Hi Micah,
i do some similar work to test d3d interop use "clCreateFromD3D9BufferKHR" on my Radeon HD4850 card, and also get CL_INVALID_D3D_OBJECT error. can you give some suggestions?
My code sample :
//Create context with D3D_Device.
cl_context_properties cps[3] =
{
CL_CONTEXT_D3D9_DEVICE,
(cl_context_properties)m_pD3DDevice,
0
};
cl_context_properties* cprops = cps;
context = clCreateContext(
cprops,
ciDeviceCount,
cdDevices,
0,
0,
&status) ;
//Get the Function Address:clCreateFromD3D9BufferKHR
typedef CL_API_ENTRY cl_mem (CL_API_CALL *Fun_clCreateFromD3D9BufferKHR)(
cl_context /* context */,
cl_mem_flags /* flags */,
IDirect3DResource9 * /* resource */,
HANDLE /* shared_handle */,
cl_int * /* errcode_ret */);
Fun_clCreateFromD3D9BufferKHR myclCreateFromD3D9BufferKHR = 0;
myclCreateFromD3D9BufferKHR= (Fun_clCreateFromD3D9BufferKHR)clGetExtensionFunctionAddress("clCreateFromD3D9BufferKHR");
// Create D3Dsurface and get the handle.
HRESULT hr = m_pD3DDevice->CreateOffscreenPlainSurface(width,
height,
(D3DFORMAT)MAKEFOURCC('N','V','1','2'),
D3DPOOL_DEFAULT,
&m_d3dOutputSurface,
&m_hD3Dhandle);
//Map the D3DSurface to cl_mem
outputBuffer = myclCreateFromD3D9BufferKHR(
context,
CL_MEM_READ_WRITE,
m_d3dOutputSurface,
m_hD3Dhandle,
&status);
Then get the Return error status = -60(CL_INVALID_D3D_OBJECT,CL_INVALID_GL_OBJECT)
Originally posted by: wb0330 Hi Micah,
i do some similar work to test d3d interop use "clCreateFromD3D9BufferKHR" on my Radeon HD4850 card, and also get CL_INVALID_D3D_OBJECT error. can you give some suggestions?
My code sample :
//Create context with D3D_Device.
cl_context_properties cps[3] = { CL_CONTEXT_D3D9_DEVICE, (cl_context_properties)m_pD3DDevice, 0 };
cl_context_properties* cprops = cps;
context = clCreateContext( cprops, ciDeviceCount, cdDevices, 0, 0, &status) ;
//Get the Function Address:clCreateFromD3D9BufferKHR
typedef CL_API_ENTRY cl_mem (CL_API_CALL *Fun_clCreateFromD3D9BufferKHR)( cl_context /* context */, cl_mem_flags /* flags */, IDirect3DResource9 * /* resource */, HANDLE /* shared_handle */, cl_int * /* errcode_ret */);
Fun_clCreateFromD3D9BufferKHR myclCreateFromD3D9BufferKHR = 0;
myclCreateFromD3D9BufferKHR= (Fun_clCreateFromD3D9BufferKHR)clGetExtensionFunctionAddress("clCreateFromD3D9BufferKHR");
// Create D3Dsurface and get the handle.
HRESULT hr = m_pD3DDevice->CreateOffscreenPlainSurface(width, height, (D3DFORMAT)MAKEFOURCC('N','V','1','2'), D3DPOOL_DEFAULT, &m_d3dOutputSurface, &m_hD3Dhandle);
//Map the D3DSurface to cl_mem
outputBuffer = myclCreateFromD3D9BufferKHR( context, CL_MEM_READ_WRITE, m_d3dOutputSurface, m_hD3Dhandle, &status);
Then get the Return error status = -60(CL_INVALID_D3D_OBJECT,CL_INVALID_GL_OBJECT)
In SDK2.1, D3D9 interop is not supported. It is expected to support in upcoming releases.
Hi genaganna,
Thank you for your relpay.
If suitable, Can you tell me When the next release is available for download? We are waiting for this feature.
Thanks.
Originally posted by: wb0330 Hi genaganna,
Thank you for your relpay.
If suitable, Can you tell me When the next release is available for download? We are waiting for this feature.
Thanks.
I cannot tell you eact dates. Just few days back SDK2.1 released. You can expect in Q3.
Got it. Thanks genaganna.
What about d3d 10 interop in 2.1 it was in 2.0 right?
Also is strange d3d9 not supported since 2.1 reports cl_amd_dx9interop extension..
Originally posted by: oscarbarenys1 What about d3d 10 interop in 2.1 it was in 2.0 right?
Also is strange d3d9 not supported since 2.1 reports cl_amd_dx9interop extension..
oscarbarenys1,
In SDK2.01, D3D10 preview version was supported. It is removed as per the Khronos rules. It will be supported in upcoming releases.
Please run CLInfo sample to know supported extensions.