From b2cc8edb1a509f39e60e4ec23688257abb7b7ccc Mon Sep 17 00:00:00 2001 From: bmjask <11672696+bmjask@users.noreply.github.com> Date: Sat, 21 Nov 2026 12:32:16 -0500 Subject: [PATCH] Olympus: share geometry wave selection --- crates/xcl/src/gpu/recomp/mod.rs | 11 +++++++++++ crates/xcl/src/gpu/recomp/pso.rs | 29 ++++++++++++++++++++++------- crates/xcl/src/hle/d3d12x/real.rs | 13 +------------ crates/xcl/tests/gpu_pso_e2e.rs | 3 ++- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs index b0a93cd..b45ef32 100644 --- a/crates/xcl/src/gpu/recomp/mod.rs +++ b/crates/xcl/src/gpu/recomp/mod.rs @@ -964,6 +964,17 @@ pub fn geometry_wave32_hazards(code: &[u8]) -> BTreeSet<&'static str> { out } +/// Translate a complete ES+GS program for the adapter-selected geometry path. +pub fn translate_geometry(code: &[u8], interface: GsInterface, geometry_wave32: bool) -> Result { + if geometry_wave32 { + let hazards = geometry_wave32_hazards(code); + if !hazards.is_empty() { + return Err(format!("geometry program requires unsupported cross-half wave64 semantics: {hazards:?}")); + } + } + translate(code, &Options { mode: Mode::Geometry(interface), wave64: true, geometry_wave32, ..Default::default() }) +} + /// Wave size the program was compiled for: 64-bit EXEC/VCC writes mean wave64. pub fn detect_wave64(code: &[u8]) -> bool { let mut off = 0; diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index 03e0aab..a1f0c98 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -99,6 +99,10 @@ pub struct TwoPass { fn two_pass(code: &[u8], mode: Mode, wave64: bool, geometry_wave32: bool, record: super::MsInterface, ps: Option<&[u8]>) -> Result { let t = translate(code, &Options { mode, wave64, geometry_wave32, ..Default::default() })?; + finish_two_pass(t, record, ps) +} + +fn finish_two_pass(t: super::Translation, record: super::MsInterface, ps: Option<&[u8]>) -> Result { if !t.complete() { let missing: Vec<&String> = t.unsupported.keys().collect(); return Err(format!("incomplete translation, missing: {missing:?}")); @@ -128,17 +132,28 @@ pub fn geometry_uses_wave32(wave_min: u32, wave_max: u32) -> bool { !(wave_min <= 64 && wave_max >= 64) } +pub fn geometry_uses_wave32_for_device(device: &ID3D12Device) -> bool { + let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS1::default(); + if unsafe { + device.CheckFeatureSupport( + D3D12_FEATURE_D3D12_OPTIONS1, + &mut options as *mut _ as _, + std::mem::size_of_val(&options) as u32, + ) + } + .is_err() + { + return true; + } + geometry_uses_wave32(options.WaveLaneCountMin, options.WaveLaneCountMax) +} + /// A legacy GS pipeline: the ES variant of a console VS + the GS as one program. pub fn console_geometry(vs: &[u8], gs: &[u8], ps: Option<&[u8]>, geometry_wave32: bool) -> Result { let (code, g) = super::geometry_program(vs, gs)?; - if geometry_wave32 { - let hazards = super::geometry_wave32_hazards(&code); - if !hazards.is_empty() { - return Err(format!("geometry program requires unsupported cross-half wave64 semantics: {hazards:?}")); - } - } let record = g.record(); - two_pass(&code, Mode::Geometry(g), true, geometry_wave32, record, ps) + let translation = super::translate_geometry(&code, g, geometry_wave32)?; + finish_two_pass(translation, record, ps) } /// XCL shader ABI root signature (see the module docs); `graphics` allows an input layout. diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 5f24757..a770f46 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -280,18 +280,7 @@ fn geometry_wave32_required(device: *mut c_void) -> bool { } unsafe { let Some(dev) = ID3D12Device::from_raw_borrowed(&device) else { return true }; - let mut options = D3D12_FEATURE_DATA_D3D12_OPTIONS1::default(); - if dev - .CheckFeatureSupport( - D3D12_FEATURE_D3D12_OPTIONS1, - &mut options as *mut _ as _, - std::mem::size_of_val(&options) as u32, - ) - .is_err() - { - return true; - } - crate::gpu::recomp::pso::geometry_uses_wave32(options.WaveLaneCountMin, options.WaveLaneCountMax) + crate::gpu::recomp::pso::geometry_uses_wave32_for_device(dev) } } diff --git a/crates/xcl/tests/gpu_pso_e2e.rs b/crates/xcl/tests/gpu_pso_e2e.rs index a2e8cf2..1e06b48 100644 --- a/crates/xcl/tests/gpu_pso_e2e.rs +++ b/crates/xcl/tests/gpu_pso_e2e.rs @@ -434,7 +434,8 @@ fn retail_es_gs_voxelize_geometry_mode() { use xcl::gpu::recomp::{self, dxc, IO_GS_PRIMS, IO_GS_VERTICES, MESH_HEADER}; let (code, g) = recomp::geometry_program(&blobs[0], &blobs[1]).expect("ES + GS pair"); assert_eq!((g.max_vertex_count, g.vertex_bytes()), (3, 64)); - let t = recomp::translate(&code, &recomp::Options { mode: recomp::Mode::Geometry(g.clone()), wave64: true, ..Default::default() }).unwrap(); + let split_wave32 = recomp::pso::geometry_uses_wave32_for_device(&_dev); + let t = recomp::translate_geometry(&code, g.clone(), split_wave32).unwrap(); assert!(t.complete(), "{:?}", t.unsupported_why); let cs = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap_or_else(|e| panic!("{e}")); let rec = g.record();