protonscr

Optionally support creating a new VkInstance for each D3D Device

dxvkopen enhancement
doitsujin/dxvk#4909 · opened 2025-05-12 by LizzyFleckenstein03 · updated 2025-06-02 · 1 comments · github
LLizzyFleckenstein03 2025-05-12 github

Renderdoc supports multiple VkInstances per application, but not multiple VkDevices per VkInstance.

This causes an issue where games that create multiple D3D Devices cannot be debugged using renderdoc in DXVK, which can be circumvented by creating a new VkInstance for each device.

Perhaps this could be toggled by a DXVK_REUSE_VKINSTANCE=0 environment variable.

For example, the following modification solves the issue for me in d3d11, but it is obviously not the correct fix.

diff --git a/src/d3d11/d3d11_main.cpp b/src/d3d11/d3d11_main.cpp
index 8ae32c00..f734169c 100644
--- a/src/d3d11/d3d11_main.cpp
+++ b/src/d3d11/d3d11_main.cpp
@@ -30,10 +30,6 @@ extern "C" {
     Com<IDXGIDXVKAdapter> dxgiVkAdapter;
     
     // Try to find the corresponding Vulkan device for the DXGI adapter
-    if (SUCCEEDED(pAdapter->QueryInterface(__uuidof(IDXGIDXVKAdapter), reinterpret_cast<void**>(&dxgiVkAdapter)))) {
-      dxvkAdapter  = dxgiVkAdapter->GetDXVKAdapter();
-      dxvkInstance = dxgiVkAdapter->GetDXVKInstance();
-    } else {
       Logger::warn("D3D11InternalCreateDevice: Adapter is not a DXVK adapter");
       DXGI_ADAPTER_DESC desc;
       pAdapter->GetDesc(&desc);
@@ -49,7 +45,6 @@ extern "C" {
 
       if (dxvkAdapter == nullptr)
         return E_FAIL;
-    }
     
     // Feature levels to probe if the
     // application does not specify any.
Ddoitsujin maintainer 2025-06-02 github

I've had a bit of a think and it's basically impossible to fix this properly. I'm aware of the issue and whenever I run into it I usually hack in a static DxvkDevice, which is also not a correct fix, but the code base is full of assumptions that Vulkan objects accessible via DXGI and D3D11 come from the same underlying instance.

This is fundamentally unfixable at this point unless we somehow manage to rip out Vulkan usage out of DXGI entirely.

Launch options