libsdl-org / SDL

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

Add multi-sampling for DirectX #8398

Open zufari4 opened 11 months ago

zufari4 commented 11 months 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 2 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 2 months ago

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

icculus commented 2 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.