diff --git a/src/gpu/gpu_dx12/gpu_dx12_core.c b/src/gpu/gpu_dx12/gpu_dx12_core.c index 7b382525..f72db1a9 100644 --- a/src/gpu/gpu_dx12/gpu_dx12_core.c +++ b/src/gpu/gpu_dx12/gpu_dx12_core.c @@ -92,18 +92,33 @@ void G_Bootstrap(void) { Panic(StringF(scratch.arena, "Failed to create ID3D12DeviceFactory: Error code 0x%F", FmtHex(hr))); } + } + } - // Enable debug layer - if (G_D12.debug_layer_enabled) - { - ID3D12Debug1 *debug = 0; - ID3D12DeviceFactory_GetConfigurationInterface(G_D12.independent.device_factory, &CLSID_D3D12Debug, &IID_ID3D12Debug1, (void **)&debug); - ID3D12Debug1_EnableDebugLayer(debug); - if (G_D12.validation_layer_enabled) - { - ID3D12Debug1_SetEnableGPUBasedValidation(debug, 1); - } - } + ////////////////////////////// + //- Enable D3D12 debug layer + + // Enable debug layer + if (G_D12.debug_layer_enabled) + { + ID3D12Debug1 *debug = 0; + HRESULT hr = 0; + if (G_D12.independent_devices_enabled) + { + hr = ID3D12DeviceFactory_GetConfigurationInterface(G_D12.independent.device_factory, &CLSID_D3D12Debug, &IID_ID3D12Debug1, (void **)&debug); + } + else + { + hr = D3D12GetDebugInterface(&IID_ID3D12Debug1, (void **)&debug); + } + if (FAILED(hr)) + { + Panic(Lit("Failed to retrieve D3D12 Debug interface")); + } + ID3D12Debug1_EnableDebugLayer(debug); + if (G_D12.validation_layer_enabled) + { + ID3D12Debug1_SetEnableGPUBasedValidation(debug, 1); } }