Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use CheckMultisampleQualityLevels and enable multisampling

I'm learning directx 11 and trying to set up multisampling. For some reason every tutorial on the internet disables multisampling and never goes over how to enable it.

First: I've searched around and can't find any examples of how to use CheckMultisampleQualityLevels. It seems like you need to create a device, call that function, find out the available levels, then destroy that device and create a new one with the settings you want. Is this the correct way to do this? Or is there a better way?

Secondly, how do you enable multisampling? Since I'm not sure how to get CheckMultisampleQualityLevels working, I tried putting in some values for DXGI_SWAP_CHAIN_DESC.SampleDesc.Count and DXGI_SWAP_CHAIN_DESC.SampleDesc.Quality (like 4 and 4) and while it does run, nothing is displayed (it does error if I put in crazy values like 33 and 2). Does this need to be set somewhere else besides the swap chain description or do shaders interfere with it in some way (I have a basic light and texture shader set up)?

I have a GTX 570, so I know it can support most AA settings. I'm following this set of tutorials, in case it's of any help: http://rastertek.com/tutindex.html

like image 933
Telanor Avatar asked Mar 16 '11 05:03

Telanor


3 Answers

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

2.While filling out the DXGI_SWAP_CHAIN_DESC, set the SampleDesc.Count and SampleDesc.Quality.

3.If multi-sample antialiasing is being used, all bound render targets and depth buffers must have the same sample counts and quality levels. (DXGI_SAMPLE_DESC structure)

According to the msdn document about D3D11_RASTERIZER_DESC (D3D11_RASTERIZER_DESC structure), API feature level 10.1 and higher, MultisampleEnable has no effect on points and triangles with regard to MSAA and impacts only the selection of the line-rendering algorithm.

You should check out the msdn for more details.

like image 77
user1253930 Avatar answered Sep 20 '22 01:09

user1253930


this helped me:

  • depth buffers must have the same sample counts and quality levels
  • depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMS;

thanks @Telanor and @user1253930

like image 45
Jinxi Avatar answered Sep 20 '22 01:09

Jinxi


You should try setting MultisampleEnable D3D11_RASTERIZER_DESC.

Also set quality to 1.

As for CheckmultisampleQuality you simply set the DXGI format you want to create. The number of samples you want. Finally pass in a pointer to a 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.

like image 21
Goz Avatar answered Sep 21 '22 01:09

Goz