Jump to content
  • Advertisement
Sign in to follow this  
leonard2012

How to enable multisampling anti-aliasing in D3D10

This topic is 2370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'am working on the issue of enabling multisampling anti-aliasing in my D3D10 project. I know there are two places where I can enable multisampling. One is before calling function [size=2]D3D10CreateDeviceAndSwapChain().

DXGI_SWAP_CHAIN_DESC sd;
sd.BufferDesc.Width = cxClient_;
sd.BufferDesc.Height = cyClient_;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// No multisampling.
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;

The other is before

CreateDepthStencilView()

D3D10_TEXTURE2D_DESC depthStencilDesc;

depthStencilDesc.Width = cxClient;
depthStencilDesc.Height = cyClient;
depthStencilDesc.MipLevels = 1;
depthStencilDesc.ArraySize = 1;
depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDesc.SampleDesc.Count = 1; // multisampling must match
depthStencilDesc.SampleDesc.Quality = 0; // swap chain values.
depthStencilDesc.Usage = D3D10_USAGE_DEFAULT;
depthStencilDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencilDesc.CPUAccessFlags = 0;
depthStencilDesc.MiscFlags = 0;


Whenever I change the count and quality to any value pairs other than (1,0), my app crashes.

I search the web for answers but find no helpful methods. Some methods may be obselete as they use old D3D APIs.

Share this post


Link to post
Share on other sites
Advertisement
If you don't create any any other render targets, then using a sample count of > 1 for your swap chain and your depth stencil buffer will enable MSAA.

What is the actual crash that you're getting? Are you checking the return values of your D3D calls to make sure that they succeed? Do you create the device with the DEBUG flag so that you get descriptive error messages?

Share this post


Link to post
Share on other sites

If you don't create any any other render targets, then using a sample count of > 1 for your swap chain and your depth stencil buffer will enable MSAA.

What is the actual crash that you're getting? Are you checking the return values of your D3D calls to make sure that they succeed? Do you create the device with the DEBUG flag so that you get descriptive error messages?

Hi, I've added the DEBUG flag. Whenever the quality is set to a value > 0, the function D3D10CreateDeviceAndSwapChain fails with both swap chain and D3D device returned as NULL. When I set the sample count of > 1 and quality of 0, the code runs OK but AA is not enabled.

Share this post


Link to post
Share on other sites

Quality is CSAA (NVIDIA stuff)
Sample count is MSAA sample count. Sample > 1 = MSAA enabled (on that texture)


Use[color=#2A2A2A] ID3D11Device::CheckMultisampleQualityLevels to see possibly quality levels

I called ID3D10Device::CheckMultisampleQualityLevels with the code

for ( UINT SampleCount = 1; SampleCount <= 8; SampleCount++ )
if ( iD3dDevice_->CheckMultisampleQualityLevels(DXGI_FORMAT_D24_UNORM_S8_UINT, SampleCount, &uiQualityLevels) != S_OK )
break;

The result is uiQualityLevels=1 for SampleCount=1/2 and uiQualityLevels=0 otherwise.
According to MSDN article

The image quality level. The higher the quality, the lower the performance. The valid range is between zero and one less than the level returned by ID3D10Device::CheckMultisampleQualityLevels.
[/quote]
Does this mean the quality level of my machine is always zero?

Share this post


Link to post
Share on other sites
How are you filling out the rest of DXGI_SWAP_CHAIN_DESC? One of those parameters is probably invalid.

Share this post


Link to post
Share on other sites

How are you filling out the rest of DXGI_SWAP_CHAIN_DESC? One of those parameters is probably invalid.

Here is the code

DXGI_SWAP_CHAIN_DESC sd;
GetClientRect(hwnd_, &rect);
cxClient_ = rect.right-rect.left;
cyClient_ = rect.bottom-rect.top;
sd.BufferDesc.Width = cxClient_;
sd.BufferDesc.Height = cyClient_;
sd.BufferDesc.RefreshRate.Numerator = 60;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
sd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
// No multisampling.
sd.SampleDesc.Count = 1;
sd.SampleDesc.Quality = 0;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferCount = 1;
sd.OutputWindow = hwnd_;
sd.Windowed = true;
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
sd.Flags = 0;
// 2. Create the ID3D10Device and IDXGISwapChain interface using
// the D3D10CreateDeviceAndSwapChain function.
UINT createDeviceFlags = 0;
#if defined(DEBUG) || defined(_DEBUG)
// In debug mode, send debug messages to the VC++ output window
createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
#endif
HR( D3D10CreateDeviceAndSwapChain(
0, //default adapter
D3D10_DRIVER_TYPE_HARDWARE,
0, // no software device
createDeviceFlags,
D3D10_SDK_VERSION,
&sd,
&iDxgiSwapChain_,
&iD3dDevice_) );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!