Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ The on/off switches below (`...=1`) are off when unset or set to `0`.
| `VICTORY_PIPELINE_LOG=<file>` | a line per title pipeline created (key, shaders, state), first used, and made or loaded (library name); `translate --cache --pipelines` writes the last kind too |
| `VICTORY_PREBUILD_KEYS=<file>` | `translate --cache --pipelines` makes nothing and lists each pack record's key, shaders and state (or why it is skipped) |
| `VICTORY_SHADER_LOOP_LIMIT=<n>` | translated shader loops stop after `n` iterations per lane instead of 2^20 (own shader cache entries); if a lower `n` makes world frames much faster, loops hitting the limit are what makes them slow |
| `VICTORY_LITERAL_HALVES=0` | disable the literal translation retry for 64-thread wave64 compute shaders on 32-lane hosts (separate shader cache entries) |
| `VICTORY_AUDIO_CAPTURE=<file.wav>` | records what the title plays (our process only) |
| `VICTORY_XMA_DUMP=<dir>` | saves the first 32 XMA voices' context and input |

Expand Down
7 changes: 1 addition & 6 deletions crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4159,12 +4159,7 @@ void main(uint3 id : SV_DispatchThreadID) {
&res,
Options {
view_marks: true,
atomic_locks: false,
atomic_lock_rounds: false,
atomic_umax: false,
bias_as_gradients: false,
host_wave32: false,
narrow_waves: false,
..Options::default()
},
)
.unwrap();
Expand Down
39 changes: 34 additions & 5 deletions crates/victory-gpu/src/shader_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ fn narrow_waves() -> bool {
})
}

/// Whether 64-thread wave64 shaders keep only the per-lane translation.
fn literal_halves_disabled() -> bool {
static OFF: OnceLock<bool> = OnceLock::new();
*OFF.get_or_init(|| std::env::var("VICTORY_LITERAL_HALVES").as_deref() == Ok("0"))
}

/// Whether this runs under Wine (on a Mac: D3DMetal's D3D12).
#[cfg(windows)]
pub(crate) fn under_wine() -> bool {
Expand All @@ -175,23 +181,25 @@ pub(crate) fn under_wine() -> bool {
}

/// [`build`] for translations with host workarounds (atomic locks, their
/// rounds and umax reduction, bias as gradients, narrow waves): their own
/// cache entries, one per combination.
/// rounds and umax reduction, bias as gradients, narrow waves, and literal
/// halves): their own cache entries, one per combination.
pub(crate) fn translation_build(options: victory_shader::emit::Options) -> &'static [u8; 32] {
let locks = options.atomic_locks;
let bias = options.bias_as_gradients;
let narrow = options.narrow_waves;
let rounds = locks && options.atomic_lock_rounds;
let umax = rounds && options.atomic_umax;
if !locks && !bias && !narrow {
let no_literal = options.host_wave32 && options.disable_literal_halves;
if !locks && !bias && !narrow && !no_literal {
return build();
}
static BUILDS: [OnceLock<[u8; 32]>; 32] = [const { OnceLock::new() }; 32];
static BUILDS: [OnceLock<[u8; 32]>; 64] = [const { OnceLock::new() }; 64];
let n = usize::from(locks)
| usize::from(bias) << 1
| usize::from(narrow) << 2
| usize::from(rounds) << 3
| usize::from(umax) << 4;
| usize::from(umax) << 4
| usize::from(no_literal) << 5;
BUILDS[n].get_or_init(|| {
let mut h = blake3::Hasher::new();
h.update(build());
Expand All @@ -210,6 +218,9 @@ pub(crate) fn translation_build(options: victory_shader::emit::Options) -> &'sta
if narrow {
h.update(b"narrow waves");
}
if no_literal {
h.update(b"literal halves disabled");
}
*h.finalize().as_bytes()
})
}
Expand All @@ -228,6 +239,7 @@ pub(crate) fn runtime_options() -> victory_shader::emit::Options {
bias_as_gradients: bias_as_gradients(),
host_wave32: host_wave32(),
narrow_waves: narrow_waves(),
disable_literal_halves: literal_halves_disabled(),
}
}

Expand Down Expand Up @@ -545,6 +557,23 @@ mod tests {
assert!(!rounds_on(false, Some("1")), "nor when asked for");
}

#[test]
fn disabling_literal_halves_changes_the_translation_key() {
let options = victory_shader::emit::Options {
host_wave32: true,
..runtime_options()
};
let on = translation_build(victory_shader::emit::Options {
disable_literal_halves: false,
..options
});
let off = translation_build(victory_shader::emit::Options {
disable_literal_halves: true,
..options
});
assert_ne!(on, off);
}

fn shader() -> HostShader {
HostShader {
stage: HwStage::Ps,
Expand Down
Loading