A proxy implementation of d3d9.dll for Direct3D 9 applications.
The module wraps the IDirect3D9 and IDirect3DDevice9 interfaces, intercepting calls between the application and the real D3D9 backend.
Application behavior remains unchanged — the proxy acts as a transparent intermediate layer.
- D3D9 render research
- Graphics call logging
- Post-processing integration
- Depth buffer access
- Graphics pipeline analysis
Application → d3d9.dll (proxy) → Real D3D9 backend (System / DXVK / Gallium Nine) → GPU
Two proxy classes are implemented:
D3D9Proxy— wrapsIDirect3D9D3D9DeviceProxy— wraps the fullIDirect3DDevice9interface
This allows one build to work on:
- Native Windows
- Wine + DXVK
- Wine + Gallium Nine
| Feature | Windows | DXVK | Gallium Nine |
|---|---|---|---|
| Transparent passthrough | ✅ | ✅ | ✅ |
| Render logging | ✅ | ✅ | ✅ |
| Depth buffer capture | ✅ | ❌ | ✅ |
| Color render target read | ✅ | ✅ | ✅ |
| Depth-based post effects | ✅ | ❌ | ✅ |
DXVK blocks depth StretchRect by design due to Vulkan translation constraints.
Place the proxy d3d9.dll next to the game executable.
Wine + DXVK:
Rename DXVK: d3d9.dll → d3d9_dxvk.dll
Place proxy: d3d9.dll (this project)
Wine + Gallium Nine:
Place proxy: d3d9.dll (this project)
Wine will use Gallium Nine automatically as the backend.
Native Windows:
Place proxy: d3d9.dll (this project)
The proxy loads C:\Windows\System32\d3d9.dll automatically.
Post-processing hooks into the Present() method:
HRESULT STDMETHODCALLTYPE Present(...) override {
// When depth_captured == true, depth_tex holds the current frame's depth buffer.
// Available on: native Windows, Gallium Nine.
// Not available on: DXVK.
return real->Present(a, b, c, d);
}Depth capture happens automatically in SetRenderTarget when the offscreen → backbuffer transition is detected. At that moment depth contains world geometry and UI has not yet been drawn.
mkdir build && cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-mingw32.cmake
makei686-w64-mingw32-g++ -std=c++17 -O2 -m32 -shared \
-o d3d9.dll src/d3d9_proxy.cpp \
-ld3d9 -ldxguid \
-static-libgcc -static-libstdc++ \
-Wl,--kill-atmkdir build && cd build
cmake .. -G "Visual Studio 17 2022" -A Win32
cmake --build . --config Release- Open Visual Studio 2019 or 2022
- Create a new DLL project
- Add
src/d3d9_proxy.cpp - Set platform to x86 (Win32)
- Project Properties → Linker → Input → Additional Dependencies:
d3d9.lib
dxguid.lib
- Build in Release x86
i686-w64-mingw32-g++ -std=c++17 -O2 -m32 -shared \
-o d3d9.dll src/d3d9_proxy.cpp \
-ld3d9 -ldxguid \
-static-libgcc -static-libstdc++ \
-Wl,--kill-atOriginally prototyped using AI-assisted development tools.