Skip to content

Commit dcd2b82

Browse files
committed
amd_ags_x64: Create DXGI factory for AGS context
Signed-off-by: Joshua Ashton <[email protected]>
1 parent 89e0303 commit dcd2b82

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

dlls/amd_ags_x64/amd_ags_x64_main.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
#include "wine/asm.h"
1212

1313
#define COBJMACROS
14+
#include "initguid.h"
15+
1416
#include "d3d11.h"
1517
#include "d3d12.h"
16-
17-
#include "initguid.h"
18+
#include "dxgi1_6.h"
1819

1920
#include "dxvk_interfaces.h"
2021

@@ -134,14 +135,16 @@ struct AGSContext
134135
struct AGSDeviceInfo *devices;
135136
VkPhysicalDeviceProperties *properties;
136137
VkPhysicalDeviceMemoryProperties *memory_properties;
138+
IDXGIFactory1 *dxgi_factory;
137139
ID3D11DeviceContext *d3d11_context;
138140
AGSDX11ExtensionsSupported_600 extensions;
139141
};
140142

141-
static HMODULE hd3d11, hd3d12;
143+
static HMODULE hd3d11, hd3d12, hdxgi;
142144
static typeof(D3D12CreateDevice) *pD3D12CreateDevice;
143145
static typeof(D3D11CreateDevice) *pD3D11CreateDevice;
144146
static typeof(D3D11CreateDeviceAndSwapChain) *pD3D11CreateDeviceAndSwapChain;
147+
static typeof(CreateDXGIFactory1) *pCreateDXGIFactory1;
145148

146149
static BOOL load_d3d12_functions(void)
147150
{
@@ -168,6 +171,18 @@ static BOOL load_d3d11_functions(void)
168171
return TRUE;
169172
}
170173

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+
171186
static AGSReturnCode vk_get_physical_device_properties(unsigned int *out_count,
172187
VkPhysicalDeviceProperties **out, VkPhysicalDeviceMemoryProperties **out_memory)
173188
{
@@ -480,6 +495,18 @@ static AGSReturnCode init_ags_context(AGSContext *context)
480495

481496
memset(context, 0, sizeof(*context));
482497

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+
483510
context->version = determine_ags_version();
484511

485512
ret = vk_get_physical_device_properties(&context->device_count, &context->properties, &context->memory_properties);
@@ -653,6 +680,11 @@ AGSReturnCode WINAPI agsDeInitialize(AGSContext *context)
653680
if (!context)
654681
return AGS_SUCCESS;
655682

683+
if (context->dxgi_factory)
684+
{
685+
IDXGIFactory1_Release(context->dxgi_factory);
686+
context->dxgi_factory = NULL;
687+
}
656688
if (context->d3d11_context)
657689
{
658690
ID3D11DeviceContext_Release(context->d3d11_context);

0 commit comments

Comments
 (0)