Gives a device access to a shared resource that is referenced by name 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).
HRESULT OpenSharedResourceByName( LPCWSTR lpName, DWORD dwDesiredAccess, REFIID returnedInterface, void **ppResource );
The name of the resource to open. This parameter cannot be NULL.
The requested access rights to the resource. In addition to the generic access rights, DXGI defines the following values:
- DXGI_SHARED_RESOURCE_READ ( 0x80000000L ) - specifies read access to the resource.
- DXGI_SHARED_RESOURCE_WRITE ( 1 ) - specifies write access to the resource.
The globally unique identifier (GUID) for the resource interface. For more info, see Remarks.
A pointer to a variable that receives a pointer to the interface for the shared resource object to access.
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.
Platform Update for Windows 7: On Windows 7 or Windows Server 2008 R2 with the Platform Update for Windows 7 installed, OpenSharedResourceByName fails with E_NOTIMPL because NTHANDLES are used. For more info about the Platform Update for Windows 7, see Platform Update for Windows 7.
The behavior of OpenSharedResourceByName is similar to the behavior of the ID3D11Device1::OpenSharedResource1 method; each call to OpenSharedResourceByName to access a resource creates a new resource object. In other words, if you call OpenSharedResourceByName twice and pass the same resource name to lpName, you receive two resource objects with different IUnknown pointers.
To share a resource between two devices
- Create the resource as shared and specify that it uses NT handles, by setting the D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag.
- 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.
- Query the resource for the IDXGIResource1 interface.
- Call the IDXGIResource1::CreateSharedHandle method to obtain the unique handle to the resource. In this IDXGIResource1::CreateSharedHandle call, you must pass a name for the resource if you want to subsequently call OpenSharedResourceByName to access the resource by name.
ID3D11Device1* pDevice; ID3D11Texture2D* pTexture2D; pDevice->OpenSharedResourceByName( “MySurface”, DXGI_SHARED_REOUSRCE_READ, __uuidof(ID3D11Texture2D), (void**)&pTexture2D);
|Minimum supported client||Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps]|
|Minimum supported server||Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps]|