Skip to content
Draft
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Open **DexNom RayTime (FSR Quality 4K)** to use the tested Series X profile. It

The baseline was tested with a PC FidelityFX 4.1.2 provider. Put the provider and its dependencies in the installed runtime's `fidelityfx` subfolder or set `VICTORY_FIDELITYFX_DIR` to the folder containing `amd_fidelityfx_upscaler_dx12.dll`. The provider is supplied separately.

### Experimental AMD Frame Generation

Frame generation is off by default. In a diagnostics build, set `VICTORY_FIDELITYFX_FRAMEGEN=4` before launching the FSR Quality preset to request Frame Generation 4.0.2. Set it to `1` to try the analytical 3.x provider. Both modes use `amd_fidelityfx_framegeneration_dx12.dll` from the same SDK folder as the upscaler.

Frame generation requires an RGBA8 swap chain. Mode 4 also requires a supported GPU and a camera sample matching the current upscale. If the proxy or the requested provider is unavailable, the runtime logs the reason and continues with ordinary presentation.

For a manual launch, use the same flags as the Quality shortcut.

```powershell
Expand Down
32 changes: 32 additions & 0 deletions crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,34 @@ impl State {
out
}

#[cfg(feature = "diagnostics")]
fn record_framegen_camera(&self, list: &HostList) {
if !crate::framegen::ml_enabled() {
return;
}
let Some(pipeline) = crate::pipeline::host_pipeline(self.pipeline as This) else {
return;
};
// The 1.0.2.1 velocity pass is identified by its shader pair.
if !pipeline.stages.iter().any(|stage| stage.shader.hash == "4adcfeaa24ae6450")
|| !pipeline.stages.iter().any(|stage| stage.shader.hash == "9ab96b7a002d6ac8")
{
return;
}
let Some(Root::Table(table)) = self.roots_ref(false).get(1) else {
return;
};
let Some(handle) = table.checked_add(8 * 4) else {
return;
};
let Some(View::Constant(address, size)) = crate::descriptor::view(handle) else {
return;
};
if let Some(viewport) = self.viewports.first() {
crate::framegen::camera::record(list, address, size, [viewport.Width, viewport.Height]);
}
}

pub(crate) fn draw(
&mut self,
list: &HostList,
Expand All @@ -3176,6 +3204,10 @@ impl State {
};
#[cfg(feature = "diagnostics")]
list.note_op(|| self.op_text(format!("draw {count}x{instances}"), false));
#[cfg(feature = "diagnostics")]
if count == 3 && instances == 1 {
self.record_framegen_camera(list);
}
let frontend = if count == 3 && instances == 1 {
self.native_frontend_viewport()
} else {
Expand Down
75 changes: 74 additions & 1 deletion crates/victory-gpu/src/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,73 @@ pub fn prepare_input(list: *const Object, resource: *const Object) -> Option<()>
Some(())
}

/// The host list while a title command list is being recorded.
pub struct Recording<'a>(&'a crate::host::HostList);

impl Recording<'_> {
/// The open D3D12 list for the provider to record into.
pub fn list(&self) -> &ID3D12GraphicsCommandList {
&self.0.list
}

/// At a host upscale recorded here: its depth and motion textures
/// (title resources) and constants feed frame generation for the next
/// present, once this list has run. Nothing when it is off.
#[cfg(feature = "diagnostics")]
pub fn frame_generation_inputs(
&self,
depth: *const Object,
motion: *const Object,
frame: FrameInputs,
) {
if !crate::framegen::enabled() {
return;
}
let (Some(depth), Some(motion)) = (
crate::resource::host_copy(depth),
crate::resource::host_copy(motion),
) else {
return;
};
crate::framegen::record(
self.0,
crate::framegen::Inputs {
depth,
motion,
frame,
pose: None,
},
);
}
}

/// What frame generation needs of an upscaled frame besides its depth and
/// motion vectors: the upscale's constants (as its description has them)
/// and the motion and depth bits of its creation flags.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
#[cfg(feature = "diagnostics")]
pub struct FrameInputs {
pub render: [u32; 2],
pub jitter: [f32; 2],
pub motion_scale: [f32; 2],
pub frame_time_ms: f32,
pub reset: bool,
/// Near, far, vertical field of view, metres per view-space unit.
pub camera: [f32; 4],
pub flags: u32,
/// The FidelityFX descriptions of the depth and motion textures.
pub depth_desc: [u32; 8],
pub motion_desc: [u32; 8],
}

/// Turns on AMD frame generation for upscaled frames (diagnostics) with
/// `amd_fidelityfx_framegeneration_dx12.dll` from `dir`: the presenter's
/// swap chain becomes its proxy. The DLL's path, or why not.
#[cfg(feature = "diagnostics")]
pub fn use_frame_generation(dir: &std::path::Path, ml: bool) -> Result<String, String> {
crate::framegen::load(dir, ml)
}

/// The producer recorded its output on the host's command list.
pub fn output_written(resource: *const Object) {
crate::texture::host_written(resource);
Expand All @@ -63,9 +130,15 @@ pub fn record<R>(
list: *const Object,
f: impl FnOnce(&ID3D12GraphicsCommandList) -> R,
) -> Option<R> {
record_upscale(list, |recording| f(recording.list()))
}

/// As [`record`], with access to the frame generation inputs for a
/// successfully recorded upscale.
pub fn record_upscale<R>(list: *const Object, f: impl FnOnce(Recording<'_>) -> R) -> Option<R> {
let mut out = None;
crate::list::with_state(list, |host, state| {
out = Some(f(&host.list));
out = Some(f(Recording(host)));
state.host_state_lost();
});
out
Expand Down
Loading