diff --git a/CHANGELOG.md b/CHANGELOG.md index 080771a..a55e061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## v29.0.0 + +- `wgpu` crate version -> 29.0.0 +- `bytemuck` crate version -> 1.25.0 +- `rand` crate version -> 0.10.0 +- `winit` crate version -> 0.30.13 +- `env_logger` crate version -> 0.11.9 +- Minor example updates following the new `wgpu` version + ## v28.0.1 - Fixed the `using_font_bytes_vec()` function which was incomplete diff --git a/Cargo.toml b/Cargo.toml index 710177f..bc4d660 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wgpu_text" authors = ["Leon (Blatko1)"] -version = "28.0.1" +version = "29.0.0" edition = "2024" description = "A simple 2D text renderer for wgpu." license = "MIT" @@ -12,17 +12,17 @@ categories = ["graphics", "rendering"] include = ["src/**/*", "LICENSE", "Cargo.toml", "README.md", ".gitignore"] [dependencies] -wgpu = "28.0.0" +wgpu = "29.0.0" glyph_brush = "0.7.12" log = "0.4.29" -bytemuck = { version = "1.24.0", features = ["derive"] } +bytemuck = { version = "1.25.0", features = ["derive"] } [dev-dependencies] -wgpu = { version = "28.0.0", features = ["spirv"] } -winit = "0.30.12" +wgpu = { version = "29.0.0", features = ["spirv"] } +winit = "0.30.13" pollster = "0.4.0" -env_logger = "0.11.8" -rand = "0.9.2" +env_logger = "0.11.9" +rand = "0.10.0" nalgebra = "0.34.1" [[example]] diff --git a/README.md b/README.md index 0ff6a21..f7c9cec 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Add the following to your `Cargo.toml` file: ```toml [dependencies] -wgpu_text = "28.0.1" +wgpu_text = "29.0.0" ``` ## **Usage** diff --git a/examples/ctx.rs b/examples/ctx.rs index 8db30dc..9d09b8a 100644 --- a/examples/ctx.rs +++ b/examples/ctx.rs @@ -17,7 +17,7 @@ impl Ctx { pub fn new(window: Arc) -> Self { let size = window.inner_size(); let backends = wgpu::Backends::from_env().unwrap_or_else(wgpu::Backends::all); - let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor { + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { backends, flags: wgpu::InstanceFlags::default(), memory_budget_thresholds: Default::default(), @@ -25,10 +25,12 @@ impl Ctx { gl: wgpu::GlBackendOptions { gles_minor_version: wgpu::Gles3MinorVersion::Automatic, fence_behavior: wgpu::GlFenceBehavior::default(), + debug_fns: wgpu::GlDebugFns::Auto, }, dx12: wgpu::Dx12BackendOptions::default(), noop: wgpu::NoopBackendOptions::from_env_or_default(), }, + display: None, }); let surface = instance.create_surface(window).unwrap(); diff --git a/examples/custom_target/custom_target.rs b/examples/custom_target/custom_target.rs index 2674db9..8f5d2b2 100644 --- a/examples/custom_target/custom_target.rs +++ b/examples/custom_target/custom_target.rs @@ -201,7 +201,8 @@ impl ApplicationHandler for State<'_> { }, ], })); - self.pipeline = Some(create_pipeline(device, &[&bind_group_layout], config)); + self.pipeline = + Some(create_pipeline(device, &[Some(&bind_group_layout)], config)); self.section = Some( Section::default() @@ -333,12 +334,17 @@ impl ApplicationHandler for State<'_> { }; let frame = match surface.get_current_texture() { - Ok(frame) => frame, - Err(_) => { + wgpu::CurrentSurfaceTexture::Success(frame) => frame, + wgpu::CurrentSurfaceTexture::Occluded => return, + _ => { surface.configure(device, config); - surface - .get_current_texture() - .expect("Failed to acquire next surface texture!") + let wgpu::CurrentSurfaceTexture::Success(frame) = + surface.get_current_texture() + else { + panic!("Failed to acquire next surface texture!"); + }; + + frame } }; let view = frame @@ -416,11 +422,14 @@ impl ApplicationHandler for State<'_> { fn new_events(&mut self, _event_loop: &ActiveEventLoop, _cause: StartCause) { if self.target_framerate <= self.delta_time.elapsed() { - self.window.clone().unwrap().request_redraw(); + let Some(window) = self.window.clone() else { + return; + }; + + window.request_redraw(); self.delta_time = Instant::now(); self.fps += 1; if self.fps_update_time.elapsed().as_millis() > 1000 { - let window = self.window.as_mut().unwrap(); window.set_title(&format!( "wgpu-text: 'custom_target' example, FPS: {}", self.fps diff --git a/examples/custom_target/pipeline.rs b/examples/custom_target/pipeline.rs index 69b18c3..e74504d 100644 --- a/examples/custom_target/pipeline.rs +++ b/examples/custom_target/pipeline.rs @@ -28,7 +28,7 @@ impl Vertex { pub fn create_pipeline( device: &wgpu::Device, - bind_group_layouts: &[&wgpu::BindGroupLayout], + bind_group_layouts: &[Option<&wgpu::BindGroupLayout>], config: &wgpu::SurfaceConfiguration, ) -> wgpu::RenderPipeline { let vertex_module = diff --git a/examples/depth.rs b/examples/depth.rs index 98a08aa..1bfa6af 100644 --- a/examples/depth.rs +++ b/examples/depth.rs @@ -221,12 +221,17 @@ impl ApplicationHandler for State<'_> { }; let frame = match surface.get_current_texture() { - Ok(frame) => frame, - Err(_) => { + wgpu::CurrentSurfaceTexture::Success(frame) => frame, + wgpu::CurrentSurfaceTexture::Occluded => return, + _ => { surface.configure(device, config); - surface - .get_current_texture() - .expect("Failed to acquire next surface texture!") + let wgpu::CurrentSurfaceTexture::Success(frame) = + surface.get_current_texture() + else { + panic!("Failed to acquire next surface texture!"); + }; + + frame } }; let view = frame @@ -331,8 +336,8 @@ fn main() { ctx: None, depth_stencil: Some(wgpu::DepthStencilState { format: DEPTH_FORMAT, - depth_write_enabled: true, - depth_compare: wgpu::CompareFunction::LessEqual, + depth_write_enabled: Some(true), + depth_compare: Some(wgpu::CompareFunction::LessEqual), stencil: wgpu::StencilState::default(), bias: wgpu::DepthBiasState::default(), }), diff --git a/examples/fonts.rs b/examples/fonts.rs index 32c4ecc..343ec77 100644 --- a/examples/fonts.rs +++ b/examples/fonts.rs @@ -2,8 +2,8 @@ mod ctx; use ctx::Ctx; -use glyph_brush::{FontId, OwnedSection}; use glyph_brush::ab_glyph::FontRef; +use glyph_brush::{FontId, OwnedSection}; use std::sync::Arc; use std::time::{Duration, Instant}; use wgpu_text::glyph_brush::{ @@ -54,12 +54,11 @@ impl ApplicationHandler for State<'_> { let device = &ctx.device; let config = &ctx.config; - self.brush = Some(BrushBuilder::using_font_bytes_vec(vec![self.font1, self.font2]).unwrap().build( - device, - config.width, - config.height, - config.format, - )); + self.brush = Some( + BrushBuilder::using_font_bytes_vec(vec![self.font1, self.font2]) + .unwrap() + .build(device, config.width, config.height, config.format), + ); self.section_0 = Some( Section::default() @@ -206,12 +205,17 @@ impl ApplicationHandler for State<'_> { }; let frame = match surface.get_current_texture() { - Ok(frame) => frame, - Err(_) => { + wgpu::CurrentSurfaceTexture::Success(frame) => frame, + wgpu::CurrentSurfaceTexture::Occluded => return, + _ => { surface.configure(device, config); - surface - .get_current_texture() - .expect("Failed to acquire next surface texture!") + let wgpu::CurrentSurfaceTexture::Success(frame) = + surface.get_current_texture() + else { + panic!("Failed to acquire next surface texture!"); + }; + + frame } }; let view = frame diff --git a/examples/performance.rs b/examples/performance.rs index 15ed905..cb8dc14 100644 --- a/examples/performance.rs +++ b/examples/performance.rs @@ -3,7 +3,7 @@ mod ctx; use ctx::Ctx; use glyph_brush::ab_glyph::FontRef; -use rand::Rng; +use rand::RngExt; use std::sync::Arc; use std::time::{Duration, Instant}; use wgpu_text::glyph_brush::{BuiltInLineBreaker, Layout, Section, Text}; @@ -163,12 +163,17 @@ impl ApplicationHandler for State<'_> { }; let frame = match surface.get_current_texture() { - Ok(frame) => frame, - Err(_) => { + wgpu::CurrentSurfaceTexture::Success(frame) => frame, + wgpu::CurrentSurfaceTexture::Occluded => return, + _ => { surface.configure(device, config); - surface - .get_current_texture() - .expect("Failed to acquire next surface texture!") + let wgpu::CurrentSurfaceTexture::Success(frame) = + surface.get_current_texture() + else { + panic!("Failed to acquire next surface texture!"); + }; + + frame } }; let view = frame diff --git a/examples/simple.rs b/examples/simple.rs index 7ca46ae..f30df3d 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -203,12 +203,17 @@ impl ApplicationHandler for State<'_> { }; let frame = match surface.get_current_texture() { - Ok(frame) => frame, - Err(_) => { + wgpu::CurrentSurfaceTexture::Success(frame) => frame, + wgpu::CurrentSurfaceTexture::Occluded => return, + _ => { surface.configure(device, config); - surface - .get_current_texture() - .expect("Failed to acquire next surface texture!") + let wgpu::CurrentSurfaceTexture::Success(frame) = + surface.get_current_texture() + else { + panic!("Failed to acquire next surface texture!"); + }; + + frame } }; let view = frame diff --git a/src/brush.rs b/src/brush.rs index 6dc31ec..034dba6 100644 --- a/src/brush.rs +++ b/src/brush.rs @@ -202,9 +202,10 @@ impl BrushBuilder<()> { pub fn using_font_bytes_vec( data_vec: Vec<&[u8]>, ) -> Result>, InvalidFont> { - let fonts = data_vec.iter().map(|data| - FontRef::try_from_slice(data) - ).collect::, InvalidFont>>()?; + let fonts = data_vec + .iter() + .map(|data| FontRef::try_from_slice(data)) + .collect::, InvalidFont>>()?; Ok(BrushBuilder::using_fonts(fonts)) } diff --git a/src/pipeline.rs b/src/pipeline.rs index 646203a..384ee02 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -44,7 +44,7 @@ impl Pipeline { let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor { label: Some("wgpu-text Render Pipeline Layout"), - bind_group_layouts: &[&cache.bind_group_layout], + bind_group_layouts: &[Some(&cache.bind_group_layout)], immediate_size: 0, });