Skip to content
Merged
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 @@ -188,6 +188,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
8 changes: 1 addition & 7 deletions crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5296,14 +5296,8 @@ 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,
per_vertex_center: false,
uav_size_level0: 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 @@ -167,6 +167,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 a size query on a writable image asks for level 0 in every
/// program (`Options::uav_size_level0`): only with
/// `VICTORY_UAV_SIZE_LEVEL0=1`. D3DMetal answers the undefined level DXC
Expand Down Expand Up @@ -246,25 +252,27 @@ pub(crate) fn under_wine() -> bool {

/// [`build`] for translations with host workarounds (atomic locks, their
/// rounds and umax reduction, bias as gradients, narrow waves, level-0
/// size queries on writable images): their own cache entries, one per
/// combination.
/// size queries on writable images, 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;
let uav_level0 = options.uav_size_level0;
if !locks && !bias && !narrow && !uav_level0 {
let no_literal = options.host_wave32 && options.disable_literal_halves;
if !locks && !bias && !narrow && !no_literal && !uav_level0 {
return build();
}
static BUILDS: [OnceLock<[u8; 32]>; 64] = [const { OnceLock::new() }; 64];
static BUILDS: [OnceLock<[u8; 32]>; 128] = [const { OnceLock::new() }; 128];
let n = usize::from(locks)
| usize::from(bias) << 1
| usize::from(narrow) << 2
| usize::from(rounds) << 3
| usize::from(umax) << 4
| usize::from(uav_level0) << 5;
| usize::from(no_literal) << 5
| usize::from(uav_level0) << 6;
BUILDS[n].get_or_init(|| {
let mut h = blake3::Hasher::new();
h.update(build());
Expand All @@ -286,6 +294,9 @@ pub(crate) fn translation_build(options: victory_shader::emit::Options) -> &'sta
if uav_level0 {
h.update(b"uav size level 0");
}
if no_literal {
h.update(b"literal halves disabled");
}
*h.finalize().as_bytes()
})
}
Expand All @@ -304,6 +315,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(),
per_vertex_center: false,
uav_size_level0: uav_size_level0(),
}
Expand Down Expand Up @@ -666,6 +678,23 @@ mod tests {
assert_ne!(translation_build(level0), build());
}

#[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
1 change: 1 addition & 0 deletions crates/victory-shader/src/emit/deltas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ mod tests {
},
None,
per_vertex_center,
false,
)
.unwrap()
.dxil
Expand Down
Loading