Coder Social home page Coder Social logo

parasyte / pixels Goto Github PK

View Code? Open in Web Editor NEW
1.8K 14.0 117.0 4.09 MB

A tiny hardware-accelerated pixel frame buffer. ๐Ÿฆ€

Home Page: https://docs.rs/pixels

License: MIT License

Rust 98.71% WGSL 1.29%
game-development emulators gpu rust pixel-perfect

pixels's Introduction

Crates.io Documentation GitHub actions GitHub activity GitHub Sponsors

Pixels Logo

A tiny hardware-accelerated pixel frame buffer. ๐Ÿฆ€

But why?

Rapidly prototype a simple 2D game, pixel-based animations, software renderers, or an emulator for your favorite platform. Then add shaders to simulate a CRT or just to spice it up with some nice VFX.

pixels is more than just a library to push pixels to a screen, but less than a full framework. You're in charge of managing a window environment, event loop, and input handling.

MSRV Policy

The Minimum Supported Rust Version for pixels will always be made available in the MSRV.md file on GitHub.

Features

  • Built on modern graphics APIs powered by wgpu: Vulkan, Metal, DirectX 12, OpenGL ES3.
    • DirectX 11, WebGL2, and WebGPU support are a work in progress.
  • Use your own custom shaders for special effects.
  • Hardware accelerated scaling on perfect pixel boundaries.
  • Supports non-square pixel aspect ratios. (WIP)

Examples

Games ๐ŸŽฎ

Demos ๐Ÿงช

Troubleshooting

Driver issues

The most common issue is having an outdated graphics driver installed on the host machine. pixels requests a low power (aka integrated) GPU by default. If the examples are not working for any reason, you may try setting the WGPU_POWER_PREF=high environment variable to see if that addresses the issue on your host machine.

You should also try to keep your graphics drivers up-to-date, especially if you have an old Intel integrated GPU. Keep in mind that some drivers and GPUs are EOL and will not be supported.

Logging

You may want to use the RUST_LOG environment variable (see env_logger for full documentation) to gain additional insight while troubleshooting the examples. RUST_LOG=trace will spew all logs to stderr on debug builds:

$ RUST_LOG=trace cargo run --package minimal-winit

And also on release builds when default features are disabled:

$ RUST_LOG=trace cargo run --package minimal-winit --release --no-default-features

Comparison with minifb

The minifb crate shares some similarities with pixels; it also allows rapid prototyping of 2D games and emulators. But it requires the use of its own window/GUI management, event loop, and input handling. One of the disadvantages with the minifb approach is the lack of hardware acceleration (except on macOS, which uses Metal but is not configurable). An advantage is that it relies on fewer dependencies.

Comparison with softbuffer

There is a more recent project called softbuffer. It provides similar capabilities to what pixels offers, but is intentionally limited to software-only (not hardware-accelerated) rasterization.

pixels's People

Contributors

aeledfyr avatar anonymousdapper avatar barzamin avatar dtcristo avatar huanzo avatar imizao avatar jeffreyrosenbluth avatar jms55 avatar joshlambda avatar kanabenki avatar lovesegfault avatar moalyousef avatar nxsaken avatar parasyte avatar prototypenm1 avatar randommist avatar schnippl0r avatar squ1dd13 avatar thomcc avatar tseli0s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pixels's Issues

How can I resize the pixel buffer itself

I want to be able to change the resolution the program is running at after initialization. I'm aware that Pixels.resize(width: u8, height: u8) resizes the surface the buffer is drawn on but that's not what I'm looking for. I've tried creating a new instance of pixels and replacing the old one like this: pixels = pixels::PixelsBuilder::new(window_size.width, window_size.height, SurfaceTexture::new(window_size.width, window_size.height, &window)).enable_vsync(false).build().unwrap();. However, this causes an error when attempting to render it again: log.txt

crash running example on linux with wayland

hello, just thought I'd file this here:

RUST_BACKTRACE=full cargo run --example invaders
    Finished dev [unoptimized + debuginfo] target(s) in 0.07s
     Running `target/debug/examples/invaders`
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0:     0x55b548e031ab - backtrace::backtrace::libunwind::trace::h89fcc71e59e3bc5b
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1:     0x55b548e031ab - backtrace::backtrace::trace_unsynchronized::h0bad9be1379e729a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2:     0x55b548e031ab - std::sys_common::backtrace::_print::hd3382a1f33c473da
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x55b548e031ab - std::sys_common::backtrace::print::h0ec6f03cfb8e76a6
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x55b548e031ab - std::panicking::default_hook::{{closure}}::h96cbf7b454e3f557
                               at src/libstd/panicking.rs:200
   5:     0x55b548e02e86 - std::panicking::default_hook::h95a8f00337383d83
                               at src/libstd/panicking.rs:214
   6:     0x55b548e0391d - std::panicking::rust_panic_with_hook::h92f98b46e22f14ed
                               at src/libstd/panicking.rs:477
   7:     0x55b548e034a2 - std::panicking::continue_panic_fmt::h25abfbb4e5b7043a
                               at src/libstd/panicking.rs:384
   8:     0x55b548e03386 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
   9:     0x55b548e1f61d - core::panicking::panic_fmt::h7e9f94035af782b3
                               at src/libcore/panicking.rs:85
  10:     0x55b548e1f55c - core::panicking::panic::hda536e6f3accfb91
                               at src/libcore/panicking.rs:49
  11:     0x55b548654f6b - core::option::Option<T>::unwrap::h53f213eec78b21d3
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libcore/macros.rs:12
  12:     0x55b5486868a7 - winit::platform_impl::platform::wayland::window::Window::current_monitor::h1fc431212bb70582
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/wayland/window.rs:334
  13:     0x55b5483471ad - winit::platform_impl::platform::Window::current_monitor::h36ec4e3753050276
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/mod.rs:433
  14:     0x55b54831588e - winit::window::Window::current_monitor::h331f66498ad0d993
                               at /home/m4b/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/window.rs:744
  15:     0x55b54831652d - invaders::create_window::h8db4b89ce4d72ed3
                               at examples/invaders/main.rs:144
  16:     0x55b548315c04 - invaders::main::h7e93825e303b3309
                               at examples/invaders/main.rs:26
  17:     0x55b5483324e0 - std::rt::lang_start::{{closure}}::h83eea46cd4c6445f
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  18:     0x55b548e03323 - std::rt::lang_start_internal::{{closure}}::h4e93c1949c7a1955
                               at src/libstd/rt.rs:49
  19:     0x55b548e03323 - std::panicking::try::do_call::h9440ccd4dc467eaa
                               at src/libstd/panicking.rs:296
  20:     0x55b548e07bfa - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  21:     0x55b548e03e2d - std::panicking::try::hc046e7ee42ee744f
                               at src/libstd/panicking.rs:275
  22:     0x55b548e03e2d - std::panic::catch_unwind::h27dfc457c200aee0
                               at src/libstd/panic.rs:394
  23:     0x55b548e03e2d - std::rt::lang_start_internal::hea1b49a567afe309
                               at src/libstd/rt.rs:48
  24:     0x55b5483324b9 - std::rt::lang_start::hf88dabd11b766af7
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  25:     0x55b548316aca - main
  26:     0x7f49b4c81153 - __libc_start_main
  27:     0x55b5482f31ae - _start

AdapterNotFound on Pixel::new

Hi, I am trying to run the minimal-winit example (on git master) and I get

Error: AdapterNotFound

I looked at #83 and #29 and tried WINIT_UNIX_BACKEND=x11 cargo run but got the same error. Installing xorg-server and libx11 but neither helped.

$ echo $XDG_SESSION_DESKTOP
gnome
 
$ echo $XDG_SESSION_TYPE        
wayland
 
$ uname -a 
Linux archlinux 5.4.43-1-lts #1 SMP Wed, 27 May 2020 23:42:34 +0000 x86_64 GNU/Linux

Running the winit example fails

I was interested in experimenting with this crate, but sadly couldn't get the example winit or my own attempts to show anything other than a black window. When running the winit example, I get the following error:

[2020-04-04T18:12:59Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2020-04-04T18:12:59Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2020-04-04T18:12:59Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }

All-black image on macOS

I'm failing to get pixels to work on macOS (specifically, macOS 10.14.6, on a MacBook Pro laptop with integrated Intel Iris Plus GPU). Both in my own project, and when I try any of the bundled examples, I simply get a black window.

For example, here's what I see when I run $ cargo run --release --package invaders. (This was on the master branch, but I see the same with the 0.0.3 tag.)

Screenshot 2020-05-02 at 17 33 06

Any idea what I might be doing wrong, or how to begin troubleshooting?

The examples for the wgpu-rs crate work fine for me, so it seems there's nothing wrong with that part.

Fix usage of winit in examples

None of our examples work on Wayland. Upon some investigation I discovered that this is due to us misusing winit. From IRC:

2020-04-12 01:34:32 kchibisov   lovesegfault: let me debug your thing.
2020-04-12 01:36:44 kchibisov   Oh, I've got the issue.
2020-04-12 01:37:16 kchibisov   yeah, they are calling to monitor too early.
2020-04-12 01:37:32 kchibisov   I absolutely hate what they are doing so.
2020-04-12 01:39:32 lovesegfault    kchibisov: Yeah, did you find they part where they draw the hidden window to figure out a good size?
2020-04-12 01:40:31 kchibisov   yeah, they are doing shit.
2020-04-12 01:40:47 kchibisov   like this code is just bad and won't work..
2020-04-12 01:41:03 kchibisov   first of all `set_inner_size` doesn't guarantee you anything.
2020-04-12 01:41:27 kchibisov   set_outer_position is not a thing on some systems.
2020-04-12 01:42:17 kchibisov   Also, on HiDPI system, initial scale factor is always 1.
2020-04-12 01:42:26 kchibisov   so you'll resize anyways.
2020-04-12 01:43:45 kchibisov   I'll propose to just use scale factor instead of monitor dimensions magic, since THERE'S NO GUARANTEE THAT THEY ARE CORRECT.
2020-04-12 01:44:34 kchibisov   like just use scale factor and don't be smart.

