mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-09 16:18:20 +00:00
[host] dxgi: fix failure to call FreeLibrary for d3d12
This commit is contained in:
parent
75e10688d4
commit
503efdd0d8
@ -52,6 +52,7 @@ struct SharedCache
|
||||
|
||||
struct D3D12Backend
|
||||
{
|
||||
HMODULE d3d12;
|
||||
unsigned width, height, pitch;
|
||||
DXGI_FORMAT format;
|
||||
|
||||
@ -90,17 +91,28 @@ static void d3d12_free(void);
|
||||
static bool d3d12_create(unsigned textures)
|
||||
{
|
||||
DEBUG_ASSERT(!this);
|
||||
|
||||
comRef_scopePush();
|
||||
bool result = false;
|
||||
HRESULT status;
|
||||
|
||||
HMODULE d3d12 = LoadLibrary("d3d12.dll");
|
||||
if (!d3d12)
|
||||
return false;
|
||||
this = calloc(1,
|
||||
sizeof(struct D3D12Backend) +
|
||||
sizeof(*this->texture) * textures);
|
||||
|
||||
if (!this)
|
||||
{
|
||||
DEBUG_ERROR("failed to allocate D3D12Backend struct");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
this->d3d12 = LoadLibrary("d3d12.dll");
|
||||
if (!this->d3d12)
|
||||
goto exit;
|
||||
|
||||
if (dxgi_debug())
|
||||
{
|
||||
D3D12GetDebugInterface_t D3D12GetDebugInterface = (D3D12GetDebugInterface_t)
|
||||
GetProcAddress(d3d12, "D3D12GetDebugInterface");
|
||||
GetProcAddress(this->d3d12, "D3D12GetDebugInterface");
|
||||
ID3D12Debug1 * debug;
|
||||
if (FAILED(status = D3D12GetDebugInterface(&IID_ID3D12Debug1, (void **)&debug)))
|
||||
DEBUG_WINERROR("D3D12GetDebugInterface", status);
|
||||
@ -114,28 +126,15 @@ static bool d3d12_create(unsigned textures)
|
||||
}
|
||||
|
||||
D3D12CreateDevice_t D3D12CreateDevice = (D3D12CreateDevice_t)
|
||||
GetProcAddress(d3d12, "D3D12CreateDevice");
|
||||
GetProcAddress(this->d3d12, "D3D12CreateDevice");
|
||||
|
||||
if (!D3D12CreateDevice)
|
||||
return false;
|
||||
|
||||
this = calloc(1,
|
||||
sizeof(struct D3D12Backend) +
|
||||
sizeof(*this->texture) * textures);
|
||||
|
||||
if (!this)
|
||||
{
|
||||
DEBUG_ERROR("failed to allocate D3D12Backend struct");
|
||||
return false;
|
||||
}
|
||||
goto exit;
|
||||
|
||||
this->textures = textures;
|
||||
this->copySleep = option_get_float("dxgi", "d3d12CopySleep");
|
||||
DEBUG_INFO("Sleep before copy : %f ms", this->copySleep);
|
||||
|
||||
bool result = false;
|
||||
comRef_scopePush();
|
||||
|
||||
comRef_defineLocal(ID3D12Device, device);
|
||||
status = D3D12CreateDevice((IUnknown *)dxgi_getAdapter(),
|
||||
D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)device);
|
||||
@ -336,6 +335,9 @@ static void d3d12_free(void)
|
||||
if (this->event)
|
||||
CloseHandle(this->event);
|
||||
|
||||
if (this->d3d12)
|
||||
FreeLibrary(this->d3d12);
|
||||
|
||||
free(this);
|
||||
this = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user