How to enable supersampling in DirectX 11?

Started by
7 comments, last by pnt1614 8 years, 1 month ago

I have googled about enabling supersampling in GPU and I have found that it can be done by using SV_SampleIndex as an pixel shader input. There is no difference after inserting the SV_SampleIndex as an input of the pixel shader. Is there anyway to check that the supersampling is enable or not in DirectX 11 and HLSL?

Advertisement

Found this:

http://www.gamedev.net/topic/637614-how-to-enable-msaa-in-directx-11/

Maybe it's useful to you :)

.:vinterberg:.

@Steven: You have to have a multi-sampled resource to render into. Once you have that, the actual rendering may or may not take advantage of the system value semantic that you mentioned (its up to you to decide if you need to access subsamples, or if you just let the rasterizer take care of that for you). After all rendering has been done, you then have to resolve your multisampled resource to a normal one for presentation to a window.

Thanks guys for your reply, but I think that rendering to a multi-sampled render target then resolving it is a MSAA rendering technique not a SSAA rendering. And using SV_SampleIndex for running pixel shader per sample instead of per pixel but I do not know how to check that the pixel shader is performed at sample frequency. I have search on the internet and they said that SSAA rendering is a two-pass rendering. First, we render to a larger render target (for example 2 times larger for both dimensions) then down sample it to the original size in the second pass. If we use a multi-sampled resource render target in the first pass, it is a combination of SSAA and MSAA, isn't it?

Thanks guys for your reply, but I think that rendering to a multi-sampled render target then resolving it is a MSAA rendering technique not a SSAA rendering.

It becomes a SSAA technique once you render your objects into the multisampled target with SV_SampleIndex as a pixel shader input, forcing it to run per-sample (unlike MSAA where the it runs per-pixel).

I have the same think and I render a full-screen quad and check it with the following simple pixel shader:


// 4 samples per pixel
float4 PS(VS_OUTPUT input, uint sampleIndex : SV_SAMPLEINDEX) : SV_TARGET
{
         if (sampleIndex % 2 == 0)
              return float4(1,0f, 0.0f, 0.0f, 1.0f);

         return float4(1.0f, 1.0f, 0.0f, 1.0f);
}

We have 4 sampes per pixel so we have red color at the 2nd and the 4rd samples and yellow color at the 1st and the 3rd samples. But the result is all red.

Samples 0 and 2 will be red, samples 1 and 3 will be yellow. How do you resolve the multisampled render target to display it?

Edit: also I have no idea if semantics are case sensitive or not, but just to be sure I would use SV_SampleIndex.

I just use ResolveSubResource to resolve the multisampled render target

Thanks for helping me guys. It works.

This topic is closed to new replies.

Advertisement