Skip to content

Commit

Permalink
Render R4 requires d3d11.dll and does not work without its presence.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Feb 15, 2018
1 parent dc9517f commit 16987f7
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions src/Layers/xrRenderPC_R4/r2_test_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, message, wParam, lParam);
}

typedef HRESULT(__stdcall* FuncPtrD3D11CreateDeviceAndSwapChain)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType,
HMODULE Software, UINT Flags, CONST D3D_FEATURE_LEVEL* pFeatureLevels, UINT FeatureLevels, UINT SDKVersion,
CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc, IDXGISwapChain** ppSwapChain, ID3D11Device** ppDevice,
D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext);

bool TestDX11Present()
{
const auto hD3D11 = XRay::LoadModule("d3d11.dll");

if (!hD3D11->exist())
{
Log("* DX11: failed to load d3d11.dll");
return false;
}

auto pD3D11CreateDeviceAndSwapChain =
(FuncPtrD3D11CreateDeviceAndSwapChain)hD3D11->getProcAddress("D3D11CreateDeviceAndSwapChain");

if (!pD3D11CreateDeviceAndSwapChain)
{
Log("* DX11: failed to get address of D3D11CreateDeviceAndSwapChain");
return false;
}

// Register class
WNDCLASSEX wcex;
ZeroMemory(&wcex, sizeof(wcex));
Expand All @@ -47,16 +25,13 @@ bool TestDX11Present()
HWND hWnd = CreateWindow("TestDX11WindowClass", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);

DXGI_SWAP_CHAIN_DESC sd;

if (!hWnd)
{
Msg("* DX11: failed to create window");
return false;
}

HRESULT hr = E_FAIL;

DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory(&sd, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = 800;
Expand All @@ -77,20 +52,18 @@ bool TestDX11Present()
ID3D11DeviceContext* pContext = NULL;
IDXGISwapChain* pSwapChain = NULL;

hr = pD3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, pFeatureLevels, 1, D3D11_SDK_VERSION,
HRESULT hr = D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, pFeatureLevels, 1, D3D11_SDK_VERSION,
&sd, &pSwapChain, &pd3dDevice, &FeatureLevel, &pContext);

if (FAILED(hr))
Msg("* D3D11: device creation failed with hr=0x%08x", hr);

if (pContext)
pContext->Release();
if (pSwapChain)
pSwapChain->Release();
if (pd3dDevice)
pd3dDevice->Release();
_RELEASE(pSwapChain);
_RELEASE(pd3dDevice);
_RELEASE(pContext);

DestroyWindow(hWnd);
UnregisterClass("TestDX11WindowClass", GetModuleHandle(NULL));

return SUCCEEDED(hr);
}
Expand Down

0 comments on commit 16987f7

Please sign in to comment.