In my d3d9 engine i want to take benifit of compute shader of d3d11. So firstly I created a vertex buffer in d3d11 with D3D11_BIND_UNORDERED_ACCESS and then tried to create the d3d9 vertex buffer with the Handle. like
D3D11_BUFFER_DESC bd;
ZeroMemory(&bd, sizeof(bd));
bd.ByteWidth = sizeof(stVertex) * 100;
bd.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_VERTEX_BUFFER ;
bd.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_ALLOW_RAW_VIEWS | D3D11_RESOURCE_MISC_SHARED;
hr = dev->CreateBuffer(&bd, NULL, &pVBuffer); // create the buffer
hr = CreateBufferUAV( dev, pVBuffer, &m_pBufOutUAV );
....
HANDLE sharedHandle = NULL;
IDXGIResource* pDXGIResource = NULL;
pVBuffer->QueryInterface(__uuidof(IDXGIResource), (LPVOID*) &pDXGIResource);
pDXGIResource->GetSharedHandle(&sharedHandle);
hr = g_pd3dDevice9->CreateVertexBuffer( 100*sizeof(stVertex), NULL ,
VERTEX::FVF_Flags, D3DPOOL_DEFAULT,
&g_pVertexBuffer9, &sharedHandle ); //ERROR :
which gives error :
Direct3D9: (ERROR) :Opened and created resources don't match, unable to open the shared resource. Direct3D9: (ERROR) :Cannot create Vidmem or Driver managed vertex buffer. Will NOT failover to Sysmem. Direct3D9: (ERROR) :Failure trying to create Vertex Buffer
After that i tried to create vertex buffer in directx9 first and tries to share that in direct11 but still it gave error.
HANDLE sharedHandle9 = NULL;
hr = g_pd3dDevice9->CreateVertexBuffer( 100*sizeof(VERTEX), NULL ,
VERTEX::FVF_Flags, D3DPOOL_DEFAULT,
&g_pVertexBuffer9, &sharedHandle9 );
ID3D11Resource* pTempResource11 = NULL;
hr = dev->OpenSharedResource( sharedHandle9 , __uuidof(ID3D11Buffer) ,(LPVOID*) &pTempResource11 ); //Error
D3D11: ERROR: ID3D11Device::OpenSharedResource: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #381: DEVICE_OPEN_SHARED_RESOURCE_INVALIDARG_RETURN ]
I am able to share textures but not buffers.please help me here.
thanks.