sotrh / learn-wgpu

Guide for using gfx-rs's wgpu library.
https://sotrh.github.io/learn-wgpu/
MIT License
1.53k stars 267 forks source link

Missing field during State::New() in "The Surface" #567

Closed ValorZard closed 2 months ago

ValorZard commented 4 months ago

In this part of the code, this is missing a field

        let (device, queue) = adapter.request_device(
            &wgpu::DeviceDescriptor {
                required_features: wgpu::Features::empty(),
                // WebGL doesn't support all of wgpu's features, so if
                // we're building for the web, we'll have to disable some.
               required_limits: if cfg!(target_arch = "wasm32") {
                    wgpu::Limits::downlevel_webgl2_defaults()
                } else {
                    wgpu::Limits::default()
                },
                label: None,
             // rust is complaining that a field named memory_hints is missing here
            },
            None, // Trace path
        ).await.unwrap();

so i decided it add it like so

let (device, queue) = adapter.request_device(
            &wgpu::DeviceDescriptor {
                // blah blah blah
                // ....
                memory_hints: Default::default(), // guess they forgot this
            }, 
        None,).await.unwrap();

I set it to the default. Apparently, this determines how much memory wgpu consumes. Cool!

sotrh commented 2 months ago

Fixed by #570