Jump to content

  • Log In with Google      Sign In   
  • Create Account


[d3d10] shared resource from Direct3D9 to Direct 3D10


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 saiwaifengyun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 27 April 2009 - 08:07 AM

I am looking for help about sharing resource from Direct3D9 to Direct3D10. The function of OpenSharedResource did not work at all.Even I used the referece hardware for D3D9 and D3D10, it did not work either. HANDLE SharedHandle=NULL; LPDIRECT3DTEXTURE9 pTexture9=NULL; hr = m_pd3d9_device->CreateTexture(720, 480, 1, D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&pTexture9, &SharedHandle); ID3D10Texture2D *pTexture10 = NULL; ID3D10Resource* tempResource10 =NULL; hr = m_pd3d10_device->OpenSharedResource(SharedHandle,__uuidof(ID3D10Resource), (void**)(&tempResource10)); //here it will return the invalid arg error. hr = tempResource10->QueryInterface(__uuidof(ID3D10Texture2D), (void**)(&pTexture10)); hr = tempResource10->Release();

Sponsor:

#2 Evil Steve   Members   -  Reputation: 1959

Like
0Likes
Like

Posted 27 April 2009 - 08:12 AM

Quote:
Original post by saiwaifengyun
I am looking for help about sharing resource from Direct3D9 to Direct3D10. The function of OpenSharedResource did not work at all.Even I used the referece hardware for D3D9 and D3D10, it did not work either.

HANDLE SharedHandle=NULL;

LPDIRECT3DTEXTURE9 pTexture9=NULL;
hr = m_pd3d9_device->CreateTexture(720, 480, 1, D3DUSAGE_RENDERTARGET,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&pTexture9, &SharedHandle);

ID3D10Texture2D *pTexture10 = NULL;
ID3D10Resource* tempResource10 =NULL;
hr = m_pd3d10_device->OpenSharedResource(SharedHandle,__uuidof(ID3D10Resource), (void**)(&tempResource10));
//here it will return the invalid arg error.
hr = tempResource10->QueryInterface(__uuidof(ID3D10Texture2D), (void**)(&pTexture10));
hr = tempResource10->Release();
You can't share a resource between D3D9 and D3D10 - the drivers are completely different, and the underlying representation could be different. You'll have to duplicate the data instead.

Steve Macpherson
Senior programmer, Firebrand Games


#3 K1nG Gr4H4m   Members   -  Reputation: 100

Like
0Likes
Like

Posted 27 April 2009 - 08:25 AM

I never tried it myself, but it seems there are a lot of restrictions. Check this: link (Assassin's post)

#4 saiwaifengyun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 27 April 2009 - 08:26 AM

However, according to the MSDN of D3D10, it seems that the resource can be shared:
http://msdn.microsoft.com/en-us/library/bb173598(VS.85).aspx?wt.slv=ColumnA

To share a resource between a Direct3D 9 device and a Direct3D 10 device the texture must have been created using the pSharedHandle argument of IDirect3DDevice9::CreateTexture. The shared Direct3D 9 handle is then passed to OpenSharedResource in the hResource argument.

The following code illustrates the method calls involved.

sharedHandle = NULL; // must be set to NULL to create, can use a valid handle here to open in D3D9
pDevice9->CreateTexture(..., pTex2D_9, &sharedHandle);
...
pDevice10->OpenSharedResource(sharedHandle, __uuidof(ID3D10Resource), (void**)(&tempResource10));
tempResource10->QueryInterface(__uuidof(ID3D10Texture2D), (void**)(&pTex2D_10));
tempResource10->Release();
// now use pTex2D_10 with pDevice10
Textures being shared from D3D9 to D3D10 have the following restrictions.

Textures must be 2D
Only 1 mip level is allowed
Texture must have default usage
Texture must be write only
MSAA textures are not allowed
Bind flags must have SHADER_RESOURCE and RENDER_TARGET set
Only R10G10B10A2_UNORM, R16G16B16A16_FLOAT and R8G8B8A8_UNORM formats are allowed
If a shared texture is updated on one device ID3D10Device::Flush must be called on that device.


#5 saiwaifengyun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 27 April 2009 - 08:31 AM

To [K1nG Gr4H4m]

These restrictions are not clear at all(even the description for opensharedresource of MSDN). Textures of D3D9 can be not created with R8G8B8A8_UNORM or SHADER_RESOURCE.

Textures being shared from D3D9 to D3D10 have the following restrictions.
Textures must be 2D
Only 1 mip level is allowed
Texture must have default usage
Texture must be write only
MSAA textures are not allowed
Bind flags must have SHADER_RESOURCE and RENDER_TARGET set
Only R10G10B10A2_UNORM, R16G16B16A16_FLOAT and R8G8B8A8_UNORM formats are allowed


#6 Evil Steve   Members   -  Reputation: 1959

Like
0Likes
Like

Posted 27 April 2009 - 08:56 PM

Quote:
Original post by saiwaifengyun
To share a resource between a Direct3D 9 device and a Direct3D 10 device the texture must have been created using the pSharedHandle argument of IDirect3DDevice9::CreateTexture. The shared Direct3D 9 handle is then passed to OpenSharedResource in the hResource argument.
Is that not only for D3D9Ex? (I'm not a D3D10 person at all).

#7 saiwaifengyun   Members   -  Reputation: 122

Like
0Likes
Like

Posted 28 April 2009 - 07:17 AM

yes, only D3D9ex supports shared resource, since the handle in the CreateTexture can be effective under D3D9ex. The MSDN document shows D3D9 can share resource to D3D10, however, it doesn't support it actually. It is not caused by the driver, because the OpenSharedResource return the D3D10 E_INVALIDARG error.

#8 K1nG Gr4H4m   Members   -  Reputation: 100

Like
0Likes
Like

Posted 29 April 2009 - 04:08 AM

That's really strange. Everything looks good. The only thing I found about that is, the device (ID3D10Device) needs to be created with the "D3D10_RESOURCE_MISC_SHARED" flag, unless it was created with the IDXGIDevice.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS