d3d12_xs device proxy: slot 62 takes (desc, w2, w3, riid, out)

The proxy read device slot 62 as (desc, riid, out), so XboxBvhBuilder's constructor, the only
known caller, got E_POINTER on its first compute PSO and threw it. Recorded on 1.0.2.1: the
DLL calls slot 62 with (desc, 0, 0, &IID_ID3D12PipelineState, out), the shape the prior art
had documented (d3d12_vulkan.md, sections 4.8 and 7). Read the IID and the output from the
fourth and fifth arguments, and log the two extra words once if they are ever non-zero.
device_proxy_test now calls slot 62 in that shape.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
S1m0ne1997
2026-11-21 21:13:10 +01:00
parent 4c75ce537a
commit 28cf235061
3 changed files with 18 additions and 6 deletions

View File

@ -346,9 +346,18 @@ HRESULT proxy_create_descriptor_heap(DeviceProxy* self, const D3D12_DESCRIPTOR_H
return hr;
}
// The Xbox slot 62 takes two more words between the description and the IID: (desc, w2, w3, riid, out). Measured
// on the package's XboxBvhBuilder.dll (its constructor passes w2 = w3 = 0 and IID_ID3D12PipelineState in the fourth
// argument), as the prior art had recorded. Their meaning is unknown; non-zero values are logged once.
HRESULT proxy_create_compute_pipeline_state(DeviceProxy* self, const D3D12_COMPUTE_PIPELINE_STATE_DESC* desc,
const IID* riid, void** out) {
std::uint64_t w2, std::uint64_t w3, const IID* riid, void** out) {
note_slot(62);
if (w2 || w3) {
static std::atomic<bool> logged{false};
if (!logged.exchange(true, std::memory_order_relaxed))
std::fprintf(stderr, "[rt] d3d12_xs: slot 62 extra words 0x%llx 0x%llx (ignored)\n",
static_cast<unsigned long long>(w2), static_cast<unsigned long long>(w3));
}
if (!riid) return E_POINTER;
if (!out) return E_POINTER;
return self->real->CreateComputePipelineState(desc, *riid, out);
@ -399,8 +408,8 @@ std::uint64_t WINAPI proxy_slot(DeviceProxy* self, std::uint64_t a1, std::uint64
reinterpret_cast<const IID*>(a2), reinterpret_cast<void**>(a3)));
} else if constexpr (Slot == 62) {
return hr_to_u64(proxy_create_compute_pipeline_state(
self, reinterpret_cast<const D3D12_COMPUTE_PIPELINE_STATE_DESC*>(a1),
reinterpret_cast<const IID*>(a2), reinterpret_cast<void**>(a3)));
self, reinterpret_cast<const D3D12_COMPUTE_PIPELINE_STATE_DESC*>(a1), a2, a3,
reinterpret_cast<const IID*>(a4), reinterpret_cast<void**>(a5)));
} else if constexpr (Slot == 76) {
return hr_to_u64(proxy_create_resource(
self, reinterpret_cast<const D3D12_HEAP_PROPERTIES*>(a1),

View File

@ -1,7 +1,8 @@
// Xbox-ABI proxy around a PC ID3D12Device.
//
// Measured Xbox device deviations used here (vtable indices, x64):
// slot 62 CreateComputePipelineState(desc, iid, out); the PC slot 62 is CreateStateObject.
// 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 76 resource creation -> PC CreateCommittedResource (PC slot 27), with the Xbox layout word ignored.
// The measured slots 9/10 (GetCPU/GPUDescriptorHandleForHeapStart) are ID3D12DescriptorHeap methods, not device
// methods: the PC device's 9/10 are CreateCommandAllocator/CreateGraphicsPipelineState and are forwarded unchanged.

View File

@ -39,7 +39,9 @@ using XboxCreateDeviceFn = HRESULT(WINAPI*)(IUnknown*, const void*, const IID*,
using XboxCreateResourceFn = HRESULT(WINAPI*)(void*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS,
const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES,
const D3D12_CLEAR_VALUE*, REFIID, void**);
using XboxCreateComputePsoFn = HRESULT(WINAPI*)(void*, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, REFIID, void**);
// Xbox slot 62: (desc, two words, iid, out), as XboxBvhBuilder.dll calls it (zeros for the two words).
using XboxCreateComputePsoFn = HRESULT(WINAPI*)(void*, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, std::uint64_t,
std::uint64_t, REFIID, void**);
using GetCpuHandleFn = D3D12_CPU_DESCRIPTOR_HANDLE(WINAPI*)(ID3D12DescriptorHeap*);
using GetGpuHandleFn = D3D12_GPU_DESCRIPTOR_HANDLE(WINAPI*)(ID3D12DescriptorHeap*);
@ -327,7 +329,7 @@ int main() {
auto create_pso = reinterpret_cast<XboxCreateComputePsoFn>(proxy_vtbl[62]);
const IID iid_pso = __uuidof(ID3D12PipelineState);
ComPtr<ID3D12PipelineState> pso;
hr = create_pso(device.Get(), &pso_desc, iid_pso, reinterpret_cast<void**>(pso.GetAddressOf()));
hr = create_pso(device.Get(), &pso_desc, 0, 0, iid_pso, reinterpret_cast<void**>(pso.GetAddressOf()));
check(SUCCEEDED(hr) && pso != nullptr, "slot 62 creates a compute PSO via CreateComputePipelineState");
check(rt::d3d12_xs::device_slot_hits(62) == 1, "slot 62 hit counter is 1");
check(rt::d3d12_xs::device_slot_first_call_seen(62), "slot 62 first-call flag is set");