Upgrade to latest wgpu, winit, egui

This commit is contained in:
Hanno Braun 2023-02-13 14:39:28 +01:00
parent 5f97cbf838
commit 925ed83988
8 changed files with 260 additions and 405 deletions

629
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -21,4 +21,4 @@ libloading = "0.7.4"
notify = "5.1.0"
thiserror = "1.0.35"
tracing = "0.1.37"
winit = "0.27.5"
winit = "0.28.1"

View File

@ -14,8 +14,8 @@ categories.workspace = true
bytemuck = "1.13.0"
chrono = "0.4.23"
crossbeam-channel = "0.5.6"
egui = "0.20.1"
egui-wgpu = "0.20.0"
egui = "0.21.0"
egui-wgpu = "0.21.0"
fj-interop.workspace = true
fj-math.workspace = true
nalgebra = "0.32.1"
@ -35,7 +35,7 @@ default_features = false
features = ["xdg-portal"]
[dependencies.wgpu]
version = "0.14.2"
version = "0.15.1"
features = ["webgl"]
# We don't depend on `getrandom` directly, but we need this to enable the `js`

View File

@ -1,4 +1,4 @@
use std::{io, mem::size_of};
use std::{io, mem::size_of, vec};
use thiserror::Error;
use tracing::debug;
@ -41,10 +41,13 @@ pub struct Renderer {
impl Renderer {
/// Returns a new `Renderer`.
pub async fn new(screen: &impl Screen) -> Result<Self, RendererInitError> {
let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
backends: wgpu::Backends::PRIMARY,
..Default::default()
});
// This is sound, as `window` is an object to create a surface upon.
let surface = unsafe { instance.create_surface(screen.window()) };
let surface = unsafe { instance.create_surface(screen.window()) }?;
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
@ -94,7 +97,8 @@ impl Renderer {
.await?;
let color_format = 'color_format: {
let supported_formats = surface.get_supported_formats(&adapter);
let capabilities = surface.get_capabilities(&adapter);
let supported_formats = capabilities.formats;
// We don't really care which color format we use, as long as we
// find one that's supported. `egui_wgpu` prints a warning though,
@ -136,6 +140,7 @@ impl Renderer {
//
// @hannobraun
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
};
surface.configure(&device, &surface_config);
@ -372,6 +377,7 @@ impl Renderer {
dimension: wgpu::TextureDimension::D2,
format: surface_config.format,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
view_formats: &[],
});
texture.create_view(&wgpu::TextureViewDescriptor::default())
}
@ -392,6 +398,7 @@ impl Renderer {
dimension: wgpu::TextureDimension::D2,
format: DEPTH_FORMAT,
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
view_formats: &[],
});
texture.create_view(&wgpu::TextureViewDescriptor::default())
@ -410,6 +417,10 @@ pub enum RendererInitError {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
/// Surface creating error
#[error("Error creating surface: {0}")]
CreateSurface(#[from] wgpu::CreateSurfaceError),
/// Graphics accelerator acquisition error
#[error("Error request adapter")]
RequestAdapter,

View File

@ -33,7 +33,7 @@ fn vertex(in: VertexInput) -> VertexOutput {
return out;
}
let pi: f32 = 3.14159265359;
const pi: f32 = 3.14159265359;
@fragment
fn frag_model(in: VertexOutput) -> FragmentOutput {

View File

@ -48,6 +48,7 @@ impl Texture {
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsages::TEXTURE_BINDING
| wgpu::TextureUsages::COPY_DST,
view_formats: &[],
});
queue.write_texture(

View File

@ -181,7 +181,7 @@ impl Gui {
&& self.options.show_debug_text_example
{
let hover_pos =
ui.input().pointer.hover_pos().unwrap_or_default();
ui.input(|input| input.pointer.hover_pos().unwrap_or_default());
ui.painter().debug_text(
hover_pos,
egui::Align2::LEFT_TOP,

View File

@ -19,8 +19,8 @@ crossbeam-channel = "0.5.6"
futures = "0.3.26"
thiserror = "1.0.35"
tracing = "0.1.37"
winit = "0.27.5"
winit = "0.28.1"
[dependencies.egui-winit]
version = "0.20.1"
version = "0.21.1"
default-features = false