Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed (hopefully) d3d9 device creation on wine. #423

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions OVP/D3D9Client/D3D9Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ IDirect3D9* g_pD3DObject = 0; // Made valid when VideoTab is created

D3D9Catalog<LPDIRECT3DTEXTURE9> *TileCatalog;

typedef IDirect3D9* (__stdcall* __Direct3DCreate9On12)(UINT SDKVersion, D3D9ON12_ARGS* pOverrideList, UINT NumOverrideEntries);

set<D3D9Mesh*> MeshCatalog;
set<SurfNative*> SurfaceCatalog;
unordered_map<string, SURFHANDLE> SharedTextures;
Expand Down Expand Up @@ -320,14 +322,22 @@ bool D3D9Client::clbkInitialise()
D3D9ON12_ARGS args = {};
args.Enable9On12 = Config->Enable9On12 != 0;

// NOTE: Link error 'unresolved external symbol' means that d3d9.lib is outdated, use the latest one.
g_pD3DObject = Direct3DCreate9On12(D3D_SDK_VERSION, &args, 1);
HMODULE hDXMod = GetModuleHandle("D3D9.dll");
__Direct3DCreate9On12 pDirect3DCreate9On12 = nullptr;

if (hDXMod) pDirect3DCreate9On12 = (__Direct3DCreate9On12)GetProcAddress(hDXMod, "Direct3DCreate9On12");

if (g_pD3DObject) {
oapiWriteLog("[D3D9] DirectX9 Created...");
if (OapiExtension::RunsUnderWINE() || pDirect3DCreate9On12 == nullptr) {
g_pD3DObject = Direct3DCreate9(D3D_SDK_VERSION);
oapiWriteLog("[D3D9] Native Interface");
}
else {
g_pD3DObject = pDirect3DCreate9On12(D3D_SDK_VERSION, &args, 1);
if (Config->Enable9On12) oapiWriteLog("[D3D9] DX9 emulation via DX12");
else oapiWriteLog("[D3D9] Native Interface");
}

if (g_pD3DObject) oapiWriteLog("[D3D9] DirectX9 Created...");
else {
oapiWriteLog("[D3D9][ERROR] Failed to create DirectX9");
FailedDeviceError();
Expand Down
Loading