D3D_FEATURE_LEVEL *pFeatureLevel, ID3D11DeviceContext
4. Flags: Optional device creation flags (that can be bitwise ORed together). Two common flags are: (a) D3D11_CREATE_DEVICE_DEBUG: For debug mode builds, this flag should be set to enable the debug layer. When the debug flag is specified, Direct3D will send debug messages to the VC++ output window;
(b) D3D11_CREATE_DEVICE_SINGLETHREADED: Improves performance if you can guarantee that Direct3D will not be called from multiple threads. If this flag is enabled, then the ID3D11Device::CreateDeferredContext method will fail (see “Note” at the end of this section).
There is also such a thing called a deferred context (ID3D11Device::CreateDeferredContext).
This is part of the multithreading support in Direct3D 11. We consider multithreading an advance topic and do not cover it in this book, but the basic idea is as follows:
1. Have the immediate context on the main rendering thread.
2. Have any additional deferred contexts on separate worker threads.
(a) Each worker thread can record graphics commands into a command list (ID3D11CommandList).
(b) The command list from each worker thread can then be executed on the main rendering thread.
If the command lists take time to assemble, which they can for complicated rendering graphs, being able to assemble the command lists in parallel on multi-core systems is advantageous.
If you wanted to change the multisampling settings at runtime, you would have to destroy and recreate the swap chain.
We use the DXGI_FORMAT_R8G8B8A8_UNORM format (8-bits red, green, blue, and alpha) for the back buffer because monitors generally do not support more than 24-bit color, so the extra precision would be wasted. The extra 8-bits of alpha is not output by the monitor, but having an extra 8-bits in the back buffer can be used for certain special effects.
IDXGIDevice* dxgiDevice = 0;
HR(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice));
IDXGIAdapter* dxgiAdapter = 0;
HR(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter));
// Finally got the IDXGIFactory interface.
IDXGIFactory* dxgiFactory = 0;
HR(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory));
// Now, create the swap chain.
IDXGISwapChain* mSwapChain; HR(dxgiFactory->CreateSwapChain(md3dDevice, &sd, &mSwapChain));
// Release our acquired COM interfaces (because we are done with them).
ReleaseCOM(dxgiDevice);
ReleaseCOM(dxgiAdapter);
ReleaseCOM(dxgiFactory);