Module: Mesa
Branch: main
Commit: ff9868c569871ff96f3d1b6b165eb85dcefd4fa3
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ff9868c569871ff96f3d1b6b165eb85dcefd4fa3

Author: Jesse Natalie <jenat...@microsoft.com>
Date:   Mon Dec 18 10:05:05 2023 -0800

d3d12: Add a debug flag to opt out of singleton behavior

For testing, it can be useful to observe behaviors on the singleton
device by just having the test also just use D3D12CreateDevice

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26744>

---

 src/gallium/drivers/d3d12/d3d12_debug.h    | 1 +
 src/gallium/drivers/d3d12/d3d12_screen.cpp | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/src/gallium/drivers/d3d12/d3d12_debug.h 
b/src/gallium/drivers/d3d12/d3d12_debug.h
index f6601bb33d7..ce2c1936f73 100644
--- a/src/gallium/drivers/d3d12/d3d12_debug.h
+++ b/src/gallium/drivers/d3d12/d3d12_debug.h
@@ -38,6 +38,7 @@ extern "C" {
 #define D3D12_DEBUG_RESOURCE      (1 << 5)
 #define D3D12_DEBUG_DEBUG_LAYER   (1 << 6)
 #define D3D12_DEBUG_GPU_VALIDATOR (1 << 7)
+#define D3D12_DEBUG_SINGLETON     (1 << 8)
 
 extern uint32_t d3d12_debug;
 
diff --git a/src/gallium/drivers/d3d12/d3d12_screen.cpp 
b/src/gallium/drivers/d3d12/d3d12_screen.cpp
index 89f6b2cb8cf..bb3e3a2e3cb 100644
--- a/src/gallium/drivers/d3d12/d3d12_screen.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_screen.cpp
@@ -68,6 +68,7 @@ d3d12_debug_options[] = {
    { "res",          D3D12_DEBUG_RESOURCE,      "Debug resources" },
    { "debuglayer",   D3D12_DEBUG_DEBUG_LAYER,   "Enable debug layer" },
    { "gpuvalidator", D3D12_DEBUG_GPU_VALIDATOR, "Enable GPU validator" },
+   { "singleton",    D3D12_DEBUG_SINGLETON,     "Disallow use of device 
factory" },
    DEBUG_NAMED_VALUE_END
 };
 
@@ -1393,6 +1394,9 @@ try_find_d3d12core_next_to_self(char *path, size_t 
path_arr_size)
 static ID3D12DeviceFactory *
 try_create_device_factory(util_dl_library *d3d12_mod)
 {
+   if (d3d12_debug & D3D12_DEBUG_SINGLETON)
+      return nullptr;
+
    /* A device factory allows us to isolate things like debug layer enablement 
from other callers,
     * and can potentially even refer to a different D3D12 redist 
implementation from others.
     */

Reply via email to