From bb0cbc21c1546820bfa4beb170147129c4234d10 Mon Sep 17 00:00:00 2001 From: Benedikt Mandelkow Date: Fri, 10 May 2024 16:10:13 +0200 Subject: [PATCH] Update project to work with wgpu 0.20 and imgui 0.12 and winit 0.29 --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++-- Cargo.toml | 30 +++++++++++++++--------------- examples/cube.rs | 9 ++++----- examples/custom-texture.rs | 5 +---- examples/hello-world.rs | 7 ++----- src/lib.rs | 2 ++ 6 files changed, 56 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 705fb2f..ba68ee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/ and this project adheres to cargo's version of [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Per Keep a Changelog there are 6 main categories of changes: + - Added - Changed - Deprecated @@ -37,7 +38,9 @@ Per Keep a Changelog there are 6 main categories of changes: ## Unreleased - Internal: Fixed Scissor-Rect to not span across Framebuffersize, by limiting to framebuffer width. @PixelboysTM -- Bump wgpu version to 0.19. @sarchar (changes based on @calcoph pull request) +- Bump wgpu version to 0.20. @sarchar (0.19), @benmkw (0.20) +- Bump imgui version to 0.12.0. @benmkw +- Bump winit version to 0.29.3. @benmkw ## v0.24.0 @@ -54,6 +57,7 @@ Released 2023-08-02 ## v0.22.0 Released 2023-02-10 + - Change `BindGroup` inside `Texture::from_raw_parts` to `Option` to allow bind group being created by `imgui-wgpu-rs` @BeastLe9enD - Make `Texture::from_raw_parts` take `Arc` instead of `T` to avoid being forced to move into the texture @BeastLe9enD - Moved from Rust Edition 2018 -> 2021 @Snowiiii @@ -62,6 +66,7 @@ Released 2023-02-10 ## v0.21.0 Released 2022-12-17 + - Bump imgui version to 0.9.0. Fix examples to match. @aholtzma-am ## v0.20.0 @@ -69,10 +74,12 @@ Released 2022-12-17 Released 2022-07-11 ### Updated + - updated `wgpu` to 0.13 @Davidster - Internal: Use Fifo present mode in examples @Davidster ### Fixed + - Fix issues with resizing due to the framebuffer size not being updated. @druks-232cc ## v0.19.0 @@ -80,14 +87,17 @@ Released 2022-07-11 Released 2021-12-30 ### Changed + - Split up render into two internal functions, `prepare` and `split_render`. - Add `SamplerDesc` to TextureConfig ### Updated + - updated wgpu dependency to `0.12` ### Removed -- unreleased `simple-api` and moved to https://github.com/benmkw/imgui-wgpu-simple-api + +- unreleased `simple-api` and moved to ## v0.18.0 @@ -98,6 +108,7 @@ Released 2021-10-08 Released 2021-10-08 #### Updated + - updated wgpu dependency to `>=0.10,<0.12` ## v0.17.1 @@ -105,9 +116,11 @@ Released 2021-10-08 Released 2021-09-22 #### Updated + - updated imgui dependency to `>=0.1,<0.9` #### Removed + - unstable simple-api is now it's own, unpublished, crate. ## v0.17.0 @@ -115,12 +128,15 @@ Released 2021-09-22 Released 2021-09-04 #### Changed + - Internal: translate shaders from SPIR-V to WGSL #### Updated + - updated `wgpu` to 0.10 #### Fixed + - Internal: fix all warnings from static analysis (clippy). - Internal: Do not render draw commands that fall outside the framebuffer - Internal: Avoid wgpu logic error by not rendering empty clip rects @@ -130,18 +146,22 @@ Released 2021-09-04 Released 2021-07-14 #### Added + - Internal: Vastly improved CI and release process. - Internal: PR and Issue Templates #### Changed + - Examples: Use `env_logger` instead of `wgpu-subscriber` - Examples: Use `pollster` as block_on provider instead of `futures` #### Fixed + - Rendering to multi-sampled images no longer errors. - Examples: Simple API examples now properly depend on that feature existing. #### Updated + - updated `wgpu` to 0.9 ## v0.15.1 @@ -149,9 +169,11 @@ Released 2021-07-14 Released 2021-05-08 #### Fixed + - removed hack due to wgpu bug #### Updated + - updated `wgpu` to 0.8.1 ## v0.15.0 @@ -159,6 +181,7 @@ Released 2021-05-08 Released 2021-05-08 #### Updated + - updated `wgpu` to 0.8 ## v0.14.0 @@ -166,6 +189,7 @@ Released 2021-05-08 Released 2021-02-12 #### Updated + - updated `imgui` to 0.7 ## v0.13.1 @@ -173,6 +197,7 @@ Released 2021-02-12 Released 2021-02-01 #### Fixed + - Readme ## v0.13.0 @@ -180,10 +205,12 @@ Released 2021-02-01 Released 2021-02-01 #### Added + - Add experimental simple api behind feature `simple_api_unstable` - Implemented `std::error::Error` for `RendererError` #### Updated + - updated to `wgpu` 0.7 - support `winit` 0.24 as well as 0.23 @@ -192,15 +219,18 @@ Released 2021-02-01 Released 2020-11-21 #### Added + - A changelog! - Shaders are now SRGB aware. Choose `RendererConfig::new()` to get shaders outputting in linear color and `RendererConfig::new_srgb()` for shaders outputting SRGB. #### Updated + - `imgui` to `0.6`. - `winit` to `0.23` #### Removed + - GLSL shaders and `glsl-to-spirv`. If you want a custom shader, provide custom spirv to `RendererConfig::with_shaders()`, however you must generate it. ## Diffs diff --git a/Cargo.toml b/Cargo.toml index 1969ed2..39ddfa4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,11 @@ [package] name = "imgui-wgpu" version = "0.24.0" -authors = ["Noah Hüsser ", "Connor Fitzgerald ", "Steven Wittens "] +authors = [ + "Noah Hüsser ", + "Connor Fitzgerald ", + "Steven Wittens ", +] edition = "2021" description = "A wgpu render backend for imgui-rs." documentation = "https://docs.rs/imgui-wgpu/" @@ -12,11 +16,7 @@ categories = ["gui", "graphics", "rendering", "rendering::graphics-api"] keywords = ["gui", "graphics", "wgpu", "imgui"] license = "MIT OR Apache-2.0" -exclude = [ - ".gitignore", - ".github", - "resources", -] +exclude = [".gitignore", ".github", "resources"] [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" @@ -34,29 +34,29 @@ replace = "## Unreleased\n\n## v{{version}}\n\nReleased {{date}}" file = "CHANGELOG.md" search = "\\[Unreleased\\]\\(https://github.com/Yatekii/imgui-wgpu-rs/compare/v([a-z0-9.-]+)\\.\\.\\.HEAD\\)" replace = "[Unreleased](https://github.com/Yatekii/imgui-wgpu-rs/compare/v{{version}}...HEAD)\n- [v{{version}}](https://github.com/Yatekii/imgui-wgpu-rs/compare/v$1...v{{version}})" -min = 0 # allow first increment +min = 0 # allow first increment [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" search = "" replace = "- [Unreleased](https://github.com/Yatekii/imgui-wgpu-rs/compare/v{{version}}...HEAD)" -min = 0 # allow non-first increment +min = 0 # allow non-first increment [dependencies] bytemuck = "1" -imgui = { git = "https://github.com/imgui-rs/imgui-rs" } +imgui = "0.12" log = "0.4" smallvec = "1" -wgpu = "0.19" +wgpu = "0.20" [dev-dependencies] bytemuck = { version = "1.13", features = ["derive"] } cgmath = "0.18" -env_logger = "0.10" -image = { version = "0.24", default-features = false, features = ["png"] } -imgui-winit-support = { git = "https://github.com/imgui-rs/imgui-rs" } +env_logger = "0.11.3" +image = { version = "0.25.1", default-features = false, features = ["png"] } +imgui-winit-support = "0.12" pollster = "0.3" -raw-window-handle = "0.5" -winit = "0.29" +raw-window-handle = "0.6.1" +winit = "0.29.3" [package.metadata.docs.rs] all-features = true diff --git a/examples/cube.rs b/examples/cube.rs index c79ec83..bb06aa5 100644 --- a/examples/cube.rs +++ b/examples/cube.rs @@ -6,7 +6,7 @@ use std::time::Instant; use wgpu::{include_wgsl, util::DeviceExt, Extent3d}; use winit::{ dpi::LogicalSize, - event::{ElementState, Event, WindowEvent, KeyEvent}, + event::{ElementState, Event, KeyEvent, WindowEvent}, event_loop::{ControlFlow, EventLoop}, keyboard::{Key, NamedKey}, window::Window, @@ -255,11 +255,14 @@ impl Example { module: &shader, entry_point: "vs_main", buffers: &vertex_buffers, + compilation_options: Default::default(), }, + fragment: Some(wgpu::FragmentState { module: &shader, entry_point: "fs_main", targets: &[Some(config.format.into())], + compilation_options: Default::default(), }), primitive: wgpu::PrimitiveState { cull_mode: Some(wgpu::Face::Back), @@ -348,7 +351,6 @@ fn main() { window.set_title(&format!("imgui-wgpu {version}")); let size = window.inner_size(); - (window, size) }; @@ -446,9 +448,6 @@ fn main() { // Event loop let _ = event_loop.run(|event, elwt| { - if cfg!(feature = "metal-auto-capture") { - elwt.exit(); - }; match event { Event::WindowEvent { event: WindowEvent::Resized(size), diff --git a/examples/custom-texture.rs b/examples/custom-texture.rs index 7558d31..5d8c4af 100644 --- a/examples/custom-texture.rs +++ b/examples/custom-texture.rs @@ -6,7 +6,7 @@ use std::time::Instant; use wgpu::Extent3d; use winit::{ dpi::LogicalSize, - event::{ElementState, Event, WindowEvent, KeyEvent}, + event::{ElementState, Event, KeyEvent, WindowEvent}, event_loop::{ControlFlow, EventLoop}, keyboard::{Key, NamedKey}, window::Window, @@ -139,9 +139,6 @@ fn main() { // Event loop let _ = event_loop.run(|event, elwt| { - if cfg!(feature = "metal-auto-capture") { - elwt.exit(); - }; match event { Event::WindowEvent { event: WindowEvent::Resized(size), diff --git a/examples/hello-world.rs b/examples/hello-world.rs index 715c87d..658eda7 100644 --- a/examples/hello-world.rs +++ b/examples/hello-world.rs @@ -7,7 +7,7 @@ use pollster::block_on; use std::time::Instant; use winit::{ dpi::LogicalSize, - event::{ElementState, Event, WindowEvent, KeyEvent}, + event::{ElementState, Event, KeyEvent, WindowEvent}, event_loop::{ControlFlow, EventLoop}, keyboard::{Key, NamedKey}, window::Window, @@ -111,9 +111,6 @@ fn main() { // Event loop let _ = event_loop.run(|event, elwt| { - if cfg!(feature = "metal-auto-capture") { - elwt.exit(); - }; match event { Event::WindowEvent { event: WindowEvent::Resized(size), @@ -135,7 +132,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::KeyboardInput { - event: + event: KeyEvent { logical_key: Key::Named(NamedKey::Escape), state: ElementState::Pressed, diff --git a/src/lib.rs b/src/lib.rs index 095794c..c8bdcec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -448,6 +448,7 @@ impl Renderer { step_mode: VertexStepMode::Vertex, attributes: &vertex_attr_array![0 => Float32x2, 1 => Float32x2, 2 => Unorm8x4], }], + compilation_options: Default::default(), }, primitive: PrimitiveState { topology: PrimitiveTopology::TriangleList, @@ -488,6 +489,7 @@ impl Renderer { }), write_mask: ColorWrites::ALL, })], + compilation_options: Default::default(), }), multiview: None, });