Jump to content
  • Advertisement
Sign in to follow this  

[D3D12] Acquiring IDXGIAdapter3 Interface from D3D12Device

This topic is 970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Many D3D12 guides on memory management best practices I have encountered thus far have recommend keeping track of available video/system memory using IDXGIAdapter3::QueryVideoMemoryInfo in order to prevent resource allocation on full heaps.  My current setup passes a ID3D12Device pointer to resource allocation classes.  It would be useful to be able to acquire the IDXGIAdapter3 interface directly from the D3D12Device, and indeed, the Microsoft documentation seems to suggest this is possible by first acquiring an IDXGIDevice interface from the D3D12Device, and then acquiring an IDXGIAdapter from the IDXGIDevice interface like so:

ID3D12Device * device = CreateD3D12Device();

IDXGIDevice * pDXGIDevice;
device.Get()->QueryInterface(IID_PPV_ARGS(&pDXGIDevice));  //<-- E_NOINTERFACE Error result.

//-- That's too bad because I would really like to do the following:
  IDXGIAdapter * pDXGIAdapter;

  // Hopefully it's possible to acquire a IDXGIAdapter3 from our IDXGIAdapter interface?
  IDXGIAdapter3 * pDXGIAdapter3;

  // Now I can query video/system memory usage.

This doesn't seem to be possible, as no IDXGIDevice interface can be acquired from the D3D12Device.  Has anyone found a work around to acquiring the IDXGIAdapter3 interface from their D3D12Device?  Perhaps there is a global D3D function call to do this? 


There are only two other workarounds I know of, creating a new type that stuffs the IDXGIAdapter3 with the D3D12Device and pass that around to required resource allocating classes, or register an event handler to fire with IDXGIAdapter3::RegisterVideoMemoryBudgetChangeNotificationEvent, which is much more elegant than the previous method, but a little overkill at the moment.


Any suggestions?  Thanks. 

Edited by DustinB

Share this post

Link to post
Share on other sites

If you want to retrieve back the dxgi adapter you used to create the d3d12 device, you have to call ID3D12Device::GetAdapterLuid. Then you pass the LUID to IDXGIFactory4::EnumAdapterByLuid .


Please note the IDXGIFactory4::EnumAdapterByLuid remarks:


For Direct3D 12, it's no longer possible to backtrack from a device to the IDXGIAdapter that was used to create it. IDXGIFactory4::EnumAdapterByLuid enables an app to retrieve information about the adapter where a D3D12 device was created. IDXGIFactory4::EnumAdapterByLuid is designed to be paired withID3D12Device::GetAdapterLuid. For more information, see DXGI 1.4 Improvements.

Edited by Alessio1989

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!