GPU: GetDevice and the DXGI device answer for every device interface level #271
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!271
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/271/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Dufftwt on GitHub · 2026-11-24 01:58 UTC · original
Dufftwt:fix/get-device-any-device-level→main· +31 −3 · 3 files · 1 commits · closed without mergingWhat's wrong
The D3D12 device answers
QueryInterfaceforID3D12Deviceand for its newer levels (device::LEVEL_IIDS: 1–8 and 11).ID3D12Device11is the one Grand Theft Auto VI creates. Two other places hand out the same device object, but each accepts only the first IID:object::parent_device:ID3D12DeviceChild::GetDevicefor every device child (command queues, command lists and allocators, resources, heaps, descriptor heaps, fences, query heaps, root and command signatures).dxgi::device_query: the DXGI device'sQueryInterface, which "also answers for the D3D12 device".So a title that holds an
ID3D12Device11and asks one of its objects for it getsE_NOINTERFACEand a null pointer:The
GetDevicedocs only ask for "the GUID for the device interface". COM'sQueryInterfacerules also require that an object reachable through one interface answers for every interface it has. WithIID_PPV_ARGS(&device11)the failure ends in a null dereference in the title.What the fix does
device::is_device, the device's own check for its interfaces (base IID and every level), becomespub(crate).parent_deviceanddxgi::device_querynow use it instead of comparing against the base IID only.How it behaves after the fix
GetDeviceon any device child, andQueryInterfaceon the DXGI device, return the device for any interface level the device itself answers:ID3D12Device,ID3D12Device1–8orID3D12Device11. Other IIDs still getE_NOINTERFACE.Tests
The new test
children_and_the_dxgi_device_give_every_device_level(indevice.rs):GetDevice(slot0x38) forID3D12Device,ID3D12Device1andID3D12Device11;QueryInterface(slot 0) for the same three IIDs.Each call must return
S_OKand the device.I ran
cargo test --workspaceon GitHub'swindows-latestwith Rust 1.98.1 fromrust-toolchain.toml:victory-gpuhas 44 passed (1 ignored), the other crates have 0 failed.main: it fails on the fence's firstGetDevicewith a device level:left: -2147467262(E_NOINTERFACE),right: 0.--test-threads=1. With 4 threads, the shader crate's GPU tests sometimes crash on that runner (#181, #244).Not tested: the title's own
GetDevicecalls.Not in this PR: none of these objects answers
IUnknown. That's a separate identity question, and nothing shows a title asking for it.@Dufftwt on GitHub · 2026-11-24 01:58 UTC · original
Closing as a duplicate of #249, which makes the same change (with broader tests) and was opened first.
Pull request closed