1
votes

The purpose is to try and share surface between two different d3d devices of different version, one being d3d9, the other being d3d9Ex or higher.

Based on the MSDN documentation where it states you can do so from link.

Direct3D resources can now be shared between devices or processes. This applies to any Direct3D resource including textures, vertex buffers, index buffers, or surfaces (such as render targets, depth stencil buffers or off-screen plain surfaces).

Also based on MSDN documentation where it states you can't do so from another link

Direct3D 10.0, Direct3D 9c, and older Direct3D runtimes do not support shared surfaces. System memory copies will continue to be used for interoperability with GDI or DXGI-based APIs.

To verify is to try it myself, thus the code:

HANDLE SharedHandle = NULL;

IDirect3DTexture9 *d3d9Tex;
pD3D9Dev->CreateTexture(Width, Height, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &d3d9Tex, &SharedHanlde);
if(FAILED(hr))
{
    LOG("failed %s %s", GetD3DErrorString(hr), CNGetErrorString(GetLastError()));
}

IDirect3DTexture9 *d3d9ExTex;
pD3D9DevEx->CreateTexture(Width, Height, 1, D3DUSAGE_RENDERTARGET, Format, D3DPOOL_DEFAULT, &d3d9ExTex, &SharedHanlde);
if(FAILED(hr))
{
    LOG("failed %s %s", GetD3DErrorString(hr), CNGetErrorString(GetLastError()));
}

Which gives:

Direct3D9: (ERROR) :Device is not capable of sharing resource. CreateTexture fails.

CreateRenderTarget gives same results.

Much disappointed with the result, my question is, is resource sharing suppose to work for d3d9 at all, or am I missing something that I should have do?

2

2 Answers

4
votes
  1. Direct3D is a generic name, it includes Direct3D 9, Direct3D 9EX, Direct3D 10 and Direct3D 11... the document said Direct3D resource can now be shared, that's not too bad, absolutely you can do this with Direct3D 10.1 and Direct3D 11.

  2. You can't do surface sharing with Direct3D 9, the document has clarify this very clearly as below.

Direct3D 10.0, Direct3D 9c, and older Direct3D runtimes do not support shared surfaces. System memory copies will continue to be used for interoperability with GDI or DXGI-based APIs.

If you read this page carefully, you can easily get the conclusion:

  • Direct3D 11, Direct2D, and Direct3D 10.1 support synchronized surface sharing
  • Direct3D 9Ex support unsynchronized surface sharing.
  • Direct3D 10.0, Direct3D 9c, and older Direct3D run-times do not support surface sharing.
0
votes

When you create a D3D9Ex device, it is also a D3D9 device. Thus you don't need anything separate.

If you want to store a D3D9Ex device into a pointer for a D3D9 device, use QueryInterface with IID_IDirect3DDevice9.