11
11
#include "wine/asm.h"
12
12
13
13
#define COBJMACROS
14
+ #include "initguid.h"
15
+
14
16
#include "d3d11.h"
15
17
#include "d3d12.h"
16
-
17
- #include "initguid.h"
18
+ #include "dxgi1_6.h"
18
19
19
20
#include "dxvk_interfaces.h"
20
21
@@ -134,14 +135,16 @@ struct AGSContext
134
135
struct AGSDeviceInfo * devices ;
135
136
VkPhysicalDeviceProperties * properties ;
136
137
VkPhysicalDeviceMemoryProperties * memory_properties ;
138
+ IDXGIFactory1 * dxgi_factory ;
137
139
ID3D11DeviceContext * d3d11_context ;
138
140
AGSDX11ExtensionsSupported_600 extensions ;
139
141
};
140
142
141
- static HMODULE hd3d11 , hd3d12 ;
143
+ static HMODULE hd3d11 , hd3d12 , hdxgi ;
142
144
static typeof (D3D12CreateDevice ) * pD3D12CreateDevice ;
143
145
static typeof (D3D11CreateDevice ) * pD3D11CreateDevice ;
144
146
static typeof (D3D11CreateDeviceAndSwapChain ) * pD3D11CreateDeviceAndSwapChain ;
147
+ static typeof (CreateDXGIFactory1 ) * pCreateDXGIFactory1 ;
145
148
146
149
static BOOL load_d3d12_functions (void )
147
150
{
@@ -168,6 +171,18 @@ static BOOL load_d3d11_functions(void)
168
171
return TRUE;
169
172
}
170
173
174
+ static BOOL load_dxgi_functions (void )
175
+ {
176
+ if (hdxgi )
177
+ return TRUE;
178
+
179
+ if (!(hdxgi = LoadLibraryA ("dxgi.dll" )))
180
+ return FALSE;
181
+
182
+ pCreateDXGIFactory1 = (void * )GetProcAddress (hdxgi , "CreateDXGIFactory1" );
183
+ return TRUE;
184
+ }
185
+
171
186
static AGSReturnCode vk_get_physical_device_properties (unsigned int * out_count ,
172
187
VkPhysicalDeviceProperties * * out , VkPhysicalDeviceMemoryProperties * * out_memory )
173
188
{
@@ -480,6 +495,18 @@ static AGSReturnCode init_ags_context(AGSContext *context)
480
495
481
496
memset (context , 0 , sizeof (* context ));
482
497
498
+ if (!load_dxgi_functions ())
499
+ {
500
+ ERR ("Could not load dxgi.dll.\n" );
501
+ return AGS_MISSING_D3D_DLL ;
502
+ }
503
+
504
+ if (FAILED (pCreateDXGIFactory1 (& IID_IDXGIFactory1 , (void * * )& context -> dxgi_factory )))
505
+ {
506
+ ERR ("Failed to create DXGIFactory1.\n" );
507
+ return AGS_DX_FAILURE ;
508
+ }
509
+
483
510
context -> version = determine_ags_version ();
484
511
485
512
ret = vk_get_physical_device_properties (& context -> device_count , & context -> properties , & context -> memory_properties );
@@ -653,6 +680,11 @@ AGSReturnCode WINAPI agsDeInitialize(AGSContext *context)
653
680
if (!context )
654
681
return AGS_SUCCESS ;
655
682
683
+ if (context -> dxgi_factory )
684
+ {
685
+ IDXGIFactory1_Release (context -> dxgi_factory );
686
+ context -> dxgi_factory = NULL ;
687
+ }
656
688
if (context -> d3d11_context )
657
689
{
658
690
ID3D11DeviceContext_Release (context -> d3d11_context );
0 commit comments