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>
This commit is contained in:
Jesse Natalie
2023-12-18 10:05:05 -08:00
committed by Marge Bot
parent bed69133cd
commit ff9868c569
2 changed files with 5 additions and 0 deletions

View File

@@ -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;

View File

@@ -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.
*/