SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Add multi-sampling for DirectX

Open zufari4 opened this issue 2 years ago • 5 comments

Please add multi-sampling for DirectX (MSAA).

For OpenGL it is possible to enable anti-aliasing:

SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 6);

But for DirectX this feature is not implemented:

static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
{
    ***
    /* Create a swap chain using the same adapter as the existing Direct3D device. */
    DXGI_SWAP_CHAIN_DESC1 swapChainDesc;
    SDL_zero(swapChainDesc);
    swapChainDesc.Width = w;
    swapChainDesc.Height = h;
    swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */
    swapChainDesc.Stereo = FALSE;
    swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */
    swapChainDesc.SampleDesc.Quality = 0;
    swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

We need the ability to change the parameter swapChainDesc.SampleDesc.Count maybe through SDL_SetHint

zufari4 avatar Oct 15 '23 14:10 zufari4

Running through SDL_Render issues tagged for 3.0 ABI, sorry if you get multiple e-mails for this...

We've implemented support for this in our GPU API proposal at #9312.

flibitijibibo avatar Jul 05 '24 21:07 flibitijibibo

We might add a property to the renderer to allow this.

icculus avatar Jul 08 '24 17:07 icculus

Okay, this is getting bumped from the 3.0 ABI milestone, because we're getting down to the wire, and we can safely add this to the API later as a new renderer creation property, that simply defaults to no multisampling, if we decide to actually do this.

We'll revisit this in a bit, one way or another.

icculus avatar Jul 29 '24 17:07 icculus

@thatcosmonaut, is implementing MSAA simply a matter of setting SampleDesc.Count to a specific value, or is there more to it than that?

slouken avatar Oct 06 '24 19:10 slouken

It's more than that, you also have to implement resolves.

thatcosmonaut avatar Oct 07 '24 17:10 thatcosmonaut