开发者

Order of operations for multisampling in DirectX 10

I'm confused on the process that needs to be done for anti-aliasing in DirectX 10. I haven't done it at all before, so it may just be that I'm confused on the procedure in general.

Here's what I know so far (or think I know): you need to enable multisampling for your RasterizerState object that you use in the shader, and that the SampleDesc in the swap chain description (DXGI_SWAP_CHAIN_DESC) needs to be set to a supported value for Count (and that Quality should stay 0, since other values or hardware-specific - though I don't know what for). Between the calls to prepare for more drawing (ClearRenderTargetView and IASetInputLayout) and the call to Present, the back buffer should be downsampled (via ResolveSubresource) to an otherwise equal-sized texture. Then, (this is开发者_如何转开发 the part I can't find anything on) somehow present the downsampled texture.

Do I have something messed up along the way? Or am I just mistaken on the last step? I saw a few resources refer to doing the sampling resolution during one last draw to a full-screen quad with a multisampled shader texture (Texture2DMS<>), but can't figure out what that would entail, or why you would do it over the device call to just resolve it that way.

Any attempt I've made at this doesn't produce any increase in image quality.


EDIT: I'm using DX11, you just use D3D10_ instead of D3D11_, thanks DeadMG.

You don't need to do any downsampling.

Find out what kind of quality modes and sample count your GPU supports. You said that the quality level should be 0, that is wrong. Use this to get the supported quality modes with sample counts:

UINT GetMSAAQuality(UINT numSamples,DXGI_FORMAT format)
    {
        UINT q=-1;
        HR(m_device->CheckMultisampleQualityLevels(format,numSamples,&q));
        return q-1;
    }

    // Use it like this:
    UINT sampleCount=4; // You set this
    UINT sampleQuality=GetMSAAQuality(sampleCount,DXGI_FORMAT_CHOOSE_ONE);

    // For swap chain
    DXGI_SWAP_CHAIN_DESC d;
    d.SampleDesc.Count=sampleCount;
    d.SampleDesc.Quality=sampleQuality;

        // Now for all the textures that you create for your
        // render targets and also for your depth buffer
        D3D11_TEXTURE2D_DESC dtex;
        dtex.SampleDesc.Quality=sampleQuality;
        dtex.SampleDesc.Count=sampleCount;

        // Now for all your render target views you must set the correct dimension type
        // based on if you use multisampling or not
        D3D11_RENDER_TARGET_VIEW_DESC drtv;
        dRtSwapChain.ViewDimension=sampleQuality==0?D3D11_RTV_DIMENSION_TEXTURE2D:D3D11_RTV_DIMENSION_TEXTURE2DMS;

 // For depth stencil view
D3D11_DEPTH_STENCIL_VIEW_DESC ddsv;
ddsv.ViewDimension=sampleQuality==0?D3D11_DSV_DIMENSION_TEXTURE2D:D3D11_DSV_DIMENSION_TEXTURE2DMS;

If you want to read a multisampled texture in your shader (if you render a fullscreen quad for example) you must declare the texture Texture2DMS<>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