From 99ba1c085f1d3a1dcd4639e55508009e318b06b6 Mon Sep 17 00:00:00 2001 From: mrp1no <137657338+mrp1no@users.noreply.github.com> Date: Mon, 23 Nov 2026 16:57:30 +0100 Subject: [PATCH 1/3] d3d12_xs: Xbox device slot 61 is CreateSamplerX, routed to the PC CreateSampler The retail title calls device slot 61 as CreateSamplerX(desc, dest handle), once per sampler, after its descriptor heaps exist (stop 20 of the RT-5 boot measurements in the coordination issue). The generic thunk forwarded it to the PC slot 61, which is CreateMetaCommand, so the sampler was never written. Slot 61 now has its own handler, like 62 and 67. It passes the description's PC D3D12_SAMPLER_DESC prefix and the handle to the PC CreateSampler (slot 22). That was enough to get the title past this call under Wine. Whatever follows the prefix in the console description is not known and is not read. A null description is skipped and logged once. A handle in the title's own heap range is #7021's translation. xs_proxy_mock_test: slot 61 reaches the mock's slot 22 with the same two words and never its slot 61; a null description reaches nothing. With main's d3d12_xs_device.cpp the new check fails. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit e22994464b17517624c898ed34b3e03c06ce2261) --- docs/d3d12_vulkan.md | 1 + runtime/shims/d3d12_xs_device.cpp | 27 ++++++++++++++++++++++++++- runtime/shims/d3d12_xs_device.h | 2 ++ runtime/test/xs_proxy_mock_test.cpp | 23 ++++++++++++++++++++--- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index 251bc27916..c6f8563af0 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -3532,6 +3532,7 @@ to be recovered from call sites (or the NDA GDK headers, if a developer has acce | PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5 | Likely the only present path of a GDKX title. Presenter + vblank-timed frame events; 1-2 planes composed into the Vulkan swapchain (placement, filter, alpha overlay, HDR10 conversions). Call shapes known; slots/layouts **Open**. | | Device slots 48/73/78/79/80 | Public HLE `Freminet`/`ScarlettX` (third-party, not Microsoft documentation) | `d3d12_xs_device.cpp` routes `CreateCommandQueueX` (48), `CreateCommandListX` (73), `SetFrameIntervalX` (78), `ScheduleFrameEventX` (79) and `WaitFrameEventX` (80) before it indexes the PC vtable. Queue and list creation use the existing create paths. The frame-event calls are a per-device token counter: `WaitFrameEventX` returns at once with a fresh non-zero token, because there is no vblank source before a presenter exists. The five indices can be moved with `LEONIDA_XS_QUEUE_X_SLOT`, `LEONIDA_XS_LIST_X_SLOT`, `LEONIDA_XS_FRAME_INTERVAL_SLOT`, `LEONIDA_XS_SCHEDULE_EVENT_SLOT` and `LEONIDA_XS_WAIT_EVENT_SLOT` (3..127; a value that names a slot the proxy already handles keeps that slot's handler); a trace that disagrees wins. | | Indirect argument type 105 | The retail title's startup creates five one-argument command signatures (device slot 41) with no root signature; one has type 105 and a 12-byte stride. Its two `ExecuteIndirect` sites, read statically, set the compute state first, as the `DISPATCH` sites do, and pass one command from the same argument buffer, on a second command list | `d3d12_xs_device.cpp` creates it as `DISPATCH` (`D3D12_DISPATCH_ARGUMENTS`). What the console does differently for it is **Open**. | +| Device slot 61 | The retail title's boot under `gta6rt --run` (stop 20 of the RT-5 measurements in #6910): called as `(desc, dest handle)` once per sampler | `d3d12_xs_device.cpp` routes it to the PC `CreateSampler` (slot 22) with the description's PC `D3D12_SAMPLER_DESC` prefix; the PC slot 61 is `CreateMetaCommand`. The layout of the description beyond the PC fields is **Open**. | | VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. | | Mesh shader tier | Public `D3D12_MESH_SHADER_TIER` | `VK_EXT_mesh_shader`; the 9,282 translated mesh shaders make this a hard requirement for any content that uses them. | | Wave MMA | Public `D3D12_WAVE_MMA_TIER` | Not used: no shader sets `WAVE_MMA` in SFI0 and none contains `v_mfma`/`v_wmma` (all 26,503, `tools/feature_scan.py`). Answer the tier query truthfully; no cooperative-matrix mapping is needed. | diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 2f307ea16e..7224b8c080 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -240,6 +240,7 @@ const char* slot_name(unsigned slot) { case 48: return "Xbox CreateCommandQueueX -> queue proxy"; case 50: return "EnqueueMakeResident (proxies unwrapped)"; case 56: return "GetResourceAllocationInfo1 (C or PC form)"; + case 61: return "Xbox CreateSamplerX -> PC CreateSampler"; case 62: return "Xbox CreateComputePipelineState"; case 67: return "Xbox DeserializeComputePipelineStateX"; case 70: return "Xbox shader-resource view from raw words"; @@ -1985,6 +1986,27 @@ HRESULT proxy_create_command_signature(DeviceProxy* self, const D3D12_COMMAND_SI return forward(self->real, &pc, root_signature, riid, out); } +// The Xbox slot 61 is CreateSamplerX(desc, dest): a sampler written to a CPU descriptor handle, with the PC +// CreateSampler's two arguments. Measured on the retail title's boot (stop 20 in #6910's RT-5 measurements): the +// title calls it once per sampler after its descriptor heaps exist, and it goes on when the call is served by the PC +// CreateSampler. The PC slot 61 is CreateMetaCommand, which would take these words as (CommandId, NodeMask, ...). +// HYPOTHESIS: the console description begins with the PC D3D12_SAMPLER_DESC (52 bytes), which is what got the title +// past this call; whatever follows it is not known and not read. The title was not seen testing a result, so a null +// description is skipped rather than reported. The handle is passed as given: a handle in the title's own heap range +// is #7021's translation. +void proxy_create_sampler_x(DeviceProxy* self, const D3D12_SAMPLER_DESC* desc, std::uint64_t dest) { + note_slot(61); + if (!desc) { + static std::atomic logged{false}; + if (!logged.exchange(true, std::memory_order_relaxed)) + std::fprintf(stderr, "[rt] d3d12_xs: slot 61 CreateSamplerX without a description (skipped)\n"); + return; + } + D3D12_CPU_DESCRIPTOR_HANDLE handle{}; + handle.ptr = static_cast(dest); + self->real->CreateSampler(desc, handle); +} + // The Xbox slot 67 creates a compute pipeline from native GPU code: (desc, riid, out), named // DeserializeComputePipelineStateX in amd_fidelityfx_upscaler_xbox.dll's messages (call at RVA 0x56d9). The desc // passes the root signature at +0x00, followed by pointer/size pairs for the shader's FSPX entries (docs/fspx.md): @@ -2438,6 +2460,9 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64 return hr_to_u64(proxy_create_command_signature( self, reinterpret_cast(a1), a2, reinterpret_cast(a3), reinterpret_cast(a4))); + } else if constexpr (Slot == 61) { + proxy_create_sampler_x(self, reinterpret_cast(a1), a2); + return 0; } else if constexpr (Slot == 67) { return hr_to_u64(proxy_create_compute_pipeline_from_native_code( self, reinterpret_cast(a1), reinterpret_cast(a2), @@ -2789,7 +2814,7 @@ ID3D12Device* device_proxy_real_device(const void* device) { bool device_slot_overridden(unsigned slot) { if (slot <= 2 || slot == 8 || slot == 9 || slot == 14 || (slot >= 17 && slot <= 24) || slot == 25 || slot == 26 || slot == 31 || slot == 32 || slot == 34 || slot == 35 || - slot == 36 || slot == 41 || slot == 45 || slot == 46 || slot == 50 || slot == 56 || slot == 62 || slot == 67 || + slot == 36 || slot == 41 || slot == 45 || slot == 46 || slot == 50 || slot == 56 || slot == 61 || slot == 62 || slot == 67 || slot == 70 || slot == 75 || slot == 76 || slot == 133 || slot == kCreateCommittedResource3X) return true; const XboxDeviceSlotRoutes& routes = xbox_device_slot_routes(); diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 5841656967..3b2c576d17 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -8,6 +8,8 @@ // the executable has been seen yet, so they are forwarded in the PC form. // slot 41 CreateCommandSignature at its PC position; a console argument of type 105 (a 12-byte dispatch, read // from the retail title's call sites) is created as D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH. +// slot 61 CreateSamplerX(desc, dest) -> PC CreateSampler (slot 22); the description's PC +// D3D12_SAMPLER_DESC prefix is passed. The PC slot 61 is CreateMetaCommand. Measured on the retail title's boot. // slot 62 CreateComputePipelineState(desc, w2, w3, iid, out): two words (0 from XboxBvhBuilder, meaning unknown) // before the IID. The PC slot 62 is CreateStateObject. // slot 67 CreateComputePipelineState from native code (desc, iid, out): converts the Xbox native-code desc diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index bf4e0b015d..7507357d53 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -997,6 +997,8 @@ int check_allocators() { return 0; } + + // ---- 7. Xbox device slots from the public HLE (48, 73, 78, 79, 80) and the retail title (41) ---- // // A device that answers ID3D12Device11 (80 PC slots) is the Vulkan layer's shape: slots 78/79 are inside its table @@ -1093,14 +1095,29 @@ int check_xbox_slots() { EXPECT(mock->calls[41] == 2 && mock->args[41][0] == word(&pc_sig)); EXPECT(mock->array[41][1] == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH); - EXPECT(xs::device_slot_overridden(41) && xs::device_slot_overridden(48) && xs::device_slot_overridden(73) && + // 61 CreateSamplerX(desc, dest): the PC CreateSampler (slot 22) gets the same two words, not the PC slot 61 + // (CreateMetaCommand). A null description is skipped without reaching the device. + D3D12_SAMPLER_DESC sampler{}; + sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; + sampler.AddressU = sampler.AddressV = sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; + sampler.MaxLOD = D3D12_FLOAT32_MAX; + const std::uint64_t sampler_handle = 0x7ff012340040ull; + raw(device, 61, word(&sampler), sampler_handle); + EXPECT(mock->calls[61] == 0 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 1); + EXPECT(mock->args[22][0] == word(&sampler) && mock->args[22][1] == sampler_handle); + raw(device, 61, 0, sampler_handle); + EXPECT(mock->calls[61] == 0 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 2); + + EXPECT(xs::device_slot_overridden(41) && xs::device_slot_overridden(48) && xs::device_slot_overridden(61) && + xs::device_slot_overridden(73) && xs::device_slot_overridden(78) && xs::device_slot_overridden(79) && xs::device_slot_overridden(80)); EXPECT(release(allocator) == 0 && real_allocator->refs == 0); EXPECT(release(queue) == 0); EXPECT(release(device) == 0 && mock->refs == 0); - std::printf("%s: device slots 48/73/78/79/80 route to a queue, a list and frame-event tokens without reaching " - "the mock's own PC slots; slot 41 creates argument type 105 as DISPATCH\n", g_label); + std::printf("%s: device slots 48/73/78/79/80 route to a queue, a list and frame-event tokens, and slot 61 to " + "CreateSampler, without reaching the mock's own PC slots; slot 41 creates argument type 105 as DISPATCH\n", + g_label); return 0; #else std::printf("%s: ID3D12Device11 is not in this SDK; Xbox slot 80's beyond-table case is not built\n", g_label); From 49fd9a4275a608ff4e7c3d6bc93766e84fd447a1 Mon Sep 17 00:00:00 2001 From: mrp1no <137657338+mrp1no@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:44:08 +0100 Subject: [PATCH 2/3] d3d12_xs: slot 61 is CreateSamplerX only for the title's calls; a host caller gets PC CreateMetaCommand The proxy also serves host callers: d3d12_vulkan_device_test drives the Vulkan device through it, and its ID3D12Device5::CreateMetaCommand call (PC slot 61) landed in proxy_create_sampler_x (found by nullmarsh on #7115: the test stopped at line 5763 instead of main's known line 6574). Slot 61 now checks the caller's return address with a classifier the runtime installs (set_console_caller, the name #7490 uses): D3D12XboxCreateDevice installs rt::shims::mapped_image_base, so only a caller in an image the guest loader mapped gets CreateSamplerX. Any other caller, and every caller when no classifier is installed, is forwarded to the PC slot 61. xs_proxy_mock_test checks all three cases: no classifier (PC slot 61), a guest caller (PC CreateSampler with the same words; a null description skipped) and a host caller under an installed classifier (PC slot 61). d3d12_vulkan_device_test again stops at line 6574, as on main. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit 8f756ebe048af042638ce51a61490f35f4f44ee3) (cherry picked from commit c915e1da45e17d46c90c32be9809e4f043a77fd3) --- docs/d3d12_vulkan.md | 2 +- runtime/shims/d3d12_xs.cpp | 6 ++++++ runtime/shims/d3d12_xs_device.cpp | 33 ++++++++++++++++++++++++++--- runtime/shims/d3d12_xs_device.h | 6 ++++++ runtime/test/xs_proxy_mock_test.cpp | 18 ++++++++++++---- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index c6f8563af0..49dd2cc1a7 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -3532,7 +3532,7 @@ to be recovered from call sites (or the NDA GDK headers, if a developer has acce | PresentX / present planes / frame events | Public GDK samples (MIT/zlib), §4.5 | Likely the only present path of a GDKX title. Presenter + vblank-timed frame events; 1-2 planes composed into the Vulkan swapchain (placement, filter, alpha overlay, HDR10 conversions). Call shapes known; slots/layouts **Open**. | | Device slots 48/73/78/79/80 | Public HLE `Freminet`/`ScarlettX` (third-party, not Microsoft documentation) | `d3d12_xs_device.cpp` routes `CreateCommandQueueX` (48), `CreateCommandListX` (73), `SetFrameIntervalX` (78), `ScheduleFrameEventX` (79) and `WaitFrameEventX` (80) before it indexes the PC vtable. Queue and list creation use the existing create paths. The frame-event calls are a per-device token counter: `WaitFrameEventX` returns at once with a fresh non-zero token, because there is no vblank source before a presenter exists. The five indices can be moved with `LEONIDA_XS_QUEUE_X_SLOT`, `LEONIDA_XS_LIST_X_SLOT`, `LEONIDA_XS_FRAME_INTERVAL_SLOT`, `LEONIDA_XS_SCHEDULE_EVENT_SLOT` and `LEONIDA_XS_WAIT_EVENT_SLOT` (3..127; a value that names a slot the proxy already handles keeps that slot's handler); a trace that disagrees wins. | | Indirect argument type 105 | The retail title's startup creates five one-argument command signatures (device slot 41) with no root signature; one has type 105 and a 12-byte stride. Its two `ExecuteIndirect` sites, read statically, set the compute state first, as the `DISPATCH` sites do, and pass one command from the same argument buffer, on a second command list | `d3d12_xs_device.cpp` creates it as `DISPATCH` (`D3D12_DISPATCH_ARGUMENTS`). What the console does differently for it is **Open**. | -| Device slot 61 | The retail title's boot under `gta6rt --run` (stop 20 of the RT-5 measurements in #6910): called as `(desc, dest handle)` once per sampler | `d3d12_xs_device.cpp` routes it to the PC `CreateSampler` (slot 22) with the description's PC `D3D12_SAMPLER_DESC` prefix; the PC slot 61 is `CreateMetaCommand`. The layout of the description beyond the PC fields is **Open**. | +| Device slot 61 | The retail title's boot under `gta6rt --run` (stop 20 of the RT-5 measurements in #6910): called as `(desc, dest handle)` once per sampler | `d3d12_xs_device.cpp` routes it to the PC `CreateSampler` (slot 22) with the description's PC `D3D12_SAMPLER_DESC` prefix, for a caller in an image the guest loader mapped; the PC slot 61 is `CreateMetaCommand`, which any other caller (a host test driving the device through the proxy) still gets. The layout of the description beyond the PC fields is **Open**. | | VRS | Public `D3D12_SHADING_RATE` / `D3D12_AXIS_SHADING_RATE` | `VK_KHR_fragment_shading_rate`; `RSSetShadingRate`/image-based rate map to `vkCmdSetFragmentShadingRateKHR`. | | Mesh shader tier | Public `D3D12_MESH_SHADER_TIER` | `VK_EXT_mesh_shader`; the 9,282 translated mesh shaders make this a hard requirement for any content that uses them. | | Wave MMA | Public `D3D12_WAVE_MMA_TIER` | Not used: no shader sets `WAVE_MMA` in SFI0 and none contains `v_mfma`/`v_wmma` (all 26,503, `tools/feature_scan.py`). Answer the tier query truthfully; no cooperative-matrix mapping is needed. | diff --git a/runtime/shims/d3d12_xs.cpp b/runtime/shims/d3d12_xs.cpp index 67ac93dd0d..173106f1cd 100644 --- a/runtime/shims/d3d12_xs.cpp +++ b/runtime/shims/d3d12_xs.cpp @@ -166,6 +166,12 @@ HRESULT WINAPI D3D12XboxCreateDevice(IUnknown* adapter, const void* params, cons std::fprintf(stderr, "[rt] d3d12_xs: D3D12XboxCreateDevice: wrapping the PC ID3D12Device in the Xbox-ABI proxy " "(slot 62 -> CreateComputePipelineState, slot 76 -> CreateCommittedResource).\n"); + // A console method whose slot is another PC method (61) is served only to the title: a caller in an image + // this loader mapped. + rt::d3d12_xs::set_console_caller([](std::uint64_t address) { + std::uint64_t base = 0; + return rt::shims::mapped_image_base(address, base); + }); } #ifdef LEONIDA_VULKAN_DEVICE diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 7224b8c080..5a39020450 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -31,6 +31,7 @@ #include #include +#include // _ReturnAddress: slot 61 serves a console caller differently from a host one #include #include @@ -240,7 +241,7 @@ const char* slot_name(unsigned slot) { case 48: return "Xbox CreateCommandQueueX -> queue proxy"; case 50: return "EnqueueMakeResident (proxies unwrapped)"; case 56: return "GetResourceAllocationInfo1 (C or PC form)"; - case 61: return "Xbox CreateSamplerX -> PC CreateSampler"; + case 61: return "Xbox CreateSamplerX -> PC CreateSampler (a host caller gets PC CreateMetaCommand)"; case 62: return "Xbox CreateComputePipelineState"; case 67: return "Xbox DeserializeComputePipelineStateX"; case 70: return "Xbox shader-resource view from raw words"; @@ -1994,6 +1995,17 @@ HRESULT proxy_create_command_signature(DeviceProxy* self, const D3D12_COMMAND_SI // past this call; whatever follows it is not known and not read. The title was not seen testing a result, so a null // description is skipped rather than reported. The handle is passed as given: a handle in the title's own heap range // is #7021's translation. +// The same proxy also serves host callers (the runtime's own tests drive the Vulkan device through it), for whom slot +// 61 is the PC ID3D12Device5::CreateMetaCommand. So the slot is CreateSamplerX only for a caller in an image the +// guest loader mapped (set_console_caller); any other caller, or every caller when no check is installed, gets the PC +// method. Without the check d3d12_vulkan_device_test's CreateMetaCommand call reached this handler (#7115). +std::atomic g_console_caller{nullptr}; + +bool is_console_caller(const void* address) { + const ConsoleCaller classify = g_console_caller.load(std::memory_order_acquire); + return classify && classify(reinterpret_cast(address)); +} + void proxy_create_sampler_x(DeviceProxy* self, const D3D12_SAMPLER_DESC* desc, std::uint64_t dest) { note_slot(61); if (!desc) { @@ -2461,8 +2473,19 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64 self, reinterpret_cast(a1), a2, reinterpret_cast(a3), reinterpret_cast(a4))); } else if constexpr (Slot == 61) { - proxy_create_sampler_x(self, reinterpret_cast(a1), a2); - return 0; + if (is_console_caller(_ReturnAddress())) { + proxy_create_sampler_x(self, reinterpret_cast(a1), a2); + return 0; + } + // A host caller: the PC slot 61 (ID3D12Device5::CreateMetaCommand), forwarded like any other PC method. + note_slot(Slot); + if (Slot >= self->slot_count) return hr_to_u64(refuse_beyond_device(Slot, self->slot_count)); + using ForwardFn = std::uint64_t(WINAPI*)(void*, std::uint64_t, std::uint64_t, std::uint64_t, + std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, + std::uint64_t, std::uint64_t, std::uint64_t, std::uint64_t, + std::uint64_t, std::uint64_t, std::uint64_t); + auto fn = reinterpret_cast(self->real_vtable[Slot]); + return fn(self->real, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); } else if constexpr (Slot == 67) { return hr_to_u64(proxy_create_compute_pipeline_from_native_code( self, reinterpret_cast(a1), reinterpret_cast(a2), @@ -2919,6 +2942,10 @@ bool heap_slot_overridden(unsigned slot) { return slot <= 2 || slot == 7 || slot == 9 || slot == 10; } +void set_console_caller(ConsoleCaller classify) { + g_console_caller.store(classify, std::memory_order_release); +} + std::uint64_t device_slot_hits(unsigned slot) { start_hit_counts(); return slot < kMaxSlots ? g_hits[slot].load(std::memory_order_relaxed) : 0; diff --git a/runtime/shims/d3d12_xs_device.h b/runtime/shims/d3d12_xs_device.h index 3b2c576d17..da7990cb4e 100644 --- a/runtime/shims/d3d12_xs_device.h +++ b/runtime/shims/d3d12_xs_device.h @@ -159,6 +159,12 @@ void set_console_descriptor_heap_handler(ConsoleDescriptorHeapHandler handler); // handles for the allocator proxy. bool device_slot_overridden(unsigned slot); +// Whether a return address is in an image the guest loader mapped, i.e. the call comes from the title. Device slot 61 +// is CreateSamplerX for such a caller and the PC ID3D12Device5::CreateMetaCommand for any other; with no check +// installed every caller is a host one. D3D12XboxCreateDevice installs rt::shims::mapped_image_base. +using ConsoleCaller = bool (*)(std::uint64_t address); +void set_console_caller(ConsoleCaller classify); + // Queue and fence proxies created by device slots 8/75 and 36. The real_* accessors return the wrapped object // (no reference added), or null when the pointer is not such a proxy. bool is_queue_proxy(const void* queue); diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 7507357d53..98be126276 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -1095,18 +1095,28 @@ int check_xbox_slots() { EXPECT(mock->calls[41] == 2 && mock->args[41][0] == word(&pc_sig)); EXPECT(mock->array[41][1] == D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH); - // 61 CreateSamplerX(desc, dest): the PC CreateSampler (slot 22) gets the same two words, not the PC slot 61 - // (CreateMetaCommand). A null description is skipped without reaching the device. + // 61 is CreateSamplerX(desc, dest) for the title and the PC CreateMetaCommand for a host caller. With no + // console-caller check installed (a host program like this one), the call is the PC slot 61. D3D12_SAMPLER_DESC sampler{}; sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; sampler.AddressU = sampler.AddressV = sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; sampler.MaxLOD = D3D12_FLOAT32_MAX; const std::uint64_t sampler_handle = 0x7ff012340040ull; raw(device, 61, word(&sampler), sampler_handle); - EXPECT(mock->calls[61] == 0 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 1); + EXPECT(mock->calls[61] == 1 && mock->calls[22] == 0 && xs::device_slot_hits(61) == 1); + // A caller the check calls the title's (here every one): the PC CreateSampler (slot 22) gets the same two words, + // not the PC slot 61. A null description is skipped without reaching the device. + xs::set_console_caller([](std::uint64_t) { return true; }); + raw(device, 61, word(&sampler), sampler_handle); + EXPECT(mock->calls[61] == 1 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 2); EXPECT(mock->args[22][0] == word(&sampler) && mock->args[22][1] == sampler_handle); raw(device, 61, 0, sampler_handle); - EXPECT(mock->calls[61] == 0 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 2); + EXPECT(mock->calls[61] == 1 && mock->calls[22] == 1 && xs::device_slot_hits(61) == 3); + // A caller outside the title's images is a host one again. + xs::set_console_caller([](std::uint64_t) { return false; }); + raw(device, 61, word(&sampler), sampler_handle); + EXPECT(mock->calls[61] == 2 && mock->calls[22] == 1); + xs::set_console_caller(nullptr); EXPECT(xs::device_slot_overridden(41) && xs::device_slot_overridden(48) && xs::device_slot_overridden(61) && xs::device_slot_overridden(73) && From 484962eb8f56486fa1a234f250c6bb0e5d287063 Mon Sep 17 00:00:00 2001 From: Mumogg <104529023+Mumogg@users.noreply.github.com> Date: Tue, 24 Nov 2026 03:52:02 -0600 Subject: [PATCH 3/3] d3d12_xs: CreateSamplerX translates a destination in the title's descriptor range Slot 61 passed the destination handle to the PC CreateSampler as given. With the title's descriptor range honoured (__XMemAllocationHooks__), a handle in that range has to be translated to the real heap's, as device slots 17 to 24 do (asked for in review on #377). Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01HxBQf4pXH8PWpC5oZsM4bt --- runtime/shims/d3d12_xs_device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 5a39020450..4dd9be621a 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -2015,7 +2015,8 @@ void proxy_create_sampler_x(DeviceProxy* self, const D3D12_SAMPLER_DESC* desc, s return; } D3D12_CPU_DESCRIPTOR_HANDLE handle{}; - handle.ptr = static_cast(dest); + // A destination in the title's own descriptor range is translated to the real heap's, as device slots 17 to 24 do. + handle = translate_cpu_handle(self, D3D12_CPU_DESCRIPTOR_HANDLE{static_cast(dest)}); self->real->CreateSampler(desc, handle); }