Feature request: additional TextureFormats for pixels.get_frame()

Thank you for the great project!

Just something I bumped into in a personal project, feel absolutely free to say this would be out of scope or similar!

I've been writing a little raytracer lately. So far, I had only written out .png image files when the whole render was ready, but I started looking into having an iterative display of the progress as a gui window.

Looking at example code:

https://github.com/parasyte/pixels/blob/master/examples/minimal-winit/src/main.rs#L49

https://github.com/parasyte/pixels/blob/master/examples/minimal-winit/src/main.rs#L111-L112

I was able to create a minimum viable example, where each draw() call generates a new sample for each pixel and blends them in with the existing pixels. However, because the get_frame() uses a wgpu::TextureFormat::Rgba8UnormSrgb, each individual color component only has u8 aka 256 possible values - converting from that back into my raytracer's float-based colors for blending and back into u8's for the buffer at every draw seems to cause quite a bit of quality loss over multiple iterations.

It seems like wgpu also has a Rgba32Float texture format. Would it be possible to expose that from pixels? This would allow people to use float-based buffers in addition to the u8-based ones ๐Ÿ™‚

Of course another workaround would be for me to store a separate float buffer, do the blending with that, and only use pixels with its u8 frames for output.

(EDIT: i may have also goofed and my artefacts may also come from another part of the code, but leaving this issue up because of the possibility of removing the extra buffer workaround in the future)

Use the preferred texture format for the swap chain

This is a followup to #134 (comment)

Note from @JMS55:

Default to wgpu::Adapter::get_swap_chain_preferred_format(), and expose the chosen option. I started on this, but I need to put some more thought into it. I forgot that the format you provide your data as to pixels and the format pixels::ScalingRenderer uses aren't necessarily the same. Also needs some thought into how we want this to work in the cases where you're using pixels::ScalingRenderer via pixels::render_with(). It also might require a bit of refactoring. I definitely need to think on this longer.

`minimal-winit` example fails on Windows 10

Hi,

I've tried running the minimal-winit example on my machine (Windows 10, GTX 780):

git clone https://github.com/parasyte/pixels.git
RUST_BACKTRACE=1 cargo run --release --package minimal-winit

and it fails with the following error:

    Finished release [optimized] target(s) in 0.19s
     Running `target\release\minimal-winit.exe`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `-2005270523`', C:\Users\ceran\.cargo\registry\src\github.com-1ecc6299db9ec823\gfx-backend-dx12-0.5.8\src\device.rs:1160:9
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
             at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace\mod.rs:66
   1: std::sys_common::backtrace::_print_fmt
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:78
   2: std::sys_common::backtrace::_print::{{impl}}::fmt
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:59
   3: core::fmt::write
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\fmt\mod.rs:1069
   4: std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\io\mod.rs:1504
   5: std::sys_common::backtrace::_print
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:62
   6: std::sys_common::backtrace::print
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:49
   7: std::panicking::default_hook::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:198
   8: std::panicking::default_hook
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:218
   9: std::panicking::rust_panic_with_hook
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:511
  10: std::panicking::begin_panic_handler
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:419
  11: std::panicking::begin_panic_fmt
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:373
  12: gfx_backend_dx12::device::<impl gfx_hal::device::Device<gfx_backend_dx12::Backend> for gfx_backend_dx12::Device>::allocate_memory
  13: gfx_memory::allocator::allocate_memory_helper
  14: gfx_memory::allocator::general::GeneralAllocator<B>::alloc_from_entry
  15: gfx_memory::allocator::general::GeneralAllocator<B>::alloc_block
  16: gfx_memory::heaps::memory_type::MemoryType<B>::alloc
  17: gfx_memory::heaps::Heaps<B>::allocate
  18: wgpu_core::device::Device<B>::create_buffer
  19: wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_create_buffer_mapped
  20: wgpu_device_create_buffer_mapped
  21: wgpu::Device::create_buffer_mapped
  22: pixels::Pixels::render
  23: core::ptr::drop_in_place
  24: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  25: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::call_event_handler
  26: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event
  27: winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}
  28: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind
  29: winit::platform_impl::platform::event_loop::public_window_callback
  30: DefSubclassProc
  31: DefSubclassProc
  32: CallWindowProcW
  33: DispatchMessageW
  34: SendMessageTimeoutW
  35: KiUserCallbackDispatcher
  36: NtUserDispatchMessage
  37: DispatchMessageW
  38: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::owned_windows
  39: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  40: winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind
  41: winit::platform_impl::platform::event_loop::process_control_flow
  42: DefSubclassProc
  43: DefSubclassProc
  44: CallWindowProcW
  45: DispatchMessageW
  46: SendMessageTimeoutW
  47: KiUserCallbackDispatcher
  48: NtUserDispatchMessage
  49: DispatchMessageW
  50: winit::platform_impl::platform::event_loop::EventLoop<T>::run
  51: core::slice::<impl [T]>::copy_from_slice
  52: core::slice::<impl [T]>::copy_from_slice
  53: <T as core::any::Any>::type_id
  54: std::rt::lang_start_internal::{{closure}}
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:52
  55: std::panicking::try::do_call
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:331
  56: std::panicking::try
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:274
  57: std::panic::catch_unwind
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panic.rs:394
  58: std::rt::lang_start_internal
             at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:51
  59: main
  60: invoke_main
             at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  61: __scrt_common_main_seh
             at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  62: BaseThreadInitThunk
  63: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DeviceLost', C:\Users\ceran\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-core-0.5.6\src\device\life.rs:263:37
stack backtrace:
   0:     0x7ff6f4918e6f - backtrace::backtrace::trace_unsynchronized
                               at C:\Users\VssAdministrator\.cargo\registry\src\github.com-1ecc6299db9ec823\backtrace-0.3.46\src\backtrace\mod.rs:66
   1:     0x7ff6f4918e6f - std::sys_common::backtrace::_print_fmt
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:78
   2:     0x7ff6f4918e6f - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:59
   3:     0x7ff6f492d8db - core::fmt::write
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\fmt\mod.rs:1069
   4:     0x7ff6f491614c - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\io\mod.rs:1504
   5:     0x7ff6f491be6c - std::sys_common::backtrace::_print
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:62
   6:     0x7ff6f491be6c - std::sys_common::backtrace::print
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\sys_common\backtrace.rs:49
   7:     0x7ff6f491be6c - std::panicking::default_hook::{{closure}}
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:198
   8:     0x7ff6f491baaf - std::panicking::default_hook
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:218
   9:     0x7ff6f491c657 - std::panicking::rust_panic_with_hook
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:511
  10:     0x7ff6f491c1df - std::panicking::begin_panic_handler
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:419
  11:     0x7ff6f492bf80 - core::panicking::panic_fmt
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\panicking.rs:111
  12:     0x7ff6f492bdc3 - core::option::expect_none_failed
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libcore\option.rs:1268
  13:     0x7ff6f487b41d - wgpu_core::device::life::LifetimeTracker<B>::triage_submissions::h2424334ea4ae951f
  14:     0x7ff6f473e9b7 - wgpu_core::device::Device<B>::maintain::ha0fccb4077162ede
  15:     0x7ff6f479e23b - wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_poll::h74fb26b513048a23
  16:     0x7ff6f471a293 - pollster::block_on::h79a9b6eab437b4d2
  17:     0x7ff6f466631b - core::ptr::drop_in_place::h6d4ff41febc01009
  18:     0x7ff6f4668c42 - core::ptr::drop_in_place::ha4847f6147387f42
  19:     0x7ff6f466cde9 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h60e65dd8a9451e24
  20:     0x7ffa89121030 - <unknown>
  21:     0x7ffa891235c6 - is_exception_typeof
  22:     0x7ffa8912c454 - _C_specific_handler
  23:     0x7ffa89123021 - is_exception_typeof
  24:     0x7ffa8912c8f1 - _CxxFrameHandler3
  25:     0x7ffa9cad016f - _chkstk
  26:     0x7ffa9ca51c56 - RtlUnwindEx
  27:     0x7ffa8912c75e - _C_specific_handler
  28:     0x7ffa891226a9 - is_exception_typeof
  29:     0x7ffa89122a01 - is_exception_typeof
  30:     0x7ffa89123127 - is_exception_typeof
  31:     0x7ffa8912c8f1 - _CxxFrameHandler3
  32:     0x7ffa9cad00ef - _chkstk
  33:     0x7ffa9ca7b474 - RtlRaiseException
  34:     0x7ffa9ca7b1c5 - RtlRaiseException
  35:     0x7ffa9a6f3e49 - RaiseException
  36:     0x7ffa89124880 - CxxThrowException
  37:     0x7ff6f491fad1 - panic_unwind::real_imp::panic
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libpanic_unwind\seh.rs:316
  38:     0x7ff6f491fa59 - panic_unwind::__rust_start_panic
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libpanic_unwind\lib.rs:96
  39:     0x7ff6f491c848 - std::panicking::rust_panic
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:563
  40:     0x7ff6f491c711 - std::panicking::rust_panic_with_hook
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:533
  41:     0x7ff6f491c1df - std::panicking::begin_panic_handler
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:419
  42:     0x7ff6f491c14c - std::panicking::begin_panic_fmt
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:373
  43:     0x7ff6f48c5837 - gfx_backend_dx12::device::<impl gfx_hal::device::Device<gfx_backend_dx12::Backend> for gfx_backend_dx12::Device>::allocate_memory::h5c9d4a73b9fce54f
  44:     0x7ff6f474324e - gfx_memory::allocator::allocate_memory_helper::he1cb53cdccb042ea
  45:     0x7ff6f4883a39 - gfx_memory::allocator::general::GeneralAllocator<B>::alloc_from_entry::h27d1efa8f674703d
  46:     0x7ff6f4883304 - gfx_memory::allocator::general::GeneralAllocator<B>::alloc_block::hc5730908048121d4
  47:     0x7ff6f4742528 - gfx_memory::heaps::memory_type::MemoryType<B>::alloc::h1143290ec0309284
  48:     0x7ff6f48238d2 - gfx_memory::heaps::Heaps<B>::allocate::h8a877baddd46b9a8
  49:     0x7ff6f47354f3 - wgpu_core::device::Device<B>::create_buffer::h7d189d08e7efe4f4
  50:     0x7ff6f47bf81e - wgpu_core::device::<impl wgpu_core::hub::Global<G>>::device_create_buffer_mapped::h61b0719f8c70383b
  51:     0x7ff6f473f5f1 - wgpu_device_create_buffer_mapped
  52:     0x7ff6f471cce3 - wgpu::Device::create_buffer_mapped::hfdc98300f8869217
  53:     0x7ff6f4718872 - pixels::Pixels::render::h8c75900a1d1505cc
  54:     0x7ff6f4666979 - core::ptr::drop_in_place::h04fc67182a42ed28
  55:     0x7ff6f466cc99 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h60e65dd8a9451e24
  56:     0x7ff6f46682ca - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::call_event_handler::hfc353dc55ec03cc7
  57:     0x7ff6f4666d1a - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::send_event::h9d0d69b8c6d09da8
  58:     0x7ff6f466eb5b - winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}::h74f1313e75735bf7
  59:     0x7ff6f46673ba - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::hfb1e46885aca08dc
  60:     0x7ff6f46691c1 - winit::platform_impl::platform::event_loop::public_window_callback::h5aa8a36e572c7452
  61:     0x7ffa894dd3b6 - DefSubclassProc
  62:     0x7ffa894dd26c - DefSubclassProc
  63:     0x7ffa9ae5e338 - CallWindowProcW
  64:     0x7ffa9ae5debc - DispatchMessageW
  65:     0x7ffa9ae706a3 - SendMessageTimeoutW
  66:     0x7ffa9cacebc4 - KiUserCallbackDispatcher
  67:     0x7ffa9a6a1704 - NtUserDispatchMessage
  68:     0x7ffa9ae5ddca - DispatchMessageW
  69:     0x7ff6f470e16f - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::owned_windows::h93b4a9a51aee181d
  70:     0x7ff6f47100c7 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h9494095fed1948cc
  71:     0x7ff6f470deaa - winit::platform_impl::platform::event_loop::runner::EventLoopRunner<T>::catch_unwind::h72ef4a2234208445
  72:     0x7ff6f470bc7d - winit::platform_impl::platform::event_loop::process_control_flow::hcb16b7ae63dfa9fb
  73:     0x7ffa894dd3b6 - DefSubclassProc
  74:     0x7ffa894dd26c - DefSubclassProc
  75:     0x7ffa9ae5e338 - CallWindowProcW
  76:     0x7ffa9ae5debc - DispatchMessageW
  77:     0x7ffa9ae706a3 - SendMessageTimeoutW
  78:     0x7ffa9cacebc4 - KiUserCallbackDispatcher
  79:     0x7ffa9a6a1704 - NtUserDispatchMessage
  80:     0x7ffa9ae5ddca - DispatchMessageW
  81:     0x7ff6f4668f04 - winit::platform_impl::platform::event_loop::EventLoop<T>::run::h1202e6213ca7c6c8
  82:     0x7ff6f466b472 - core::slice::<impl [T]>::copy_from_slice::h1e30d6cdbba43a4c
  83:     0x7ff6f466bb51 - core::slice::<impl [T]>::copy_from_slice::h1e30d6cdbba43a4c
  84:     0x7ff6f46645d6 - <T as core::any::Any>::type_id::h033edcfbac7515d2
  85:     0x7ff6f491c97a - std::rt::lang_start_internal::{{closure}}
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:52
  86:     0x7ff6f491c97a - std::panicking::try::do_call
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:331
  87:     0x7ff6f491c97a - std::panicking::try
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panicking.rs:274
  88:     0x7ff6f491c97a - std::panic::catch_unwind
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\panic.rs:394
  89:     0x7ff6f491c97a - std::rt::lang_start_internal
                               at /rustc/c7087fe00d2ba919df1d813c040a5d47e43b0fe7\/src\libstd\rt.rs:51
  90:     0x7ff6f466bf27 - main
  91:     0x7ff6f49dce68 - invoke_main
                               at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  92:     0x7ff6f49dce68 - __scrt_common_main_seh
                               at d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  93:     0x7ffa9b506fd4 - BaseThreadInitThunk
  94:     0x7ffa9ca7cec1 - RtlUserThreadStart
thread panicked while panicking. aborting.
error: process didn't exit successfully: `target\release\minimal-winit.exe` (exit code: 0xc000041d)

I'm not really sure what the problem is, as my drivers are up-to-date (451.67) ๐Ÿคท

Render-api-v2 further enhancements

Pixel should store and give out Rc<Device> and probably Rc<Queue> as well.

PixelBuilder should have a scaling_renderer_with_input_texture(texture: &TextureView) method, or don't store it in Pixel, and have the user construct it themselves.

error: could not compile `wgpu-native`

Adding pixels = "0.0.2" to dependencies causes the following error when compiling. I can tell it's an issue with Visual Studio build tools because when i installed them it made the link.exe exit code change from 1181 to 1120. but besides that i'm not really sure what the issue is

   Compiling wgpu-native v0.4.2
