Merge agent/dlss: DLSS Frame Generation on Series X with the colour without the interface, Streamline timing line (VICTORY_FRAMEGEN, off by default)
Runs from the main path (chain z1): z-fg-a/b with VICTORY_FRAMEGEN=1: gameplay 43.3 / 38.3 ms, cutscene median 47.8 / 41.1 ms, 0 s over 100 ms (z-base: 39.3 / 43.5 ms); first in-game run y-fg-a (cold shader cache) stalled for that reason only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
175d62fc6b
6 files changed
+732
-16
No files matched your search
@@ -4424,6 +4424,9 @@ impl State {
|
||||
self.window = None;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
self.trace("draw", vertices, first);
|
||||
if crate::streamline::hudless_wanted() {
|
||||
self.before_shown_target(list, vertices == 3 && instances == 1);
|
||||
}
|
||||
let ready = self.prepare(list, false);
|
||||
// A pipeline with the rectangle geometry stage draws the title's
|
||||
// vertices as they are; any other gets its rectangles expanded.
|
||||
@@ -4460,6 +4463,29 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
/// With frame generation (`crate::streamline`), before a draw into one
|
||||
/// colour target without depth: if the target is one the title presents,
|
||||
/// the draw is told there, where the colour without the interface is
|
||||
/// copied in front of the title's interface composite. `triangle`: one
|
||||
/// triangle, one instance (the composite's shape). Only copies and
|
||||
/// barriers are recorded; the target is moved back to a render target by
|
||||
/// the draw's own preparation.
|
||||
fn before_shown_target(&self, list: &HostList, triangle: bool) {
|
||||
if self.depth != 0 {
|
||||
return;
|
||||
}
|
||||
let &[target] = self.targets.as_slice() else {
|
||||
return;
|
||||
};
|
||||
let Some(p) = crate::pipeline::host_pipeline(self.pipeline as This) else {
|
||||
return;
|
||||
};
|
||||
if p.compute || p.mesh {
|
||||
return;
|
||||
}
|
||||
crate::streamline::before_target_draw(list, target as This, p, triangle);
|
||||
}
|
||||
|
||||
/// Whether the bound pipeline completes rectangles itself, in the
|
||||
/// geometry stage rectangle pipelines get (`HostPipeline::rects`).
|
||||
fn completes_rects(&self) -> bool {
|
||||
@@ -4592,6 +4618,9 @@ impl State {
|
||||
self.window = None;
|
||||
#[cfg(feature = "diagnostics")]
|
||||
self.trace("indexed", indices, first);
|
||||
if crate::streamline::hudless_wanted() {
|
||||
self.before_shown_target(list, false);
|
||||
}
|
||||
// Indexed rectangles are drawn by the rectangle geometry stage
|
||||
// alone (nothing expands them on the CPU).
|
||||
let lost = self.topology == RECTANGLES && !self.completes_rects();
|
||||
|
||||
@@ -1279,6 +1279,9 @@ pub(crate) struct HostList {
|
||||
/// The upscaling (`crate::streamline`) recorded in the list, noted for
|
||||
/// the present after its submission; 0 for none.
|
||||
upscale: std::sync::atomic::AtomicU64,
|
||||
/// The copy of the colour without the interface (`crate::streamline`)
|
||||
/// recorded in the list, noted likewise; 0 for none.
|
||||
hudless: std::sync::atomic::AtomicU64,
|
||||
/// Counts the list in [`ALIVE`] while it lives.
|
||||
_alive: Counted,
|
||||
/// The texts of the markers `note_op` set, in order (for device-removed
|
||||
@@ -4224,6 +4227,7 @@ impl Host {
|
||||
indirect_run: Mutex::default(),
|
||||
holding: std::sync::atomic::AtomicBool::new(false),
|
||||
upscale: std::sync::atomic::AtomicU64::new(0),
|
||||
hudless: std::sync::atomic::AtomicU64::new(0),
|
||||
_alive: Counted::new(),
|
||||
#[cfg(feature = "diagnostics")]
|
||||
notes,
|
||||
@@ -5604,6 +5608,10 @@ impl Host {
|
||||
if id != 0 {
|
||||
crate::streamline::submitted(id);
|
||||
}
|
||||
let id = run.take_hudless();
|
||||
if id != 0 {
|
||||
crate::streamline::hudless_submitted(id);
|
||||
}
|
||||
}
|
||||
let was_working = working(true);
|
||||
submitting(1, runs.len());
|
||||
@@ -6460,6 +6468,7 @@ impl HostList {
|
||||
let _resetting = crate::timeline::span("resetting a host list");
|
||||
self._alive.used();
|
||||
self.upscale.store(0, Ordering::Relaxed);
|
||||
self.hudless.store(0, Ordering::Relaxed);
|
||||
*self.coming.lock().unwrap_or_else(|e| e.into_inner()) = None;
|
||||
*self.deferred() = Deferred::default();
|
||||
self.states.lock().unwrap_or_else(|e| e.into_inner()).clear();
|
||||
@@ -7449,6 +7458,22 @@ impl HostList {
|
||||
self.upscale.swap(0, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// The list recorded copy `id` of the colour without the interface
|
||||
/// (`crate::streamline`, frame generation).
|
||||
pub(crate) fn mark_hudless(&self, id: u64) {
|
||||
self.hudless.store(id, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
/// The copy the list recorded (0 for none).
|
||||
pub(crate) fn hudless(&self) -> u64 {
|
||||
self.hudless.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// As [`HostList::hudless`], taken.
|
||||
pub(crate) fn take_hudless(&self) -> u64 {
|
||||
self.hudless.swap(0, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// Runs `work` when the list is submitted, in order with its copies.
|
||||
/// `work` may write title memory (refreshes after it copy again).
|
||||
pub(crate) fn defer(&self, work: impl Fn() + Send + 'static) {
|
||||
@@ -8874,7 +8899,7 @@ impl Host {
|
||||
|
||||
/// The swap chain formats a presented texture can be copied into: its own
|
||||
/// family's.
|
||||
fn swap_format(format: DXGI_FORMAT) -> Option<DXGI_FORMAT> {
|
||||
pub(crate) fn swap_format(format: DXGI_FORMAT) -> Option<DXGI_FORMAT> {
|
||||
Some(match format.0 {
|
||||
27..=32 => DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
87 | 90 | 91 => DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
@@ -9610,7 +9635,9 @@ impl Host {
|
||||
size: [width, height],
|
||||
},
|
||||
);
|
||||
let called = crate::streamline::present_called(&presenting);
|
||||
let _ = p.swap_chain.Present(0, DXGI_PRESENT(0));
|
||||
crate::streamline::present_returned(called);
|
||||
crate::streamline::present_ends(presenting);
|
||||
showing.next("the frame meter");
|
||||
#[cfg(feature = "diagnostics")]
|
||||
@@ -9624,6 +9651,14 @@ impl Host {
|
||||
}
|
||||
}
|
||||
|
||||
/// Lets the swap chain and what presents with it go, once everything
|
||||
/// sent has run (`victory upscaler-check`: before Streamline is shut
|
||||
/// down; nothing presents afterwards).
|
||||
pub(crate) fn drop_presenter(&self) {
|
||||
settle_now(WHY_SYNC);
|
||||
*self.presenter.lock().unwrap_or_else(|e| e.into_inner()) = None;
|
||||
}
|
||||
|
||||
fn presenter(
|
||||
&self,
|
||||
width: u32,
|
||||
@@ -9661,13 +9696,23 @@ impl Host {
|
||||
let swap_chain = match proxied {
|
||||
Some(Ok(swap_chain)) => {
|
||||
crate::streamline::swap_chain_made(true, None);
|
||||
// Frame generation must be off across a change between
|
||||
// windowed and full screen (Streamline's guide, 12.0):
|
||||
// the system's own Alt+Enter is not taken for this window.
|
||||
if let Ok(parent) = swap_chain.GetParent::<IDXGIFactory1>() {
|
||||
let _ = parent.MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
}
|
||||
swap_chain
|
||||
}
|
||||
Some(Err(e)) => {
|
||||
crate::streamline::swap_chain_made(false, Some(&e));
|
||||
factory.CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?.cast::<IDXGISwapChain3>()?
|
||||
}
|
||||
None => factory.CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?.cast::<IDXGISwapChain3>()?,
|
||||
// (`VICTORY_STREAMLINE_PRESENT=1`, DLSS without frame
|
||||
// generation: Streamline's proxy of it, for its present hook.)
|
||||
None => crate::streamline::present_hooked(
|
||||
factory.CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?.cast::<IDXGISwapChain3>()?,
|
||||
),
|
||||
};
|
||||
let copy = self.new_list()?;
|
||||
copy.close();
|
||||
|
||||
@@ -71,6 +71,14 @@ pub struct Asked {
|
||||
pub reactive: bool,
|
||||
/// `VICTORY_STREAMLINE_LOG=<folder>`: Streamline's own log there, verbose.
|
||||
pub log_dir: Option<PathBuf>,
|
||||
/// `VICTORY_FRAMEGEN_HUDLESS=0`: with frame generation, no colour
|
||||
/// without the interface is copied or tagged where the title draws its
|
||||
/// interface into the frame (Series X).
|
||||
pub hudless: bool,
|
||||
/// `VICTORY_STREAMLINE_PRESENT=1`: with DLSS and no frame generation,
|
||||
/// our swap chain is Streamline's proxy of it, so that Streamline sees
|
||||
/// the presents (its bookkeeping per frame).
|
||||
pub present_hook: bool,
|
||||
}
|
||||
|
||||
impl Asked {
|
||||
@@ -102,6 +110,8 @@ impl Asked {
|
||||
mvec: plan::pair(var("VICTORY_DLSS_MV").as_deref()),
|
||||
reactive: var("VICTORY_DLSS_REACTIVE").is_none_or(|v| v.trim() != "0"),
|
||||
log_dir: var("VICTORY_STREAMLINE_LOG").filter(|v| !v.trim().is_empty() && v.trim() != "0").map(PathBuf::from),
|
||||
hudless: var("VICTORY_FRAMEGEN_HUDLESS").is_none_or(|v| v.trim() != "0"),
|
||||
present_hook: on("VICTORY_STREAMLINE_PRESENT"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -194,6 +204,7 @@ struct Sl {
|
||||
get_feature_function: abi::SlGetFeatureFunction,
|
||||
get_new_frame_token: abi::SlGetNewFrameToken,
|
||||
set_d3d_device: abi::SlSetD3DDevice,
|
||||
shutdown: abi::SlShutdown,
|
||||
}
|
||||
|
||||
static SL: OnceLock<Sl> = OnceLock::new();
|
||||
@@ -237,6 +248,8 @@ unsafe impl Sync for Proxies {}
|
||||
static PROXIES: OnceLock<Proxies> = OnceLock::new();
|
||||
/// Our present goes through Streamline's swap chain.
|
||||
static SWAP_CHAIN_PROXIED: AtomicBool = AtomicBool::new(false);
|
||||
/// Our swap chain is Streamline's proxy of it ([`present_hooked`]).
|
||||
static PRESENT_HOOKED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// Library calls that are not thread safe, and what the upscaling keeps
|
||||
/// between frames, one caller at a time.
|
||||
@@ -537,6 +550,7 @@ fn load(path: &Path) -> Result<Sl, String> {
|
||||
get_feature_function: get!(c"slGetFeatureFunction", abi::SlGetFeatureFunction),
|
||||
get_new_frame_token: get!(c"slGetNewFrameToken", abi::SlGetNewFrameToken),
|
||||
set_d3d_device: get!(c"slSetD3DDevice", abi::SlSetD3DDevice),
|
||||
shutdown: get!(c"slShutdown", abi::SlShutdown),
|
||||
_library: library,
|
||||
})
|
||||
}
|
||||
@@ -711,6 +725,7 @@ pub(crate) fn swap_chain_factory(factory: &IDXGIFactory2) -> Option<(IDXGIFactor
|
||||
/// frame generation stays off).
|
||||
pub(crate) fn swap_chain_made(proxied: bool, error: Option<&windows::core::Error>) {
|
||||
SWAP_CHAIN_PROXIED.store(proxied, Release);
|
||||
HUDLESS_WANTED.store(proxied && FG_READY.load(Acquire) && PLAN.get().is_some_and(|p| p.asked.hudless), Release);
|
||||
if proxied {
|
||||
tracing::info!("Streamline: our swap chain is Streamline's proxy; DLSS Frame Generation can run on its presents");
|
||||
} else {
|
||||
@@ -722,6 +737,36 @@ pub(crate) fn swap_chain_made(proxied: bool, error: Option<&windows::core::Error
|
||||
}
|
||||
}
|
||||
|
||||
/// `VICTORY_STREAMLINE_PRESENT=1`, DLSS without frame generation: Streamline's
|
||||
/// proxy of `swap_chain`, whose Present, ResizeBuffers and GetBuffer run
|
||||
/// Streamline's hooks first (its common plugin frees what it retired and
|
||||
/// keeps its video memory budget at each present; without it, it logs
|
||||
/// "presentCommon() was not observed" after 60 upscalings and frees nothing
|
||||
/// it retired). `swap_chain` itself if the switch is off, frame generation
|
||||
/// owns the swap chain, or the upgrade fails.
|
||||
pub(crate) fn present_hooked(swap_chain: IDXGISwapChain3) -> IDXGISwapChain3 {
|
||||
let (Some(plan), Some(sl)) = (PLAN.get(), SL.get()) else { return swap_chain };
|
||||
if !plan.asked.present_hook || !plan.dlss || !DLSS_READY.load(Acquire) || SWAP_CHAIN_PROXIED.load(Acquire) {
|
||||
return swap_chain;
|
||||
}
|
||||
let mut raw = swap_chain.as_raw();
|
||||
// SAFETY: an owned reference of ours; on success `raw` is a new proxy
|
||||
// that holds its own reference to the swap chain.
|
||||
let code = unsafe { (sl.upgrade_interface)(&mut raw) };
|
||||
if code != 0 || raw.is_null() || raw == swap_chain.as_raw() {
|
||||
tracing::warn!(
|
||||
"Streamline: the swap chain was not upgraded: {} ({code}); presents stay unseen by Streamline",
|
||||
abi::result_name(code)
|
||||
);
|
||||
return swap_chain;
|
||||
}
|
||||
tracing::info!("Streamline: our swap chain is Streamline's proxy of it (VICTORY_STREAMLINE_PRESENT=1): it sees every present");
|
||||
PRESENT_HOOKED.store(true, Release);
|
||||
// SAFETY: the proxy's one reference, now ours; it implements the swap
|
||||
// chain interfaces up to IDXGISwapChain4 and holds the swap chain.
|
||||
unsafe { IDXGISwapChain3::from_raw(raw) }
|
||||
}
|
||||
|
||||
fn frame_token(sl: &Sl, index: u32) -> Option<*mut abi::FrameToken> {
|
||||
let mut token = std::ptr::null_mut();
|
||||
// SAFETY: an out pointer and an index.
|
||||
@@ -972,7 +1017,13 @@ fn record(list: *mut c_void, textures: &Textures, camera: &plan::Camera, pre_exp
|
||||
let (Some(optimal_of), Some(set_options)) = (functions.dlss_optimal, functions.dlss_set_options) else {
|
||||
return Err("no DLSS functions".into());
|
||||
};
|
||||
// (Timed with frame generation: its present shares this lock and
|
||||
// Streamline with the upscaling.)
|
||||
let began = plan.framegen.then(std::time::Instant::now);
|
||||
let mut calls = calls();
|
||||
if let Some(began) = began {
|
||||
spent(T_UPSCALE_LOCK, began);
|
||||
}
|
||||
let output = camera.output;
|
||||
let optimal = |calls: &mut Calls, mode: u32| -> Option<[u32; 2]> {
|
||||
if let Some(&(_, _, size)) = calls.optimal.iter().find(|(o, m, _)| *o == output && *m == mode) {
|
||||
@@ -1035,6 +1086,9 @@ fn record(list: *mut c_void, textures: &Textures, camera: &plan::Camera, pre_exp
|
||||
if code != 0 {
|
||||
return Err(format!("slEvaluateFeature: {} ({code})", abi::result_name(code)));
|
||||
}
|
||||
if let Some(began) = began {
|
||||
spent(T_UPSCALE, began);
|
||||
}
|
||||
Ok(Recorded { mode, optimal: optimal_of_mode(mode), changed, jitter: constants.jitter_offset, mvec_scale: constants.mvec_scale })
|
||||
}
|
||||
|
||||
@@ -1052,6 +1106,220 @@ pub fn upscaler_destroyed(context: usize) {
|
||||
tracing::info!(code, result = abi::result_name(code), "DLSS: the title's upscaler was destroyed; DLSS let go of its resources");
|
||||
}
|
||||
|
||||
/// The title's interface composite where the interface is no plane of the
|
||||
/// present (Series X): one triangle that blends the interface target
|
||||
/// (3840x2160, premultiplied) over the frame's colour, with these vertex and
|
||||
/// pixel shaders, the frame's last draw into the texture it presents. Seen
|
||||
/// in every frame listing of 2026-11-26 (stock 3840x2160 output: once a
|
||||
/// frame, after the scene's composite into the same texture) and bound from
|
||||
/// frame 3 on in the 1440p runs with DLSS; `draw::State::native_frontend_viewport`
|
||||
/// (DexNom's) names the same draw.
|
||||
const INTERFACE_COMPOSITE: [&str; 2] = ["0602c2384acbb3b2", "a78d088fa55aa495"];
|
||||
|
||||
/// Whether draws are looked at for the colour without the interface: frame
|
||||
/// generation runs on our swap chain and `VICTORY_FRAMEGEN_HUDLESS` is not 0.
|
||||
#[inline]
|
||||
pub(crate) fn hudless_wanted() -> bool {
|
||||
HUDLESS_WANTED.load(Relaxed)
|
||||
}
|
||||
|
||||
static HUDLESS_WANTED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// The host textures of the last presents (their addresses): the textures
|
||||
/// the title presents (it has two, in turn).
|
||||
static SHOWN: [std::sync::atomic::AtomicUsize; 4] = [const { std::sync::atomic::AtomicUsize::new(0) }; 4];
|
||||
static SHOWN_NEXT: AtomicU32 = AtomicU32::new(0);
|
||||
|
||||
/// A copy of a presented texture taken in front of the interface composite.
|
||||
struct Copied {
|
||||
id: u64,
|
||||
/// The host texture copied (its address).
|
||||
target: usize,
|
||||
texture: ID3D12Resource,
|
||||
}
|
||||
|
||||
// SAFETY: D3D12 resources are free-threaded.
|
||||
unsafe impl Send for Copied {}
|
||||
|
||||
/// The copies recorded in lists not submitted yet, and those submitted and
|
||||
/// not presented yet, in submission order.
|
||||
static HUD_PENDING: Mutex<Vec<Copied>> = Mutex::new(Vec::new());
|
||||
static HUD_SUBMITTED: Mutex<Vec<Copied>> = Mutex::new(Vec::new());
|
||||
static HUD_NEXT_ID: AtomicU64 = AtomicU64::new(0);
|
||||
|
||||
/// The two textures the copies go to in turn (a present reads one while the
|
||||
/// next frame's lists may already be recorded), with their size and format.
|
||||
struct HudlessTextures {
|
||||
size: [u32; 2],
|
||||
format: i32,
|
||||
textures: [ID3D12Resource; 2],
|
||||
}
|
||||
|
||||
// SAFETY: as above.
|
||||
unsafe impl Send for HudlessTextures {}
|
||||
|
||||
static HUD_TEXTURES: Mutex<Option<HudlessTextures>> = Mutex::new(None);
|
||||
|
||||
// Since the last line about it (every ten seconds): copies recorded, presents
|
||||
// tagged with one, presents with frame generation on that had none, composite
|
||||
// draws, those after a copy in their list, draws of other pipelines into a
|
||||
// presented texture.
|
||||
static HUD_COUNTS: [AtomicU64; 6] = [const { AtomicU64::new(0) }; 6];
|
||||
const HUD_COPIES: usize = 0;
|
||||
const HUD_TAGGED: usize = 1;
|
||||
const HUD_MISSING: usize = 2;
|
||||
const HUD_COMPOSITES: usize = 3;
|
||||
const HUD_AGAIN: usize = 4;
|
||||
const HUD_OTHERS: usize = 5;
|
||||
|
||||
fn lock<T>(mutex: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
|
||||
mutex.lock().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
/// Before a draw of `pipeline` into `target` alone (no depth), with frame
|
||||
/// generation: if `target` is a texture the title presents and the draw is
|
||||
/// the title's interface composite ([`INTERFACE_COMPOSITE`]; `triangle`: one
|
||||
/// triangle, one instance), the target as it is now, the frame without the
|
||||
/// interface, is copied into a texture of ours, recorded into `list` in
|
||||
/// front of the draw; the present after the list's submission tags it as
|
||||
/// the colour without the interface. One copy a list. Other pipelines that
|
||||
/// draw into a presented texture are named in the log once each: the
|
||||
/// interface is in the copy if one of them draws it before the composite.
|
||||
pub(crate) fn before_target_draw(
|
||||
list: &crate::host::HostList,
|
||||
target: crate::object::This,
|
||||
pipeline: &crate::pipeline::host::HostPipeline,
|
||||
triangle: bool,
|
||||
) {
|
||||
let Some(texture) = crate::resource::host_resource(target) else { return };
|
||||
let shown = texture.as_raw() as usize;
|
||||
if !SHOWN.iter().any(|s| s.load(Relaxed) == shown) {
|
||||
return;
|
||||
}
|
||||
let composite = triangle && INTERFACE_COMPOSITE.iter().all(|hash| pipeline.stages.iter().any(|s| s.shader.hash == *hash));
|
||||
if !composite {
|
||||
HUD_COUNTS[HUD_OTHERS].fetch_add(1, Relaxed);
|
||||
static SEEN: Mutex<Vec<usize>> = Mutex::new(Vec::new());
|
||||
let key = std::ptr::from_ref(pipeline) as usize;
|
||||
let mut seen = lock(&SEEN);
|
||||
if !seen.contains(&key) && seen.len() < 24 {
|
||||
seen.push(key);
|
||||
tracing::info!(
|
||||
pipeline = %pipeline.name,
|
||||
state = %pipeline.state,
|
||||
triangle,
|
||||
after_the_copy_in_its_list = list.hudless() != 0,
|
||||
"DLSS Frame Generation: this pipeline draws into the texture the title presents (the scene's composite does; an interface drawn here before the interface composite would be in the colour without the interface)"
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
HUD_COUNTS[HUD_COMPOSITES].fetch_add(1, Relaxed);
|
||||
if list.hudless() != 0 {
|
||||
HUD_COUNTS[HUD_AGAIN].fetch_add(1, Relaxed);
|
||||
return;
|
||||
}
|
||||
let began = std::time::Instant::now();
|
||||
let id = HUD_NEXT_ID.fetch_add(1, Relaxed) + 1;
|
||||
let Some(copy) = hudless_texture(texture, id) else { return };
|
||||
// The target as a copy's source: the composite's own preparation makes
|
||||
// it a render target again.
|
||||
const COPY_SOURCE: u32 = 0x800;
|
||||
crate::list::ensure_state(list, target, COPY_SOURCE);
|
||||
// SAFETY: an open list; the source is in the copy source state in it,
|
||||
// ours stays a copy's destination; same size, one level, formats of one
|
||||
// family.
|
||||
unsafe { list.list.CopyResource(©, texture) };
|
||||
list.keep(©);
|
||||
list.keep(texture);
|
||||
let mut pending = lock(&HUD_PENDING);
|
||||
pending.retain(|c| id.saturating_sub(c.id) < 16);
|
||||
pending.push(Copied { id, target: shown, texture: copy });
|
||||
drop(pending);
|
||||
list.mark_hudless(id);
|
||||
HUD_COUNTS[HUD_COPIES].fetch_add(1, Relaxed);
|
||||
spent(T_COPY, began);
|
||||
// SAFETY: a live texture.
|
||||
let desc = unsafe { texture.GetDesc() };
|
||||
once!(
|
||||
info,
|
||||
width = desc.Width,
|
||||
height = desc.Height,
|
||||
format = desc.Format.0,
|
||||
pipeline = %pipeline.name,
|
||||
state = %pipeline.state,
|
||||
"DLSS Frame Generation: the colour without the interface is copied in front of the title's interface composite (first time)"
|
||||
);
|
||||
}
|
||||
|
||||
/// One of the two textures the colour without the interface is copied to
|
||||
/// (copy `id`'s), made like `target` in the swap chain's format; `None` if
|
||||
/// `target` is no plain 2D texture of a format that is shown.
|
||||
fn hudless_texture(target: &ID3D12Resource, id: u64) -> Option<ID3D12Resource> {
|
||||
// SAFETY: a live texture.
|
||||
let desc = unsafe { target.GetDesc() };
|
||||
let plain = desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D
|
||||
&& desc.DepthOrArraySize == 1
|
||||
&& desc.MipLevels == 1
|
||||
&& desc.SampleDesc.Count == 1;
|
||||
let format = crate::host::swap_format(desc.Format).filter(|_| plain);
|
||||
let Some(format) = format else {
|
||||
once!(
|
||||
warn,
|
||||
format = desc.Format.0,
|
||||
levels = desc.MipLevels,
|
||||
samples = desc.SampleDesc.Count,
|
||||
"DLSS Frame Generation: the presented texture cannot be copied for the colour without the interface; none is tagged"
|
||||
);
|
||||
return None;
|
||||
};
|
||||
let size = [desc.Width as u32, desc.Height];
|
||||
let mut textures = lock(&HUD_TEXTURES);
|
||||
if textures.as_ref().is_none_or(|t| t.size != size || t.format != format.0) {
|
||||
let device = &crate::host::host()?.device;
|
||||
let make = || texture(device, size, format, D3D12_RESOURCE_FLAG_NONE, COPY_DEST);
|
||||
match (make(), make()) {
|
||||
(Ok(a), Ok(b)) => *textures = Some(HudlessTextures { size, format: format.0, textures: [a, b] }),
|
||||
(Err(e), _) | (_, Err(e)) => {
|
||||
once!(warn, error = %e, "DLSS Frame Generation: no texture for the colour without the interface; none is tagged");
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
textures.as_ref().map(|t| t.textures[(id % 2) as usize].clone())
|
||||
}
|
||||
|
||||
/// A host list that recorded copy `id` of the colour without the interface
|
||||
/// is submitted (in submission order, before the present that follows it).
|
||||
pub(crate) fn hudless_submitted(id: u64) {
|
||||
let copied = {
|
||||
let mut pending = lock(&HUD_PENDING);
|
||||
let at = pending.iter().position(|c| c.id == id);
|
||||
at.map(|i| pending.swap_remove(i))
|
||||
};
|
||||
if let Some(copied) = copied {
|
||||
let mut submitted = lock(&HUD_SUBMITTED);
|
||||
if submitted.len() >= 8 {
|
||||
submitted.remove(0);
|
||||
}
|
||||
submitted.push(copied);
|
||||
}
|
||||
}
|
||||
|
||||
/// At a present of host texture `shown`: it is one the title presents
|
||||
/// ([`SHOWN`]), and the first copy of it submitted since its last present,
|
||||
/// if any, is the frame's colour without the interface.
|
||||
fn hudless_for(shown: &ID3D12Resource) -> Option<ID3D12Resource> {
|
||||
let shown = shown.as_raw() as usize;
|
||||
if !SHOWN.iter().any(|s| s.load(Relaxed) == shown) {
|
||||
SHOWN[SHOWN_NEXT.fetch_add(1, Relaxed) as usize % SHOWN.len()].store(shown, Relaxed);
|
||||
}
|
||||
let mut submitted = lock(&HUD_SUBMITTED);
|
||||
let first = submitted.iter().position(|c| c.target == shown).map(|i| submitted.remove(i));
|
||||
submitted.retain(|c| c.target != shown);
|
||||
first.map(|c| c.texture)
|
||||
}
|
||||
|
||||
/// The planes a present shows (Series S: the scene and the interface over
|
||||
/// it), the host states they are in, and the back buffer's size.
|
||||
pub(crate) struct Planes<'a> {
|
||||
@@ -1077,16 +1345,23 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>) -> Option<Presentin
|
||||
// The tagged textures' states are those the submissions before this
|
||||
// present left: only the line of submissions orders the two.
|
||||
if !crate::queue::line_on() && !CHECKING.load(Relaxed) {
|
||||
HUDLESS_WANTED.store(false, Relaxed);
|
||||
once!(warn, "DLSS Frame Generation: the line of submissions did not start; frame generation stays off");
|
||||
return None;
|
||||
}
|
||||
// Where the interface is no plane of its own (Series X): the copy of
|
||||
// this texture taken in front of the title's interface composite.
|
||||
let hudless = if planes.overlay.is_none() && hudless_wanted() { hudless_for(planes.base.0) } else { None };
|
||||
let (sl, functions) = (SL.get()?, FUNCTIONS.get()?);
|
||||
let (set_options, marker) = (functions.dlssg_set_options?, functions.pcl_set_marker?);
|
||||
let began = std::time::Instant::now();
|
||||
let frame = frame as u32;
|
||||
let token = frame_token(sl, frame)?;
|
||||
let mark = |m: u32| {
|
||||
let began = std::time::Instant::now();
|
||||
// SAFETY: a marker for a token of ours.
|
||||
unsafe { marker(m, token) };
|
||||
spent(T_MARKERS, began);
|
||||
};
|
||||
let mut calls = calls();
|
||||
if calls.simulating != Some(frame) {
|
||||
@@ -1107,6 +1382,9 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>) -> Option<Presentin
|
||||
let on = if let Some((id, depth, motion, camera)) = fresh {
|
||||
PRESENTED_ID.store(id, Relaxed);
|
||||
let plan = PLAN.get()?;
|
||||
// (Frame generation reads the camera's planes and matrices: the
|
||||
// nearer plane is the near one, whichever way the title names them.)
|
||||
let camera = camera.planes_in_order();
|
||||
let constants = camera.constants(plan.asked.jitter, plan.asked.mvec);
|
||||
// SAFETY: constants for this frame and viewport.
|
||||
let code = unsafe { (sl.set_constants)(&constants, token, &viewport) };
|
||||
@@ -1123,6 +1401,15 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>) -> Option<Presentin
|
||||
if let Some((over, over_state)) = planes.overlay {
|
||||
resources.push((abi::Resource::texture(planes.base.0.as_raw(), planes.base.1), abi::BUFFER_HUDLESS_COLOR, planes.size));
|
||||
resources.push((abi::Resource::texture(over.as_raw(), over_state), abi::BUFFER_UI_COLOR_AND_ALPHA, planes.size));
|
||||
} else if let Some(copy) = &hudless {
|
||||
// One plane with the interface drawn into it: the copy taken in
|
||||
// front of the interface composite (ours, always a copy's
|
||||
// destination; Streamline holds it until the tags of the frame
|
||||
// go).
|
||||
resources.push((abi::Resource::texture(copy.as_raw(), COPY_DEST), abi::BUFFER_HUDLESS_COLOR, planes.size));
|
||||
HUD_COUNTS[HUD_TAGGED].fetch_add(1, Relaxed);
|
||||
} else if hudless_wanted() {
|
||||
HUD_COUNTS[HUD_MISSING].fetch_add(1, Relaxed);
|
||||
}
|
||||
let tags: Vec<abi::ResourceTag> = resources
|
||||
.iter_mut()
|
||||
@@ -1140,6 +1427,15 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>) -> Option<Presentin
|
||||
output = ?camera.output,
|
||||
back_buffer = ?planes.size,
|
||||
interface_plane = planes.overlay.is_some(),
|
||||
interface_free_copy = hudless.is_some(),
|
||||
depth_state = format_args!("{:#x}", resources[0].0.state),
|
||||
motion_state = format_args!("{:#x}", resources[1].0.state),
|
||||
near = constants.camera_near,
|
||||
far = constants.camera_far,
|
||||
fov = constants.camera_fov,
|
||||
depth_inverted = camera.depth_inverted(),
|
||||
jitter = ?constants.jitter_offset,
|
||||
mvec_scale = ?constants.mvec_scale,
|
||||
"DLSS Frame Generation: first frame with depth and motion vectors tagged"
|
||||
);
|
||||
code == 0
|
||||
@@ -1170,15 +1466,63 @@ pub(crate) fn present_begins(frame: u64, planes: Planes<'_>) -> Option<Presentin
|
||||
}
|
||||
if calls.framegen_on {
|
||||
FG_ON.fetch_add(1, Relaxed);
|
||||
FG_ON_ALL.fetch_add(1, Relaxed);
|
||||
// What it takes of the card's memory: before its first present and
|
||||
// some seconds of presents later.
|
||||
let presents = FG_ON_ALL.fetch_add(1, Relaxed) + 1;
|
||||
if (presents == 1 || presents == 240)
|
||||
&& !CHECKING.load(Relaxed)
|
||||
&& let Some(host) = crate::host::host()
|
||||
{
|
||||
host.log_video_memory(if presents == 1 {
|
||||
"right before the first present with frame generation on"
|
||||
} else {
|
||||
"240 presents with frame generation on later"
|
||||
});
|
||||
}
|
||||
} else {
|
||||
FG_OFF.fetch_add(1, Relaxed);
|
||||
}
|
||||
drop(calls);
|
||||
mark(abi::PRESENT_START);
|
||||
spent(T_BEFORE, began);
|
||||
Some(Presenting { token, frame })
|
||||
}
|
||||
|
||||
// Since the last frame-rate line, microseconds: on the presenting thread
|
||||
// before the present (of them in the latency markers), in the present call
|
||||
// (and the longest), after it (of them asking frame generation's state); on
|
||||
// the threads that record upscalings, recording one (of them waiting for our
|
||||
// lock); recording the copy of the colour without the interface.
|
||||
static TIMES: [AtomicU64; 9] = [const { AtomicU64::new(0) }; 9];
|
||||
const T_BEFORE: usize = 0;
|
||||
const T_MARKERS: usize = 1;
|
||||
const T_PRESENT: usize = 2;
|
||||
const T_PRESENT_LONGEST: usize = 3;
|
||||
const T_AFTER: usize = 4;
|
||||
const T_STATE: usize = 5;
|
||||
const T_UPSCALE: usize = 6;
|
||||
const T_UPSCALE_LOCK: usize = 7;
|
||||
const T_COPY: usize = 8;
|
||||
|
||||
fn spent(slot: usize, since: std::time::Instant) {
|
||||
TIMES[slot].fetch_add(since.elapsed().as_micros() as u64, Relaxed);
|
||||
}
|
||||
|
||||
/// When the present call of a frame [`present_begins`] began begins: `None`
|
||||
/// without frame generation (nothing is timed then).
|
||||
pub(crate) fn present_called(presenting: &Option<Presenting>) -> Option<std::time::Instant> {
|
||||
presenting.is_some().then(std::time::Instant::now)
|
||||
}
|
||||
|
||||
/// The present call that began at `called` returned.
|
||||
pub(crate) fn present_returned(called: Option<std::time::Instant>) {
|
||||
if let Some(called) = called {
|
||||
let took = called.elapsed().as_micros() as u64;
|
||||
TIMES[T_PRESENT].fetch_add(took, Relaxed);
|
||||
TIMES[T_PRESENT_LONGEST].fetch_max(took, Relaxed);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn present_error(error: *const i32) {
|
||||
// SAFETY: the error for the call.
|
||||
let code = unsafe { error.as_ref() }.copied().unwrap_or(0);
|
||||
@@ -1191,6 +1535,7 @@ pub(crate) fn present_ends(presenting: Option<Presenting>) {
|
||||
let Some(Presenting { token, frame }) = presenting else { return };
|
||||
let (Some(sl), Some(functions)) = (SL.get(), FUNCTIONS.get()) else { return };
|
||||
let (Some(marker), Some(get_state)) = (functions.pcl_set_marker, functions.dlssg_get_state) else { return };
|
||||
let began = std::time::Instant::now();
|
||||
// SAFETY: a marker for this frame's token.
|
||||
unsafe { marker(abi::PRESENT_END, token) };
|
||||
let mut calls = calls();
|
||||
@@ -1199,11 +1544,14 @@ pub(crate) fn present_ends(presenting: Option<Presenting>) {
|
||||
unsafe { marker(abi::SIMULATION_START, next) };
|
||||
calls.simulating = Some(frame.wrapping_add(1));
|
||||
}
|
||||
spent(T_MARKERS, began);
|
||||
if calls.framegen_on {
|
||||
let mut state = abi::DlssgState::default();
|
||||
let viewport = abi::ViewportHandle::new(VIEWPORT_FG);
|
||||
let asked = std::time::Instant::now();
|
||||
// SAFETY: a structure to fill, no options (no estimate asked).
|
||||
let code = unsafe { get_state(&viewport, &mut state, std::ptr::null()) };
|
||||
spent(T_STATE, asked);
|
||||
if code == 0 {
|
||||
FG_SHOWN.fetch_add(u64::from(state.num_frames_actually_presented), Relaxed);
|
||||
FG_SHOWN_ALL.fetch_add(u64::from(state.num_frames_actually_presented), Relaxed);
|
||||
@@ -1216,6 +1564,7 @@ pub(crate) fn present_ends(presenting: Option<Presenting>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
spent(T_AFTER, began);
|
||||
}
|
||||
|
||||
/// Our swap chain's buffers are about to be made again: frame generation is
|
||||
@@ -1245,13 +1594,48 @@ pub(crate) fn resizing() {
|
||||
/// stand-in depth and motion vectors tagged, frame generation on. The lines
|
||||
/// say what happened.
|
||||
pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
let mut lines = check_run(output, device, present);
|
||||
lines.extend(shut_down());
|
||||
lines
|
||||
}
|
||||
|
||||
/// The host device was made for [`check`].
|
||||
static CHECK_DEVICE: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// The end of [`check`] with a device: frame generation off, our swap chain
|
||||
/// let go, Streamline shut down (`slShutdown`), before the process ends.
|
||||
/// Streamline's guide asks for the shutdown before the devices go. Without
|
||||
/// it the process failed fast at its exit after `--present` (exit code
|
||||
/// 0xC0000409, which some shells show as 9), with frame generation on and
|
||||
/// its swap chain still up; with it the exit code is 0 (2026-11-27, SDK
|
||||
/// 2.14.16). Nothing of Streamline is called afterwards.
|
||||
/// `VICTORY_CHECK_TEARDOWN=0`: left out.
|
||||
fn shut_down() -> Option<String> {
|
||||
if !CHECK_DEVICE.load(Relaxed) || std::env::var("VICTORY_CHECK_TEARDOWN").is_ok_and(|v| v.trim() == "0") {
|
||||
return None;
|
||||
}
|
||||
let (sl, host) = (SL.get()?, crate::host::host()?);
|
||||
resizing();
|
||||
host.drop_presenter();
|
||||
for ready in [&FG_READY, &DLSS_READY, &SWAP_CHAIN_PROXIED, &HUDLESS_WANTED] {
|
||||
ready.store(false, Release);
|
||||
}
|
||||
*lock(&SUBMITTED) = None;
|
||||
lock(&HUD_SUBMITTED).clear();
|
||||
// SAFETY: initialised; nothing of it is in use or called from here on.
|
||||
let code = unsafe { (sl.shutdown)() };
|
||||
Some(format!("Streamline shut down: {} ({code})", abi::result_name(code)))
|
||||
}
|
||||
|
||||
fn check_run(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
let mut lines = Vec::new();
|
||||
let mut asked = match Asked::from_env() {
|
||||
Ok(asked) => asked,
|
||||
Err(why) => return vec![why],
|
||||
};
|
||||
asked.dlss = true;
|
||||
asked.framegen = true;
|
||||
// (`VICTORY_STREAMLINE_PRESENT=1` is for DLSS without frame generation.)
|
||||
asked.framegen = !asked.present_hook;
|
||||
let available = match load_and_init(&asked, false) {
|
||||
Ok(available) => available,
|
||||
Err(why) => return vec![format!("Streamline did not load from {}: {why}", asked.dir.display())],
|
||||
@@ -1260,7 +1644,13 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
"Streamline loaded from {}: DLSS {}, frame generation {} on this GPU",
|
||||
asked.dir.display(),
|
||||
if available.dlss { "supported" } else { "NOT supported" },
|
||||
if available.framegen { "supported" } else { "NOT supported" }
|
||||
if available.framegen {
|
||||
"supported"
|
||||
} else if asked.framegen {
|
||||
"NOT supported"
|
||||
} else {
|
||||
"not asked for (VICTORY_STREAMLINE_PRESENT=1)"
|
||||
}
|
||||
));
|
||||
if !device {
|
||||
return lines;
|
||||
@@ -1269,6 +1659,7 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
lines.push("no host D3D12 device".into());
|
||||
return lines;
|
||||
};
|
||||
CHECK_DEVICE.store(true, Relaxed);
|
||||
let (dlss, framegen) = (DLSS_READY.load(Acquire), FG_READY.load(Acquire));
|
||||
lines.push(format!("device handed over: DLSS ready {dlss}, frame generation ready {framegen} (queue through Streamline's device proxy)"));
|
||||
let render = asked.mode.render_size(output);
|
||||
@@ -1277,8 +1668,9 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
motion_scale: [render[0] as f32, render[1] as f32],
|
||||
render,
|
||||
output,
|
||||
near: 0.1,
|
||||
far: 10_000.0,
|
||||
// (The far plane first, as the title names them.)
|
||||
near: 10_000.0,
|
||||
far: 0.15,
|
||||
fov_y: 1.0,
|
||||
reset: true,
|
||||
flags: plan::FFX_HIGH_DYNAMIC_RANGE | plan::FFX_DEPTH_INVERTED | plan::FFX_AUTO_EXPOSURE,
|
||||
@@ -1317,7 +1709,14 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
textures[DEPTH] = Some((depth.clone(), SHADER_READ));
|
||||
textures[MOTION] = Some((motion.clone(), SHADER_READ));
|
||||
textures[OUTPUT] = Some((out, UNORDERED));
|
||||
for round in 0..3 {
|
||||
// (`VICTORY_STREAMLINE_PRESENT=1`: DLSS alone, with a present through
|
||||
// Streamline's proxy of our swap chain after each upscaling, more of
|
||||
// them than Streamline waits for a present.)
|
||||
let hooked = present && asked.present_hook && !framegen;
|
||||
for round in 0..if hooked { 120 } else { 3 } {
|
||||
if hooked && round > 0 {
|
||||
host.present_planes(&base, 0, None, round);
|
||||
}
|
||||
let id = NEXT_ID.fetch_add(1, Relaxed) + 1;
|
||||
let list = match host.new_list() {
|
||||
Ok(list) => list,
|
||||
@@ -1349,11 +1748,26 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
lines.push("DLSS ran three times on stand-in textures; the device is fine".into());
|
||||
lines.push(if hooked {
|
||||
format!(
|
||||
"DLSS ran 120 times on stand-in textures with a present after each; our swap chain is {}Streamline's proxy of it (VICTORY_STREAMLINE_PRESENT=1); the device is fine",
|
||||
if PRESENT_HOOKED.load(Relaxed) { "" } else { "NOT " }
|
||||
)
|
||||
} else {
|
||||
"DLSS ran three times on stand-in textures; the device is fine".into()
|
||||
});
|
||||
}
|
||||
if present && framegen {
|
||||
CHECKING.store(true, Relaxed);
|
||||
let (on, shown) = (FG_ON_ALL.load(Relaxed), FG_SHOWN_ALL.load(Relaxed));
|
||||
// A stand-in for the colour without the interface, tagged as the
|
||||
// copies in front of the title's interface composite are: ours, a
|
||||
// copy's destination, of the back buffer's size and format.
|
||||
let copy = {
|
||||
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
texture(device, output, DXGI_FORMAT_R8G8B8A8_UNORM, D3D12_RESOURCE_FLAG_NONE, COPY_DEST).ok()
|
||||
};
|
||||
let tagged = HUD_COUNTS[HUD_TAGGED].load(Relaxed);
|
||||
for frame in 1..=180u64 {
|
||||
let id = NEXT_ID.fetch_add(1, Relaxed) + 1;
|
||||
*SUBMITTED.lock().unwrap_or_else(|e| e.into_inner()) = Some(Noted {
|
||||
@@ -1362,14 +1776,18 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
motion: Source::Fixed(motion.clone(), SHADER_READ),
|
||||
camera,
|
||||
});
|
||||
if let Some(copy) = © {
|
||||
lock(&HUD_SUBMITTED).push(Copied { id: frame, target: base.as_raw() as usize, texture: copy.clone() });
|
||||
}
|
||||
host.present_planes(&base, 0, None, frame);
|
||||
std::thread::sleep(std::time::Duration::from_millis(16));
|
||||
}
|
||||
crate::host::settle_for_fence();
|
||||
lines.push(format!(
|
||||
"frame generation: 180 presents, {} with it on, {} frames shown by it, status {:#x} (0 is fine){}",
|
||||
"frame generation: 180 presents, {} with it on, {} frames shown by it, {} presents tagged with a colour without the interface, status {:#x} (0 is fine){}",
|
||||
FG_ON_ALL.load(Relaxed) - on,
|
||||
FG_SHOWN_ALL.load(Relaxed) - shown,
|
||||
HUD_COUNTS[HUD_TAGGED].load(Relaxed) - tagged,
|
||||
FG_STATUS.load(Relaxed),
|
||||
if SWAP_CHAIN_PROXIED.load(Relaxed) { "" } else { "; the swap chain is NOT Streamline's proxy" }
|
||||
));
|
||||
@@ -1385,6 +1803,7 @@ pub fn check(output: [u32; 2], device: bool, present: bool) -> Vec<String> {
|
||||
|
||||
const SHADER_READ: u32 = 0xc0;
|
||||
const UNORDERED: u32 = 0x8;
|
||||
const COPY_DEST: u32 = 0x400;
|
||||
|
||||
/// A stand-in texture for [`check`] (its contents are whatever the memory held).
|
||||
fn texture(
|
||||
@@ -1435,5 +1854,31 @@ pub(crate) fn line(frames: f64) {
|
||||
FG_STATUS.load(Relaxed),
|
||||
if FG_READY.load(Relaxed) && SWAP_CHAIN_PROXIED.load(Relaxed) { "" } else { "; not running (see above)" }
|
||||
);
|
||||
// Where the time of a frame goes in Streamline's calls.
|
||||
let t: Vec<u64> = TIMES.iter().map(|t| t.swap(0, Relaxed)).collect();
|
||||
if on + off > 0 {
|
||||
let ms = |slot: usize| t[slot] as f64 / 1000.0 / frames;
|
||||
tracing::info!(
|
||||
"DLSS Frame Generation, time per frame: the presenting thread {:.2} ms before the present call, {:.2} ms in it (the longest {:.1} ms), {:.2} ms after it; of those {:.2} ms in the latency markers and {:.2} ms asking frame generation's state; an upscaling recorded in {:.2} ms ({:.2} ms of it waiting for the lock it shares with the present); the copy of the colour without the interface recorded in {:.3} ms",
|
||||
ms(T_BEFORE),
|
||||
ms(T_PRESENT),
|
||||
t[T_PRESENT_LONGEST] as f64 / 1000.0,
|
||||
ms(T_AFTER),
|
||||
ms(T_MARKERS),
|
||||
ms(T_STATE),
|
||||
ms(T_UPSCALE),
|
||||
ms(T_UPSCALE_LOCK),
|
||||
ms(T_COPY)
|
||||
);
|
||||
}
|
||||
// Every tenth line (about ten seconds): the colour without the
|
||||
// interface, where the title draws the interface into the frame.
|
||||
static LINES: AtomicU32 = AtomicU32::new(0);
|
||||
if hudless_wanted() && LINES.fetch_add(1, Relaxed) % 10 == 9 {
|
||||
let [copies, tagged, missing, composites, again, others] = [0, 1, 2, 3, 4, 5].map(|i| HUD_COUNTS[i].swap(0, Relaxed));
|
||||
tracing::info!(
|
||||
"DLSS Frame Generation, colour without the interface, last ten lines: {copies} copies in front of the title's interface composite, {tagged} presents tagged with one, {missing} presents with frame generation on had none; {composites} interface composite draws into a presented texture ({again} after a copy in their list), {others} draws of other pipelines into one"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,6 +197,20 @@ impl Camera {
|
||||
self.flags & FFX_DISPLAY_RESOLUTION_MOTION_VECTORS != 0
|
||||
}
|
||||
|
||||
/// The camera with its nearer plane as the near one. FidelityFX takes
|
||||
/// the two distances in either order (its upscaler reads the smaller as
|
||||
/// the near plane and lets the inverted-depth flag say which end of the
|
||||
/// depth range it is), and the title, whose depth is inverted, names the
|
||||
/// far plane first (near 10000, far 0.15 in the first dispatch of
|
||||
/// 2026-11-26). Streamline's constants name them as they are.
|
||||
pub fn planes_in_order(&self) -> Camera {
|
||||
let mut camera = *self;
|
||||
if self.near > self.far && self.far > 0.0 {
|
||||
(camera.near, camera.far) = (self.far, self.near);
|
||||
}
|
||||
camera
|
||||
}
|
||||
|
||||
/// The size the motion vectors cover.
|
||||
pub fn motion_size(&self) -> [u32; 2] {
|
||||
if self.display_motion_vectors() { self.output } else { self.render }
|
||||
@@ -462,6 +476,34 @@ mod tests {
|
||||
assert_eq!(invert(&[[0.0; 4]; 4]), None);
|
||||
}
|
||||
|
||||
/// The title names the far plane first (inverted depth): in order, the
|
||||
/// projection puts the nearer plane at depth 1 and the farther at 0; as
|
||||
/// named, it took the farther for the near plane of an endless range.
|
||||
#[test]
|
||||
fn planes_named_far_first_are_put_in_order() {
|
||||
let mut named = camera(FFX_DEPTH_INVERTED);
|
||||
(named.near, named.far) = (10_000.0, 0.15);
|
||||
let ordered = named.planes_in_order();
|
||||
assert_eq!((ordered.near, ordered.far), (0.15, 10_000.0));
|
||||
assert_eq!(ordered.planes_in_order(), ordered);
|
||||
let c = ordered.constants([1.0, 1.0], [1.0, 1.0]);
|
||||
assert_eq!((c.camera_near, c.camera_far), (0.15, 10_000.0));
|
||||
let depth = |z: f32| {
|
||||
let m = &c.camera_view_to_clip;
|
||||
(z * m[2][2] + m[3][2]) / (z * m[2][3] + m[3][3])
|
||||
};
|
||||
assert!((depth(0.15) - 1.0).abs() < 1e-5 && depth(10_000.0).abs() < 1e-5);
|
||||
// As named: an endless range from 10000 on.
|
||||
let wrong = named.constants([1.0, 1.0], [1.0, 1.0]);
|
||||
assert_eq!(wrong.camera_view_to_clip[3][2], 10_000.0);
|
||||
// An endless far plane, or a plane at 0, is left alone.
|
||||
let mut endless = camera(FFX_DEPTH_INVERTED);
|
||||
(endless.near, endless.far) = (0.15, f32::MAX);
|
||||
assert_eq!(endless.planes_in_order(), endless);
|
||||
(endless.near, endless.far) = (0.15, 0.0);
|
||||
assert_eq!(endless.planes_in_order(), endless);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multiplier_pairs() {
|
||||
assert_eq!(pair(None), [1.0, 1.0]);
|
||||
|
||||
@@ -232,6 +232,16 @@ extern "C" fn ffxCreateContext(context: *mut *mut c_void, desc: *mut Header, mem
|
||||
call(desc)
|
||||
};
|
||||
if code != OK || context.is_null() {
|
||||
// Frame generation without DLSS leaves the upscaling to the title's
|
||||
// own FidelityFX, which is made for the Series S sizes only.
|
||||
if code != OK && !streamline::upscaling() {
|
||||
tracing::error!(
|
||||
code,
|
||||
max_render = ?asked.max_render,
|
||||
max_output = ?asked.max_output,
|
||||
"FidelityFX: the title's own upscaler was not made at these sizes (its shipping FSR4 takes 1280x720 or 1920x1080 in, 1920x1080 out): with frame generation at another output size, set VICTORY_DLSS=1 as well; the title fails at its first upscaling without an upscaler"
|
||||
);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
// SAFETY: the context was made.
|
||||
|
||||
+151
-6
@@ -37,7 +37,15 @@ own upscaling and our plain present run as before.
|
||||
three times on stand-in textures.
|
||||
- `victory upscaler-check --present`: as `--device`, then three seconds of
|
||||
presents in a window of ours with frame generation on stand-in depth and
|
||||
motion vectors; it reports how many frames frame generation showed.
|
||||
motion vectors and a stand-in colour without the interface; it reports how
|
||||
many frames frame generation showed and how many presents were tagged
|
||||
with that colour. With a device, the check ends by switching frame
|
||||
generation off, letting the swap chain go and calling `slShutdown`
|
||||
(`VICTORY_CHECK_TEARDOWN=0`: not; the process then fails fast at its
|
||||
exit, code 0xC0000409, which some shells show as 9).
|
||||
- `VICTORY_STREAMLINE_PRESENT=1` with `--present`: DLSS alone, 120
|
||||
upscalings with a present after each through Streamline's proxy of our
|
||||
swap chain (no "presentCommon() was not observed" may follow).
|
||||
|
||||
Windows 10 2004 or later, a GeForce RTX GPU (frame generation: RTX 40 or
|
||||
later), hardware-accelerated GPU scheduling on (frame generation needs it).
|
||||
@@ -56,6 +64,8 @@ later), hardware-accelerated GPU scheduling on (frame generation needs it).
|
||||
| `VICTORY_DLSS_MV` | `x,y` | `1,1` | multipliers for the motion-vector scale |
|
||||
| `VICTORY_DLSS_REACTIVE` | `0` | on | `0`: the title's reactive mask is not given to DLSS |
|
||||
| `VICTORY_FSR_PATH` | `1` | off | the title's FidelityFX path at `VICTORY_DLSS_MODE`'s scale with its own FidelityFX (no Streamline): the comparison for DLSS |
|
||||
| `VICTORY_FRAMEGEN_HUDLESS` | `0` | on (with `VICTORY_FRAMEGEN=1`) | `0`: no colour without the interface is copied or tagged on Series X (generated frames then warp the interface) |
|
||||
| `VICTORY_STREAMLINE_PRESENT` | `1` | off | DLSS without frame generation: our swap chain is Streamline's proxy of it, so Streamline sees the presents (no "presentCommon() was not observed") |
|
||||
|
||||
## How it works
|
||||
|
||||
@@ -121,8 +131,44 @@ without a new upscaling (menus, loads) switches it off and clears the tags.
|
||||
Reflex low latency is on (frame generation needs it); `slReflexSleep` is not
|
||||
called. On Series S, whose interface is a second plane, the scene plane is the
|
||||
colour without the interface and the interface plane its colour and alpha
|
||||
(premultiplied, as our composer blends them). On Series X the interface is
|
||||
drawn into the scene's output: no interface-free colour is tagged yet.
|
||||
(premultiplied, as our composer blends them).
|
||||
|
||||
**The colour without the interface on Series X.** There the title keeps the
|
||||
interface in a target of its own (3840x2160, RGBA8, with its own depth) and
|
||||
blends it over the frame itself: one triangle with the shaders vertex
|
||||
`0602c2384acbb3b2`, pixel `a78d088fa55aa495` (blend one, 1 - source alpha: the
|
||||
interface target is premultiplied), the last draw into the texture it presents,
|
||||
after the scene's composite into that texture. Every frame listing of
|
||||
2026-11-26 has it once a frame (stock 3840x2160 output), and the 1440p runs
|
||||
with DLSS bind the same pipeline from frame 3 on. With frame generation
|
||||
(`crate::streamline::before_target_draw`, called by `draw::State::draw`): in
|
||||
front of that draw, when its one target is a texture the title presented
|
||||
before, the target is copied into a texture of ours (two, in turn; the back
|
||||
buffer's size and format, always a copy's destination), recorded into the
|
||||
title's list at that place. A list makes one copy. When the list is submitted
|
||||
the copy is noted, and the present of that texture tags the first copy
|
||||
submitted since its last present as `kBufferTypeHUDLessColor`. Other pipelines
|
||||
that draw into a presented texture are named in the log once each: an interface
|
||||
element drawn there before the composite would be in the copy, one drawn after
|
||||
it is warped as before. The interface target is not tagged as the interface's
|
||||
colour and alpha: its size is not the back buffer's at a 1440p output.
|
||||
|
||||
**The camera's planes.** The title names the far plane first (near 10000, far
|
||||
0.15, inverted depth), which FidelityFX takes in either order. Frame
|
||||
generation's constants get them in order (near 0.15, far 10000), and the
|
||||
projection made of them; DLSS Super Resolution's are as before.
|
||||
|
||||
**Windowed and full screen.** With frame generation the system's Alt+Enter is
|
||||
not taken for the window (`DXGI_MWA_NO_ALT_ENTER`): Streamline wants frame
|
||||
generation off across such a change. When the presented size or format
|
||||
changes, frame generation is switched off before the swap chain's buffers are
|
||||
made again, and on again at the next present with an upscaling.
|
||||
|
||||
**Frame generation alone** (`VICTORY_FRAMEGEN=1` without `VICTORY_DLSS=1`)
|
||||
leaves the upscaling to the title's own FidelityFX, which is made for the
|
||||
Series S sizes only (1280x720 or 1920x1080 in, 1920x1080 out): at a 1440p
|
||||
output its upscaler is not made (an error in the log says so) and the title
|
||||
fails at its first upscaling. Use both switches there.
|
||||
|
||||
## Log lines
|
||||
|
||||
@@ -140,19 +186,118 @@ upscalings by DLSS, … failed, … left to the title's FidelityFX` and `DLSS Fr
|
||||
Generation: … presents with it on, … off, … frames shown by it (status …)`.
|
||||
`FidelityFX: the title's own upscaling runs: <why>` names each reason once.
|
||||
|
||||
Frame generation: `DLSS Frame Generation switched frame=… on=… code=…` at each
|
||||
change; `DLSS Frame Generation: first frame with depth and motion vectors
|
||||
tagged` (sizes, the states of the two textures, near, far, jitter,
|
||||
motion-vector scale, `interface_plane`, `interface_free_copy`); `video memory
|
||||
as the system counts it, right before the first present with frame generation
|
||||
on` and `… 240 presents with frame generation on later`; `DLSS Frame
|
||||
Generation status changed` (anything but 0 is a fault); `DLSS Frame Generation:
|
||||
a present failed hresult=…`. Series X: `DLSS Frame Generation: the colour
|
||||
without the interface is copied in front of the title's interface composite
|
||||
(first time)` (size, format, pipeline), `DLSS Frame Generation: this pipeline
|
||||
draws into the texture the title presents` (once per pipeline), and every ten
|
||||
frame-rate lines `DLSS Frame Generation, colour without the interface, last ten
|
||||
lines: … copies in front of the title's interface composite, … presents tagged
|
||||
with one, … presents with frame generation on had none; … interface composite
|
||||
draws into a presented texture (… after a copy in their list), … draws of other
|
||||
pipelines into one`.
|
||||
|
||||
## The first run with frame generation in the title
|
||||
|
||||
Switches: `VICTORY_DLSS=1 VICTORY_DLSS_MODE=quality VICTORY_FRAMEGEN=1
|
||||
VICTORY_THIN=1 VICTORY_NATIVE_1440P=1`, Series X (the launcher: `-FrameGen`).
|
||||
Before it, once: `victory upscaler-check --present` (below, line 1).
|
||||
|
||||
1. Without the title: `frame generation: 180 presents, 180 with it on, 360
|
||||
frames shown by it, 180 presents tagged with a colour without the
|
||||
interface, status 0x0`, then `Streamline shut down: ok (0)`, exit code 0.
|
||||
(Fewer than 360 shown, 291 in one run of 2026-11-27, when the PC is busy:
|
||||
frame generation drops a generated frame that comes too late.)
|
||||
2. It started: `Streamline loaded … dlss=true framegen=true`, `Streamline: DLSS
|
||||
Frame Generation loaded`, `Streamline: Reflex low latency on … code=0`,
|
||||
`the direct queue was made through the device proxy`, `our swap chain is
|
||||
Streamline's proxy`. `frame generation stays off` or `not running (see
|
||||
above)` anywhere: it does not run; the line before says why.
|
||||
3. It switched on in the world: `DLSS Frame Generation switched … on=true
|
||||
code=0` at the first frame with an upscaling, then `first frame with depth
|
||||
and motion vectors tagged` with `near=0.15 far=10000`, `depth_inverted=true`,
|
||||
`interface_free_copy=true`.
|
||||
4. Generated frames are shown: each second `DLSS Frame Generation: N presents
|
||||
with it on, 0 off, 2N frames shown by it (status 0x0)`. `frames shown`
|
||||
equal to `presents`: none was generated. Our caption and frame-rate line
|
||||
count the title's frames only; NVIDIA's overlay or PresentMon shows twice
|
||||
that. (`DLSSG_IndicatorText`, a DWORD of 2 under
|
||||
`HKLM\SOFTWARE\NVIDIA Corporation\Global\NGXCore`, makes frame generation
|
||||
write its state on the picture.)
|
||||
5. No fault: no `DLSS Frame Generation status changed`, no `a present failed`,
|
||||
no line of target `streamline` at ERROR, no `presentCommon() was not
|
||||
observed`. A pink tint over the picture is frame generation's own sign of
|
||||
an invalid state.
|
||||
6. Off and on: at the pause menu, a load or a video, `DLSS Frame Generation
|
||||
switched … on=false` when the title stops upscaling and `on=true` when it
|
||||
upscales again; the per-second line then counts presents `off`. If the
|
||||
pause menu keeps upscaling, frame generation stays on behind it.
|
||||
7. The interface: the ten-second line has as many `copies` as `presents tagged
|
||||
with one`, about one per present with frame generation on, and `had none`
|
||||
near 0 in gameplay; the map, the subtitles and the prompts stand still and
|
||||
sharp while the camera turns. `this pipeline draws into the texture the
|
||||
title presents` should name one pipeline, the scene's composite (blend
|
||||
false); any other with `blend true` is an interface element drawn outside
|
||||
the interface target. Compare with `VICTORY_FRAMEGEN_HUDLESS=0`: the
|
||||
interface wobbles at the edges of moving things behind it.
|
||||
8. Motion vectors (`VICTORY_DLSS_MV`, default `1,1`): turn the camera slowly
|
||||
and evenly past upright edges (poles, door frames) and look at a still
|
||||
interface element's neighbourhood and at the edges. Right: edges stay
|
||||
single in every frame. Wrong sign or scale: every other frame shows the
|
||||
edge doubled or pulled the wrong way (a judder at half the shown rate), and
|
||||
DLSS itself smears a trail behind moving edges. Try `-1,1` (x flipped; turn
|
||||
left and right), `1,-1` (y flipped; look up and down), then `2,2` and
|
||||
`0.5,0.5` (scale): if `1,1` is right, each of them is visibly worse. The
|
||||
`DLSS: upscaling recorded` line has `mvec_scale` (1/1706, 1/960 at Quality:
|
||||
the title's vectors are in render pixels).
|
||||
9. Jitter (`VICTORY_DLSS_JITTER`, default `1,1`): stand still and look at fine
|
||||
detail (wire, lettering on signs, distant railings). Right: it settles
|
||||
within a second to a sharp, steady picture. Wrong sign: it stays soft and
|
||||
crawls. Try `-1,1`, `1,-1`, `-1,-1`; take the sharpest steady one. The
|
||||
jitter changes nothing for frame generation itself.
|
||||
10. Video memory: the two `video memory … frame generation on` lines; the
|
||||
difference of `in use` is what frame generation took (NVIDIA: about 489 MB
|
||||
at 1440p). `in use` over the budget of the card's own memory, or the PC's
|
||||
shared memory growing by hundreds of MB in the memory line, means it does
|
||||
not fit: use a smaller DLSS mode.
|
||||
11. A removed device: `host GPU device removed after …`, `; device removed:
|
||||
…`, `DLSS Frame Generation: a present failed hresult=0x887a0005` (removed),
|
||||
`0x887a0006` (hung) or `0x887a0007` (reset), the window gone with exit code
|
||||
0x887a0005. With `VICTORY_STREAMLINE_LOG=<folder>` Streamline's own log has
|
||||
the plugin's last words.
|
||||
|
||||
## Limits
|
||||
|
||||
- Motion vectors: blocks of wrong motion inside character silhouettes (likely
|
||||
the heat-haze pass `731a39171b568298`) show as smearing with DLSS and as
|
||||
warped shapes in generated frames.
|
||||
- No interface-free colour on Series X: generated frames warp the interface
|
||||
with the scene.
|
||||
- The colour without the interface on Series X is a copy in front of one
|
||||
known draw (the interface composite by its shaders, this build's); not yet
|
||||
seen running in the title. Interface drawn into the frame by another
|
||||
pipeline is not told apart. The interface's own colour and alpha are not
|
||||
tagged there.
|
||||
- Camera matrices are made, not the title's (see above).
|
||||
- "presentCommon() was not observed" (Streamline, once a run, with DLSS and no
|
||||
frame generation): our swap chain is not Streamline's then, so its common
|
||||
plugin sees no present; it frees nothing it retired (what DLSS let go of when
|
||||
the title's upscaler is destroyed stays allocated until the process ends).
|
||||
`VICTORY_STREAMLINE_PRESENT=1` gives it the presents.
|
||||
- HDR output (a 16-bit float swap chain) is not supported by frame generation
|
||||
(status 4).
|
||||
- Video memory: the title's FidelityFX context stays allocated beside DLSS's;
|
||||
frame generation needs about 0.5 GB more at 1440p.
|
||||
- Latency: frame generation holds a frame back; it is meant for a base frame
|
||||
rate of 60 and up.
|
||||
- `slShutdown` is not called; the process ends with the title.
|
||||
- `slShutdown` is not called in the title; the process ends with the title.
|
||||
Where the title leaves through the C runtime's exit with frame generation
|
||||
on, the process may fail fast at its very end as the check did without its
|
||||
shutdown (exit code 0xC0000409): no fault of the run before it.
|
||||
|
||||
Credits: the FidelityFX description layouts and the image patch of the
|
||||
FidelityFX path are DexNom's (DexNom/VIctory, GPL-3.0-or-later).
|
||||
Reference in new issue
Block a user