Identify the failing operation in the D3D12 host startup warning (PR #439)
Squashed from pr-439 (0e2de1c7, 59cc6176) onto pr-review; import line merged with PR #242's WAIT_OBJECT_0.
This commit is contained in:
1 parent
feb90adeb1
commit
f37703e54d
1 file changed
+30
-17
@@ -8,6 +8,7 @@
|
|||||||
use std::sync::atomic::{AtomicU32, Ordering};
|
use std::sync::atomic::{AtomicU32, Ordering};
|
||||||
use std::sync::{Mutex, OnceLock};
|
use std::sync::{Mutex, OnceLock};
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
use windows::Win32::Foundation::{HANDLE, HWND, LPARAM, LRESULT, RECT, WAIT_OBJECT_0, WPARAM};
|
use windows::Win32::Foundation::{HANDLE, HWND, LPARAM, LRESULT, RECT, WAIT_OBJECT_0, WPARAM};
|
||||||
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0;
|
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0;
|
||||||
use windows::Win32::Graphics::Direct3D12::*;
|
use windows::Win32::Graphics::Direct3D12::*;
|
||||||
@@ -867,14 +868,14 @@ pub(crate) fn host() -> Option<&'static Host> {
|
|||||||
HOST.get_or_init(|| match create() {
|
HOST.get_or_init(|| match create() {
|
||||||
Ok(host) => Some(host),
|
Ok(host) => Some(host),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::warn!(error = %e, "no host D3D12 device; command lists will not run");
|
tracing::warn!(error = %format_args!("{e:#}"), "no host D3D12 device; command lists will not run");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.as_ref()
|
.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create() -> windows::core::Result<Host> {
|
fn create() -> anyhow::Result<Host> {
|
||||||
// SAFETY: plain D3D12 object creation with valid descriptions.
|
// SAFETY: plain D3D12 object creation with valid descriptions.
|
||||||
unsafe {
|
unsafe {
|
||||||
// The debug layer only in builds with diagnostics.
|
// The debug layer only in builds with diagnostics.
|
||||||
@@ -928,25 +929,31 @@ fn create() -> windows::core::Result<Host> {
|
|||||||
// is an access violation in this process (a crash report with the
|
// is an access violation in this process (a crash report with the
|
||||||
// address and instruction) instead of a GPU fault and driver reset.
|
// address and instruction) instead of a GPU fault and driver reset.
|
||||||
if cfg!(feature = "diagnostics") && crate::switch::on("VICTORY_D3D12_WARP") {
|
if cfg!(feature = "diagnostics") && crate::switch::on("VICTORY_D3D12_WARP") {
|
||||||
let adapter = warp_adapter()?;
|
let adapter = warp_adapter().context("selecting the WARP adapter")?;
|
||||||
D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device)?;
|
D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device)
|
||||||
|
.context("D3D12CreateDevice(WARP, FL 12_0, ID3D12Device)")?;
|
||||||
tracing::info!("host device on the software adapter (WARP)");
|
tracing::info!("host device on the software adapter (WARP)");
|
||||||
} else {
|
} else {
|
||||||
// The card the monitor is on, else the one with the most memory (or the one
|
// The card the monitor is on, else the one with the most memory (or the one
|
||||||
// VICTORY_ADAPTER names), not Windows' first adapter, which is
|
// VICTORY_ADAPTER names), not Windows' first adapter, which is
|
||||||
// often an integrated GPU.
|
// often an integrated GPU.
|
||||||
if let Some((adapter, name, own)) = victory_shader::emit::host::hardware_adapter()
|
if let Some((adapter, name, own)) = victory_shader::emit::host::hardware_adapter()
|
||||||
&& D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device).is_ok()
|
&& D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device)
|
||||||
|
.inspect_err(|e| tracing::warn!(adapter = %name, error = %e, "D3D12CreateDevice(selected adapter, FL 12_0, ID3D12Device) failed"))
|
||||||
|
.is_ok()
|
||||||
{
|
{
|
||||||
tracing::info!(adapter = %name, own_memory_mb = own >> 20, "host device on the card the monitor is on, else the one with the most memory of its own (VICTORY_ADAPTER names another)");
|
tracing::info!(adapter = %name, own_memory_mb = own >> 20, "host device on the card the monitor is on, else the one with the most memory of its own (VICTORY_ADAPTER names another)");
|
||||||
}
|
}
|
||||||
if device.is_none() {
|
if device.is_none() {
|
||||||
D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device)?;
|
D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut device)
|
||||||
|
.context("D3D12CreateDevice(default adapter, FL 12_0, ID3D12Device)")?;
|
||||||
}
|
}
|
||||||
// Whether a GPU hang ends the run or freezes the PC (#1054).
|
// Whether a GPU hang ends the run or freezes the PC (#1054).
|
||||||
crate::tdr::log();
|
crate::tdr::log();
|
||||||
}
|
}
|
||||||
let device = device.ok_or_else(windows::core::Error::empty)?;
|
let device = device
|
||||||
|
.ok_or_else(windows::core::Error::empty)
|
||||||
|
.context("D3D12CreateDevice returned an empty device")?;
|
||||||
require_direct_heaps(&device);
|
require_direct_heaps(&device);
|
||||||
// Before anything is made with it (`VICTORY_RECORD`).
|
// Before anything is made with it (`VICTORY_RECORD`).
|
||||||
#[cfg(feature = "diagnostics")]
|
#[cfg(feature = "diagnostics")]
|
||||||
@@ -1011,26 +1018,32 @@ fn create() -> windows::core::Result<Host> {
|
|||||||
// its device proxy.
|
// its device proxy.
|
||||||
let queue: ID3D12CommandQueue = match crate::streamline::device_made(&device) {
|
let queue: ID3D12CommandQueue = match crate::streamline::device_made(&device) {
|
||||||
Some(queue) => queue,
|
Some(queue) => queue,
|
||||||
None => device.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC {
|
None => device
|
||||||
|
.CreateCommandQueue(&D3D12_COMMAND_QUEUE_DESC {
|
||||||
Type: D3D12_COMMAND_LIST_TYPE_DIRECT,
|
Type: D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})?,
|
})
|
||||||
|
.context("CreateCommandQueue(DIRECT)")?,
|
||||||
};
|
};
|
||||||
let fence: ID3D12Fence = device.CreateFence(0, D3D12_FENCE_FLAG_NONE)?;
|
let fence: ID3D12Fence = device
|
||||||
let event = CreateEventW(None, false, false, None)?;
|
.CreateFence(0, D3D12_FENCE_FLAG_NONE)
|
||||||
let rtvs: ID3D12DescriptorHeap =
|
.context("CreateFence")?;
|
||||||
device.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
|
let event = CreateEventW(None, false, false, None).context("CreateEventW")?;
|
||||||
|
let rtvs: ID3D12DescriptorHeap = device
|
||||||
|
.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
|
||||||
Type: D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
|
Type: D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
|
||||||
NumDescriptors: RTV_RING,
|
NumDescriptors: RTV_RING,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})?;
|
})
|
||||||
|
.context("CreateDescriptorHeap(RTV)")?;
|
||||||
let rtv_size = device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
let rtv_size = device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV);
|
||||||
let dsvs: ID3D12DescriptorHeap =
|
let dsvs: ID3D12DescriptorHeap = device
|
||||||
device.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
|
.CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
|
||||||
Type: D3D12_DESCRIPTOR_HEAP_TYPE_DSV,
|
Type: D3D12_DESCRIPTOR_HEAP_TYPE_DSV,
|
||||||
NumDescriptors: RTV_RING,
|
NumDescriptors: RTV_RING,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})?;
|
})
|
||||||
|
.context("CreateDescriptorHeap(DSV)")?;
|
||||||
let dsv_size = device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
let dsv_size = device.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
||||||
let adapter = CreateDXGIFactory2::<IDXGIFactory4>(DXGI_CREATE_FACTORY_FLAGS(0))
|
let adapter = CreateDXGIFactory2::<IDXGIFactory4>(DXGI_CREATE_FACTORY_FLAGS(0))
|
||||||
.and_then(|factory| factory.EnumAdapterByLuid::<IDXGIAdapter3>(device.GetAdapterLuid()))
|
.and_then(|factory| factory.EnumAdapterByLuid::<IDXGIAdapter3>(device.GetAdapterLuid()))
|
||||||
|
|||||||
Reference in new issue
Block a user