error: linking with `link.exe` failed: exit code: 1120                                                                                                                                                           
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.0.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.1.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.10.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.11.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.12.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.13.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.14.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.15.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.2.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.3.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.4.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.5.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.6.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.7.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.8.rcgu.o" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.wgpu_native.en5mh52n-cgu.9.rcgu.o" "/OUT:C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.dll" "/DEF:C:\\Users\\Elijah.000\\AppData\\Local\\Temp\\rustc4TueJz\\lib.def" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.34v9405h3id8js4v.rcgu.o" "/OPT:REF,NOICF" "/DEBUG" "/NATVIS:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis" "/LIBPATH:C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps" "/LIBPATH:C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\build\\spirv_cross-f3d9b019adf8d1cb\\out" "/LIBPATH:C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libvec_map-40fb2e5d5d0bc20b.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\librendy_memory-8614eebacdbb81a9.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libslab-b1cc884c5d3910bc.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libcolorful-3ede600e241666fb.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libhibitset-ad63090756d84f0e.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libatom-c15e81f62dc325cd.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libcopyless-9f41f5589cc8ab14.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\librendy_descriptor-15573bdc80762527.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\librelevant-7488e35bb90ea782.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_backend_vulkan-7a6c8454137b179b.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libarrayvec-45fe720c8d49f620.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libash-da0ab63a15323307.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libshared_library-e6a53d52cf18c69b.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\liblazy_static-0f47665919efc2d9.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_backend_empty-a0ee0debaa849907.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_backend_dx12-6c0a521388a10b9f.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libd3d12-00976f5315de69c1.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_backend_dx11-b5330d49df5998b9.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libwio-d4df133721f2b090.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libparking_lot-08e5deeab469a8aa.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libparking_lot_core-f6afc758b0160a11.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\liblock_api-c2f9817bc400f72c.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libscopeguard-19462f381fd9fbb0.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\liblog-2f1435f61e41e05c.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libcfg_if-ec34dfddbd9996eb.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\liblibloading-43125fb797a1dc59.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libwinapi-4cf64f1039488f76.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\librange_alloc-ff00a044b445ffa1.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_auxil-abebb060e143bdc1.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libfxhash-489e4aed8ff73b88.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libbyteorder-2a5fd6a6439254fb.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libspirv_cross-654419f765893819.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libgfx_hal-6d176bf1b3028b46.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libraw_window_handle-84e5fe61dbf81096.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\liblibc-2d3dc14927d80887.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libsmallvec-4c20a3406e05d320.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libmaybe_uninit-bdc337cabcc28eef.rlib" "C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\libbitflags-32fd7420814d3220.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-8a5a44f7d6eecc27.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libpanic_unwind-02c4adc465c51179.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libhashbrown-f168923b2471eb89.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-83de629a6fe6ea7e.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libbacktrace-dbe2f79a4dff2bfb.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_demangle-fd31f5868238b806.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libunwind-bb388fc928b4655e.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcfg_if-840a2fbe6ef93d4e.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-fa038a450c7df728.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc-d9c83a19446f1049.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_std_workspace_core-6cba6311351b7f84.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-5da1591a1c8aa4bd.rlib" "C:\\Users\\Elijah.000\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcompiler_builtins-f0f714497ea6aee0.rlib" "advapi32.lib" "cfgmgr32.lib" "d3d11.lib" "d3d12.lib" "d3dcompiler.lib" "dxgi.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "synchronization.lib" "user32.lib" "winspool.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib" "/DLL" "/IMPLIB:C:\\Users\\Elijah.000\\Desktop\\coding\\Rust\\Game\\babel\\target\\debug\\deps\\wgpu_native-e421b97e10ca0957.dll.lib"
  = note:    Creating library C:\Users\Elijah.000\Desktop\coding\Rust\Game\babel\target\debug\deps\wgpu_native-e421b97e10ca0957.dll.lib and object C:\Users\Elijah.000\Desktop\coding\Rust\Game\babel\target\debug\deps\wgpu_native-e421b97e10ca0957.dll.exp
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_parser.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_hlsl.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_msl.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cfg.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o)'
          LINK : warning LNK4217: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(wrapper.o)' in function '"public: __cdecl std::runtime_error::runtime_error(class std::runtime_error const &)" (??0runtime_error@std@@QEAA@AEBV01@@Z)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross_util.o)'
          LINK : warning LNK4286: symbol '??0exception@std@@QEAA@AEBV01@@Z (public: __cdecl std::exception::exception(class std::exception const &))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_glsl.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_parser.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_hlsl.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_msl.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cfg.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o)'
          LINK : warning LNK4217: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(wrapper.o)' in function '"public: virtual __cdecl std::runtime_error::~runtime_error(void)" (??1runtime_error@std@@UEAA@XZ)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_cross_util.o)'
          LINK : warning LNK4286: symbol '??1exception@std@@UEAA@XZ (public: virtual __cdecl std::exception::~exception(void))' defined in 'msvcrt.lib(throw_bad_alloc.obj)' is imported by 'libspirv_cross-654419f765893819.rlib(spirv_glsl.o)'
          libspirv_cross-654419f765893819.rlib(spirv_parser.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_hlsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cfg.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(wrapper.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_util.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
          libspirv_cross-654419f765893819.rlib(spirv_glsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl std::exception::exception(char const * const &)" (__imp_??0exception@std@@QEAA@AEBQEBD@Z)
            Hint on symbols that are defined and could potentially match:
              "__declspec(dllimport) public: __cdecl std::exception::exception(class std::exception const &)" (__imp_??0exception@std@@QEAA@AEBV01@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_hlsl.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(wrapper.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(spirv_cross_util.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(spirv_glsl.o) : error LNK2001: unresolved external symbol __imp_sprintf_s
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_cfg.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_parser.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(wrapper.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_glsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_hlsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base0@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_parser.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_hlsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cfg.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(wrapper.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z) 
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_util.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_glsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) char const * __cdecl std::_Winerror_map(int)" (__imp_?_Winerror_map@std@@YAPEBDH@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl terminate(void)" (__imp_?terminate@@YAXXZ) referenced in function "public: void __cdecl std::list<unsigned int,class std::allocator<unsigned int> >::swap(class std::list<unsigned int,class std::allocator<unsigned int> > &)" (?swap@?$list@IV?$allocator@I@std@@@std@@QEAAXAEAV12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl terminate(void)" (__imp_?terminate@@YAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_parser.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Swap_all(struct std::_Container_base0 &)" (__imp_?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Swap_all(struct std::_Container_base0 &)" (__imp_?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_hlsl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Swap_all(struct std::_Container_base0 &)" (__imp_?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Swap_all(struct std::_Container_base0 &)" (__imp_?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross_parsed_ir.o) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base0::_Swap_all(struct std::_Container_base0 &)" (__imp_?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl std::_Container_base12::_Container_base12(void)" (__imp_??0_Container_base12@std@@QEAA@XZ) referenced in function "public: __cdecl std::_Deque_val<struct std::_Deque_simple_types<struct spirv_cross::SPIRFunction *> >::_Deque_val<struct std::_Deque_simple_types<struct spirv_cross::SPIRFunction *> >(void)" (??0?$_Deque_val@U?$_Deque_simple_types@PEAUSPIRFunction@spirv_cross@@@std@@@std@@QEAA@XZ)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl std::_Container_base12::~_Container_base12(void)" (__imp_??1_Container_base12@std@@QEAA@XZ) referenced in function "public: __cdecl std::_Deque_val<struct std::_Deque_simple_types<struct spirv_cross::SPIRFunction *> >::~_Deque_val<struct std::_Deque_simple_types<struct spirv_cross::SPIRFunction *> >(void)" (??1?$_Deque_val@U?$_Deque_simple_types@PEAUSPIRFunction@spirv_cross@@@std@@@std@@QEAA@XZ)
          libspirv_cross-654419f765893819.rlib(spirv_cross.o) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl std::_Container_base12::_Orphan_all(void)" (__imp_?_Orphan_all@_Container_base12@std@@QEAAXXZ) referenced in function "public: void __cdecl std::_Deque_alloc<0,struct std::_Deque_base_types<struct spirv_cross::SPIRFunction *,class std::allocator<struct spirv_cross::SPIRFunction *> > >::_Free_proxy(void)" (?_Free_proxy@?$_Deque_alloc@$0A@U?$_Deque_base_types@PEAUSPIRFunction@spirv_cross@@V?$allocator@PEAUSPIRFunction@spirv_cross@@@std@@@std@@@std@@QEAAXXZ)
          libspirv_cross-654419f765893819.rlib(spirv_glsl.o) : error LNK2019: unresolved external symbol __imp_sprintf referenced in function "protected: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl spirv_cross::CompilerGLSL::convert_float_to_string(struct spirv_cross::SPIRConstant const &,unsigned int,unsigned int)" (?convert_float_to_string@CompilerGLSL@spirv_cross@@IEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBUSPIRConstant@2@II@Z)
          libspirv_cross-654419f765893819.rlib(spirv_msl.o) : error LNK2001: unresolved external symbol __imp_sprintf
          C:\Users\Elijah.000\Desktop\coding\Rust\Game\babel\target\debug\deps\wgpu_native-e421b97e10ca0957.dll : fatal error LNK1120: 10 unresolved externals


error: aborting due to previous error

error: could not compile `wgpu-native`.

To learn more, run the command again with --verbose.```

space invaders - panicked at attempt to subtract with overflow

~/personal_projects/rust/vendor/parasyte/pixels (master)$ DEBUG=true RUST_BACKTRACE=1 cargo run --example invaders --features=invaders
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/examples/invaders`
thread 'main' panicked at 'attempt to subtract with overflow', simple-invaders/src/debug.rs:40:25
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:188
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:205
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:464
  11: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:373
  12: rust_begin_unwind
             at src/libstd/panicking.rs:302
  13: core::panicking::panic_fmt
             at src/libcore/panicking.rs:139
  14: core::panicking::panic
             at src/libcore/panicking.rs:70
  15: simple_invaders::debug::draw_invaders
             at simple-invaders/src/debug.rs:40
  16: simple_invaders::World::draw
             at simple-invaders/src/lib.rs:317
  17: invaders::main::{{closure}}
             at examples/invaders/main.rs:43
  18: winit::platform_impl::platform::sticky_exit_callback
             at /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/mod.rs:693
  19: winit::platform_impl::platform::x11::EventLoop<T>::run_return
             at /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/x11/mod.rs:292
  20: winit::platform_impl::platform::x11::EventLoop<T>::run
             at /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/x11/mod.rs:389
  21: winit::platform_impl::platform::EventLoop<T>::run
             at /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/platform_impl/linux/mod.rs:640
  22: winit::event_loop::EventLoop<T>::run
             at /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.20.0-alpha4/src/event_loop.rs:148
  23: invaders::main
             at examples/invaders/main.rs:36
  24: std::rt::lang_start::{{closure}}
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/rt.rs:61
  25: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:48
  26: std::panicking::try::do_call
             at src/libstd/panicking.rs:287
  27: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:78
  28: std::panicking::try
             at src/libstd/panicking.rs:265
  29: std::panic::catch_unwind
             at src/libstd/panic.rs:396
  30: std::rt::lang_start_internal
             at src/libstd/rt.rs:47
  31: std::rt::lang_start
             at /rustc/73528e339aae0f17a15ffa49a8ac608f50c6cf14/src/libstd/rt.rs:61
  32: main
  33: __libc_start_main
  34: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Game panicked couple of times, with or without DEBUG=true.

Use a pre-compiled shaderc

Building pixels requires cmake, Python, and a bunch of non-rusty tools. It also makes the initial compilation take about 10 minutes on my recent laptop.

shaderc is one of the heaviest dependencies right now. There are a few "manual hacks" that you can try to link against a precompiled shaderc, but we need a real solution. See: https://github.com/google/shaderc-rs#setup

Until rust-gamedev/wg#23 comes to fruition, we might be able to patch shaderc-rs, but we would need a source of pre-compiled libs for all major platforms.

Fix resize with wgpu 0.5

I think I mangled something in #60 that caused window resizing to act weird.
image
Is this the correct behavior? Why doesn't the grid take up the whole screen? Perhaps that should be added to the example if not?

Panic in wgpu when no adapters are available

Original report: #29 (comment)

Debug Backtrace
     Running `target/debug/examples/invaders`
[2019-11-05T08:37:36Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTermPhysDevs:  Failed to detect any valid GPUs in the current config
    object info: (type: INSTANCE, hndl: 94142666705760)
    
[2019-11-05T08:37:36Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
    object info: (type: INSTANCE, hndl: 94142666705760)
    
[2019-11-05T08:37:36Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTermPhysDevs:  Failed to detect any valid GPUs in the current config
    object info: (type: INSTANCE, hndl: 94142666705760)
    
[2019-11-05T08:37:36Z ERROR gfx_backend_vulkan] 
    GENERAL [Loader Message (0)] : setupLoaderTrampPhysDevs:  Failed during dispatch call of 'vkEnumeratePhysicalDevices' to lower layers or loader to get count.
    object info: (type: INSTANCE, hndl: 94142666705760)
    
[2019-11-05T08:37:36Z ERROR gfx_backend_vulkan] Could not enumerate physical devices! Initialization of a object has failed
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
   0:     0x559f4b21165b - backtrace::backtrace::libunwind::trace::h89fcc71e59e3bc5b
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/libunwind.rs:88
   1:     0x559f4b21165b - backtrace::backtrace::trace_unsynchronized::h0bad9be1379e729a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.34/src/backtrace/mod.rs:66
   2:     0x559f4b21165b - std::sys_common::backtrace::_print::hd3382a1f33c473da
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x559f4b21165b - std::sys_common::backtrace::print::h0ec6f03cfb8e76a6
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x559f4b21165b - std::panicking::default_hook::{{closure}}::h96cbf7b454e3f557
                               at src/libstd/panicking.rs:200
   5:     0x559f4b211336 - std::panicking::default_hook::h95a8f00337383d83
                               at src/libstd/panicking.rs:214
   6:     0x559f4b211dcd - std::panicking::rust_panic_with_hook::h92f98b46e22f14ed
                               at src/libstd/panicking.rs:477
   7:     0x559f4b211952 - std::panicking::continue_panic_fmt::h25abfbb4e5b7043a
                               at src/libstd/panicking.rs:384
   8:     0x559f4b211836 - rust_begin_unwind
                               at src/libstd/panicking.rs:311
   9:     0x559f4b22dacd - core::panicking::panic_fmt::h7e9f94035af782b3
                               at src/libcore/panicking.rs:85
  10:     0x559f4b22da0c - core::panicking::panic::hda536e6f3accfb91
                               at src/libcore/panicking.rs:49
  11:     0x559f4ae9aa98 - core::option::Option<T>::unwrap::h6a8982082ab21bf2
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libcore/macros.rs:12
  12:     0x559f4afb2a7d - wgpu_request_adapter
                               at /home/caemor/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-native-0.4.0/src/instance.rs:474
  13:     0x559f4adb33de - wgpu::Adapter::request::h5d0f480938252090
                               at /home/caemor/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.4.0/src/lib.rs:545
  14:     0x559f4adabe25 - pixels::PixelsBuilder::build::h59b6760c73bac5f1
                               at src/lib.rs:413
  15:     0x559f4adab2e4 - pixels::Pixels::new::hd357520d8b07f9a8
                               at src/lib.rs:140
  16:     0x559f4a6eae21 - invaders::main::h1045af4f645b64f7
                               at examples/invaders/main.rs:28
  17:     0x559f4a6e8d20 - std::rt::lang_start::{{closure}}::hda704dadbaa610b3
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  18:     0x559f4b2117d3 - std::rt::lang_start_internal::{{closure}}::h4e93c1949c7a1955
                               at src/libstd/rt.rs:49
  19:     0x559f4b2117d3 - std::panicking::try::do_call::h9440ccd4dc467eaa
                               at src/libstd/panicking.rs:296
  20:     0x559f4b2160aa - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  21:     0x559f4b2122dd - std::panicking::try::hc046e7ee42ee744f
                               at src/libstd/panicking.rs:275
  22:     0x559f4b2122dd - std::panic::catch_unwind::h27dfc457c200aee0
                               at src/libstd/panic.rs:394
  23:     0x559f4b2122dd - std::rt::lang_start_internal::hea1b49a567afe309
                               at src/libstd/rt.rs:48
  24:     0x559f4a6e8cf9 - std::rt::lang_start::h6eaa7268c68ca014
                               at /rustc/625451e376bb2e5283fc4741caa0a3e8a2ca4d54/src/libstd/rt.rs:64
  25:     0x559f4a6ebcfa - main
  26:     0x7febf9b9f153 - __libc_start_main
  27:     0x559f4a6df1ae - _start
  28:                0x0 - <unknown>

Feature request: force a particular scaling factor

I recently ported my emulator to use pixels, and it's great! I love the automatic scaling to the window size.

However, I would also like to allow my users to select a scaling factor that they prefer, regardless of window size. I tried passing my own values to pixels.resize, but this doesn't do what I want.

X11 error / GPU failed to acquire a swapchain frame

Running 'minimal-winit' example on Ubuntu 20.04. This is the logs I get to stdout.

INTEL-MESA: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:08Z ERROR winit::platform_impl::platform] X11 error: XError {
        description: "BadDrawable (invalid Pixmap or Window parameter)",
        error_code: 9,
        request_code: 149,
        minor_code: 4,
    }
[2021-02-05T13:58:09Z ERROR minimal_winit] pixels.render() failed: The GPU failed to acquire a swapchain frame.

The window doesn't render anything and stays completely black. Also doesn't respond to any input, nor does it close when the X button is pressed. When the window is resized, it closes / crashes with no log to stdout.

Black screen on macOS 10.14.6

When running pixels on my MacBook the screen remains black. I've tried running the simple examples on both my MacBook and Linux desktop and everything worked as expected on linux.

rust version
rustc 1.40.0 (73528e339 2019-12-16)
pixels version
pixels = "0.0.3"

Conway example fails with STATUS_ACCESS_VIOLATION on Windows 10

This occurs in both release and debug modes.

Windows Version 10.0.18362 Build 18362
GeForce RTX 2060 (mobile) using driver 430.86

> cargo run --release --example conway
[ snip ]

error: process didn't exit successfully: `target\release\examples\conway.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)

Errors when running examples with gdb

I'm getting a multitude of errors when running the minimal-winit example with gdb, with the latest version of pixels. I'm not sure whether this is actually the fault of pixels, or one of its dependencies.

I'm running Windows 10, and I've tried running both MINGW's version of gdb on the minimal-winit.exe binary, as well as debugging via VS Code using cppvsdbg.

In both cases, I first get an error of the form

warning: D3D12 WARNING: ID3D12Device::CreateConstantBufferView: Resource 0x000001BA43D327C0:'Unnamed ID3D12Resource Object' and 1 other resources contain the GPU Virtual Address range [0x0000000076460000, 0x00000000764600ff] on a Heap (0x000001BA43D2F7B0:'Unnamed ID3D12Heap Object').  This may be OK as long as all of these resources are in the same state however developer probably did not intend to make use of this behavior. [ STATE_CREATION WARNING #926: HEAP_ADDRESS_RANGE_INTERSECTS_MULTIPLE_BUFFERS]

I then continuously get errors of the form

D3D12 ERROR: ID3D12GraphicsCommandList::Reset: Reset fails because the command list was not closed. [ EXECUTION ERROR #544: COMMAND_LIST_OPEN]
D3D12 ERROR: ID3D12CommandAllocator::Reset: The command allocator cannot be reset because a command list is currently being recorded with the allocator. [ EXECUTION ERROR #543: COMMAND_ALLOCATOR_CANNOT_RESET]

When debugging via VS Code, exceptions are thrown:

Exception thrown at 0x00007FFDB45FA799 in minimal-winit.exe: Microsoft C++ exception: _com_error at memory location 0x00000067B6CEEE88.

When checking the option to break on exceptions, the program stops at a location with the following call stack:

KernelBase.dll!00007ffdb45fa799() (Unknown Source:0)
ucrtbase.dll!00007ffdb54fb6fd() (Unknown Source:0)
D3D12.dll!00007ffd74875c0c() (Unknown Source:0)
minimal-winit.exe!winapi::um::d3d12::ID3D12CommandAllocator::Reset() Line 217 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-0.3.9\src\macros.rs:217)
minimal-winit.exe!gfx_backend_dx12::command::{{impl}}::begin(gfx_backend_dx12::command::CommandBuffer * self, gfx_hal::command::CommandBufferFlags _flags, gfx_hal::command::CommandBufferInheritanceInfo<gfx_backend_dx12::Backend>) Line 1165 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\gfx-backend-dx12-0.5.8\src\command.rs:1165)
minimal-winit.exe!gfx_hal::command::CommandBuffer::begin_primary<gfx_backend_dx12::command::CommandBuffer,gfx_backend_dx12::Backend>(gfx_backend_dx12::command::CommandBuffer * self, gfx_hal::command::CommandBufferFlags flags) Line 123 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\gfx-hal-0.5.3\src\command\mod.rs:123)
minimal-winit.exe!wgpu_core::hub::Global<wgpu_core::hub::IdentityManagerFactory>::device_create_command_encoder<wgpu_core::hub::IdentityManagerFactory,gfx_backend_dx12::Backend>(wgpu_core::id::Id<wgpu_core::device::Device<gfx_backend_empty::Backend>> self, wgpu_types::CommandEncoderDescriptor * device_id, core::marker::PhantomData<wgpu_core::id::Id<wgpu_core::command::CommandBuffer<gfx_backend_empty::Backend>>> desc) Line 1356 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-core-0.5.6\src\device\mod.rs:1356)
minimal-winit.exe!wgpu_native::device::wgpu_device_create_command_encoder(wgpu_core::id::Id<wgpu_core::device::Device<gfx_backend_empty::Backend>> device_id, core::option::Option<wgpu_types::CommandEncoderDescriptor*> desc) Line 302 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-native-0.5.1\src\device.rs:302)
minimal-winit.exe!wgpu::Device::create_command_encoder(wgpu::CommandEncoderDescriptor * self) Line 702 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.5.2\src\lib.rs:702)
minimal-winit.exe!pixels::Pixels::render_with<closure-0>(pixels::{{impl}}::render::closure-0 self) Line 283 (d:\Dropbox\Programming\rust\pixelsnew2\src\lib.rs:283)
minimal-winit.exe!pixels::Pixels::render() Line 235 (d:\Dropbox\Programming\rust\pixelsnew2\src\lib.rs:235)
minimal-winit.exe!minimal_winit::main::{{closure}}(minimal_winit::main::closure-0 * event, winit::event::Event<()>, winit::event_loop::EventLoopWindowTarget<()> * control_flow, winit::event_loop::ControlFlow *) Line 50 (d:\Dropbox\Programming\rust\pixelsnew2\examples\minimal-winit\src\main.rs:50)
minimal-winit.exe!winit::platform_impl::platform::event_loop::{{impl}}::run_return::{{closure}}<(),closure-0>(winit::platform_impl::platform::event_loop::{{impl}}::run_return::closure-0 * event, winit::event::Event<()> control_flow, winit::event_loop::ControlFlow *) Line 201 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:201)
minimal-winit.exe!alloc::boxed::{{impl}}::call_mut<(winit::event::Event<()>, mut winit::event_loop::ControlFlow*),FnMut<(winit::event::Event<()>, mut winit::event_loop::ControlFlow*)>>(core::ops::function::Box<FnMut<(winit::event::Event<()>, mut winit::event_loop::ControlFlow*)>> * self, winit::event::Event<()> args, winit::event_loop::ControlFlow *) Line 1023 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\liballoc\boxed.rs:1023)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::{{closure}}<()>(winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::closure-0) Line 239 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:239)
minimal-winit.exe!std::panic::{{impl}}::call_once<(),closure-0>(std::panic::AssertUnwindSafe<closure-0> self) Line 319 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:319)
minimal-winit.exe!std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,()>(unsigned char * data) Line 307 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:307)
minimal-winit.exe!panic_unwind::__rust_maybe_catch_panic() Line 86 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libpanic_unwind\lib.rs:86)
minimal-winit.exe!std::panicking::try<(),std::panic::AssertUnwindSafe<closure-0>>(std::panic::AssertUnwindSafe<closure-0> f) Line 281 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281)
minimal-winit.exe!std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,()>(std::panic::AssertUnwindSafe<closure-0> f) Line 394 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:394)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::catch_unwind<(),(),closure-0>(winit::platform_impl::platform::event_loop::runner::{{impl}}::call_event_handler::closure-0 self) Line 150 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::call_event_handler<()>(winit::event::Event<()> self) Line 247 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:247)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::send_event<()>(winit::event::Event<()> self) Line 208 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:208)
minimal-winit.exe!winit::platform_impl::platform::event_loop::SubclassInput<()>::send_event<()>(winit::event::Event<()> self) Line 90 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:90)
minimal-winit.exe!winit::platform_impl::platform::event_loop::public_window_callback::{{closure}}<()>(winit::platform_impl::platform::event_loop::public_window_callback::closure-0 *) Line 820 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:820)
minimal-winit.exe!core::ops::function::FnOnce::call_once<closure-0,()>(winit::platform_impl::platform::event_loop::public_window_callback::closure-0) Line 232 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libcore\ops\function.rs:232)
minimal-winit.exe!std::panic::{{impl}}::call_once<isize,closure-0>(std::panic::AssertUnwindSafe<closure-0> self) Line 318 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:318)
minimal-winit.exe!std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,isize>(unsigned char * data) Line 305 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:305)
minimal-winit.exe!panic_unwind::__rust_maybe_catch_panic() Line 86 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libpanic_unwind\lib.rs:86)
minimal-winit.exe!std::panicking::try<isize,std::panic::AssertUnwindSafe<closure-0>>(std::panic::AssertUnwindSafe<closure-0> f) Line 281 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281)
minimal-winit.exe!std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,isize>(std::panic::AssertUnwindSafe<closure-0> f) Line 395 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:395)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::catch_unwind<(),isize,closure-0>(winit::platform_impl::platform::event_loop::public_window_callback::closure-0 self) Line 150 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150)
minimal-winit.exe!winit::platform_impl::platform::event_loop::public_window_callback<()>(winapi::shared::windef::HWND__ * window, unsigned int msg, unsigned __int64 wparam, __int64 lparam, unsigned __int64, unsigned __int64 subclass_input_ptr) Line 1893 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:1893)
comctl32.dll!00007ffdae0eb762() (Unknown Source:0)
comctl32.dll!00007ffdae0eb625() (Unknown Source:0)
user32.dll!00007ffdb5f55c1d() (Unknown Source:0)
user32.dll!00007ffdb5f557ec() (Unknown Source:0)
user32.dll!00007ffdb5f61f83() (Unknown Source:0)
ntdll.dll!00007ffdb76bfde4() (Unknown Source:0)
win32u.dll!00007ffdb56a1764() (Unknown Source:0)
user32.dll!00007ffdb5f556fc() (Unknown Source:0)
minimal-winit.exe!winit::platform_impl::platform::event_loop::flush_paint_messages::{{closure}}<()>(winit::platform_impl::platform::event_loop::flush_paint_messages::closure-0 * redraw_window, winapi::shared::windef::HWND__ *) Line 682 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:682)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::owned_windows<(),closure-0>(winit::platform_impl::platform::event_loop::flush_paint_messages::closure-0 self) Line 188 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:188)
minimal-winit.exe!winit::platform_impl::platform::event_loop::flush_paint_messages<()>(core::option::Option<mut winapi::shared::windef::HWND__*> except, winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()> * runner) Line 683 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:683)
minimal-winit.exe!winit::platform_impl::platform::event_loop::thread_event_target_callback::{{closure}}<()>(winit::platform_impl::platform::event_loop::thread_event_target_callback::closure-0) Line 1938 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:1938)
minimal-winit.exe!std::panic::{{impl}}::call_once<isize,closure-0>(std::panic::AssertUnwindSafe<closure-0> self) Line 318 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:318)
minimal-winit.exe!std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure-0>,isize>(unsigned char * data) Line 305 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:305)
minimal-winit.exe!panic_unwind::__rust_maybe_catch_panic() Line 86 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libpanic_unwind\lib.rs:86)
minimal-winit.exe!std::panicking::try<isize,std::panic::AssertUnwindSafe<closure-0>>(std::panic::AssertUnwindSafe<closure-0> f) Line 281 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281)
minimal-winit.exe!std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure-0>,isize>(std::panic::AssertUnwindSafe<closure-0> f) Line 395 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:395)
minimal-winit.exe!winit::platform_impl::platform::event_loop::runner::EventLoopRunner<()>::catch_unwind<(),isize,closure-0>(winit::platform_impl::platform::event_loop::thread_event_target_callback::closure-0 self) Line 150 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop\runner.rs:150)
minimal-winit.exe!winit::platform_impl::platform::event_loop::thread_event_target_callback<()>(winapi::shared::windef::HWND__ * window, unsigned int msg, unsigned __int64 wparam, __int64 lparam, unsigned __int64, unsigned __int64 subclass_input_ptr) Line 2120 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:2120)
comctl32.dll!00007ffdae0eb762() (Unknown Source:0)
comctl32.dll!00007ffdae0eb625() (Unknown Source:0)
user32.dll!00007ffdb5f55c1d() (Unknown Source:0)
user32.dll!00007ffdb5f557ec() (Unknown Source:0)
user32.dll!00007ffdb5f61f83() (Unknown Source:0)
ntdll.dll!00007ffdb76bfde4() (Unknown Source:0)
win32u.dll!00007ffdb56a1764() (Unknown Source:0)
user32.dll!00007ffdb5f556fc() (Unknown Source:0)
minimal-winit.exe!winit::platform_impl::platform::event_loop::EventLoop<()>::run_return<(),closure-0>(minimal_winit::main::closure-0 self) Line 217 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:217)
minimal-winit.exe!winit::platform_impl::platform::event_loop::EventLoop<()>::run<(),closure-0>(winit::platform_impl::platform::event_loop::EventLoop<()> self, minimal_winit::main::closure-0 event_handler) Line 185 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\platform_impl\windows\event_loop.rs:185)
minimal-winit.exe!winit::event_loop::EventLoop<()>::run<(),closure-0>(winit::event_loop::EventLoop<()> self, minimal_winit::main::closure-0 event_handler) Line 149 (c:\Users\drandreasdr\.cargo\registry\src\github.com-1ecc6299db9ec823\winit-0.22.2\src\event_loop.rs:149)
minimal-winit.exe!minimal_winit::main() Line 46 (d:\Dropbox\Programming\rust\pixelsnew2\examples\minimal-winit\src\main.rs:46)
minimal-winit.exe!std::rt::lang_start::{{closure}}<core::result::Result<(), pixels::Error>>(std::rt::lang_start::closure-0 *) Line 67 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67)
[Inline Frame] minimal-winit.exe!std::rt::lang_start_internal::{{closure}}() Line 52 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:52)
minimal-winit.exe!std::panicking::try::do_call<closure-0,i32>() Line 305 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:305)
minimal-winit.exe!panic_unwind::__rust_maybe_catch_panic() Line 86 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libpanic_unwind\lib.rs:86)
[Inline Frame] minimal-winit.exe!std::panicking::try() Line 281 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panicking.rs:281)
[Inline Frame] minimal-winit.exe!std::panic::catch_unwind() Line 394 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\panic.rs:394)
minimal-winit.exe!std::rt::lang_start_internal() Line 51 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:51)
minimal-winit.exe!std::rt::lang_start<core::result::Result<(), pixels::Error>>(core::result::Result<(), pixels::Error>(*)() main, __int64 argc, unsigned char * * argv) Line 67 (d:\rustc\b8cedc00407a4c56a3bda1ed605c6fc166655447\src\libstd\rt.rs:67)
minimal-winit.exe!main๏ฟฝ() (Unknown Source:0)
[Inline Frame] minimal-winit.exe!invoke_main() Line 78 (d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78)
minimal-winit.exe!__scrt_common_main_seh() Line 288 (d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ffdb6677bd4() (Unknown Source:0)
ntdll.dll!00007ffdb768ce51() (Unknown Source:0)

Render API v3

This ticket will track exploration to improve the render API further. This is a superset of #107

First up: Refactor the render API to follow the middleware pattern. This API replaces the CommandEncoder and TextureView references with a single RenderPass ref.

I'm not able to get this to work with closures, so the new API will force the caller to manage the swap chain, command encoder, and render pass. This design isn't in the spirit of pixels, which wants to minimize user responsibility over the GPU.

I also had trouble reusing the RenderPass for both pixels and the custom-shader example, as described by the Encapsulating Graphics Work article. The custom shader samples from a texture that is written by the pixels render pipeline. I have not found a way to make this work with a single render pass, but some quick searching indicates that Vulkan has a concept of subpasses for this (and I cannot find any mention of this concept in webgpu).

Even if subpasses were implicit, the pixel that the fragment shader works on would need to be inout, which is apparently not valid at global scope. I wasn't even able to create a render pass with multiple color attachments (hoping the first pass would use the first attachment, the second pass uses the second attachment) but that didn't work because the render pipeline needs to know about all attachments! I must be missing something because deferred rendering doesn't appear to be possible at all.

Applications exit/crash on window resize on Linux systems

Hi @parasyte,

I have written a small application using pixels and found out that the application crashes on a window resize. I can reproduce the same behaviour with running the example application minimal-winit.

Resizing the window provides the following error message:
[2020-10-09T18:56:49Z ERROR minimal_winit] pixels.render() failed: The GPU failed to acquire a swapchain frame.

Removing the error handling on the pixels.render() call (line 49) and just unwrap()-ing it delivers the following error message:
thread 'main' panicked at 'called 'Result::unwrap()' on an 'Err' value: Swapchain(Outdated)', examples/minimal-winit/src/main.rs:49:29

I tested the window resize on different Linux systems and graphics drivers: ArchLinux+amdgpu, ArchLinux+nvidia, Debian 10+intel. All systems were running X11, not Wayland.
Performing a window resize with the example running under Windows 10 is working as expected.

I have also tested other examples from frameworks that base on winit (piston, amethyst) and window resizing works as expected.

Kind regards

Full Backtrace:

thread 'main' panicked at 'called 'Result::unwrap()' on an 'Err' value: Swapchain(Outdated)', examples/minimal-winit/src/main.rs:49:29
stack backtrace:
   0:     0x562710bc8340 - std::backtrace_rs::backtrace::libunwind::trace::h577ea05e9ca4629a
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/../../backtrace/src/backtrace/libunwind.rs:96
   1:     0x562710bc8340 - std::backtrace_rs::backtrace::trace_unsynchronized::h50b9b72b84c7dd56
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/../../backtrace/src/backtrace/mod.rs:66
   2:     0x562710bc8340 - std::sys_common::backtrace::_print_fmt::h6541cf9823837fac
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/sys_common/backtrace.rs:79
   3:     0x562710bc8340 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf64fbff071026df5
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/sys_common/backtrace.rs:58
   4:     0x562710bead6c - core::fmt::write::h9ddafa4860d8adff
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/fmt/mod.rs:1082
   5:     0x562710bc57a7 - std::io::Write::write_fmt::h1d2ee292d2b65481
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/io/mod.rs:1514
   6:     0x562710bca670 - std::sys_common::backtrace::_print::ha25f9ff5080d886d
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/sys_common/backtrace.rs:61
   7:     0x562710bca670 - std::sys_common::backtrace::print::h213e8aa8dc5405c0
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/sys_common/backtrace.rs:48
   8:     0x562710bca670 - std::panicking::default_hook::{{closure}}::h6482fae49ef9d963
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:200
   9:     0x562710bca3bc - std::panicking::default_hook::he30ad7589e0970f9
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:219
  10:     0x562710bcacd3 - std::panicking::rust_panic_with_hook::haa1ed36ada4ffb03
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:569
  11:     0x562710bca8a9 - std::panicking::begin_panic_handler::{{closure}}::h7001af1bb21aeaeb
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:476
  12:     0x562710bc87cc - std::sys_common::backtrace::__rust_end_short_backtrace::h39910f557f5f2367
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/sys_common/backtrace.rs:153
  13:     0x562710bca869 - rust_begin_unwind
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:475
  14:     0x562710be8901 - core::panicking::panic_fmt::h4e2659771ebc78eb
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/panicking.rs:85
  15:     0x562710be8723 - core::option::expect_none_failed::h448b58a024c2c33a
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/option.rs:1221
  16:     0x56270ffa17dd - core::result::Result<T,E>::unwrap::h23db5a3d825cf25a
                               at /home/_/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:973
  17:     0x56270ffb3fba - minimal_winit::main::{{closure}}::h06100a03ce68d0d7
                               at /tmp/pixels/examples/minimal-winit/src/main.rs:49
  18:     0x56270ffb1163 - winit::platform_impl::platform::sticky_exit_callback::h1516e1425b3c5c8a
                               at /home/_/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.2/src/platform_impl/linux/mod.rs:698
  19:     0x56270ffb22a5 - winit::platform_impl::platform::x11::EventLoop<T>::run_return::h3cf3834f72dcc8c4
                               at /home/_/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.2/src/platform_impl/linux/x11/mod.rs:312
  20:     0x56270ffb328b - winit::platform_impl::platform::x11::EventLoop<T>::run::h157996e81a5c9084
                               at /home/_/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.2/src/platform_impl/linux/x11/mod.rs:390
  21:     0x56270ffb0d18 - winit::platform_impl::platform::EventLoop<T>::run::h6739777b3595d3a7
                               at /home/_/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.2/src/platform_impl/linux/mod.rs:645
  22:     0x56270ffbfd33 - winit::event_loop::EventLoop<T>::run::h98885696453ed85f
                               at /home/_/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.2/src/event_loop.rs:149
  23:     0x56270ffd69bc - minimal_winit::main::ha83f5fbf0b8052eb
                               at /tmp/pixels/examples/minimal-winit/src/main.rs:45
  24:     0x56270ffd956b - core::ops::function::FnOnce::call_once::hb4b1578fcdd13503
                               at /home/_/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
  25:     0x56270ff8d19e - std::sys_common::backtrace::__rust_begin_short_backtrace::h0505aa401a658e29
                               at /home/_/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137
  26:     0x56270ffbe681 - std::rt::lang_start::{{closure}}::h7f28f9e41a3d708b
                               at /home/_/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66
  27:     0x562710bcb0d1 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6a3209f124be2235
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ops/function.rs:259
  28:     0x562710bcb0d1 - std::panicking::try::do_call::h88ce358792b64df0
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:373
  29:     0x562710bcb0d1 - std::panicking::try::h6311c259678e50fc
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panicking.rs:337
  30:     0x562710bcb0d1 - std::panic::catch_unwind::h56c5716807d659a1
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/panic.rs:379
  31:     0x562710bcb0d1 - std::rt::lang_start_internal::h73711f37ecfcb277
                               at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/std/src/rt.rs:51
  32:     0x56270ffbe657 - std::rt::lang_start::h715b996db0bf322c
                               at /home/_/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65
  33:     0x56270ffd70ba - main
  34:     0x7fbaba1d2152 - __libc_start_main
  35:     0x56270ff8d0be - _start
  36:                0x0 - <unknown>

Add a method to translate mouse coordinates to pixel buffer coordinates

This came up in #37; users will want to use mouse interactions with their favorite window manager, and pixels needs to provide a method for converting coordinates from window surface texture space to pixel buffer texture space. This is especially tricky after resizing the window, since the pixel buffer texture is always scaled to the nearest integer size, leaving a border if necessary.

Safety dance!

See Rust Safety Dance - it's cute!

There is one bit of unsafe code, and that's the Deref impl for the Spirv type:

pixels/src/macros.rs

Lines 34 to 36 in e0225c1

unsafe {
std::slice::from_raw_parts(self.0.as_ptr() as *const u32, self.0.len() / 4)
}

Making pixels 100% safe Rust is kind of a hilarious challenge in an ironic way, considering it sits on top of a mountain of unsafe.

SDL2 support on macOS

There are many crates for interfacing with SDL2. There is only one that also uses raw_window_handle and that's beryllium.

When I attempted to port the minimal-winit example to SDL2 with beryllium, I ran into a showstopper where the raw_window_handle impl is not able to provide an NSView on macOS, and wgpu/gfx doesn't try to get the default contentView from the NSWindow. So it sees a NULL pointer and panics with window does not have a valid contentView.

I could workaround this issue by making the example depend on cocoa, at the expense of adding code that shouldn't be in the example anyway. Another option is building a crate specifically for transforming a raw_window_handle into a raw_window_handle with an NSView. ๐Ÿ˜

Add option for wgpu::PresentMode::Fifo

Hi. It would be nice to have the option to use wgpu::PresentMode::Fifo for V-Sync to be able to limit the execution speed of the event loop. Is there a reason that enabling V-Sync defines explicitly Mailbox as PresentMode?

Cannot compile examples on Manjaro Linux

Hello.When i want to run the minimal-winit example, it fails with the following error message:

error: failed to run custom build command for `x11 v2.18.2`

Caused by:
  process didn't exit successfully: `/run/media/johndoe/drive/pixels/target/debug/build/x11-5f6202afb00aebc3/build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=X11_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=X11_STATIC
  cargo:rerun-if-env-changed=X11_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Command { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"x11\" \"x11 >= 1.4.99.1\"", cause: Os { code: 2, kind: NotFound, message: "No such file or directory" } }', /home/johndoe/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-2.18.2/build.rs:36:67
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

OS: Manjaro Linux with KDE DE

Publish on crates.io

Publishing the crate is currently blocked on wgpu 0.4. We're pinning to an arbitrary revision which fixes some important issues on macOS:

wgpu = { git = "https://github.com/gfx-rs/wgpu-rs", rev = "697393df4793e1a58578209885036114adfb9213" }

Black border on resizing

When I resize the window on the minimal-winit example on macOS Catalina I've got a black border around the content. I have the same problem with the other examples.

image

Scaling display with GPU

Hi, in the announcement posts for this package, there was an example of a chip8 emulator written with it that had a 64x32 pixels screen that was scaled up 50x. How do I do this?

Fix `pixels-mocks` crate

We have cargo doctests enabled in CI, but many of them do not run because they are tagged with no_run. The reason for this is the pixels-mocks crate doesn't generate valid code (it just compiles).

This has resulted in at least one bad example that would have hit an assertion failure:

pixels/src/lib.rs

Lines 352 to 367 in de21862

/// ```no_run
/// # use pixels::Pixels;
/// # let surface = wgpu::Surface::create(&pixels_mocks::RWH);
/// # let surface_texture = pixels::SurfaceTexture::new(1024, 768, surface);
/// const WIDTH: u32 = 320;
/// const HEIGHT: u32 = 240;
///
/// let mut pixels = Pixels::new(WIDTH, HEIGHT, surface_texture)?;
///
/// let pixel_pos = pixels.clamp_pixel_pos((-19, 20));
/// assert_eq!(pixel_pos, (0, 20));
///
/// let pixel_pos = pixels.clamp_pixel_pos((11, 3000));
/// assert_eq!(pixel_pos, (11, 240));
/// # Ok::<(), pixels::Error>(())
/// ```

The last assertion should compare against (11, 239)

Fixing the pixels-mocks crate enough that the examples can run would have prevented this error.

Switch from accepting an `&[u8]` to exposing an `&mut [u8]`

This is from a hint provided by Ralith:

you should arrange for your library to expose an &mut [u8] rather than taking a &[u8] as input; in the future this will allow you to save a copy

Two public API changes:

  • Pixels::render(&mut self, &[u8]) to Pixels::render(&mut self)
  • Add Pixels::get_frame(&mut self) -> &mut [u8]

Using the new API will look like this:

let mut pixels = Pixels::new(320, 240, surface_texture)?;

// ... in `EventsCleared` handler ...
invaders.update(&dt, &controls);
window.request_redraw();

// ... in `RedrawRequested` handler ...
invaders.draw(pixels.get_frame());
pixels.render();

UI with pixels

Hey, I'm pretty new to graphics programming and wgpu. I was wondering how you'd go about adding UI while using pixels?

Would a library like Iced work, since it has wgpu support?

Is this where you'd use render passes?

Cargo workspaces to replace built-in features for building examples

The original switch to feature flags was a workaround for some limitations with complex dependency management with Cargo. A much better approach is using Cargo workspaces to put each example into its own isolated package.

Old way to run an example:

cargo run --release --example invaders --features invaders

New way:

cargo run --release --package invaders

It will be cleaner to maintain, and even cleaner to run! win-win!!

WASM support

It would be awesome if we could get this crate working with WASM! I've looked into this a little bit, and here's what I've found so far. I figure this is more of a tracking issue than anything else, because it looks like the implementation is blocked on more upstream support in wgpu.

First (and easiest), we need to expose an API to create a Pixels instance without blocking. Blocking is not allowed in WASM. This is pretty easy: just add an async version of build() that doesn't use pollster.

After doing this, I modified the minimal-winit example to add a canvas and spawn the (now async) example in WASM. I also modified the default texture format to be Rgba8Unorm because SRGB is not currently supported in Chrome.

Then, I built the example while targeting wasm32-unknown-unknown, and generated the bindings with wasm-bindgen-cli

$ RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build --manifest-path examples\minimal-winit\Cargo.toml --target wasm32-unknown-unknown
$ wasm-bindgen --out-dir target\generated --web .\target\wasm32-unknown-unknown\debug\minimal-winit.wasm
$ python3 -m http.server

Next, I started an HTTP server in the root directory, and loaded the server in my browser (Chrome canary). Further instructions on how to do this here.

Here's where I'm stuck. I get a panic because buffer_get_mapped_range_mut (called by create_buffer_init) isn't implemented for the web backend in wgpu:

minimal-winit.js:333 panicked at 'not implemented', C:\Users\aruss\.cargo\registry\src\github.com-1ecc6299db9ec823\wgpu-0.6.0\src\backend\web.rs:1157:9

Stack:

Error
    at imports.wbg.__wbg_new_59cb74e423758ede (http://localhost:8000/target/generated/minimal-winit.js:339:19)
    at console_error_panic_hook::Error::new::h4bc2c46dd82b9ea7 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[3405]:0xa6966)
    at console_error_panic_hook::hook_impl::h810a5a414ea0321f (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[390]:0x3e1b2)
    at console_error_panic_hook::hook::h47f770812af45fc2 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[3935]:0xadd3a)
    at core::ops::function::Fn::call::heaa8aaab91c5f390 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[3043]:0xa1033)
    at std::panicking::rust_panic_with_hook::h3e6619a8809a443a (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[896]:0x6406f)
    at std::panicking::begin_panic::hee06aa61d0ace97b (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[1504]:0x7e321)
    at <wgpu::backend::web::Context as wgpu::Context>::buffer_get_mapped_range_mut::h2675a7cb5a19d270 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[2536]:0x97f65)
    at <wgpu::Device as wgpu::util::DeviceExt>::create_buffer_init::ha62d9f473e3f1ad2 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[151]:0x17f47)
    at pixels::renderers::ScalingRenderer::new::hedee3d7f7c822c12 (http://localhost:8000/minimal-winit_bg.wasm:wasm-function[130]:0xcb89)

You can see the code that I wrote to do this on my fork.

Feature request: Easy way to use shaders to process images

Say you wanted to add a blur effect to your game. This is easy enough to do: Before you submit your frame to pixels for rendering, calculate the blur, and modify the frame. You have direct access to an array of pixels representing your image, and it's simple.

But wait, it's really slow! You could try adding rayon, but indexing an array in parallel is somewhat tricky, and it's still not quite the speed you wanted. Plus, you're operating on the original image, and not the scaled version that pixels generates, so you will end up with a lower quality result.

Instead, since pixels already uses wgpu, why not do this on the GPU? The problem is that pixels::RenderPass involves learning a ton about wgpu. Instead, I propose a simpler api:

/// Provides a simple way to do parallel processing of images on the GPU
/// 
/// `shader` is a SPIR-V shader, for instance generated with pixels::include_spv!(), that matches the below format
///
/// ```glsl
/// #version 450
/// 
/// layout(set = 0, binding = 0, rgba8ui) uniform uimage2D pixels; // Read only texture generated by the default pixels renderer
/// layout(set = 0, binding = 1, rgba8ui) uniform uimage2D previous_pass; // Read only texture of the previous pass's result
/// layout(set = 0, binding = 2, rgba8ui) uniform uimage2D output; // Writeable texture, write your results to it. For the last render pass, this would be the swapchain's texture.
/// 
/// void main() {
///     // TODO: Show how to get the image size here (all textures would be the same size as the swapchain output)
///     // TODO: Show how to get the current pixel's coordinates here (x, y) (0..IMAGE_WIDTH, 0..IMAGE_HEIGHT)
///     // TODO: Show how to read a pixel (r, g, b, a) (u8, u8, u8, u8) at a given coordinate from a texture
///     // TODO: Show how to write a pixel to output
/// }
/// ```
fn add_simple_render_pass(shader: Vec<u32>) {}

Unanswered questions:

  1. I'm assuming this would use compute shaders. Can we write to the swapchain directly like this? If not, maybe we could have the user supply a fragment shader instead. Pixels would provide the vertex shader.
  2. Do we want to give more control of input/output textures, and how each pass is executed, instead of just a chain? Maybe look at how specs allows specifying parallel systems for this.
  3. Figure out how to fill in the TODO's in the shader
  4. How does this integrate with pixels' regular render passes?

no_std simple-invaders

Lokathor proposed a tongue-in-cheek question about whether simple-invaders runs on N64. It could easily run on N64 if it was no_std! It can continue using Vec and friends from core, but will need to play nicely with a bump allocator. E.g. replacing temporary vectors with arrayvec, like this one:

let mut destroy = Vec::new();

Another thing to do is moving load_pcx to a build script:

/// Convert PCX data to raw pixels
fn load_pcx(pcx: &[u8]) -> CachedSprite {
let mut reader = pcx::Reader::new(Cursor::new(pcx)).unwrap();
let width = reader.width() as usize;
let height = reader.height() as usize;
let mut result = Vec::new();
if reader.is_paletted() {
// Read the raw pixel data
let mut buffer = Vec::new();
buffer.resize_with(width * height, Default::default);
for y in 0..height {
let a = y as usize * width;
let b = a + width;
reader.next_row_paletted(&mut buffer[a..b]).unwrap();
}
// Read the pallete
let mut palette = Vec::new();
let palette_length = reader.palette_length().unwrap() as usize;
palette.resize_with(palette_length * 3, Default::default);
reader.read_palette(&mut palette).unwrap();
// Copy to result with an alpha component
let pixels = buffer
.into_iter()
.map(|pal| {
let i = pal as usize * 3;
&palette[i..i + 3]
})
.flatten()
.cloned()
.collect::<Vec<u8>>();
result.extend_from_slice(&pixels);
} else {
for _ in 0..height {
// Read the raw pixel data
let mut buffer = Vec::new();
buffer.resize_with(width * 3, Default::default);
reader.next_row_rgb(&mut buffer[..]).unwrap();
// Copy to result with an alpha component
let pixels = buffer
.chunks(3)
.map(|rgb| {
let mut rgb = rgb.to_vec();
rgb.push(255);
rgb
})
.flatten()
.collect::<Vec<u8>>();
result.extend_from_slice(&pixels);
}
}
(width, height, Rc::new(result))
}

And finally, replacing rand_core::OsRng with rand_xorshift or randomize

That should be it, for now! Whatever I decide to use for audio will have to be no_std compatible as well. My two options are some-DSP-crate or a decoder like lewton or hound to create raw PCM samples in a build script.

minimal-sdl2 - Could not retrieve any SDL2 window info on Ubuntu 19.10

$ cargo run --example minimal-sdl2 --features="minimal-sdl2"
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/examples/minimal-sdl2`
thread 'main' panicked at 'Could not retrieve any SDL2 window info, and Osspial wrote the trait to be infallible despite that clearly not always being the case, so now you got this panic. https://github.com/rust-windowing/raw-window-handle/issues/new', /home/roman/.cargo/registry/src/github.com-1ecc6299db9ec823/beryllium-0.1.2/src/window.rs:152:7
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Dep installed with:

sudo apt install libsdl2-dev

Should I install something else? I have found this links:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.