Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/retail_boot_chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
17 changes: 14 additions & 3 deletions runtime/shims/d3d12_xs_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,10 @@ inline void note_list_slot(unsigned slot, std::uint64_t a1 = 0, std::uint64_t a2
static_cast<unsigned long long>(a3), static_cast<unsigned long long>(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)) ||
Expand All @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1442,8 +1450,11 @@ HRESULT proxy_create_command_list_x(DeviceProxy* self, std::uint64_t desc_word,
if (!allocator) allocator = reinterpret_cast<ID3D12CommandAllocator*>(allocator_word);
auto* initial_state = reinterpret_cast<ID3D12PipelineState*>(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<IUnknown*>(created), self, riid, out);
}
Expand Down
37 changes: 37 additions & 0 deletions runtime/test/xs_proxy_mock_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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<std::uint64_t>(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;
Expand Down Expand Up @@ -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;
Expand Down
Loading