libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.19k stars 1.86k forks source link

Add multi-sampling for DirectX #8398

Open zufari4 opened 1 year ago

zufari4 commented 1 year ago

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

flibitijibibo commented 4 months ago

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.

icculus commented 4 months ago

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

icculus commented 4 months ago

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.

slouken commented 1 month ago

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

thatcosmonaut commented 1 month ago

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