Tests: no process-wide switch in a parallel test, registry cleanup and advapi32 routing checked

- The structured / block-chain HLSL comparison set XCL_RECOMP_NO_STRUCTURED for the whole
  process while other recompiler tests ran in parallel: now Options::structured.
- gpu_pso_e2e: releasing the mesh stand-in removes exactly one TWO_PASS entry (the tests there
  run one at a time).
- resolver: advapi32!RegOpenKeyW resolves to kernelx, RegSetValueExW to the real advapi32.
- scripts/test.ps1 lists the sample-data variables not set (their tests pass without running);
  README says so.
This commit is contained in:
ivall
2026-11-21 17:06:15 +01:00
parent 61492f6694
commit 1c8fae9ec0
6 changed files with 32 additions and 7 deletions
+3 -2
View File
@@ -109,8 +109,9 @@ Unit tests, an end-to-end test with our own "console title" (`tests/testtitle`)
(D3D12, SM 6.6; skipped without a GPU / DXC). Tests on real game data are opt-in through
environment variables pointing at your own files – `XCL_SAMPLE_RPF` (shader pack),
`XCL_SAMPLE_DLLS` (the game's console DLLs), `XCL_SAMPLE_TTPF` (texture archive),
`XCL_SAMPLE_BK2` (a movie), `XCL_SAMPLE_BVH4` – described in `HANDOFF.md`. No game data is part
of the repository.
`XCL_SAMPLE_BK2` (a movie), `XCL_SAMPLE_BVH4` – described in `HANDOFF.md`; without them those
tests pass without running anything (`scripts/test.ps1` lists the ones not set). No game data is
part of the repository.
## Licenses
+5 -2
View File
@@ -313,11 +313,14 @@ pub struct Options {
/// then exactly the single-window form); 2..4 add `mem1`.. (u3..) and pick the window of
/// every access from the high address bits
pub mem_windows: u32,
/// structured control flow when the program allows it (false, or `XCL_RECOMP_NO_STRUCTURED`:
/// always the guarded block chain)
pub structured: bool,
}
impl Default for Options {
fn default() -> Self {
Options { mode: Mode::Kernel, wave64: true, hw_wave: 0, static_sampler_base: 0, mem_windows: 1 }
Options { mode: Mode::Kernel, wave64: true, hw_wave: 0, static_sampler_base: 0, mem_windows: 1, structured: true }
}
}
@@ -1076,7 +1079,7 @@ pub fn translate(code: &[u8], opt: &Options) -> Result<Translation, String> {
let ctx = Ctx { insts: &insts, starts: &starts, leaders: &leaders, loops: &loops, edges: &edges, memo: Default::default() };
let mut flags = BTreeSet::new();
let mut code = String::new();
if gs_jump.is_none() && std::env::var_os("XCL_RECOMP_NO_STRUCTURED").is_none() && structurable(&ctx, 0, u64::MAX).is_some() {
if gs_jump.is_none() && opt.structured && std::env::var_os("XCL_RECOMP_NO_STRUCTURED").is_none() && structurable(&ctx, 0, u64::MAX).is_some() {
// structured control flow: plain if / loops, no block dispatch on `pc` (much
// smaller for DXC and the driver on big programs)
emit_structured(&ctx, &mut em, &mut code, 0, u64::MAX, None, 0, None, &BTreeSet::new(), 1, &mut blocks, &mut flags);
+2 -3
View File
@@ -46,9 +46,8 @@ fn hlsl_is_generated_for_straight_line_and_branches() {
// forward branches only: a plain `if`, no loop and no block dispatch on pc
assert!(t.hlsl.contains("if (!(") && !t.hlsl.contains("pc ==") && !t.hlsl.contains("for (;;)") && t.hlsl.contains("[WaveSize(64)]"), "{}", t.hlsl);
// the guarded block chain (fallback form) for the same program
unsafe { std::env::set_var("XCL_RECOMP_NO_STRUCTURED", "1") };
let g = translate(&code, &Options::default()).unwrap();
unsafe { std::env::remove_var("XCL_RECOMP_NO_STRUCTURED") };
// (an option, not the environment variable: other tests translate at the same time)
let g = translate(&code, &Options { structured: false, ..Options::default() }).unwrap();
assert!(g.hlsl.contains("if (pc == 0u)") && !g.hlsl.contains("while"), "{}", g.hlsl);
// a backward branch: only its range becomes a loop
let code = prog(&[
+16
View File
@@ -351,3 +351,19 @@ pub fn get_proc_address(h: usize, what: &ImportName) -> Option<usize> {
}
system_proc_in(h, what)
}
#[cfg(test)]
mod tests {
use super::*;
/// advapi32 imports go to kernelx: the registry functions the GDK thunks use for the device
/// type are XCL's, everything else is the real advapi32.
#[test]
fn advapi32_imports_route_through_kernelx() {
let name = |s: &str| ImportName::Name { hint: 0, name: s.into() };
let (a, s) = resolve_inner("advapi32.dll", &name("RegOpenKeyW"), 0);
assert!(a != 0 && matches!(s, Source::Hle(ref m) if m == crate::hle::KERNELX), "{s:?}");
let (a, s) = resolve_inner("advapi32.dll", &name("RegSetValueExW"), 0);
assert!(a != 0 && matches!(s, Source::System(ref d) if d == "advapi32.dll"), "{s:?}");
}
}
+3
View File
@@ -287,7 +287,10 @@ fn retail_pipelines_built_in_the_background_behind_a_stand_in() {
assert!(real::two_pass_of(raw).is_some(), "the two-pass parts through the stand-in");
println!("mesh: the call returned after {call:?}, the real pipeline was ready after {:?}", t0.elapsed());
// the title releases the stand-in: its real pipeline goes with it, the address is forgotten
// (the tests here run one at a time: the count is this test's)
let two_pass = real::two_pass_count();
drop(mesh);
assert_eq!(real::two_pass_count(), two_pass - 1, "the released pipeline's compute pass is gone");
assert_eq!(pso_async::resolve(raw), raw);
assert!(real::two_pass_of(raw).is_none());
}
+3
View File
@@ -1,6 +1,9 @@
# Build everything (the e2e test needs the test title + DLL) and run all tests.
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
# tests on game data pass without running anything when their variable is not set
$missing = 'XCL_SAMPLE_RPF', 'XCL_SAMPLE_DLLS', 'XCL_SAMPLE_TTPF', 'XCL_SAMPLE_BK2', 'XCL_SAMPLE_BVH4' | Where-Object { -not (Test-Path "env:$_") }
if ($missing) { Write-Host "not set, their tests are skipped: $($missing -join ', ')" }
cargo build --workspace
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test --workspace -- --test-threads=4