1

So I have recently started using SharpDX, and have stumbled into a problem. I have no idea how to get SharpDX to multisample. I have found two things related; you can specify a SampleDescription when creating the SwapChainDescription, but any input other than (1, 0) throws a Wrong Parameter exception.

The other thing I found was SamplerState, which I put on my pixel shader, didn't do anything. I played around a lot with the parameters, but there was no visible change whatsoever.

I am sure I am missing something, but without any previous directX knowlegde I have no idea really what exactly to look for.

2
  • Welcome to SO! Please edit your post to include your code that isn't working, which will allow us to better help you. Commented Jan 23, 2014 at 22:22
  • Have you solved your problem? Commented Mar 20, 2014 at 18:28

3 Answers 3

3

This will come in handy in your case:

int maxsamples = Device.MultisampleCountMaximum;

int res = device.CheckMultisampleQualityLevels(SharpDX.DXGI.Format.R8G8B8A8_UNorm, samplecount);

If res returns 0 then this Sample count is not supported.

Also please note that some options are not compatible, so if you create your SwapChain with:

sd.Usage = (other usages) | Usage.UnorderedAccess;

You are not allowed to use multisampling.

Another very useful technique to spot the problems for those errors:

Create your device with DeviceCreationFlags.Debug

In your startup project properties (debug section), tick "Enable native code debugging".

Any API call that fails will give you an error description in the debug output window.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi, when I use Device.MultisampleCountMaximum, I get a value of 32. But whatever format and samplecount I pass to CheckMultisampleQualityLevels, it always returns 1. However, when I then try to use new SampleDescription(samplecount, 1) it throws an exception saying this combination is not supported. What am I doing wrong?
new SampleDescription(samplecount, 0) , since you can go up to maxlevels - 1
0

I had the same problem, could not get Multisampling to work until I enabled the debugging and got a good hint (really wished I had done this hours ago and saved a whole lot of testing!).

Initially I read somewhere that the DepthStencilBuffer had the same SampleDescription as the Render texture - but I'm not so sure as it appears to work without this as a quick test just showed.

The thing for me was to create the DepthStencilView with a DepthStencilViewDescription that has "Dimension = DepthStencilViewDimension.Texture2DMultisampled".

Comments

0

Just a heads up on when you are doing multisampling.

When you set your rendertarget, if passing a rendertarget and depthstencil, you need to ensure they both have the same multisampling level.

So, for rendering to the backbuffer you have defined with MSAA, you will need to create a depth buffer with the same MSAA level.

BUT, if you are have a rendertarget that will be a texture that is fed back into the pipeline, you can define a non MSAA texture and a NON MSAA depth buffer, which is handy as you can use a sampler on the texture (you cant use a normal sampler for a MSAA Resource texture).

Most of this info maybe not new for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.