Search code examples
directxdirectx-11direct3d11dxgi

Is CreateDXGIFactory always create the newest version of IDXGIFactory system support?


I use CreateDXGIFactory to create a IDXGIFactory(the oldest version), and then use this IDXGIFactory to query IDXGIFactory6, it succeed.(My system version is Win10 1803).

1.So, is this fuction CreateDXGIFactory always create the newest version of IDXGIFactory which the system support?

The similar thing, D3D11CreateDevice create the base version of ID3D11Device, and I can query the ID3D11Device3 successfully?

2.The second question, is fuction D3D11CreateDevice create the newest version of ID3D11Device which the system support?


Solution

  • D3D11CreateDevice is simpler because it is a single entry point. The documentation does not operate with terms "older version" and "newer version". Instead it suggests that API creates an object with requested interface, and which is adequate to the system you are on and to requested creation arguments (feature level and such). Following that you can obtain access to newer features, when available, by querying newer interfaces, which documentation suggests as well:

    To create a Direct3D 11.1 device (ID3D11Device1), which is available on Windows 8, Windows Server 2012, and Windows 7 and Windows Server 2008 R2 with the Platform Update for Windows 7 installed, you first create a ID3D11Device with this function, and then call the QueryInterface method on the ID3D11Device object to obtain the ID3D11Device1 interface.

    To create a Direct3D 11.2 device (ID3D11Device2), which is available on Windows 8.1 and Windows Server 2012 R2, you first create a ID3D11Device with this function, and then call the QueryInterface method on the ID3D11Device object to obtain the ID3D11Device2 interface.

    That is, you start creating device the same way and then you query new interfaces. Implementation may or may not respond by stepping up to "newer implementation" depending on whether you ever queried those new interfaces. Either way it remains implementation specific, including that such behavior can technically be changed as long as it transparent to applications consuming the API in this documented way.

    With DXGI there are two API entry points CreateDXGIFactory and CreateDXGIFactory1. The documentation suggests that you don't mix API consumption via 1.0 and 1.1 interfaces.

    Do not mix the use of DXGI 1.0 (IDXGIFactory) and DXGI 1.1 (IDXGIFactory1) in an application. Use IDXGIFactory or IDXGIFactory1, but not both in an application.

    This does not necessarily mean that the two functions are creating different factories. Microsoft reserves the right to adjust the behavior as long as you abide by documented guidelines.

    If you are not going to do anything that goes beyond DGXI 1.0 you can use CreateDXGIFactory on older and newer systems. If you need features of 1.1 and above you are supposed to start with CreateDXGIFactory1. Also note that the two functions have different availability across environments and this is one of the reasons they two exist in first place.