How do you use CheckMultisampleQualityLevels and enable multisampling

I am learning directx 11 and trying to set up multisampling. For some reason, every tutorial on the Internet disables multisampling and never discusses how to enable it.

First: I searched and cannot find examples of using CheckMultisampleQualityLevels . It seems that you need to create a device, call this function, find out the available levels, then destroy this device and create a new one with the necessary settings. Is this the right way to do this? Or is there a better way?

Secondly, how do you enable multisampling? Since I'm not sure how to get the CheckMultisampleQualityLevels work, I tried to insert some values ​​for DXGI_SWAP_CHAIN_DESC.SampleDesc.Count and DXGI_SWAP_CHAIN_DESC.SampleDesc.Quality (for example, 4 and 4), and nothing is displayed (this is an error if I put it (this is an error if I put in crazy values ​​like 33 and 2). Does it need to be installed somewhere else besides the description of the swap chains, or somehow interfere with the shaders (I have a base light and a texture shader)?

I have a GTX 570, so I know that it can support most AA settings. I follow this set of tutorials if this helps: http://rastertek.com/tutindex.html

+4
source share
3 answers

1.Call ID3D11Device :: CheckMultisampleQualityLevels , which gives you the level of quality supported by the adapter.

2. Fill in DXGI_SWAP_CHAIN_DESC , set SampleDesc.Count and SampleDesc.Quality.

3. If anti-aliasing with multiple samples is used, all related rendering objects and depth buffers should have the same samples and quality levels. ( structure DXGI_SAMPLE_DESC )

According to the msdn document on D3D11_RASTERIZER_DESC ( structure D3D11_RASTERIZER_DESC ), API functionality level 10.1 and higher, MultisampleEnable does not affect points and triangles with refers to MSAA and affects only the choice of line rendering algorithm.

For more information you should check msdn.

+5
source

You should try setting MultisampleEnable D3D11_RASTERIZER_DESC .

Also set the quality to 1.

As for CheckmultisampleQuality, you just set the DXGI format you want to create. The number of samples you want. Finally, pass the pointer to uint and it will return the number of quality levels available to you. If it returns 0, then multisampling is not supported, otherwise you know what quality levels you can set.

+1
source

it helps me:

  • Depth buffers
  • must have the same samples and quality levels
  • depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;

thanks @Telanor and @ user1253930

+1
source

Source: https://habr.com/ru/post/1343879/


All Articles