Skip to content

Commit

Permalink
D3D11: Disable DXGI message handling junk
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Oct 30, 2020
1 parent f575bd0 commit 5b736d1
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/FNA3D_Driver_D3D11.c
Original file line number Diff line number Diff line change
Expand Up @@ -4966,23 +4966,21 @@ static void D3D11_PLATFORM_GetDefaultAdapter(
);
}

static inline void* GetDXGIHandle(SDL_Window *window)
{
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWindowWMInfo((SDL_Window*) window, &info);
return (void*) info.info.win.window; /* HWND */
}

static void D3D11_PLATFORM_CreateSwapChain(
D3D11Renderer *renderer,
FNA3D_PresentationParameters *pp
) {
IDXGIOutput *output;
DXGI_SWAP_CHAIN_DESC swapchainDesc;
DXGI_MODE_DESC swapchainBufferDesc;
SDL_SysWMinfo info;
HWND dxgiHandle;
HRESULT res;

SDL_VERSION(&info.version);
SDL_GetWindowWMInfo((SDL_Window*) pp->deviceWindowHandle, &info);
dxgiHandle = info.info.win.window;

/* Initialize swapchain buffer descriptor */
swapchainBufferDesc.Width = 0;
swapchainBufferDesc.Height = 0;
Expand Down Expand Up @@ -5010,7 +5008,7 @@ static void D3D11_PLATFORM_CreateSwapChain(
swapchainDesc.SampleDesc.Quality = 0;
swapchainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapchainDesc.BufferCount = 3;
swapchainDesc.OutputWindow = (HWND) GetDXGIHandle((SDL_Window*) pp->deviceWindowHandle);
swapchainDesc.OutputWindow = dxgiHandle;
swapchainDesc.Windowed = 1;
swapchainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapchainDesc.Flags = 0;
Expand All @@ -5023,6 +5021,20 @@ static void D3D11_PLATFORM_CreateSwapChain(
&renderer->swapchain
);
ERROR_CHECK("Could not create swapchain")

/* Disable DXGI window crap */
res = IDXGIFactory_MakeWindowAssociation(
(IDXGIFactory*) renderer->factory,
dxgiHandle,
DXGI_MWA_NO_WINDOW_CHANGES
);
if (FAILED(res))
{
FNA3D_LogWarn(
"MakeWindowAssociation failed! Error Code: %08X",
res
);
}
}

#endif
Expand Down

0 comments on commit 5b736d1

Please sign in to comment.