chore: update dependencies

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-03-17 22:42:15 -05:00
parent 41586d8cc4
commit fedae65cc8
3 changed files with 690 additions and 885 deletions

1515
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -11,13 +11,12 @@ anyhow = "1.0"
bitfield = "0.14" bitfield = "0.14"
clap = { version = "4.0", features = ["cargo"] } clap = { version = "4.0", features = ["cargo"] }
gilrs = "0.10" gilrs = "0.10"
winit = "0.27" winit = "0.28"
egui = "0.19" egui = "0.21"
wgpu = "0.14" egui_wgpu_backend = "0.22"
egui_wgpu_backend = "0.20" egui_winit_platform = "0.18"
egui_winit_platform = "0.16" pollster = "0.3"
pollster = "0.2" rodio = "0.17"
rodio = "0.16"
rtrb = "0.2" rtrb = "0.2"
directories-next = "2.0" directories-next = "2.0"
tracing = "0.1" tracing = "0.1"

View File

@ -1,11 +1,12 @@
use egui::{Context, TextureId}; use egui::{Context, TextureId};
use egui_wgpu_backend::{RenderPass, ScreenDescriptor}; use egui_wgpu_backend::{wgpu, RenderPass, ScreenDescriptor};
use egui_winit_platform::Platform; use egui_winit_platform::Platform;
use wgpu::{ use wgpu::{
Adapter, Backends, Color, CommandEncoder, CompositeAlphaMode, Device, Extent3d, FilterMode, Adapter, CommandEncoder, Device, Extent3d, FilterMode, Instance, Queue, RequestDeviceError,
Instance, Queue, RequestDeviceError, Surface, SurfaceConfiguration, Texture, TextureFormat, Surface, SurfaceCapabilities, SurfaceConfiguration, Texture, TextureView,
TextureUsages, TextureView, TextureViewDescriptor, TextureViewDescriptor,
}; };
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use winit::error::OsError; use winit::error::OsError;
use winit::event::{ElementState, Event, KeyboardInput}; use winit::event::{ElementState, Event, KeyboardInput};
@ -42,20 +43,26 @@ pub struct Gui {
impl Gui { impl Gui {
pub fn new<T>(title: String, event_loop: &EventLoop<T>, cpu: &Cpu) -> Self { pub fn new<T>(title: String, event_loop: &EventLoop<T>, cpu: &Cpu) -> Self {
use wgpu::InstanceDescriptor;
let window = build_window(event_loop).expect("build window"); let window = build_window(event_loop).expect("build window");
let instance = Instance::new(Backends::PRIMARY); let instance = Instance::new(InstanceDescriptor::default());
let surface = unsafe { instance.create_surface(&window) }; let surface = unsafe {
instance
.create_surface(&window)
.expect("create wgpu instance surface")
};
let adapter = request_adapter(&instance, &surface).expect("request adaptor"); let adapter = request_adapter(&instance, &surface).expect("request adaptor");
let (device, queue) = request_device(&adapter).expect("request device"); let (device, queue) = request_device(&adapter).expect("request device");
let texture_format = surface.get_supported_formats(&adapter)[0]; // First is preferred
let alpha_mode = surface.get_supported_alpha_modes(&adapter)[0]; let capabilities = surface.get_capabilities(&adapter);
let surface_config = surface_config(&window, alpha_mode, texture_format);
let surface_config = surface_config(&window, capabilities);
surface.configure(&device, &surface_config); surface.configure(&device, &surface_config);
let platform = platform(&window); let platform = platform(&window);
let mut render_pass = RenderPass::new(&device, texture_format, 1); let mut render_pass = RenderPass::new(&device, surface_config.format, 1);
let texture_size = texture_size(); let texture_size = texture_size();
let texture = create_texture(&device, texture_size); let texture = create_texture(&device, texture_size);
@ -112,7 +119,7 @@ impl Gui {
} }
pub fn paint(&mut self, cpu: &Cpu) { pub fn paint(&mut self, cpu: &Cpu) {
use wgpu::SurfaceError; use wgpu::{Color, SurfaceError};
let data = emu::pixel_buf(cpu); let data = emu::pixel_buf(cpu);
write_to_texture(&self.queue, &self.texture, data, self.texture_size); write_to_texture(&self.queue, &self.texture, data, self.texture_size);
@ -350,21 +357,18 @@ fn request_device(adapter: &Adapter) -> Result<(Device, Queue), RequestDeviceErr
)) ))
} }
fn surface_config( fn surface_config(window: &Window, capabilities: SurfaceCapabilities) -> SurfaceConfiguration {
window: &Window, use egui_wgpu_backend::wgpu::{PresentMode, TextureFormat, TextureUsages};
alpha_mode: CompositeAlphaMode,
format: TextureFormat,
) -> SurfaceConfiguration {
use wgpu::PresentMode;
let size = window.inner_size(); let size = window.inner_size();
SurfaceConfiguration { SurfaceConfiguration {
usage: TextureUsages::RENDER_ATTACHMENT, usage: TextureUsages::RENDER_ATTACHMENT,
format, format: capabilities.formats[0],
width: size.width as u32, width: size.width as u32,
height: size.height as u32, height: size.height as u32,
present_mode: PresentMode::Fifo, present_mode: PresentMode::Fifo,
alpha_mode, alpha_mode: capabilities.alpha_modes[0],
view_formats: vec![TextureFormat::Bgra8UnormSrgb],
} }
} }
@ -391,16 +395,17 @@ fn texture_size() -> Extent3d {
} }
fn create_texture(device: &Device, size: Extent3d) -> Texture { fn create_texture(device: &Device, size: Extent3d) -> Texture {
use wgpu::{TextureDescriptor, TextureDimension}; use wgpu::{TextureDescriptor, TextureDimension, TextureFormat, TextureUsages};
device.create_texture(&TextureDescriptor { device.create_texture(&TextureDescriptor {
size, size,
mip_level_count: 1, mip_level_count: 1,
sample_count: 1, sample_count: 1,
dimension: TextureDimension::D2, dimension: TextureDimension::D2,
format: TextureFormat::Rgba8UnormSrgb, format: TextureFormat::Bgra8Unorm,
usage: TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING, usage: TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING,
label: Some("gb_pixel_buffer"), label: Some("gb_pixel_buffer"),
view_formats: &[TextureFormat::Bgra8Unorm],
}) })
} }