Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to enable multisampling anti-aliasing in D3D10


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 17 April 2012 - 09:31 AM

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 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;[/size]
[size=4]   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;[/size]
[size=4]

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.

Sponsor:

#2 MJP   Moderators   -  Reputation: 10214

Like
0Likes
Like

Posted 17 April 2012 - 11:32 AM

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?

#3 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 18 April 2012 - 01:23 AM

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.

#4 jameszhao00   Members   -  Reputation: 267

Like
0Likes
Like

Posted 18 April 2012 - 03:09 AM

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


Use ID3D11Device::CheckMultisampleQualityLevels to see possibly quality levels

#5 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 18 April 2012 - 05:49 AM

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


Use 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.

Does this mean the quality level of my machine is always zero?

#6 MJP   Moderators   -  Reputation: 10214

Like
0Likes
Like

Posted 18 April 2012 - 11:51 AM

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

#7 leonard2012   Members   -  Reputation: 167

Like
0Likes
Like

Posted 19 April 2012 - 08:01 AM

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS