HRESULT D3D11CreateDevice flag

HRESULT D3D11CreateDevice( IDXGIAdapter *pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL *pFeatureLevels, UINT FeatureLevels, UINT SDKVersion, ID3D11Device **ppDevice,

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);





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值