From 3fb162ea3a1c3f85236e52e121684b0c732b6a14 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 19 Jul 2022 17:48:16 -0500 Subject: [PATCH] c/client: Turn off depth formats for D3D11, they are breaking Vulkan right now --- doc/changes/compositor/mr.943.md | 2 +- src/xrt/compositor/client/comp_d3d11_client.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/doc/changes/compositor/mr.943.md b/doc/changes/compositor/mr.943.md index 7438007dc..269a08270 100644 --- a/doc/changes/compositor/mr.943.md +++ b/doc/changes/compositor/mr.943.md @@ -8,4 +8,4 @@ - mr.1340 --- -Full support for D3D11 client applications on Windows. +Initial support for D3D11 client applications on Windows. diff --git a/src/xrt/compositor/client/comp_d3d11_client.cpp b/src/xrt/compositor/client/comp_d3d11_client.cpp index 77871bbb8..fe2cd44b7 100644 --- a/src/xrt/compositor/client/comp_d3d11_client.cpp +++ b/src/xrt/compositor/client/comp_d3d11_client.cpp @@ -50,6 +50,7 @@ using namespace std::chrono; using xrt::compositor::client::unique_swapchain_ref; DEBUG_GET_ONCE_LOG_OPTION(log, "D3D_COMPOSITOR_LOG", U_LOGGING_INFO) +DEBUG_GET_ONCE_BOOL_OPTION(allow_depth, "D3D_COMPOSITOR_ALLOW_DEPTH", false); /*! * Spew level logging. @@ -824,10 +825,26 @@ try { // Passthrough our formats from the native compositor to the client. uint32_t count = 0; for (uint32_t i = 0; i < xcn->base.info.format_count; i++) { + // Can we turn this format into DXGI? DXGI_FORMAT f = d3d_vk_format_to_dxgi(xcn->base.info.formats[i]); if (f == 0) { continue; } + // And back to Vulkan? + auto v = d3d_dxgi_format_to_vk(f); + if (v == 0) { + continue; + } + // Do we have a typeless version of it? + DXGI_FORMAT typeless = d3d_dxgi_format_to_typeless_dxgi(f); + if (typeless == f) { + continue; + } + // Sometimes we have to forbid depth formats to avoid errors in Vulkan. + if (!debug_get_bool_option_allow_depth() && + (f == DXGI_FORMAT_D32_FLOAT || f == DXGI_FORMAT_D16_UNORM || f == DXGI_FORMAT_D24_UNORM_S8_UINT)) { + continue; + } c->base.base.info.formats[count++] = f; }