From 0d70ec3edd9c2c3748b5a97e4b978a6471f41b38 Mon Sep 17 00:00:00 2001 From: mokkamokacaffe <329663686+mokkamokacaffe@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:55:03 +0100 Subject: [PATCH] Shaders: defer direct mesh cache probes --- crates/xcl/src/gpu/recomp/pso.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index 8a8b95b065..f1f719cf51 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -737,6 +737,14 @@ fn finish_two_pass(t: super::Translation, record: super::MsInterface, ps: Option /// The mesh-shader (NGG) program of a console MS container; the pass-through carries what /// the pixel shader `ps` (its container: console or PC) reads. +fn defer_direct_mesh_translation() -> Result<(), String> { + if dxc::defer() { + Err("direct mesh translation deferred".into()) + } else { + Ok(()) + } +} + pub fn console_mesh(blob: &[u8], ps: Option<&[u8]>, split_wave64: bool) -> Result { let sh = xbox::parse(blob).ok_or("not a console shader container")?; let f = sh.fssm.iter().find(|f| f.stages.first().is_some_and(|s| s.hw == 7)).ok_or("no NGG hardware variant")?; @@ -748,6 +756,7 @@ pub fn console_mesh(blob: &[u8], ps: Option<&[u8]>, split_wave64: bool) -> Resul let wave64 = super::detect_wave64(code); // `XCL_DIRECT_DXIL=1`: the compute pass through the direct DXIL translator (HLSL fallback) if crate::gpu::dxil::kernel::enabled() { + defer_direct_mesh_translation()?; let o = crate::gpu::dxil::kernel::KernelOptions { wave64, split: wave64 && split_wave64, mem_windows: mem_windows(), sampler_base: 0 }; match crate::gpu::dxil::kernel::translate_mesh(code, o, ms) { Ok(k) => { @@ -912,6 +921,15 @@ pub fn abi_root_signature_with(dev: &ID3D12Device, graphics: bool, samplers: &[S mod shader_cache_tests { use super::*; + #[test] + fn direct_mesh_translation_defers_only_during_a_cached_only_probe() { + assert!(defer_direct_mesh_translation().is_ok()); + let (result, missed) = dxc::cached_only(defer_direct_mesh_translation); + assert_eq!(result.unwrap_err(), "direct mesh translation deferred"); + assert!(missed); + assert!(defer_direct_mesh_translation().is_ok()); + } + #[test] fn translated_identity_tracks_sources_and_dxc() { let built_source = env!("XCL_TRANSLATOR_SOURCE_ID");