protonscr

D3D12GetInterface is missing from MinGW-built d3d12.dll

vkd3dclosed
HansKristian-Work/vkd3d-proton#2140 · opened 2024-09-29 by zopsicle · updated 2024-09-30 · 0 comments · github
Zzopsicle 2024-09-29 github

Using vkd3d-proton 2.13 on Wine 9.0. Not having issues with any specific title but debugging an issue I ran across while testing my own code against vkd3d-proton.

Example program:

#include <windows.h>
#include <iostream>

int main()
{
    std::cout << GetProcAddress(LoadLibraryA("d3d12.dll"), "D3D12GetInterface") << '\n';
    return 0;
}
$ clang-cl main.cpp
$ wine64 main.exe

Expected behavior:

Program outputs non-zero address of D3D12GetInterface from d3d12.dll.

Actual behavior:

Program outputs 00000000.


AFAICT d3d12.dll is supposed to export D3D12GetInterface, but d3d12.dll from vkd3d-proton does not, because it is missing from d3d12.def.

It is marked DLLEXPORT*:

https://github.com/HansKristian-Work/vkd3d-proton/blob/ea251471db8524216ac23f38afe9d141fff38a30/libs/d3d12/main.c#L195

but is missing from d3d12.def which is used when building with MinGW and as a result this symbol is not exported from d3d12.dll.

The problem I ran into is: this seems to cause GetProcAddress(LoadLibraryA("d3d12.dll"), "D3D12GetInterface") to evaluate to null with vkd3d-proton. On Windows with native DirectX 12 (not vkd3d-proton) this expression evaluates to non-null.

Adding D3D12GetInterface to d3d12.def indeed makes the expression evaluate to non-null and I can call the function: https://github.com/zopsicle/vkd3d-proton/blob/d5cecf87328569162427da7e0c4c64dfa38b872f/libs/d3d12/d3d12.def#L6

I’m just wondering if this is intentional or an oversight. AFAICT this function is dead because nothing in the DLL calls it and the DLL doesn’t export it. I don’t think a lot of games use this API because its usage was niche before the recent ID3D12SDKConfiguration1 API (which vkd3d-proton doesn’t implement, but that’s fine and off-topic) or maybe I’m misunderstanding this API and misusing it.

* Which expands to nothing because the def files are supposed to be used instead (730933dc01c2319570d482240e94875d24b56a07).
But is not missing from d3d12core.def.

Proton versions

DLLs