learn-wgpu: Textures example in Instancing tutorial fails with segmentation fault

Hi, I got segmentation fault with an example using textures in Instancing tutorial. Does this only happen on me? I’m using Wayland and GNOME3 on Manjaro Linux.

Note that my window manager behaves a bit strangely in that it resizes windows after it is created. I suspect the resize is the cause, so I want to know whether this is reproducible on other environments or a very rare issue.

What I did was adding this section to code/beginner/tutorial7-instancing/Cargo.toml

[[example]]
name = "tutorial7-texture"
path = "examples/texture_instances.rs"

and running the command below:

$ cargo run --example tutorial7-texture
warning: unused variable: `instance_buffer_size`
   --> code/beginner/tutorial7-instancing/examples/texture_instances.rs:393:13
    |
393 |         let instance_buffer_size = instance_data.len() * std::mem::size_of::<cgmath::Matrix4<f32>>();
    |             ^^^^^^^^^^^^^^^^^^^^ help: consider prefixing with an underscore: `_instance_buffer_size`
    |
    = note: `#[warn(unused_variables)]` on by default

warning: field is never read: `instances`
   --> code/beginner/tutorial7-instancing/examples/texture_instances.rs:278:5
    |
278 |     instances: Vec<Instance>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

    Finished dev [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/examples/tutorial7-texture`
Segmentation fault (core dumped)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 25 (21 by maintainers)

Most upvoted comments

There is a requirement that all copy_buffer_to_texture calls must have bytes_per_row be a multiple of 256. This went unenforced in wgpu 0.5. However we also added queue.write_texture which does not need everything to be aligned just so, and will fix things automagically for you.