chore: update dependencies
This commit is contained in:
parent
36e46d3780
commit
41bc4f7afe
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
14
Cargo.toml
|
@ -8,14 +8,14 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
bitfield = "0.13"
|
bitfield = "0.14"
|
||||||
clap = { version = "3.1", features = ["cargo"] }
|
clap = { version = "3.1", features = ["cargo"] }
|
||||||
gilrs = "0.8"
|
gilrs = "0.9"
|
||||||
winit = "0.26"
|
winit = "0.27"
|
||||||
egui = "0.15"
|
egui = "0.19"
|
||||||
wgpu = "0.11"
|
wgpu = "0.13"
|
||||||
egui_wgpu_backend = "0.14"
|
egui_wgpu_backend = "0.19"
|
||||||
egui_winit_platform = "0.12"
|
egui_winit_platform = "0.16"
|
||||||
pollster = "0.2"
|
pollster = "0.2"
|
||||||
rodio = "0.15"
|
rodio = "0.15"
|
||||||
rtrb = "0.2"
|
rtrb = "0.2"
|
||||||
|
|
23
src/gui.rs
23
src/gui.rs
|
@ -1,4 +1,4 @@
|
||||||
use egui::{ClippedMesh, CtxRef, TextureId};
|
use egui::{ClippedPrimitive, Context, TextureId};
|
||||||
use egui_wgpu_backend::{BackendError, RenderPass, ScreenDescriptor};
|
use egui_wgpu_backend::{BackendError, RenderPass, ScreenDescriptor};
|
||||||
use egui_winit_platform::Platform;
|
use egui_winit_platform::Platform;
|
||||||
use wgpu::{
|
use wgpu::{
|
||||||
|
@ -117,7 +117,7 @@ pub fn surface_config(window: &Window, format: TextureFormat) -> SurfaceConfigur
|
||||||
format,
|
format,
|
||||||
width: size.width as u32,
|
width: size.width as u32,
|
||||||
height: size.height as u32,
|
height: size.height as u32,
|
||||||
present_mode: PresentMode::Immediate,
|
present_mode: PresentMode::Mailbox,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +187,9 @@ pub fn write_to_texture(
|
||||||
pub fn expose_texture_to_egui(
|
pub fn expose_texture_to_egui(
|
||||||
render_pass: &mut RenderPass,
|
render_pass: &mut RenderPass,
|
||||||
device: &Device,
|
device: &Device,
|
||||||
texture: &Texture,
|
view: &TextureView,
|
||||||
) -> TextureId {
|
) -> TextureId {
|
||||||
render_pass.egui_texture_from_wgpu_texture(device, texture, FILTER_MODE)
|
render_pass.egui_texture_from_wgpu_texture(device, view, FILTER_MODE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -225,14 +225,14 @@ pub fn execute_render_pass(
|
||||||
render_pass: &mut RenderPass,
|
render_pass: &mut RenderPass,
|
||||||
encoder: &mut CommandEncoder,
|
encoder: &mut CommandEncoder,
|
||||||
view: &TextureView,
|
view: &TextureView,
|
||||||
jobs: Vec<ClippedMesh>,
|
jobs: Vec<ClippedPrimitive>,
|
||||||
descriptor: &ScreenDescriptor,
|
descriptor: &ScreenDescriptor,
|
||||||
) -> Result<(), BackendError> {
|
) -> Result<(), BackendError> {
|
||||||
render_pass.execute(encoder, view, &jobs, descriptor, Some(wgpu::Color::BLACK))
|
render_pass.execute(encoder, view, &jobs, descriptor, Some(wgpu::Color::BLACK))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: TextureId) {
|
pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &Context, texture_id: TextureId) {
|
||||||
use crate::{cpu, instruction, ppu};
|
use crate::{cpu, instruction, ppu};
|
||||||
|
|
||||||
fn selectable_text(ui: &mut egui::Ui, mut text: &str) -> egui::Response {
|
fn selectable_text(ui: &mut egui::Ui, mut text: &str) -> egui::Response {
|
||||||
|
@ -240,7 +240,7 @@ pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: Textur
|
||||||
}
|
}
|
||||||
|
|
||||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||||
egui::menu::menu(ui, "File", |ui| {
|
ui.menu_button("File", |ui| {
|
||||||
if ui.button("Quit").clicked() {
|
if ui.button("Quit").clicked() {
|
||||||
app.quit = true;
|
app.quit = true;
|
||||||
}
|
}
|
||||||
|
@ -322,12 +322,13 @@ pub fn draw_egui(cpu: &Cpu, app: &mut GuiState, ctx: &CtxRef, texture_id: Textur
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
let ie = cpu.int_enable();
|
let ie = cpu.int_enable();
|
||||||
|
|
||||||
let r_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'R');
|
// TODO: Reimplement this
|
||||||
let e_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'E');
|
// let r_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'R');
|
||||||
let q_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'Q');
|
// let e_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'E');
|
||||||
|
// let q_len = ctx.fonts().glyph_width(egui::TextStyle::Body, 'Q');
|
||||||
|
|
||||||
ui.label("IE:");
|
ui.label("IE:");
|
||||||
ui.add_space(q_len - (e_len - r_len));
|
// ui.add_space(q_len - (e_len - r_len));
|
||||||
let _ = ui.selectable_label(ie & 0b01 == 0x01, "VBlank");
|
let _ = ui.selectable_label(ie & 0b01 == 0x01, "VBlank");
|
||||||
let _ = ui.selectable_label(ie >> 1 & 0x01 == 0x01, "LCD STAT");
|
let _ = ui.selectable_label(ie >> 1 & 0x01 == 0x01, "LCD STAT");
|
||||||
let _ = ui.selectable_label(ie >> 2 & 0x01 == 0x01, "Timer");
|
let _ = ui.selectable_label(ie >> 2 & 0x01 == 0x01, "Timer");
|
||||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -8,8 +8,9 @@ use gilrs::Gilrs;
|
||||||
use gui::GuiState;
|
use gui::GuiState;
|
||||||
use rodio::{OutputStream, Sink};
|
use rodio::{OutputStream, Sink};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
use wgpu::TextureViewDescriptor;
|
||||||
use winit::event::{Event, WindowEvent};
|
use winit::event::{Event, WindowEvent};
|
||||||
use winit::event_loop::EventLoop;
|
use winit::event_loop::{EventLoop, EventLoopBuilder};
|
||||||
|
|
||||||
const AUDIO_ENABLED: bool = true;
|
const AUDIO_ENABLED: bool = true;
|
||||||
|
|
||||||
|
@ -47,15 +48,13 @@ fn main() {
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
// --Here lies a lot of winit + wgpu Boilerplate--
|
// --Here lies a lot of winit + wgpu Boilerplate--
|
||||||
let event_loop: EventLoop<Event<()>> = EventLoop::with_user_event();
|
let event_loop: EventLoop<Event<()>> = EventLoopBuilder::with_user_event().build();
|
||||||
let window = gui::build_window(&event_loop).expect("build window");
|
let window = gui::build_window(&event_loop).expect("build window");
|
||||||
|
|
||||||
let (instance, surface) = gui::create_surface(&window);
|
let (instance, surface) = gui::create_surface(&window);
|
||||||
let adapter = gui::request_adapter(&instance, &surface).expect("request adaptor");
|
let adapter = gui::request_adapter(&instance, &surface).expect("request adaptor");
|
||||||
let (device, queue) = gui::request_device(&adapter).expect("request device");
|
let (device, queue) = gui::request_device(&adapter).expect("request device");
|
||||||
let format = surface
|
let format = surface.get_supported_formats(&adapter)[0]; // First is preferred
|
||||||
.get_preferred_format(&adapter)
|
|
||||||
.expect("get surface format");
|
|
||||||
|
|
||||||
let mut config = gui::surface_config(&window, format);
|
let mut config = gui::surface_config(&window, format);
|
||||||
surface.configure(&device, &config);
|
surface.configure(&device, &config);
|
||||||
|
@ -79,7 +78,9 @@ fn main() {
|
||||||
let texture_size = gui::texture_size();
|
let texture_size = gui::texture_size();
|
||||||
let texture = gui::create_texture(&device, texture_size);
|
let texture = gui::create_texture(&device, texture_size);
|
||||||
gui::write_to_texture(&queue, &texture, emu::pixel_buf(&cpu), texture_size);
|
gui::write_to_texture(&queue, &texture, emu::pixel_buf(&cpu), texture_size);
|
||||||
let texture_id = gui::expose_texture_to_egui(&mut render_pass, &device, &texture);
|
|
||||||
|
let view = texture.create_view(&TextureViewDescriptor::default());
|
||||||
|
let texture_id = gui::expose_texture_to_egui(&mut render_pass, &device, &view);
|
||||||
|
|
||||||
// Load ROM if filepath was provided
|
// Load ROM if filepath was provided
|
||||||
if let Some(path) = m.value_of("rom") {
|
if let Some(path) = m.value_of("rom") {
|
||||||
|
@ -165,15 +166,16 @@ fn main() {
|
||||||
platform.begin_frame();
|
platform.begin_frame();
|
||||||
gui::draw_egui(&cpu, &mut app, &platform.context(), texture_id);
|
gui::draw_egui(&cpu, &mut app, &platform.context(), texture_id);
|
||||||
// End the UI frame. We could now handle the output and draw the UI with the backend.
|
// End the UI frame. We could now handle the output and draw the UI with the backend.
|
||||||
let (_, paint_commands) = platform.end_frame(Some(&window));
|
let full_output = platform.end_frame(Some(&window));
|
||||||
let paint_jobs = platform.context().tessellate(paint_commands);
|
let paint_jobs = platform.context().tessellate(full_output.shapes);
|
||||||
|
|
||||||
let mut encoder = gui::create_command_encoder(&device);
|
let mut encoder = gui::create_command_encoder(&device);
|
||||||
let screen_descriptor = gui::create_screen_descriptor(&window, &config);
|
let screen_descriptor = gui::create_screen_descriptor(&window, &config);
|
||||||
|
let tdelta = full_output.textures_delta;
|
||||||
// Upload all resources for the GPU.
|
// Upload all resources for the GPU.
|
||||||
render_pass.update_texture(&device, &queue, &platform.context().texture());
|
render_pass
|
||||||
render_pass.update_user_textures(&device, &queue);
|
.add_textures(&device, &queue, &tdelta)
|
||||||
|
.expect("add texture ok");
|
||||||
render_pass.update_buffers(&device, &queue, &paint_jobs, &screen_descriptor);
|
render_pass.update_buffers(&device, &queue, &paint_jobs, &screen_descriptor);
|
||||||
|
|
||||||
// Record all render passes.
|
// Record all render passes.
|
||||||
|
|
Loading…
Reference in New Issue