Skip to content

Latest commit

 

History

History
140 lines (102 loc) · 5.17 KB

nf-d3d10-id3d10device-opensharedresource.md

File metadata and controls

140 lines (102 loc) · 5.17 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:d3d10.ID3D10Device.OpenSharedResource
ID3D10Device::OpenSharedResource (d3d10.h)
Give a device access to a shared resource created on a different Direct3d device.
ID3D10Device interface [Direct3D 10]
OpenSharedResource method
ID3D10Device.OpenSharedResource
ID3D10Device::OpenSharedResource
OpenSharedResource
OpenSharedResource method [Direct3D 10]
OpenSharedResource method [Direct3D 10]
ID3D10Device interface
d3d10/ID3D10Device::OpenSharedResource
direct3d10.id3d10device_opensharedresource
e1b41a59-f80c-625e-e0a5-cc59636f10e1
direct3d10\id3d10device_opensharedresource.htm
direct3d10
VS|directx_sdk|~\id3d10device_opensharedresource.htm
12/05/2018
ID3D10Device interface [Direct3D 10],OpenSharedResource method, ID3D10Device.OpenSharedResource, ID3D10Device::OpenSharedResource, OpenSharedResource, OpenSharedResource method [Direct3D 10], OpenSharedResource method [Direct3D 10],ID3D10Device interface, d3d10/ID3D10Device::OpenSharedResource, direct3d10.id3d10device_opensharedresource, e1b41a59-f80c-625e-e0a5-cc59636f10e1
d3d10.h
Windows
Windows
19H1
ID3D10Device::OpenSharedResource
d3d10/ID3D10Device::OpenSharedResource
c++
APIRef
kbSyntax
COM
D3d10.h
ID3D10Device.OpenSharedResource

ID3D10Device::OpenSharedResource

-description

Give a device access to a shared resource created on a different Direct3d device.

-parameters

-param hResource [in]

Type: HANDLE

A resource handle. See remarks.

-param ReturnedInterface [in]

Type: REFIID

The globally unique identifier (GUID) for the resource interface. See remarks.

-param ppResource [out]

Type: void**

Address of a pointer to the resource we are gaining access to.

-returns

Type: HRESULT

This method returns one of the following Direct3D 10 Return Codes.

-remarks

To share a resource between two Direct3D 10 devices the resource must have been created with the D3D10_RESOURCE_MISC_SHARED flag, if it was created using the ID3D10Device interface. If it was created using the IDXGIDevice interface, then the resource is always shared.

The REFIID, or GUID, of the interface to the resource can be obtained by using the __uuidof() macro. For example, __uuidof(ID3D10Buffer) will get the GUID of the interface to a buffer resource.

When sharing a resource between two Direct3D 10 devices the unique handle of the resource can be obtained by querying the resource for the IDXGIResource interface and then calling GetSharedHandle.


IDXGIResource* pOtherResource(NULL);
hr = pOtherDeviceResource->QueryInterface( __uuidof(IDXGIResource), (void**)&pOtherResource );
HANDLE sharedHandle;
pOtherResource->GetSharedHandle(&sharedHandle);
      

The only resources that can be shared are 2D non-mipmapped textures.

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 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.

-see-also

ID3D10Device Interface