Skip to content
Closed
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
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
12 changes: 12 additions & 0 deletions runtime/test/xs_proxy_mock_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,18 @@ int check_xbox_slots() {
// output on failure, so an invalid call would clear this pointer.
EXPECT(release(list) == 0);

// The Xbox ID3D12GraphicsCommandListX IID maps to PC ID3D12GraphicsCommandList on creation and QueryInterface.
const IID xbox_list_iid = {0xc3827890, 0x4024, 0x474c, {0x98, 0xcf, 0x64, 0x5b, 0x51, 0xdc, 0x48, 0x74}};
void* xbox_list = nullptr;
EXPECT(hr_of(raw(device, 73, word(&desc), word(allocator), 0, word(&xbox_list_iid), word(&xbox_list))) == S_OK);
EXPECT(xs::is_command_list_proxy(xbox_list));
EXPECT(mock->calls[12] == 2 &&
IsEqualIID(*reinterpret_cast<const IID*>(mock->args[12][4]), __uuidof(ID3D12GraphicsCommandList)));
void* qi_xbox_list = nullptr;
EXPECT(hr_of(raw(xbox_list, 0, word(&xbox_list_iid), word(&qi_xbox_list))) == S_OK && qi_xbox_list == xbox_list);
EXPECT(release(qi_xbox_list) == 1);
EXPECT(release(xbox_list) == 0);

// Missing description, allocator or output: E_INVALIDARG/E_POINTER before the real device is called.
EXPECT(hr_of(raw(device, 73, 0, word(allocator), 0, word(&list_iid), word(&list))) == E_INVALIDARG);
EXPECT(hr_of(raw(device, 73, word(&desc), 0, 0, word(&list_iid), word(&list))) == E_INVALIDARG);
Expand Down