jack1232 / wgpu03

2 stars 0 forks source link

example wgpu03 panics on linux #1

Open ToddG opened 1 year ago

ToddG commented 1 year ago

On my linux machine, example wgpu02 lists my adapters an opens a blank window as expected. Here are the adapters it lists:

/home/todd/temp/wgpu-examples/wgpu02/target/debug/wgpu02
AdapterInfo { name: "AMD Unknown (RADV RENOIR)", vendor: 4098, device: 5686, device_type: IntegratedGpu, backend: Vulkan }
AdapterInfo { name: "llvmpipe (LLVM 15.0.6, 256 bits)", vendor: 65541, device: 0, device_type: Cpu, backend: Vulkan }
AdapterInfo { name: "RENOIR (renoir, LLVM 15.0.6, DRM 3.47, 5.19.0-42-generic)", vendor: 4098, device: 0, device_type: Other, backend: Gl }

However, example wgpu03 panics with:

"Failed to find an appropriate adapter"

here in the .request_adapter() call:

pub async fn run(event_loop: EventLoop<()>, window: Window) {      
    let size = window.inner_size();
    let instance = wgpu::Instance::new(wgpu::Backends::DX12);
    let surface = unsafe { instance.create_surface(&window) };
    let adapter = instance
        .request_adapter(&wgpu::RequestAdapterOptions {
            power_preference: wgpu::PowerPreference::default(),
            compatible_surface: Some(&surface),
            force_fallback_adapter: false,
        })
        .await
        .expect("Failed to find an appropriate adapter");

Machine

$ uname -a

Linux 5.19.0-42-generic #43~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Apr 21 16:51:08 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy

$ sudo lspci -v | less

01:00.0 VGA compatible controller: NVIDIA Corporation TU116M [GeForce GTX 1660 Ti Mobile] (rev a1) (prog-if 00 [VGA controller])
        Subsystem: ASUSTeK Computer Inc. TU116M [GeForce GTX 1660 Ti Mobile]
        Flags: fast devsel, IRQ 255, IOMMU group 9
        Memory at fb000000 (32-bit, non-prefetchable) [disabled] [size=16M]
        Memory at b0000000 (64-bit, prefetchable) [disabled] [size=256M]
        Memory at c0000000 (64-bit, prefetchable) [disabled] [size=32M]
        I/O ports at f000 [disabled] [size=128]
        Expansion ROM at fc000000 [disabled] [size=512K]
        Capabilities: [60] Power Management version 3
        Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
        Capabilities: [78] Express Legacy Endpoint, MSI 00
        Capabilities: [100] Virtual Channel
        Capabilities: [250] Latency Tolerance Reporting
        Capabilities: [258] L1 PM Substates
        Capabilities: [128] Power Budgeting <?>
        Capabilities: [420] Advanced Error Reporting
        Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
        Capabilities: [900] Secondary PCI Express
        Capabilities: [bb0] Physical Resizable BAR
        Kernel modules: nvidiafb, nouveau

$ sudo lshw -numeric -C display

  *-display UNCLAIMED       
       description: VGA compatible controller
       product: TU116M [GeForce GTX 1660 Ti Mobile] [10DE:2191]
       vendor: NVIDIA Corporation [10DE]
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress vga_controller cap_list
       configuration: latency=0
       resources: memory:fb000000-fbffffff memory:b0000000-bfffffff memory:c0000000-c1ffffff ioport:f000(size=128) memory:fc000000-fc07ffff
  *-display
       description: VGA compatible controller
       product: Renoir [1002:1636]
       vendor: Advanced Micro Devices, Inc. [AMD/ATI] [1002]
       physical id: 0
       bus info: pci@0000:05:00.0
       logical name: /dev/fb0
       version: c6
       width: 64 bits
       clock: 33MHz
       capabilities: pm pciexpress msi msix vga_controller bus_master cap_list fb
       configuration: depth=32 driver=amdgpu latency=0 resolution=2560,1440
       resources: irq:43 memory:d0000000-dfffffff memory:e0000000-e01fffff ioport:c000(size=256) memory:fc500000-fc57ffff

Clearly I have a GPU see specs here. What do I need to do to get the wgpu03 example working?

jack1232 commented 1 year ago

My Windows 11 machine has backends DX12 and Vulkan, and I found that DX12 works better. So I used DX12 backend to create the instance:

let instance = wgpu::Instance::new(wgpu::Backends::DX12);

In your Linux machine, you may use Vulkan backend instead:

let instance = wgpu::Instance::new(wgpu::Backends::VULKAN);

or just use all() as backend:

let instance = wgpu::Instance::new(wgpu::Backends::all());

don't know if this fixes your problem.