31
31
#include "FNA3D_Driver_D3D11.h"
32
32
#include "FNA3D_Driver_D3D11_shaders.h"
33
33
34
+ #ifdef USE_SDL3
35
+ #include <SDL3/SDL.h>
36
+ #else
34
37
#include <SDL.h>
35
38
#ifndef FNA3D_DXVK_NATIVE
36
39
#include <SDL_syswm.h>
37
40
#endif /* !FNA3D_DXVK_NATIVE */
41
+ #define SDL_Mutex SDL_mutex
42
+ #endif
38
43
39
44
/* D3D11 Libraries */
40
45
@@ -213,7 +218,7 @@ typedef struct D3D11Renderer /* Cast FNA3D_Renderer* to this! */
213
218
IDXGIAdapter1 * adapter ;
214
219
ID3DUserDefinedAnnotation * annotation ;
215
220
BOOL supportsTearing ;
216
- SDL_mutex * ctxLock ;
221
+ SDL_Mutex * ctxLock ;
217
222
SDL_iconv_t iconv ;
218
223
219
224
/* Window surfaces */
@@ -1067,11 +1072,7 @@ static void D3D11_DestroyDevice(FNA3D_Device *device)
1067
1072
swapchainData = renderer -> swapchainDatas [i ];
1068
1073
ID3D11RenderTargetView_Release (swapchainData -> swapchainRTView );
1069
1074
IDXGISwapChain_Release (swapchainData -> swapchain );
1070
- SDL_SetWindowData (
1071
- (SDL_Window * ) swapchainData -> windowHandle ,
1072
- WINDOW_SWAPCHAIN_DATA ,
1073
- NULL
1074
- );
1075
+ SDL_ClearProperty (SDL_GetWindowProperties (swapchainData -> windowHandle ), WINDOW_SWAPCHAIN_DATA );
1075
1076
SDL_free (renderer -> swapchainDatas [i ]);
1076
1077
}
1077
1078
SDL_free (renderer -> swapchainDatas );
@@ -1532,9 +1533,10 @@ static void D3D11_SwapBuffers(
1532
1533
}
1533
1534
}
1534
1535
1535
- swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
1536
- (SDL_Window * ) overrideWindowHandle ,
1537
- WINDOW_SWAPCHAIN_DATA
1536
+ swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
1537
+ SDL_GetWindowProperties (overrideWindowHandle ),
1538
+ WINDOW_SWAPCHAIN_DATA ,
1539
+ NULL
1538
1540
);
1539
1541
if (swapchainData == NULL )
1540
1542
{
@@ -1544,9 +1546,10 @@ static void D3D11_SwapBuffers(
1544
1546
(SDL_Window * ) overrideWindowHandle ,
1545
1547
NULL
1546
1548
);
1547
- swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
1548
- (SDL_Window * ) overrideWindowHandle ,
1549
- WINDOW_SWAPCHAIN_DATA
1549
+ swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
1550
+ SDL_GetWindowProperties (overrideWindowHandle ),
1551
+ WINDOW_SWAPCHAIN_DATA ,
1552
+ NULL
1550
1553
);
1551
1554
D3D11_INTERNAL_UpdateSwapchainRT (
1552
1555
renderer ,
@@ -2545,10 +2548,7 @@ static void D3D11_INTERNAL_CreateSwapChain(
2545
2548
#ifdef FNA3D_DXVK_NATIVE
2546
2549
dxgiHandle = (HWND ) windowHandle ;
2547
2550
#else
2548
- SDL_SysWMinfo info ;
2549
- SDL_VERSION (& info .version );
2550
- SDL_GetWindowWMInfo ((SDL_Window * ) windowHandle , & info );
2551
- dxgiHandle = info .info .win .window ;
2551
+ dxgiHandle = (HWND ) SDL_GetProperty (SDL_GetWindowProperties (windowHandle ), SDL_PROP_WINDOW_WIN32_HWND_POINTER , NULL );
2552
2552
#endif /* FNA3D_DXVK_NATIVE */
2553
2553
2554
2554
/* Initialize swapchain buffer descriptor */
@@ -2676,7 +2676,7 @@ static void D3D11_INTERNAL_CreateSwapChain(
2676
2676
swapchainData -> windowHandle = windowHandle ;
2677
2677
swapchainData -> swapchainRTView = NULL ;
2678
2678
swapchainData -> format = backBufferFormat ;
2679
- SDL_SetWindowData (( SDL_Window * ) windowHandle , WINDOW_SWAPCHAIN_DATA , swapchainData );
2679
+ SDL_SetProperty ( SDL_GetWindowProperties ( windowHandle ) , WINDOW_SWAPCHAIN_DATA , swapchainData );
2680
2680
if (growSwapchains )
2681
2681
{
2682
2682
if (renderer -> swapchainDataCount >= renderer -> swapchainDataCapacity )
@@ -2771,9 +2771,10 @@ static void D3D11_INTERNAL_CreateBackbuffer(
2771
2771
/* Create or update the swapchain */
2772
2772
if (parameters -> deviceWindowHandle != NULL )
2773
2773
{
2774
- swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
2775
- (SDL_Window * ) parameters -> deviceWindowHandle ,
2776
- WINDOW_SWAPCHAIN_DATA
2774
+ swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
2775
+ SDL_GetWindowProperties (parameters -> deviceWindowHandle ),
2776
+ WINDOW_SWAPCHAIN_DATA ,
2777
+ NULL
2777
2778
);
2778
2779
if (swapchainData == NULL )
2779
2780
{
@@ -2783,9 +2784,10 @@ static void D3D11_INTERNAL_CreateBackbuffer(
2783
2784
parameters -> deviceWindowHandle ,
2784
2785
NULL
2785
2786
);
2786
- swapchainData = (D3D11SwapchainData * ) SDL_GetWindowData (
2787
- (SDL_Window * ) parameters -> deviceWindowHandle ,
2788
- WINDOW_SWAPCHAIN_DATA
2787
+ swapchainData = (D3D11SwapchainData * ) SDL_GetProperty (
2788
+ SDL_GetWindowProperties (parameters -> deviceWindowHandle ),
2789
+ WINDOW_SWAPCHAIN_DATA ,
2790
+ NULL
2789
2791
);
2790
2792
}
2791
2793
else
@@ -2796,7 +2798,7 @@ static void D3D11_INTERNAL_CreateBackbuffer(
2796
2798
/* Surface format changed, recreate entirely */
2797
2799
IDXGISwapChain_Release (swapchainData -> swapchain );
2798
2800
2799
- /*
2801
+ /*
2800
2802
* DXGI will crash in some cases if we don't flush deferred swapchain destruction:
2801
2803
*
2802
2804
* DXGI ERROR: IDXGIFactory::CreateSwapChain: Only one flip model swap chain can be
@@ -5212,7 +5214,6 @@ static uint8_t D3D11_PrepareWindowAttributes(uint32_t *flags)
5212
5214
}
5213
5215
5214
5216
/* No window flags required */
5215
- SDL_SetHint (SDL_HINT_VIDEO_EXTERNAL_CONTEXT , "1" );
5216
5217
#ifdef FNA3D_DXVK_NATIVE
5217
5218
/* ... unless this is DXVK */
5218
5219
* flags = SDL_WINDOW_VULKAN ;
@@ -5544,7 +5545,7 @@ static FNA3D_Device* D3D11_CreateDevice(
5544
5545
{
5545
5546
res = D3D11CreateDeviceFunc (
5546
5547
(driverType == D3D_DRIVER_TYPE_WARP ) ? NULL : (IDXGIAdapter * ) renderer -> adapter ,
5547
- driverType ,
5548
+ driverType ,
5548
5549
NULL ,
5549
5550
flags ,
5550
5551
& levels [i ],
0 commit comments