Description
When host_supports_target_device
gets called on a GPU target, it ends up creating a device and running a "check" with some data upload and copy.
Would it be possible to do query a device runtime in a different way that would not entail creating a device?
The reason I am asking is because the d3d12 debug layer is kind of a total wreck when it comes to creating devices:
- D3D12 devices (
D3D12Device
) are singletons per adapter (IDXGIAdapter
)
https://docs.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-d3d12createdevice"If a Direct3D 12 device already exists in the current process for a given adapter, then a subsequent call to D3D12CreateDevice returns the existing device."
ID3D12Debug::EnableDebugLayer()
must be called before any device gets created:
https://learn.microsoft.com/en-us/windows/win32/api/d3d12sdklayers/nf-d3d12sdklayers-id3d12debug-enabledebuglayer"Calling this API (
ID3D12Debug::EnableDebugLayer
) after creating the D3D12 device will cause the D3D12 runtime to remove the device."
This puts us on a precarious situation: if the non-debug
d3d12 runtime module is used first, followed by a use of the -debug
module, D3D12CreateDevice
in the -debug
module will fail with DXGI_ERROR_DEVICE_RESET
because a device for the same adapter is being created again, but this time it is after EnableDebugLayer()
has been called.
Tutorial 12, for example, calls host_supports_target_device()
to check that the host supports the d3d12 target, and then may go ahead and create a -debug
runtime later to actually run the tutorial.
AFAIK, there's no way around it.