zig-gamedev icon indicating copy to clipboard operation
zig-gamedev copied to clipboard

Replace deprecated DiscoverDefaultPhysicalDevices with EnumerateAdapters or RequestAdapter

Open Pyrolistical opened this issue 2 years ago • 4 comments

Running any sample prints a warning:

> zig build instanced_pills_wgpu-run 
steps [8/12] zig build-exe instanced_pills_wgpu Debug native... LLD Link... Warning: DiscoverDefaultPhysicalDevices is deprecated. Call EnumerateAdapters or RequestAdapter instead.
info: [zgpu] High-performance device has been selected:
info: [zgpu]   Name: AMD Radeon RX 6950 XT
info: [zgpu]   Driver: D3D12 driver version 31.0.23013.1023
info: [zgpu]   Adapter type: discrete_gpu
info: [zgpu]   Backend type: d3d12

Warning: DiscoverDefaultPhysicalDevices is deprecated. Call EnumerateAdapters or RequestAdapter instead.

That warning is caused by https://github.com/zig-gamedev/zig-gamedev/blob/f0a2b026d86401494fcaa2d74ed73b370491810f/libs/zgpu/src/zgpu.zig#L103

Which eventually calls https://github.com/hexops/dawn/blob/80c358eb63e5f19aa6af04e9bb9903b6c93249bd/src/dawn/native/Instance.cpp#L196

Pyrolistical avatar Jan 29 '24 23:01 Pyrolistical

I get the same warning:

➜  zig-gamedev git:(main) mzig build instanced_pills_wgpu-run
steps [7/12] Warning: DiscoverDefaultPhysicalDevices is deprecated. Call EnumerateAdapters or RequestAdapter instead.
info: [zgpu] High-performance device has been selected:
info: [zgpu]   Name: Apple M2 Max
info: [zgpu]   Driver: Metal driver on macOS Version 14.3 (Build 23D56)
info: [zgpu]   Adapter type: discrete_gpu
info: [zgpu]   Backend type: metal

But on my machine, changing the number of instances when running eventually crashes the app. Without any error message. We think this is an Apple Silicon specific bug. But have you ever seen that happen on your machine?

image

kamidev avatar Feb 02 '24 23:02 kamidev

That's a different issue. The higher the number of instances, the more memory it takes. I suspect the crash is when you run out of memory.

Pyrolistical avatar Feb 02 '24 23:02 Pyrolistical

Yes, perhaps it is unrelated to the issue you reported. But what should happen if you choose 1 000 000 instances (even once) is nothing. Memory usage will increase momentarily but the app should not crash. This is the case on an Intel Mac and some other machines. But on Apple Silicon it can crash the machine.

kamidev avatar Feb 04 '24 06:02 kamidev

This is a known issue we are trying to fix and it would be helpful to know if your (non Apple Silicon) machine behaves correctly, too.

kamidev avatar Feb 04 '24 06:02 kamidev