upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/test/xmem_test.cpp
diff options
context:
space:
mode:
authoromardev29 <154835571+omardev29@users.noreply.github.com>2026-11-22 04:37:35 +0100
committeromardev29 <154835571+omardev29@users.noreply.github.com>2026-11-22 04:58:12 +0100
commit3da355d29089fdc747483de98b62aaa43ce55e12 (patch)
treee1decbcd51df7e877fb3726815a7b5d3f049512a /runtime/test/xmem_test.cpp
parent4a36bb19979b611f525d027f92e0fefad1626546 (diff)
FSR: Xbox backend descriptor, console command-list map, XMemGetWorkingSetStatistics and device slot 67
amd_fidelityfx_upscaler_xbox.dll, measured with Ghidra 12.2 (through REA) and run by fsr_dispatch_test on PC devices (RTX 2000 Ada and WARP) behind the Xbox-ABI proxy. Backend descriptor: the provider's create walks the chain for type 0x01000002, {header, device} with the device at +0x10, and ends in FFX_API_RETURN_ERROR without it (what RT-3 got with 0x0200000x). With it the DLL creates its backend through the proxy: device slots 14, 15, 18, 19, 27, 38 and 76 and heap slot 9, at the shapes the PC order and the measured overrides predict; slot 76 takes the seven CreateCommittedResource arguments. No earlier test here reached slot 76 or heap slot 9. Two runtime bugs it found: - XMemGetWorkingSetStatistics takes (kind, stats*): all seven call sites pass kind 0x20000001 in ECX and a stack buffer in RDX. The one-argument shim wrote to address 0x20000001. - Device slot 67 is a console-only compute-pipeline call (a code blob in its desc), not the PC CreateProtectedResourceSession1 the proxy forwarded it to. The proxy now refuses it (E_NOTIMPL). The context: on the RTX 2000 Ada the create stops at the DLL's HRESULT check, because the driver refuses its R9G9B9E5_SHAREDEXP texture with ALLOW_UNORDERED_ACCESS (WARP takes it). The test reports that stop and retries with one PC stand-in (that texture as R32_UINT). On the context it records one ffxDispatch into a logging command list that is never executed. The console command list, from that run and the DLL's recorder (RVA 0x59a0), the same 13 calls on both devices: slots 14, 15, 25 and 26 at their PC positions, then SetDescriptorHeaps at 32 (PC 28, seen in the run), SetComputeRootDescriptorTable at 35 (PC 31), ClearUnorderedAccessViewUint at 53 (PC 49, seen in the run), ExecuteIndirect at 61 (PC 59), and console-only methods at 85 and 141. 33 and 41 fit SetComputeRootSignature and SetComputeRootConstantBufferView by shape; the docs mark them inferred. The logging list forwards only measured slots. The list object also carries a write cursor and limits (+0x18, +0x28, +0x30) the DLL writes root arguments and dispatches through while there is room; with the cursor at the limit every command takes the vtable. These are the fields docs section 3.4 measured in the BVH builder without a meaning. The dispatch stops at the DLL's compute pipeline: its 29 shaders are DXBC with an ACCC part (payload tag FSPX) and no DXIL, and the PC runtime refuses them at slot 62; the dispatch goes on with the null pipeline and faults, which the test reports as the documented PC limit. Its C++ `throw` also shows the loader gap: _CxxThrowException finds no image base for a manually mapped image. The test's fault report gives the faulting module and RVA, the access, the C++ throw's ThrowInfo, image base and unwound stack, and the HRESULT the DLL formatted with the DLL frames that made the failing call. Docs: d3d12_vulkan.md Appendix A.3 and open question 2, d3d12_command_objects.md 3.4 and 3.5a, design.md and runtime/README.md.
Diffstat (limited to 'runtime/test/xmem_test.cpp')
-rw-r--r--runtime/test/xmem_test.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/runtime/test/xmem_test.cpp b/runtime/test/xmem_test.cpp
index 6fff5634b..4087df4d7 100644
--- a/runtime/test/xmem_test.cpp
+++ b/runtime/test/xmem_test.cpp
@@ -18,7 +18,9 @@ namespace {
18using XMemAllocFn = void*(__stdcall*)(size_t, uint64_t); 18using XMemAllocFn = void*(__stdcall*)(size_t, uint64_t);
19using XMemFreeFn = void(__stdcall*)(void*, uint64_t); 19using XMemFreeFn = void(__stdcall*)(void*, uint64_t);
20using XMemVirtualQueryFn = SIZE_T(__stdcall*)(HANDLE, const void*, void*); 20using XMemVirtualQueryFn = SIZE_T(__stdcall*)(HANDLE, const void*, void*);
21using XMemGetWorkingSetStatisticsFn = BOOL(__stdcall*)(void*); 21// BOOL XMemGetWorkingSetStatistics(UINT32 kind, stats*): the FSR DLL passes kind 0x20000001 at every call site.
22using XMemGetWorkingSetStatisticsFn = BOOL(__stdcall*)(uint32_t, void*);
23constexpr uint32_t kMeasuredKind = 0x20000001;
22 24
23int g_checks = 0; 25int g_checks = 0;
24int g_failures = 0; 26int g_failures = 0;
@@ -69,8 +71,10 @@ void test_alloc(XMemAllocFn alloc, XMemFreeFn free_mem) {
69void test_working_set(XMemGetWorkingSetStatisticsFn get_stats) { 71void test_working_set(XMemGetWorkingSetStatisticsFn get_stats) {
70 alignas(64) uint8_t stats[64]; 72 alignas(64) uint8_t stats[64];
71 std::memset(stats, 0xa5, sizeof(stats)); 73 std::memset(stats, 0xa5, sizeof(stats));
72 const BOOL ok = get_stats(stats); 74 // The pointer is the second argument: the first (0x20000001 here, as the FSR DLL passes it) must never be written
73 check(ok != FALSE, "XMemGetWorkingSetStatistics(64-byte out) returns TRUE"); 75 // through, which is what the one-argument form did.
76 const BOOL ok = get_stats(kMeasuredKind, stats);
77 check(ok != FALSE, "XMemGetWorkingSetStatistics(kind, 64-byte out) returns TRUE");
74 78
75 uint64_t working_set = 0; 79 uint64_t working_set = 0;
76 std::memcpy(&working_set, stats + 8, sizeof(working_set)); 80 std::memcpy(&working_set, stats + 8, sizeof(working_set));
@@ -85,7 +89,8 @@ void test_working_set(XMemGetWorkingSetStatisticsFn get_stats) {
85 } 89 }
86 check(ok != FALSE && tail_untouched, "XMemGetWorkingSetStatistics leaves bytes 16..63 untouched"); 90 check(ok != FALSE && tail_untouched, "XMemGetWorkingSetStatistics leaves bytes 16..63 untouched");
87 91
88 check(get_stats(nullptr) == FALSE, "XMemGetWorkingSetStatistics(nullptr) returns FALSE without crashing"); 92 check(get_stats(kMeasuredKind, nullptr) == FALSE,
93 "XMemGetWorkingSetStatistics(kind, nullptr) returns FALSE without crashing");
89} 94}
90 95
91void test_virtual_query(XMemVirtualQueryFn query) { 96void test_virtual_query(XMemVirtualQueryFn query) {