d3d12_xs: accept Xbox ID3D12GraphicsCommandListX IID in CreateCommandListX

This commit is contained in:
madhyn
2026-11-24 02:31:55 -03:00
parent 8f481cf16f
commit 386d6ac5dd
2 changed files with 26 additions and 3 deletions

View File

@ -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)) ||
@ -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<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);
}

View File

@ -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);