diff --git a/docs/retail_boot_chain.md b/docs/retail_boot_chain.md index cbe29cf831..fd07905be9 100644 --- a/docs/retail_boot_chain.md +++ b/docs/retail_boot_chain.md @@ -79,7 +79,7 @@ queues come from this slot, the first of them a compute queue. The first queue c Xbox device slot 73 is `(desc, allocator, pso, riid, out)`. `desc` is 16 bytes and its first word reads as the `D3D12_COMMAND_LIST_TYPE`. `riid` is a console command-list IID that is not in the PC SDK (#3520 records that the -package doesn't export it). The shim's unknown-IID log names it on the player's machine. Creating an +package doesn't export it). A retail run logged it as `{c3827890-4024-474c-98cf-645b51dc4874}` (#445). Creating an `ID3D12GraphicsCommandList` of that type and handing out #2490's console list proxy gets all 581 lists created and closed. diff --git a/runtime/shims/d3d12_xs_device.cpp b/runtime/shims/d3d12_xs_device.cpp index 7f7040fdd9..d962fd10fe 100644 --- a/runtime/shims/d3d12_xs_device.cpp +++ b/runtime/shims/d3d12_xs_device.cpp @@ -983,6 +983,10 @@ inline void note_list_slot(unsigned slot, std::uint64_t a1 = 0, std::uint64_t a2 static_cast(a3), static_cast(a4)); } +// Measured Xbox ID3D12GraphicsCommandListX IID passed to device slot 73 (CreateCommandListX). +constexpr IID kXboxGraphicsCommandListXIid = { + 0xc3827890, 0x4024, 0x474c, {0x98, 0xcf, 0x64, 0x5b, 0x51, 0xdc, 0x48, 0x74}}; + inline bool is_list_iid(const IID& iid) { return IsEqualIID(iid, __uuidof(IUnknown)) || IsEqualIID(iid, __uuidof(ID3D12Object)) || IsEqualIID(iid, __uuidof(ID3D12DeviceChild)) || IsEqualIID(iid, __uuidof(ID3D12CommandList)) || @@ -994,7 +998,8 @@ inline bool is_list_iid(const IID& iid) { IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList5)) || IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList6)) || IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList7)) || - IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList8)); + IsEqualIID(iid, __uuidof(ID3D12GraphicsCommandList8)) || + IsEqualIID(iid, kXboxGraphicsCommandListXIid); } inline unsigned long list_add_ref(ListProxy* self) { return self->refs.fetch_add(1, std::memory_order_relaxed) + 1; } @@ -1022,7 +1027,10 @@ inline HRESULT list_query_interface(ListProxy* self, const IID* riid, void** out if (supports_iid(self->real, *riid)) log_refused_iid("list", *riid); return E_NOINTERFACE; } - if (!supports_iid(self->real, *riid)) return E_NOINTERFACE; + const IID real_iid = IsEqualIID(*riid, kXboxGraphicsCommandListXIid) + ? __uuidof(ID3D12GraphicsCommandList) + : *riid; + if (!supports_iid(self->real, real_iid)) return E_NOINTERFACE; *out = self; list_add_ref(self); return S_OK; @@ -1442,8 +1450,11 @@ HRESULT proxy_create_command_list_x(DeviceProxy* self, std::uint64_t desc_word, if (!allocator) allocator = reinterpret_cast(allocator_word); auto* initial_state = reinterpret_cast(initial_state_word); void* created = nullptr; + const IID& create_iid = IsEqualIID(*riid, kXboxGraphicsCommandListXIid) + ? __uuidof(ID3D12GraphicsCommandList) + : *riid; const HRESULT hr = self->real->CreateCommandList(0, type, allocator, initial_state, - *riid, &created); + create_iid, &created); if (FAILED(hr)) return hr; return wrap_list(static_cast(created), self, riid, out); } diff --git a/runtime/test/xs_proxy_mock_test.cpp b/runtime/test/xs_proxy_mock_test.cpp index 224030247c..9235962d26 100644 --- a/runtime/test/xs_proxy_mock_test.cpp +++ b/runtime/test/xs_proxy_mock_test.cpp @@ -91,6 +91,8 @@ struct Mock { bool allocator_tag; // allocator: answers kLeonidaCommandAllocatorTag; device: the allocators it makes do bool create_null; // device: creation returns create_result with no object HRESULT create_result; // device: what creation returns (S_OK makes the object) + bool list_refuse; // device: CreateCommandList refuses every riid with E_NOINTERFACE + IID create_riid; // device: copy of the riid its last CreateCommandList got (the caller's may be a local) Mock* last_child; // device: the object its last creation or open made unsigned calls[kMockSlots]; std::uint64_t args[kMockSlots][5]; @@ -276,8 +278,10 @@ HRESULT WINAPI mock_create_command_list(Mock* self, std::uint64_t node_mask, std self->args[12][2] = allocator; self->args[12][3] = initial_state; self->args[12][4] = reinterpret_cast(riid); + if (riid) self->create_riid = *riid; if (!out) return S_FALSE; *out = nullptr; + if (self->list_refuse) return E_NOINTERFACE; if (self->create_null || FAILED(self->create_result)) return self->create_result; Mock* child = new_mock(Kind::command_list); child->list_level = self->list_level; @@ -1504,6 +1508,39 @@ int check_console_command_list() { EXPECT(real_queue->array[10][0] == word(unwrapped_list)); EXPECT(real_queue->array[10][1] == word(real_list)); + // 5b. Public list revisions the proxy does not model and unknown private IIDs must not trigger a retry. + // Spell out the Windows SDK's ID3D12GraphicsCommandList9 IID so this also builds with older headers. + const IID list9_iid = {0x34ed2808, 0xffe6, 0x4c2b, {0xb1, 0x1a, 0xca, 0xbd, 0x2b, 0x0c, 0x59, 0xe1}}; + const IID unknown_iid = {0x12345678, 0x1234, 0x1234, {1, 2, 3, 4, 5, 6, 7, 8}}; + for (const IID* iid : {&list9_iid, &unknown_iid}) { + const unsigned calls_before = mock_device->calls[12]; + void* unsupported_list = list_proxy; + EXPECT(hr_of(raw(device, 73, word(&desc), word(allocator), 0, word(iid), word(&unsupported_list))) == + E_NOINTERFACE); + EXPECT(!unsupported_list && mock_device->calls[12] == calls_before + 1); + } + + // The measured Xbox list IID is created as ID3D12GraphicsCommandList in one call and stays queryable on the proxy. + const IID console_iid = {0xc3827890, 0x4024, 0x474c, {0x98, 0xcf, 0x64, 0x5b, 0x51, 0xdc, 0x48, 0x74}}; + const unsigned calls12_before = mock_device->calls[12]; + void* console_list = nullptr; + EXPECT(hr_of(raw(device, 73, word(&desc), word(allocator), 0, word(&console_iid), word(&console_list))) == S_OK); + EXPECT(xs::is_command_list_proxy(console_list) && mock_device->calls[12] == calls12_before + 1); + EXPECT(IsEqualIID(mock_device->create_riid, __uuidof(ID3D12GraphicsCommandList))); + void* console_list_qi = nullptr; + EXPECT(hr_of(raw(console_list, 0, word(&console_iid), word(&console_list_qi))) == S_OK); + EXPECT(console_list_qi == console_list && release(console_list_qi) == 1); + EXPECT(release(console_list) == 0); + + // The PC device refuses even ID3D12GraphicsCommandList for a PC IID: E_NOINTERFACE comes back as is, no retry. + mock_device->list_refuse = true; + const unsigned calls12_refused = mock_device->calls[12]; + console_list = nullptr; + EXPECT(hr_of(raw(device, 73, word(&desc), word(allocator), 0, word(&list_iid), word(&console_list))) == + E_NOINTERFACE); + EXPECT(!console_list && mock_device->calls[12] == calls12_refused + 1); + mock_device->list_refuse = false; + // 6. Test with list_level = 7 (supporting ID3D12GraphicsCommandList7, 81 slots) mock_device->list_level = 7; void* list7_proxy = nullptr;