Update dependencies (#230)

* Move to Edition 2021
* Update `wgpu`, `raw-window-handle`, and all dependencies for the examples
* Update MSRV
* Closes #244
This commit is contained in:
Jay Oster 2021-12-31 14:57:57 -08:00 committed by GitHub
parent 32e14dac7d
commit c1962ae35c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 107 additions and 109 deletions

View file

@ -13,7 +13,7 @@ jobs:
rust:
- stable
- beta
- 1.54.0
- 1.57.0
steps:
- name: Checkout sources
uses: actions/checkout@v2
@ -73,7 +73,7 @@ jobs:
rust:
- stable
- beta
- 1.54.0
- 1.57.0
steps:
- name: Checkout sources
uses: actions/checkout@v2

View file

@ -3,7 +3,7 @@ name = "pixels"
description = "A tiny library providing a GPU-powered pixel frame buffer."
version = "0.8.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
edition = "2021"
repository = "https://github.com/parasyte/pixels"
readme = "README.md"
keywords = ["pixels", "2D", "GPU", "framebuffer"]
@ -20,17 +20,17 @@ include = [
[dependencies]
bytemuck = "1.7"
raw-window-handle = "0.3"
raw-window-handle = "0.4"
thiserror = "1.0"
ultraviolet = "0.8"
wgpu = "0.11"
wgpu = "0.12"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
pollster = "0.2"
[dev-dependencies]
pixels-mocks = { path = "internals/pixels-mocks" }
winit = "0.25"
winit = "0.26"
[workspace]
resolver = "2"

View file

@ -2,7 +2,7 @@
| `pixels` version | `rustc` version |
|------------------|-----------------|
| `0.9.0` | `1.54.0` |
| `0.9.0` | `1.57.0` |
| `0.8.0` | `1.52.0` |
| `0.7.0` | `1.52.0` |
| `0.6.0` | `1.52.0` |

View file

@ -2,8 +2,7 @@
name = "conway"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -18,5 +17,5 @@ line_drawing = "1.0"
log = "0.4"
pixels = { path = "../.." }
randomize = "3.0"
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -2,8 +2,7 @@
name = "custom-shader"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -15,5 +14,5 @@ bytemuck = "1.7"
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -19,7 +19,7 @@ fn vs_main(
[[group(0), binding(0)]] var r_tex_color: texture_2d<f32>;
[[group(0), binding(1)]] var r_tex_sampler: sampler;
[[block]] struct Locals {
struct Locals {
time: f32;
};
[[group(0), binding(2)]] var<uniform> r_locals: Locals;

View file

@ -84,10 +84,7 @@ impl NoiseRenderer {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
filtering: true,
comparison: false,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
wgpu::BindGroupLayoutEntry {
@ -139,6 +136,7 @@ impl NoiseRenderer {
write_mask: wgpu::ColorWrites::ALL,
}],
}),
multiview: None,
});
Self {

View file

@ -2,8 +2,7 @@
name = "imgui-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -13,9 +12,9 @@ default = ["optimize"]
[dependencies]
env_logger = "0.9"
imgui = "0.8"
imgui-wgpu = "0.18"
imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-25"] }
imgui-wgpu = "0.19"
imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-26"] }
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -2,8 +2,7 @@
name = "invaders"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -19,5 +18,5 @@ log = "0.4"
pixels = { path = "../.." }
randomize = "3.0"
simple-invaders = { path = "simple-invaders" }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -2,8 +2,7 @@
name = "minimal-egui"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -11,11 +10,11 @@ optimize = ["log/release_max_level_warn"]
default = ["optimize"]
[dependencies]
egui = "0.15"
egui_wgpu_backend = "0.14"
egui-winit = { version = "0.15", default-features = false, features = ["links"] }
egui = "0.16"
egui_wgpu_backend = "0.16"
egui-winit = { version = "0.16", default-features = false, features = ["links"] }
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -65,15 +65,13 @@ impl Framework {
/// Prepare egui.
pub(crate) fn prepare(&mut self, window: &Window) {
// Begin the egui frame.
// Run the egui frame and create all paint jobs to prepare for rendering.
let raw_input = self.egui_state.take_egui_input(window);
self.egui_ctx.begin_frame(raw_input);
let (output, paint_commands) = self.egui_ctx.run(raw_input, |egui_ctx| {
// Draw the demo application.
self.gui.ui(&self.egui_ctx);
self.gui.ui(egui_ctx);
});
// End the egui frame and create all paint jobs to prepare for rendering.
let (output, paint_commands) = self.egui_ctx.end_frame();
self.egui_state
.handle_output(window, &self.egui_ctx, output);
self.paint_jobs = self.egui_ctx.tessellate(paint_commands);
@ -88,7 +86,7 @@ impl Framework {
) -> Result<(), BackendError> {
// Upload all resources to the GPU.
self.rpass
.update_texture(&context.device, &context.queue, &self.egui_ctx.texture());
.update_texture(&context.device, &context.queue, &self.egui_ctx.font_image());
self.rpass
.update_user_textures(&context.device, &context.queue);
self.rpass.update_buffers(
@ -119,9 +117,10 @@ impl Gui {
fn ui(&mut self, ctx: &CtxRef) {
egui::TopBottomPanel::top("menubar_container").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::menu::menu(ui, "File", |ui| {
ui.menu_button("File", |ui| {
if ui.button("About...").clicked() {
self.window_open = true;
ui.close_menu();
}
})
});

View file

@ -2,8 +2,7 @@
name = "minimal-fltk"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]

View file

@ -26,7 +26,6 @@ fn main() -> Result<(), Error> {
let mut win = Window::default()
.with_size(WIDTH as i32, HEIGHT as i32)
.with_label("Hello Pixels");
win.make_resizable(true);
win.end();
win.show();

View file

@ -2,8 +2,7 @@
name = "minimal-sdl2"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -11,7 +10,9 @@ optimize = ["log/release_max_level_warn"]
default = ["optimize"]
[dependencies]
beryllium = { version = "0.3", features = ["extern_crate_raw_window_handle"] }
beryllium = { version = "0.7", features = ["use-raw-window-handle"] }
env_logger = "0.9"
fermium = { version = "20016.1.1", default-features = false }
log = "0.4"
pixels = { path = "../.." }
zstring = "0.1"

View file

@ -2,8 +2,14 @@
#![forbid(unsafe_code)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use beryllium::*;
use beryllium::{
event::Event,
init::{InitFlags, Sdl},
window::WindowFlags,
};
use fermium::keycode;
use pixels::{Pixels, SurfaceTexture};
use zstring::zstr;
const WIDTH: u32 = 320;
const HEIGHT: u32 = 240;
@ -19,35 +25,37 @@ struct World {
fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let sdl = SDL::init(InitFlags::default())?;
let window =
sdl.create_raw_window("Hello Pixels", WindowPosition::Centered, WIDTH, HEIGHT, 0)?;
let sdl = Sdl::init(InitFlags::EVERYTHING)?;
let window = sdl.create_vk_window(
zstr!("Hello Pixels"),
None,
(WIDTH as i32, HEIGHT as i32),
WindowFlags::ALLOW_HIGHDPI,
)?;
let mut pixels = {
// TODO: Beryllium does not expose the SDL2 `GetDrawableSize` APIs, so choosing the correct
// surface texture size is not possible.
let surface_texture = SurfaceTexture::new(WIDTH, HEIGHT, &window);
let surface_texture = SurfaceTexture::new(WIDTH, HEIGHT, &*window);
Pixels::new(WIDTH, HEIGHT, surface_texture)?
};
let mut world = World::new();
'game_loop: loop {
match sdl.poll_events().and_then(Result::ok) {
while let Some(event) = sdl.poll_event() {
match event {
// Close events
Some(Event::Quit { .. }) => break 'game_loop,
Some(Event::Keyboard(KeyboardEvent {
key: KeyInfo { keycode: key, .. },
..
})) if key == Keycode::ESCAPE => break 'game_loop,
Event::Quit { .. } => break 'game_loop,
Event::Keyboard { keycode: key, .. } if key == keycode::SDLK_ESCAPE => {
break 'game_loop
}
// Resize the window
Some(Event::Window(WindowEvent {
event: WindowEventEnum::Resized { w, h },
..
})) => pixels.resize_surface(w as u32, h as u32),
Event::WindowResized { width, height, .. } => pixels.resize_surface(width, height),
_ => (),
}
}
// Update internal state
world.update();

View file

@ -2,21 +2,20 @@
name = "minimal-web"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
optimize = ["log/release_max_level_warn"]
web = ["wgpu/webgl", "winit/web-sys"]
web = ["wgpu/webgl"]
default = ["optimize"]
[dependencies]
log = "0.4"
pixels = { path = "../.." }
wgpu = "0.11"
winit = "0.25"
winit_input_helper = "0.10"
wgpu = "0.12"
winit = "0.26"
winit_input_helper = "0.11"
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"

View file

@ -2,8 +2,7 @@
name = "minimal-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -14,5 +13,5 @@ default = ["optimize"]
env_logger = "0.9"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"

View file

@ -2,8 +2,7 @@
name = "raqote-winit"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
resolver = "2"
edition = "2021"
publish = false
[features]
@ -15,8 +14,8 @@ env_logger = "0.9"
euclid = "0.22"
log = "0.4"
pixels = { path = "../.." }
winit = "0.25"
winit_input_helper = "0.10"
winit = "0.26"
winit_input_helper = "0.11"
[dependencies.raqote]
git = "https://github.com/jrmuizel/raqote.git"

View file

@ -2,8 +2,8 @@
name = "pixels-mocks"
version = "0.1.0"
authors = ["Jay Oster <jay@kodewerx.org>"]
edition = "2018"
edition = "2021"
publish = false
[dependencies]
raw-window-handle = "0.3"
raw-window-handle = "0.4"

View file

@ -5,9 +5,7 @@ pub struct Rwh;
unsafe impl raw_window_handle::HasRawWindowHandle for Rwh {
fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
#[cfg(target_os = "macos")]
return raw_window_handle::RawWindowHandle::MacOS(
raw_window_handle::macos::MacOSHandle::empty(),
);
return raw_window_handle::RawWindowHandle::AppKit(raw_window_handle::AppKitHandle::empty());
#[cfg(any(
target_os = "linux",
target_os = "dragonfly",
@ -16,13 +14,11 @@ unsafe impl raw_window_handle::HasRawWindowHandle for Rwh {
target_os = "openbsd",
))]
return raw_window_handle::RawWindowHandle::Wayland(
raw_window_handle::unix::WaylandHandle::empty(),
raw_window_handle::WaylandHandle::empty(),
);
#[cfg(target_os = "windows")]
return raw_window_handle::RawWindowHandle::Windows(
raw_window_handle::windows::WindowsHandle::empty(),
);
return raw_window_handle::RawWindowHandle::Win32(raw_window_handle::Win32Handle::empty());
#[cfg(target_os = "ios")]
return raw_window_handle::RawWindowHandle::IOS(raw_window_handle::ios::IOSHandle::empty());
return raw_window_handle::RawWindowHandle::UiKit(raw_window_handle::UiKitHandle::empty());
}
}

View file

@ -5,7 +5,7 @@ struct VertexOutput {
[[builtin(position)]] position: vec4<f32>;
};
[[block]] struct Locals {
struct Locals {
transform: mat4x4<f32>;
};
[[group(0), binding(2)]] var<uniform> r_locals: Locals;

View file

@ -425,6 +425,8 @@ const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
R16Uint
| R16Sint
| R16Float
| R16Unorm
| R16Snorm
| Rg8Unorm
| Rg8Snorm
| Rg8Uint
@ -438,6 +440,8 @@ const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
| Rg16Uint
| Rg16Sint
| Rg16Float
| Rg16Unorm
| Rg16Snorm
| Rgba8Unorm
| Rgba8UnormSrgb
| Rgba8Snorm
@ -457,7 +461,9 @@ const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
| Rg32Float
| Rgba16Uint
| Rgba16Sint
| Rgba16Float => 8.0, // 64.0 / 8.0
| Rgba16Float
| Rgba16Unorm
| Rgba16Snorm => 8.0, // 64.0 / 8.0
// 128-bit formats, 8 bits per component
Rgba32Uint
@ -471,12 +477,12 @@ const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
| Bc1RgbaUnormSrgb
| Bc4RUnorm
| Bc4RSnorm
| Etc2RgbUnorm
| Etc2RgbUnormSrgb
| Etc2RgbA1Unorm
| Etc2RgbA1UnormSrgb
| EacRUnorm
| EacRSnorm => 0.5, // 4.0 * 4.0 / 8.0
| Etc2Rgb8Unorm
| Etc2Rgb8UnormSrgb
| Etc2Rgb8A1Unorm
| Etc2Rgb8A1UnormSrgb
| EacR11Unorm
| EacR11Snorm => 0.5, // 4.0 * 4.0 / 8.0
// 4x4 blocks, 16 bytes per block
Bc2RgbaUnorm
@ -489,8 +495,10 @@ const fn get_texture_format_size(texture_format: wgpu::TextureFormat) -> f32 {
| Bc6hRgbSfloat
| Bc7RgbaUnorm
| Bc7RgbaUnormSrgb
| EacRgUnorm
| EacRgSnorm
| EacRg11Unorm
| EacRg11Snorm
| Etc2Rgba8Unorm
| Etc2Rgba8UnormSrgb
| Astc4x4RgbaUnorm
| Astc4x4RgbaUnormSrgb => 1.0, // 4.0 * 4.0 / 16.0

View file

@ -96,10 +96,7 @@ impl ScalingRenderer {
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
filtering: true,
comparison: false,
},
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: None,
},
wgpu::BindGroupLayoutEntry {
@ -108,7 +105,7 @@ impl ScalingRenderer {
ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false,
min_binding_size: None, // TODO: More efficent to specify this
min_binding_size: None, // TODO: More efficient to specify this
},
count: None,
},
@ -159,6 +156,7 @@ impl ScalingRenderer {
write_mask: wgpu::ColorWrites::ALL,
}],
}),
multiview: None,
});
// Create clipping rectangle