Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Get correct adapter info consistent with wgpuAdapterGetProperties #418

Merged

Conversation

lalitshankarchowdhury
Copy link
Contributor

wgpuAdapterGetInfo was returning incorrect adapter info, which was inconsistent with the previous version (wgpuAdapterGetProperties).

With wgpuAdapterGetProperties:

vendorID: 4098
vendorName: AMD proprietary driver
architecture: 
deviceID: 5686
name: AMD Radeon(TM) Graphics
driverDescription: 24.3.1 (AMD proprietary shader compiler)
adapterType: 0x1
backendType: 0x6

With wgpuAdapterGetInfo:

vendorID: 4098
vendorName: 0x1002
architecture:
deviceID: 5686
name: 0x1636
driverDescription: AMD Radeon(TM) Graphics
adapterType: 0x1
backendType: 0x6

This is what AdapterInfo struct contains:

AdapterInfo {
    name: "AMD Radeon(TM) Graphics",
    vendor: 4098,
    device_type: IntegratedGpu,
    driver: "AMD proprietary driver",
    driver_info: "24.3.1 (AMD proprietary shader compiler)",
    backend: Vulkan,
}

And this is the output after my patch:

vendorID: 4098
vendorName: AMD proprietary driver
architecture:
deviceID: 5686
name: AMD Radeon(TM) Graphics
driverDescription: 24.3.1 (AMD proprietary shader compiler)
adapterType: 0x1
backendType: 0x6

All outputs were fetched from C++.

Copy link
Collaborator

@rajveermalviya rajveermalviya left a comment

Choose a reason for hiding this comment

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

Thanks for catching it and pursuing to fix it!
LGTM!

src/lib.rs Outdated Show resolved Hide resolved
Co-authored-by: Rajesh Malviya <rajveer0malviya@gmail.com>
@rajveermalviya rajveermalviya enabled auto-merge (squash) September 8, 2024 18:10
@rajveermalviya rajveermalviya merged commit 5bd6da3 into gfx-rs:trunk Sep 8, 2024
16 checks passed
@almarklein
Copy link
Collaborator

I pushed a new tag/release.

@almarklein
Copy link
Collaborator

almarklein commented Sep 9, 2024

Oh wait, I'm not sure if these changes are correct. This is what the WebGPU docs say:

image

So, description should map to name, like it did, and device should be the device_id.

@rajveermalviya
Copy link
Collaborator

So, there are explicit fields for deviceId and vendorId in webgpu.h, and the JS spec for device string says that it should be a vendor-specific adapter so this does seem correct mapping. One that seems off is the vendor string which we currently map to AdapterInfo.driver, this could maybe changed to a todo and return an empty string.

I attempted to check what Dawn maps these strings to and discovered that wgpu-native and Dawn are results are similar:

wgpu-native Dawn
Screenshot 2024-09-09 at 17 29 00 Screenshot 2024-09-09 at 17 17 39
wgpu-native Dawn
Screenshot 2024-09-09 at 17 31 15 Screenshot 2024-09-09 at 17 30 45

@almarklein
Copy link
Collaborator

almarklein commented Sep 9, 2024

Aha, thanks for the explanation. I am/was a in part confused by the WebGPU docs saying "'device' is a string that may be a PCI device ID.". That "may" is important, because in our case its not 😉

edit: In wgpu-py we need to map this to a WebGPU compliant dict, and this part feels like its not yet well-defined yet

@almarklein
Copy link
Collaborator

almarklein commented Sep 9, 2024

For future reference, in Chrome I currently get a rather empty dict:

image

@rajveermalviya
Copy link
Collaborator

Yeah I saw that too, it's probably to prevent fingerprinting.

@lalitshankarchowdhury
Copy link
Contributor Author

lalitshankarchowdhury commented Sep 9, 2024

The PCI ID is given by DeviceID BTW 😄.

While creating this PR I had to do a double take and match up with Dawn to check if I was correct or not. 😂

As for the AdapterInfo.driver, it's supposed to be the driver vendor.

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.

3 participants