Skip to content

Commit

Permalink
Fix D3D11 build
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Mar 20, 2024
1 parent 6f86b6f commit 436db65
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions src/FNA3D_Driver_D3D11.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,18 @@ static void D3D11_DestroyDevice(FNA3D_Device *device)
swapchainData = renderer->swapchainDatas[i];
ID3D11RenderTargetView_Release(swapchainData->swapchainRTView);
IDXGISwapChain_Release(swapchainData->swapchain);
SDL_ClearProperty(SDL_GetWindowProperties(swapchainData->windowHandle), WINDOW_SWAPCHAIN_DATA);
#if SDL_MAJOR_VERSION >= 3
SDL_ClearProperty(
SDL_GetWindowProperties(swapchainData->windowHandle),
WINDOW_SWAPCHAIN_DATA
);
#else
SDL_SetWindowData(
(SDL_Window*) swapchainData->windowHandle,
WINDOW_SWAPCHAIN_DATA,
NULL
);
#endif
SDL_free(renderer->swapchainDatas[i]);
}
SDL_free(renderer->swapchainDatas);
Expand Down Expand Up @@ -1533,11 +1544,18 @@ static void D3D11_SwapBuffers(
}
}

#if SDL_MAJOR_VERSION >= 3
swapchainData = (D3D11SwapchainData*) SDL_GetProperty(
SDL_GetWindowProperties(overrideWindowHandle),
WINDOW_SWAPCHAIN_DATA,
NULL
);
#else
swapchainData = (D3D11SwapchainData*) SDL_GetWindowData(
(SDL_Window*) overrideWindowHandle,
WINDOW_SWAPCHAIN_DATA
);
#endif
if (swapchainData == NULL)
{
D3D11_INTERNAL_CreateSwapChain(
Expand All @@ -1546,11 +1564,18 @@ static void D3D11_SwapBuffers(
(SDL_Window*) overrideWindowHandle,
NULL
);
#if SDL_MAJOR_VERSION >= 3
swapchainData = (D3D11SwapchainData*) SDL_GetProperty(
SDL_GetWindowProperties(overrideWindowHandle),
WINDOW_SWAPCHAIN_DATA,
NULL
);
#else
swapchainData = (D3D11SwapchainData*) SDL_GetWindowData(
(SDL_Window*) overrideWindowHandle,
WINDOW_SWAPCHAIN_DATA
);
#endif
D3D11_INTERNAL_UpdateSwapchainRT(
renderer,
swapchainData,
Expand Down Expand Up @@ -2548,7 +2573,18 @@ static void D3D11_INTERNAL_CreateSwapChain(
#ifdef FNA3D_DXVK_NATIVE
dxgiHandle = (HWND) windowHandle;
#else
dxgiHandle = (HWND) SDL_GetProperty(SDL_GetWindowProperties(windowHandle), SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
#if SDL_MAJOR_VERSION >= 3
dxgiHandle = (HWND) SDL_GetProperty(
SDL_GetWindowProperties(windowHandle),
SDL_PROP_WINDOW_WIN32_HWND_POINTER,
NULL
);
#else
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
SDL_GetWindowWMInfo((SDL_Window*) windowHandle, &info);
dxgiHandle = info.info.win.window;
#endif
#endif /* FNA3D_DXVK_NATIVE */

/* Initialize swapchain buffer descriptor */
Expand Down Expand Up @@ -2676,7 +2712,11 @@ static void D3D11_INTERNAL_CreateSwapChain(
swapchainData->windowHandle = windowHandle;
swapchainData->swapchainRTView = NULL;
swapchainData->format = backBufferFormat;
#if SDL_MAJOR_VERSION >= 3
SDL_SetProperty(SDL_GetWindowProperties(windowHandle), WINDOW_SWAPCHAIN_DATA, swapchainData);
#else
SDL_SetWindowData((SDL_Window*) windowHandle, WINDOW_SWAPCHAIN_DATA, swapchainData);
#endif
if (growSwapchains)
{
if (renderer->swapchainDataCount >= renderer->swapchainDataCapacity)
Expand Down Expand Up @@ -2771,11 +2811,18 @@ static void D3D11_INTERNAL_CreateBackbuffer(
/* Create or update the swapchain */
if (parameters->deviceWindowHandle != NULL)
{
#if SDL_MAJOR_VERSION >= 3
swapchainData = (D3D11SwapchainData*) SDL_GetProperty(
SDL_GetWindowProperties(parameters->deviceWindowHandle),
WINDOW_SWAPCHAIN_DATA,
NULL
);
#else
swapchainData = (D3D11SwapchainData*) SDL_GetWindowData(
(SDL_Window*) parameters->deviceWindowHandle,
WINDOW_SWAPCHAIN_DATA
);
#endif
if (swapchainData == NULL)
{
D3D11_INTERNAL_CreateSwapChain(
Expand All @@ -2784,11 +2831,18 @@ static void D3D11_INTERNAL_CreateBackbuffer(
parameters->deviceWindowHandle,
NULL
);
#if SDL_MAJOR_VERSION >= 3
swapchainData = (D3D11SwapchainData*) SDL_GetProperty(
SDL_GetWindowProperties(parameters->deviceWindowHandle),
WINDOW_SWAPCHAIN_DATA,
NULL
);
#else
swapchainData = (D3D11SwapchainData*) SDL_GetWindowData(
(SDL_Window*) parameters->deviceWindowHandle,
WINDOW_SWAPCHAIN_DATA
);
#endif
}
else
{
Expand Down Expand Up @@ -5214,6 +5268,9 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)
}

/* No window flags required */
#if SDL_MAJOR_VERSION < 3
SDL_SetHint(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, "1");
#endif
#ifdef FNA3D_DXVK_NATIVE
/* ... unless this is DXVK */
*flags = SDL_WINDOW_VULKAN;
Expand Down

0 comments on commit 436db65

Please sign in to comment.