ID3D11Device1::OpenSharedResource1 Method

Gives a device access to a shared resource that is referenced by a handle and that was created on a different device. You must have previously created the resource as shared and specified that it uses NT handles (that is, you set the D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag).

Syntax

public:
HRESULT OpenSharedResource1(
         HANDLE hResource,
         REFIID returnedInterface,
         void **ppResource
)  

Parameters

hResource
Type: HANDLE 

[in] A handle to the resource to open. For more info about this parameter, see Remarks.

returnedInterface
Type: REFIID 

[in] The globally unique identifier (GUID) for the resource interface. For more info about this parameter, see Remarks.

ppResource
Type: void **

[out] A pointer to a variable that receives a pointer to the interface for the shared resource object to access.

Return value

Type: HRESULT 

This method returns one of the Direct3D 11 return codes. This method also returns E_ACCESSDENIED if the permissions to access the resource aren’t valid.

Remarks

The behavior of OpenSharedResource1 is similar to the behavior of the ID3D11Device::OpenSharedResource method; each call to OpenSharedResource1 to access a resource creates a new resource object. In other words, if you call OpenSharedResource1 twice and pass the same resource handle to hResource, you receive two resource objects with different IUnknown pointers.

To share a resource between two devices

  1. Create the resource as shared and specify that it uses NT handles, by setting the D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag.
  2. Obtain the REFIID, or GUID, of the interface to the resource by using the __uuidof() macro. For example, __uuidof(ID3D11Texture2D) retrieves the GUID of the interface to a 2D texture.
  3. Query the resource for the IDXGIResource1 interface.
  4. Call the IDXGIResource1::CreateSharedHandle method to obtain the unique handle to the resource.

Requirements

Header: Declared in d3d11_x.h (d3d11_1.h on other Windows platforms).

Library: Use d3d11_x.lib (d3d11.lib on other Windows platforms).

See also

ID3D11Device1

ID3D11Device1 Members