view

ID3D11RenderTargetView* mRenderTargetView;

 ID3D11Texture2D* backBuffer;

 mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer));


md3dDevice->CreateRenderTargetView(backBuffer, 0, &mRenderTargetView); 

ReleaseCOM(backBuffer);


the multisampling settings used for the depth/stencil buffer must match the settings used for the render target.



CPUAccessFlags: Specifies how the CPU will access the resource. 

If the CPU needs to write to the resource, specify D3D11_CPU_ACCESS_WRITE. A resource with write access must have usage D3D11_USAGE_DYNAMIC or D3D11_USAGE_STAGING.

 If the CPU needs to read from the buffer, specify D3D11_CPU_ACCESS_READ. A buffer with read access must have usage D3D11_USAGE_STAGING. 

For the depth/stencil buffer, only the GPU writes and reads to the depth/buffer; therefore, we can specify zero for this value, as the CPU will not be reading or writing to the depth/stencil buffer.


We commented that the usage flags D3D11_USAGE_DYNAMIC and D3D11_USAGE_STAGING should be avoided because there is a performance penalty. The common factor is that the CPU is involved with both of these flags. Going back and forth between CPU and GPU memory incurs a performance hit. For maximum speed, graphics hardware works best when we create all of our resources and upload the data to the GPU, and the resources stay on the GPU where only the GPU reads and writes to the resources. However, for some applications, these flags cannot beavoided and the CPU must get involved, but you should always try to minimize the usage of these flags.

The second parameter of CreateTexture2D is a pointer to initial data to fill the texture with. However, because this texture is to be used as the depth/stencil buffer, we do not need to fill it ourselves with any data. Direct3D will write to the depth/stencil buffer directly when performing depth buffering and stencil operations. Thus, we specify null for the second parameter. 


The second parameter of CreateDepthStencilView is a pointer to a D3D11_DEPTH_STENCIL_VIEW_DESC. Among other things, this structure describes the data type (format) of the elements in the resource. If the resource was created with a typed format (i.e., not typeless), then this parameter can be null, which indicates to create a view to the first mipmap level of this resource (the depth/stencil buffer was created with only one mipmap level) with the format the resource was created with. (Mipmaps are discussed in Chapter 8.) Because we specified the type of our depth/stencil buffer, we specify null for this parameter.




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值