Skip to content

Conversation

tychedelia
Copy link
Collaborator

Setting up some test infrastructure, and it's a bit frustrating not to be able to select a given adapter by a stable identifier when multiple GPUs with the same vendor id exist.

Adds the PCI bus id and device uuid to AdapterInfo on Vulkan.

@cwfitzgerald
Copy link
Member

If you wouldn't mind, it shouldn't be hard to wire up these in d3d via https://learn.microsoft.com/en-us/windows/win32/api/dxgi/ns-dxgi-dxgi_adapter_desc which has all this info.

If you're feeling extra crazy, you could also wire this up on GL via https://registry.khronos.org/OpenGL/extensions/EXT/EXT_external_objects.txt, but not touching that one is also understandable lol.

@jimblandy
Copy link
Member

@tychedelia Can you clear up the CI failures? We generally don't start reviewing PRs until CI likes them.

@tychedelia
Copy link
Collaborator Author

@tychedelia Can you clear up the CI failures? We generally don't start reviewing PRs until CI likes them.

Yes, apologies was just (slowly) doing @cwfitzgerald's suggestion.

I've removed Uuid as there doesn't appear a way to do this in the Windows API. But the bus ID is sufficient for a stable identifier and probably more useful anyway.

@cwfitzgerald
Copy link
Member

cwfitzgerald commented Oct 8, 2025

Is the Luid in the adapter info not the same? I thought that was how you matched devices when doing cross api interop.

@tychedelia
Copy link
Collaborator Author

Is the Luid in the adapter info not the same? I thought that was how you matched devices when doing cross api interop.

I am not super familiar with these APIs but the docs here suggest it's not valid across restarts, which limits its usefullness relative to the Uuid provided by Vulkan.

https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12device-getadapterluid

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code's fine and we can land. So the purpose of this is to differentiate between multiple cards on the same machine, across backends?

}
}

fn get_adapter_pci_info(vendor_id: u32, device_id: u32) -> String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the hell did you figure out how to do this lmao

"dep:range-alloc",
"dep:windows-core",
"dep:gpu-allocator",
"gpu-allocator/d3d12",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kpreid is this a problem for feature sets? I'm never quite sure how implicit features work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh hmm, i may have resolved a merge conflict incorrectly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it — this line should be dropped. It would not hurt but it would not have any effect.

Copy link
Collaborator

@kpreid kpreid Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm never quite sure how implicit features work.

The rule is that if

  • a dependency is optional, and
  • not mentioned using dep: syntax anywhere in [features],

then it gets an implicit feature. (When RFC 3491 is implemented in a future edition, implicit features will no longer be created and this will be an error.)

@tychedelia
Copy link
Collaborator Author

tychedelia commented Oct 16, 2025

So the purpose of this is to differentiate between multiple cards on the same machine, across backends?

Yeah so the immediate thing is that I'm trying to set up benchmarking for bevy on my build server, but I need a way to have a stable reference to a particular card when I'm spawning docker containers. Iteration order alone probably would work for this but it's also important longer term for some media server/installation things that use multiple cards that you for sure know you are getting the physical outputs for cards plugged into a certain slot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants