D3D12.X command lists in the console's vtable layout

The console ID3D12GraphicsCommandList keeps PC slots 0-27 and 56-59, puts the query methods
right after ExecuteBundle (28-31 = PC 52-55) and so has SetDescriptorHeaps ... DiscardResource
4 slots later (32-55 = PC 28-51); List1 sits at 104-109 (PC 60-65), the shading-rate methods
at 124 / 125. XCL gave titles the PC layout, so e.g. the console SetDescriptorHeaps (#32) ran
PC SetGraphicsRootDescriptorTable. Layout as observed on Fortnite's RHI call sites; it agrees
with FSR4's ClearUnorderedAccessViewUint at #53.

- real::console_remap: title calls at a console slot run the PC method (with XCL's own
  overrides); the runtime keeps the PC entries.
- The test title calls the console layout (SetGraphicsRootSignature #34, OMSetRenderTargets
  #50, ClearRenderTargetView #52) – the triangle still renders and reads back.
- HANDOFF: PresentX, frame pacing and the command list layout.
This commit is contained in:
ivall
2026-11-21 18:47:53 +01:00
parent 5a5c32b977
commit 861869f585
3 changed files with 66 additions and 4 deletions
+23
View File
@@ -518,6 +518,29 @@ unknown records), the result read with `bvh::Bvh::trace` = brute force on 500 ra
## In progress (unfinished)
Nothing open.
## PresentX, frame pacing, the console command list layout (session 5, 2026-11-21; Fortnite is the next test title)
Slots and semantics as observed on Fortnite (UE RHI call sites); XCL's own evidence agrees where it has any.
- **PresentX = command queue #30** `(planeCount, planes, parameters)`, plane 0 `{ u64 frame token; u32 resource count @8;
ID3D12Resource** @0x10 }` → `present::present_x` presents that resource at once (S_OK always) and marks the token
flipped; the back-buffer guessing only runs until a title's first PresentX.
- **Frame clock = device #78–#81** (`d3d12x/frame.rs`): SetFrameIntervalX(output, µs, periodicity, flags) → S_FALSE
(16 667 / 33 333 / 50 000 / 66 667 µs; 8 333 / 25 000 only on a ≥ 119 Hz display, else E_INVALIDARG);
ScheduleFrameEventX(type 0 origin / 1 / 2, offset µs, ancillary `{ u32 count; HANDLE* @8; i32* signaled @0x10 }`,
flags 1 = unschedule) → S_FALSE, 0x10000000 when it starts the clock; WaitFrameEventX(type, timeout ms, ancillary,
flags 1 wait all / 2 token on timeout, token in/out) → S_OK / S_FALSE (timeout), a new 48-bit token at each origin;
GetFrameStatisticsX(token, type, count, stats `{ u32 type; i64 origin @0x10; i64 flip @0x18 }`). A clock thread
(high-resolution waitable timer + spin) releases the origin semaphore / sets the events and the ancillary handles;
not locked to the host vblank.
- **ID3D12GraphicsCommandList console layout** (`real::console_remap`): 0–27 and 56–59 as on PC; 28–31 = PC 52–55
(BeginQuery, EndQuery, ResolveQueryData, SetPredication); 32–55 = PC 28–51 (SetDescriptorHeaps … DiscardResource, so
SetGraphicsRootSignature #34, OMSetRenderTargets #50, ClearRenderTargetView #52, ClearUnorderedAccessViewUint #53 –
as FSR4 calls it); List1 at 104–109 (PC 60–65); shading rate 124 / 125 (PC 77 / 78). Title calls only (make_split);
the console-only methods in between (depth bounds 68, KickoffX 93, depth bias 94, …) stay guarded and are reported.
- Console slots past a class's public PC methods now work (inside the runtime's internal entries: title → console
method, runtime → its own). The test title calls the console layout (#34 / #50 / #52) and runs frame clock + PresentX.
- Next with the exe: the console-only command-list methods Fortnite calls (report.json lists them), title heaps /
placed resources at title addresses, occlusion queries (the console allows nesting them, PC does not).
## Contributions merged (session 5, 2026-11-21, PRs #5, #6, #8, part of #7)
- **#5** more RDNA2 instructions (scalar movrel / bitcmp / bfe64, d16 typed buffers, f64 ceil / fract / rndne / frexp /
sqrt / rsq / class, v_swaprel, pknorm f16…) with tests. Fixed on the GPU (RX 9070), where its GPU tests had not run:
+25
View File
@@ -456,6 +456,17 @@ unsafe fn class_for(obj: *mut c_void, orig: usize, kind: Kind) -> usize {
}
}
}
// the console's layout of the same PC methods (title calls only; the runtime keeps PC's)
let pc = v.clone();
for (x, p) in console_remap(kind) {
if x < public {
v[1 + x] = super::guard::make_split(pc[1 + p], pc[1 + x]);
} else if x < scanned {
v[1 + x] = super::guard::make_split(pc[1 + p], *ot.add(x));
} else if x < total {
v[1 + x] = pc[1 + p];
}
}
// slots where the console's method differs from the PC one at the same index
for (slot, f) in console_slots(kind) {
if slot < public {
@@ -504,6 +515,20 @@ unsafe fn class_for(obj: *mut c_void, orig: usize, kind: Kind) -> usize {
/// assumed to follow it (each checks its arguments and otherwise goes to the PC method).
/// * device #12 `CreateCommandList` (only with console lists on): console code gets a
/// console-shaped list (D3D12.X inline code writes into it), XCL's own code a PC one.
/// (console slot, PC slot) of PC methods that sit elsewhere in the console's vtable.
/// ID3D12GraphicsCommandList (from the Fortnite RHI call sites, matching XCL's own evidence
/// – FSR4 calls ClearUnorderedAccessViewUint at #53): 0–27 and 56–59 as on PC; the query
/// methods come right after ExecuteBundle (28–31 = PC 52–55: BeginQuery, EndQuery,
/// ResolveQueryData, SetPredication), so SetDescriptorHeaps … DiscardResource move up by 4
/// (32–55 = PC 28–51); ID3D12GraphicsCommandList1 is at 104–109 (PC 60–65), the shading-rate
/// methods at 124 / 125 (PC 77 / 78). The console-only methods in between stay guarded.
fn console_remap(kind: Kind) -> Vec<(usize, usize)> {
match kind {
Kind::CommandList => (28..=31).map(|x| (x, x + 24)).chain((32..=55).map(|x| (x, x - 4))).chain((104..=109).map(|x| (x, x - 44))).chain([(124, 77), (125, 78)]).collect(),
_ => Vec::new(),
}
}
fn console_slots(kind: Kind) -> Vec<(usize, usize)> {
match kind {
Kind::Device => {
+18 -4
View File
@@ -46,6 +46,19 @@ macro_rules! ensure {
($c:expr, $($m:tt)*) => { if !$c { return Err(format!($($m)*)); } };
}
/// A command list method at its console slot: from SetDescriptorHeaps (PC 28) on, the
/// console list has the PC methods 4 slots further (the query methods come first).
unsafe fn xslot<F: Copy>(list: &ID3D12GraphicsCommandList, slot: usize) -> F {
transmute_copy(&*(*(list.as_raw() as *const *const usize)).add(slot))
}
type OmSetRenderTargets = unsafe extern "system" fn(*mut c_void, u32, *const D3D12_CPU_DESCRIPTOR_HANDLE, i32, *const D3D12_CPU_DESCRIPTOR_HANDLE);
type ClearRtv = unsafe extern "system" fn(*mut c_void, D3D12_CPU_DESCRIPTOR_HANDLE, *const [f32; 4], u32, *const RECT);
type SetRootSignature = unsafe extern "system" fn(*mut c_void, *mut c_void);
const X_SET_GRAPHICS_ROOT_SIGNATURE: usize = 34;
const X_OM_SET_RENDER_TARGETS: usize = 50;
const X_CLEAR_RENDER_TARGET_VIEW: usize = 52;
fn e(x: windows::core::Error) -> String {
format!("{x}")
}
@@ -273,7 +286,7 @@ pub fn present_x_frame() -> Result<(), String> {
dev.CreateRenderTargetView(&bb, None, rtv);
let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(e)?;
let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, None).map_err(e)?;
list.ClearRenderTargetView(rtv, &[0.1, 0.5, 0.9, 1.0], None);
xslot::<ClearRtv>(&list, X_CLEAR_RENDER_TARGET_VIEW)(list.as_raw(), rtv, &[0.1, 0.5, 0.9, 1.0], 0, std::ptr::null());
// consoles want the back buffer in COMMON / PRESENT for PresentX
list.ResourceBarrier(&[D3D12_RESOURCE_BARRIER {
Type: D3D12_RESOURCE_BARRIER_TYPE_TRANSITION,
@@ -382,11 +395,12 @@ pub fn render_triangle() -> Result<(), String> {
let alloc: ID3D12CommandAllocator = dev.CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT).map_err(e)?;
let list: ID3D12GraphicsCommandList = dev.CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, &alloc, &pso).map_err(e)?;
list.OMSetRenderTargets(1, Some(&rtv), false, None);
list.ClearRenderTargetView(rtv, &[0.0, 0.0, 1.0, 1.0], None);
// console slots (OMSetRenderTargets #50, ClearRenderTargetView #52, SetGraphicsRootSignature #34)
xslot::<OmSetRenderTargets>(&list, X_OM_SET_RENDER_TARGETS)(list.as_raw(), 1, &rtv, 0, std::ptr::null());
xslot::<ClearRtv>(&list, X_CLEAR_RENDER_TARGET_VIEW)(list.as_raw(), rtv, &[0.0, 0.0, 1.0, 1.0], 0, std::ptr::null());
list.RSSetViewports(&[D3D12_VIEWPORT { TopLeftX: 0.0, TopLeftY: 0.0, Width: w as f32, Height: h as f32, MinDepth: 0.0, MaxDepth: 1.0 }]);
list.RSSetScissorRects(&[RECT { left: 0, top: 0, right: w as i32, bottom: h as i32 }]);
list.SetGraphicsRootSignature(&rs);
xslot::<SetRootSignature>(&list, X_SET_GRAPHICS_ROOT_SIGNATURE)(list.as_raw(), rs.as_raw());
list.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
list.DrawInstanced(3, 1, 0, 0);
let barrier = D3D12_RESOURCE_BARRIER {