GPU: VICTORY_* switches set to 0 are off

Six diagnostic switches (VICTORY_D3D12_DEBUG, _GBV, _DRED, _WARP,
VICTORY_GPU_TIMING and VICTORY_DUMP_TARGETS) were on whenever their
variable existed, so VICTORY_D3D12_WARP=0 still selected the software
adapter. They now go through one helper that reads a value other than 0
as on and an unset variable or 0 as off; every other value keeps the
meaning it had. The README says so above its switch table.

(cherry picked from commit a4974e4c21c16e2305942e37a868647d42eefe37)
This commit is contained in:
KoLolX3 authored and local committed 2026-11-25 01:02:59 -06:00
1 parent 394cc9a5c3
commit 3c250125c5
5 files changed
+54 -9

No files matched your search

+5 -8
View File
@@ -553,8 +553,7 @@ fn create() -> windows::core::Result<Host> {
// SAFETY: plain D3D12 object creation with valid descriptions.
unsafe {
// The debug layer only in builds with diagnostics.
let debug =
cfg!(feature = "diagnostics") && std::env::var_os("VICTORY_D3D12_DEBUG").is_some();
let debug = cfg!(feature = "diagnostics") && crate::switch::on("VICTORY_D3D12_DEBUG");
if debug {
let mut layer: Option<ID3D12Debug> = None;
match D3D12GetDebugInterface(&mut layer) {
@@ -565,7 +564,7 @@ fn create() -> windows::core::Result<Host> {
// descriptor heap indices and the like become messages naming
// the command instead of page faults. Without state tracking
// (directly indexed textures are not transitioned).
if std::env::var_os("VICTORY_D3D12_GBV").is_some()
if crate::switch::on("VICTORY_D3D12_GBV")
&& let Some(l) = &layer
{
if let Ok(d1) = l.cast::<ID3D12Debug1>() {
@@ -594,7 +593,7 @@ fn create() -> windows::core::Result<Host> {
// Diagnostics: the software adapter, on which a shader's wild access
// is an access violation in this process (a crash report with the
// address and instruction) instead of a GPU fault and driver reset.
if cfg!(feature = "diagnostics") && std::env::var_os("VICTORY_D3D12_WARP").is_some() {
if cfg!(feature = "diagnostics") && crate::switch::on("VICTORY_D3D12_WARP") {
let adapter = warp_adapter()?;
D3D12CreateDevice(&adapter, D3D_FEATURE_LEVEL_12_0, &mut device)?;
tracing::info!("host device on the software adapter (WARP)");
@@ -1326,9 +1325,7 @@ fn record_twin_copy(
/// builds).
pub(crate) fn dred_on() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| {
cfg!(feature = "diagnostics") && std::env::var_os("VICTORY_D3D12_DRED").is_some()
})
*ON.get_or_init(|| cfg!(feature = "diagnostics") && crate::switch::on("VICTORY_D3D12_DRED"))
}
/// Indirect mesh dispatches since the last frame line: the largest group
@@ -1352,7 +1349,7 @@ fn card_budget() -> bool {
#[cfg(feature = "diagnostics")]
fn timing() -> bool {
static ON: OnceLock<bool> = OnceLock::new();
*ON.get_or_init(|| std::env::var_os("VICTORY_GPU_TIMING").is_some())
*ON.get_or_init(|| crate::switch::on("VICTORY_GPU_TIMING"))
}
/// Names a host object for the device-removed report, which names the