Hi
I am trying to share resource between directx9 and directx11,having some problems regarding this.
what i am doing is this :-
STEP1: created a shared texture with format D3DFMT_A8R8G8B8 in directx9 and get its shared handle.
STEP2: open the shared texture with directx11 device using the handle.
STEP3: create UAV of texture creating in step3.
but step 3 fails with error
D3D11: ERROR: ID3D11Device::CreateUnorderedAccessView: The format (0x57, B8G8R8A8_UNORM) cannot be used with a Typed Unordered Access View. [ STATE_CREATION ERROR #2097344: CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT ]
D3D11: ERROR: ID3D11Device::CreateUnorderedAccessView: A UnorderedAccessView cannot be created of a Resource that did not specify the D3D11_BIND_UNORDERED_ACCESS BindFlag. [ STATE_CREATION ERROR #2097342: CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE ]
please help me here that how can i create UAV of a shared texture which is created in directx9.
//code
//DX9
HRESULT hr = g_pd3dDevice9->CreateTexture( Width , Height , 1 , D3DUSAGE_RENDERTARGET , D3DFMT_A8R8G8B8 ,D3DPOOL_DEFAULT , &g_pTexture , &g_pSharedHandleTex9 );
//DX11
hr = m_pDevice11->OpenSharedResource( g_pSharedHandleTex9 , __uuidof(ID3D11Texture2D) , (void**)&m_pTetxure); //success
hr = m_pDevice11->CreateUnorderedAccessView( m_pTetxure, NULL, &m_pTetxureUAV); //fails
so,instead of this, I tried to do
STEP1: create a texture in directx11 format DXGI_FORMAT_R8G8B8A8_UNORM (with UAV bind flag)
STEP2: created a shared texture with format D3DFMT_A8R8G8B8 in directx9 and get its shared handle.
STEP3: open the shared texture with directx11 device using the handle.
STEP4: CopyResource() from the texture created on step 1 to the shared texture.
but the step4 failed,with error
D3D11: ERROR: ID3D11DeviceContext::CopyResource: Cannot invoke CopyResource when the Formats of each Resource are not the same or at least castable to each other, unless one format is compressed (DXGI_FORMAT_R9G9B9E5_SHAREDEXP, or DXGI_FORMAT_BC[1,2,3,4,5]_* ) and the source format is similar to the dest according to: BC[1|4] ~= R16G16B16A16|R32G32, BC[2|3|5] ~= R32G32B32A32, R9G9B9E5_SHAREDEXP ~= R32. [ RESOURCE_MANIPULATION ERROR #284: COPYRESOURCE_INVALIDSOURCE ]
I thought that D3DFMT_A8R8G8B8 and DXGI_FORMAT_R8G8B8A8_UNORM should match , just like DXGI_FORMAT_R32_FLOAT and D3DFMT_R32F matches.please help me here.
code:
//DX9
HRESULT hr = g_pd3dDevice9->CreateTexture( Width , Height , 1 , D3DUSAGE_RENDERTARGET , D3DFMT_A8R8G8B8 ,D3DPOOL_DEFAULT , &g_pTexture , &g_pSharedHandleTex9 );
//DX11
D3D11_TEXTURE2D_DESC desc;
desc.Width = width;
desc.Height = height;
....
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
hr = m_pDevice11->CreateTexture2D(&desc, NULL, &m_pTetxure); //success
...
...
hr = m_pDevice->OpenSharedResource( g_pSharedHandleTex9 , __uuidof(ID3D11Texture2D) , (void**)&m_pSTexture);
m_pDeviceContext11->CopyResource( m_pSTexture, m_pTetxure ); //fails