diff options
| author | 2025-03-09 01:38:34 +0100 | |
|---|---|---|
| committer | 2025-03-09 01:38:34 +0100 | |
| commit | fb2544021a40d029a99cadda7cf59acf5e7dc455 (patch) | |
| tree | 3760dd8a8c1d3bafaadefd3e07c7c70820e8d582 /wgpu | |
| parent | 86e8494bfa460bdbf506695f8f4b4f01a9cf5088 (diff) | |
| download | iced-fb2544021a40d029a99cadda7cf59acf5e7dc455.tar.gz iced-fb2544021a40d029a99cadda7cf59acf5e7dc455.tar.bz2 iced-fb2544021a40d029a99cadda7cf59acf5e7dc455.zip  | |
Update `wgpu` to `24` and use `cryoglyph` fork
Co-authored-by: Winfried Baumann <codewing@web.de>
Diffstat (limited to '')
| -rw-r--r-- | wgpu/Cargo.toml | 2 | ||||
| -rw-r--r-- | wgpu/src/image/atlas.rs | 10 | ||||
| -rw-r--r-- | wgpu/src/text.rs | 56 | ||||
| -rw-r--r-- | wgpu/src/window/compositor.rs | 16 | 
4 files changed, 43 insertions, 41 deletions
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml index 4b6b0483..50c9f588 100644 --- a/wgpu/Cargo.toml +++ b/wgpu/Cargo.toml @@ -32,7 +32,7 @@ bitflags.workspace = true  bytemuck.workspace = true  futures.workspace = true  glam.workspace = true -glyphon.workspace = true +cryoglyph.workspace = true  guillotiere.workspace = true  log.workspace = true  rustc-hash.workspace = true diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs index a1ec0d7b..3cede8b6 100644 --- a/wgpu/src/image/atlas.rs +++ b/wgpu/src/image/atlas.rs @@ -344,15 +344,15 @@ impl Atlas {              });          encoder.copy_buffer_to_texture( -            wgpu::ImageCopyBuffer { +            wgpu::TexelCopyBufferInfo {                  buffer: &buffer, -                layout: wgpu::ImageDataLayout { +                layout: wgpu::TexelCopyBufferLayout {                      offset: offset as u64,                      bytes_per_row: Some(4 * image_width + padding),                      rows_per_image: Some(image_height),                  },              }, -            wgpu::ImageCopyTexture { +            wgpu::TexelCopyTextureInfo {                  texture: &self.texture,                  mip_level: 0,                  origin: wgpu::Origin3d { @@ -407,7 +407,7 @@ impl Atlas {              }              encoder.copy_texture_to_texture( -                wgpu::ImageCopyTexture { +                wgpu::TexelCopyTextureInfo {                      texture: &self.texture,                      mip_level: 0,                      origin: wgpu::Origin3d { @@ -417,7 +417,7 @@ impl Atlas {                      },                      aspect: wgpu::TextureAspect::default(),                  }, -                wgpu::ImageCopyTexture { +                wgpu::TexelCopyTextureInfo {                      texture: &new_texture,                      mip_level: 0,                      origin: wgpu::Origin3d { diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs index 33fbd4dc..274cc4b7 100644 --- a/wgpu/src/text.rs +++ b/wgpu/src/text.rs @@ -12,10 +12,10 @@ use std::sync::{self, Arc};  pub use crate::graphics::Text; -const COLOR_MODE: glyphon::ColorMode = if color::GAMMA_CORRECTION { -    glyphon::ColorMode::Accurate +const COLOR_MODE: cryoglyph::ColorMode = if color::GAMMA_CORRECTION { +    cryoglyph::ColorMode::Accurate  } else { -    glyphon::ColorMode::Web +    cryoglyph::ColorMode::Web  };  pub type Batch = Vec<Item>; @@ -70,7 +70,7 @@ impl Cache {  }  struct Upload { -    renderer: glyphon::TextRenderer, +    renderer: cryoglyph::TextRenderer,      buffer_cache: BufferCache,      transformation: Transformation,      version: usize, @@ -86,7 +86,7 @@ pub struct Storage {  }  struct Group { -    atlas: glyphon::TextAtlas, +    atlas: cryoglyph::TextAtlas,      version: usize,      should_trim: bool,      handle: Arc<()>, // Keeps track of active uploads @@ -97,7 +97,7 @@ impl Storage {          Self::default()      } -    fn get(&self, cache: &Cache) -> Option<(&glyphon::TextAtlas, &Upload)> { +    fn get(&self, cache: &Cache) -> Option<(&cryoglyph::TextAtlas, &Upload)> {          if cache.text.is_empty() {              return None;          } @@ -112,10 +112,10 @@ impl Storage {          &mut self,          device: &wgpu::Device,          queue: &wgpu::Queue, -        viewport: &glyphon::Viewport, +        viewport: &cryoglyph::Viewport,          encoder: &mut wgpu::CommandEncoder,          format: wgpu::TextureFormat, -        state: &glyphon::Cache, +        state: &cryoglyph::Cache,          cache: &Cache,          new_transformation: Transformation,          bounds: Rectangle, @@ -130,7 +130,7 @@ impl Storage {              );              Group { -                atlas: glyphon::TextAtlas::with_color_mode( +                atlas: cryoglyph::TextAtlas::with_color_mode(                      device, queue, state, format, COLOR_MODE,                  ),                  version: 0, @@ -175,7 +175,7 @@ impl Storage {                  }              }              hash_map::Entry::Vacant(entry) => { -                let mut renderer = glyphon::TextRenderer::new( +                let mut renderer = cryoglyph::TextRenderer::new(                      &mut group.atlas,                      device,                      wgpu::MultisampleState::default(), @@ -257,13 +257,13 @@ impl Storage {      }  } -pub struct Viewport(glyphon::Viewport); +pub struct Viewport(cryoglyph::Viewport);  impl Viewport {      pub fn update(&mut self, queue: &wgpu::Queue, resolution: Size<u32>) {          self.0.update(              queue, -            glyphon::Resolution { +            cryoglyph::Resolution {                  width: resolution.width,                  height: resolution.height,              }, @@ -273,10 +273,10 @@ impl Viewport {  #[allow(missing_debug_implementations)]  pub struct Pipeline { -    state: glyphon::Cache, +    state: cryoglyph::Cache,      format: wgpu::TextureFormat, -    atlas: glyphon::TextAtlas, -    renderers: Vec<glyphon::TextRenderer>, +    atlas: cryoglyph::TextAtlas, +    renderers: Vec<cryoglyph::TextRenderer>,      prepare_layer: usize,      cache: BufferCache,  } @@ -287,8 +287,8 @@ impl Pipeline {          queue: &wgpu::Queue,          format: wgpu::TextureFormat,      ) -> Self { -        let state = glyphon::Cache::new(device); -        let atlas = glyphon::TextAtlas::with_color_mode( +        let state = cryoglyph::Cache::new(device); +        let atlas = cryoglyph::TextAtlas::with_color_mode(              device, queue, &state, format, COLOR_MODE,          ); @@ -320,7 +320,7 @@ impl Pipeline {                      text,                  } => {                      if self.renderers.len() <= self.prepare_layer { -                        self.renderers.push(glyphon::TextRenderer::new( +                        self.renderers.push(cryoglyph::TextRenderer::new(                              &mut self.atlas,                              device,                              wgpu::MultisampleState::default(), @@ -346,7 +346,7 @@ impl Pipeline {                          Ok(()) => {                              self.prepare_layer += 1;                          } -                        Err(glyphon::PrepareError::AtlasFull) => { +                        Err(cryoglyph::PrepareError::AtlasFull) => {                              // If the atlas cannot grow, then all bets are off.                              // Instead of panicking, we will just pray that the result                              // will be somewhat readable... @@ -417,7 +417,7 @@ impl Pipeline {      }      pub fn create_viewport(&self, device: &wgpu::Device) -> Viewport { -        Viewport(glyphon::Viewport::new(device, &self.state)) +        Viewport(cryoglyph::Viewport::new(device, &self.state))      }      pub fn end_frame(&mut self) { @@ -431,15 +431,15 @@ impl Pipeline {  fn prepare(      device: &wgpu::Device,      queue: &wgpu::Queue, -    viewport: &glyphon::Viewport, +    viewport: &cryoglyph::Viewport,      encoder: &mut wgpu::CommandEncoder, -    renderer: &mut glyphon::TextRenderer, -    atlas: &mut glyphon::TextAtlas, +    renderer: &mut cryoglyph::TextRenderer, +    atlas: &mut cryoglyph::TextAtlas,      buffer_cache: &mut BufferCache,      sections: &[Text],      layer_bounds: Rectangle,      layer_transformation: Transformation, -) -> Result<(), glyphon::PrepareError> { +) -> Result<(), cryoglyph::PrepareError> {      let mut font_system = font_system().write().expect("Write font system");      let font_system = font_system.raw(); @@ -447,7 +447,7 @@ fn prepare(          Paragraph(Paragraph),          Editor(Editor),          Cache(text_cache::KeyHash), -        Raw(Arc<glyphon::Buffer>), +        Raw(Arc<cryoglyph::Buffer>),      }      let allocations: Vec<_> = sections @@ -618,13 +618,13 @@ fn prepare(                  &(clip_bounds * transformation * layer_transformation),              )?; -            Some(glyphon::TextArea { +            Some(cryoglyph::TextArea {                  buffer,                  left,                  top,                  scale: transformation.scale_factor()                      * layer_transformation.scale_factor(), -                bounds: glyphon::TextBounds { +                bounds: cryoglyph::TextBounds {                      left: clip_bounds.x as i32,                      top: clip_bounds.y as i32,                      right: (clip_bounds.x + clip_bounds.width) as i32, @@ -643,6 +643,6 @@ fn prepare(          atlas,          viewport,          text_areas, -        &mut glyphon::SwashCache::new(), +        &mut cryoglyph::SwashCache::new(),      )  } diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 4fe689cf..bc932b44 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -54,7 +54,7 @@ impl Compositor {          settings: Settings,          compatible_window: Option<W>,      ) -> Result<Self, Error> { -        let instance = wgpu::Instance::new(wgpu::InstanceDescriptor { +        let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {              backends: settings.backends,              flags: if cfg!(feature = "strict-assertions") {                  wgpu::InstanceFlags::debugging() @@ -81,12 +81,13 @@ impl Compositor {              .and_then(|window| instance.create_surface(window).ok());          let adapter_options = wgpu::RequestAdapterOptions { -            power_preference: wgpu::util::power_preference_from_env() -                .unwrap_or(if settings.antialiasing.is_none() { +            power_preference: wgpu::PowerPreference::from_env().unwrap_or( +                if settings.antialiasing.is_none() {                      wgpu::PowerPreference::LowPower                  } else {                      wgpu::PowerPreference::HighPerformance -                }), +                }, +            ),              compatible_surface: compatible_surface.as_ref(),              force_fallback_adapter: false,          }; @@ -263,6 +264,7 @@ pub fn present<T: AsRef<str>>(              wgpu::SurfaceError::OutOfMemory => {                  Err(compositor::SurfaceError::OutOfMemory)              } +            wgpu::SurfaceError::Other => Err(compositor::SurfaceError::Other),          },      }  } @@ -280,7 +282,7 @@ impl graphics::Compositor for Compositor {              None | Some("wgpu") => {                  let mut settings = Settings::from(settings); -                if let Some(backends) = wgpu::util::backend_bits_from_env() { +                if let Some(backends) = wgpu::Backends::from_env() {                      settings.backends = backends;                  } @@ -451,9 +453,9 @@ pub fn screenshot<T: AsRef<str>>(      encoder.copy_texture_to_buffer(          texture.as_image_copy(), -        wgpu::ImageCopyBuffer { +        wgpu::TexelCopyBufferInfo {              buffer: &output_buffer, -            layout: wgpu::ImageDataLayout { +            layout: wgpu::TexelCopyBufferLayout {                  offset: 0,                  bytes_per_row: Some(dimensions.padded_bytes_per_row as u32),                  rows_per_image: None,  | 
