Skip to content

Commit

Permalink
Update dependencies, clean up, fix GDB stub
Browse files Browse the repository at this point in the history
The hardware 3D renderer has been disabled due to
gfx-rs/wgpu#5572
  • Loading branch information
kelpsyberry committed Aug 6, 2024
1 parent e9191a1 commit 6a3b248
Show file tree
Hide file tree
Showing 19 changed files with 821 additions and 629 deletions.
1,193 changes: 696 additions & 497 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ debugger-hooks = ["bft-r", "bft-w"]
[dependencies]
emu-utils = { git = "https://github.com/kelpsyberry/emu-utils" }
proc-bitfield = { version = "0.4", features = ["nightly"] }
bitflags = "2.5"
bitflags = "2.6"
cfg-if = "1.0"
slog = { version = "2.7", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
Expand Down
3 changes: 0 additions & 3 deletions core/src/ds_slot/rom/empty.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use super::super::RomOutputLen;
#[cfg(feature = "log")]
use crate::utils::mem_prelude::*;
#[allow(unused_imports)]
use crate::utils::Bytes;
use crate::utils::Savestate;

#[derive(Savestate)]
Expand Down
2 changes: 1 addition & 1 deletion core/src/gpu/engine_3d/renderer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{Polygon, RenderingState, ScreenVertex};
use crate::{gpu::Scanline, utils::Bytes};
use crate::{gpu::Scanline, utils::mem_prelude::*};

pub trait RendererTx {
fn set_capture_enabled(&mut self, capture_enabled: bool);
Expand Down
6 changes: 3 additions & 3 deletions frontend/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ dust-wgpu-2d = { path = "../../render/wgpu-2d" }
dust-wgpu-3d = { path = "../../render/wgpu-3d", features = ["threaded"] }

# UI
winit = { version = "0.29", features = ["serde"] }
wgpu = "0.19"
imgui = { version = "0.11", features = ["docking", "tables-api"] }
winit = { version = "0.30", features = ["serde"] }
wgpu = "22.0"
imgui = { version = "0.12", features = ["docking", "tables-api"] }
imgui-winit-support = { git = "https://github.com/kelpsyberry/imgui-rs" }
imgui-wgpu = { git = "https://github.com/kelpsyberry/imgui-wgpu" }
opener = "0.7"
Expand Down
9 changes: 4 additions & 5 deletions frontend/desktop/src/emu/gdb_server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,10 @@ impl Server {
unreachable!();
}

if let Ok((reader, writer)) = self
.listener
.accept()
.and_then(|(writer, _)| Ok((BufReader::new(writer.try_clone()?), writer)))
{
if let Ok((reader, writer)) = self.listener.accept().and_then(|(stream, _)| {
// stream.set_nonblocking(true)?;
Ok((BufReader::new(stream.try_clone()?), stream))
}) {
self.state = State::Running(RunningState {
reader,
writer,
Expand Down
2 changes: 1 addition & 1 deletion frontend/desktop/src/emu/soft_renderer_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use dust_core::{
},
Scanline, SCREEN_HEIGHT,
},
utils::Bytes,
utils::mem_prelude::*,
};
use dust_soft_3d::{Renderer, RenderingData};
use std::{
Expand Down
1 change: 0 additions & 1 deletion frontend/desktop/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
const_mut_refs,
slice_as_chunks,
duration_constants,
lazy_cell,
hash_extract_if
)]
#![warn(clippy::all)]
Expand Down
199 changes: 90 additions & 109 deletions frontend/desktop/src/ui/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ use std::{
use winit::window::Icon;
use winit::{
dpi::{LogicalSize, PhysicalSize},
event::{Event, StartCause, WindowEvent},
event::{Event, WindowEvent},
event_loop::EventLoop,
window::{Window as WinitWindow, WindowBuilder as WinitWindowBuilder},
window::{Window as WinitWindow, WindowAttributes},

Check warning on line 22 in frontend/desktop/src/ui/window.rs

View workflow job for this annotation

GitHub Actions / Run clippy (macos-latest, no default features)

unused import: `WindowAttributes`

warning: unused import: `WindowAttributes` --> frontend/desktop/src/ui/window.rs:22:37 | 22 | window::{Window as WinitWindow, WindowAttributes}, | ^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
};
#[cfg(target_os = "macos")]
use winit::{
platform::macos::WindowBuilderExtMacOS,
platform::macos::WindowAttributesExtMacOS,
raw_window_handle::{HasWindowHandle, RawWindowHandle},
};

Expand Down Expand Up @@ -73,6 +73,7 @@ impl GfxDevice {
max_bind_groups: 5,
..wgpu::Limits::downlevel_webgl2_defaults()
},
memory_hints: wgpu::MemoryHints::MemoryUsage,
},
None,
)
Expand Down Expand Up @@ -329,16 +330,14 @@ impl ImGuiState {

pub struct Builder {
pub event_loop: EventLoop<()>,
window: HiddenWindow,
window: NewWindow,
pub imgui: imgui::Context,
}

struct HiddenWindow {
window: WinitWindow,
scale_factor: f64,
struct NewWindow {
gfx_device: GfxDevice,
imgui: ImGuiState,
imgui_winit: imgui_winit_support::WinitPlatform,
title: String,
default_logical_size: (u32, u32),
srgb_mode: SrgbMode,
#[cfg(target_os = "macos")]
macos_title_bar_is_hidden: bool,
Expand Down Expand Up @@ -517,7 +516,7 @@ pub enum ControlFlow {
}

enum WindowState {
Hidden(HiddenWindow),
New(NewWindow),
Shown(Window),
}

Expand All @@ -531,46 +530,16 @@ impl Builder {
#[cfg(target_os = "macos")] macos_title_bar_is_hidden: bool,
) -> Self {
let event_loop = EventLoop::new().expect("couldn't create event loop");
let window_builder = WinitWindowBuilder::new()
.with_title(title)
.with_inner_size(LogicalSize::new(
default_logical_size.0,
default_logical_size.1,
))
.with_visible(false);
#[cfg(target_os = "macos")]
let window_builder = if macos_title_bar_is_hidden {
window_builder
.with_titlebar_transparent(true)
.with_fullsize_content_view(true)
} else {
window_builder
};
let window = window_builder
.build(&event_loop)
.expect("couldn't create window");
let scale_factor = window.scale_factor();

let gfx_device = GfxDevice::new(features, adapter).await;

let mut imgui = imgui::Context::create();

let imgui_state = ImGuiState::new(scale_factor, &mut imgui);

let mut imgui_winit = imgui_winit_support::WinitPlatform::init(&mut imgui);
imgui_winit.attach_window(
imgui.io_mut(),
&window,
imgui_winit_support::HiDpiMode::Default,
);
let imgui = imgui::Context::create();

#[allow(unused_mut)]
let mut window = HiddenWindow {
window,
scale_factor,
let mut window = NewWindow {
title: title.into(),
default_logical_size,
gfx_device,
imgui: imgui_state,
imgui_winit,
srgb_mode,
#[cfg(target_os = "macos")]
macos_title_bar_is_hidden,
Expand Down Expand Up @@ -623,71 +592,88 @@ impl Builder {
let mut on_exit_imgui = ManuallyDrop::new(on_exit_imgui);
let mut on_exit = ManuallyDrop::new(on_exit);

let mut window_ = ManuallyDrop::new(WindowState::Hidden(self.window));
let mut window_ = ManuallyDrop::new(WindowState::New(self.window));
let mut imgui_ = ManuallyDrop::new(self.imgui);
let mut state_ = ManuallyDrop::new(None);

let _ = self.event_loop.run(move |event, elwt| {

Check warning on line 599 in frontend/desktop/src/ui/window.rs

View workflow job for this annotation

GitHub Actions / Run clippy (macos-latest, no default features)

use of deprecated method `winit::event_loop::EventLoop::<T>::run`: use `EventLoop::run_app` instead

warning: use of deprecated method `winit::event_loop::EventLoop::<T>::run`: use `EventLoop::run_app` instead --> frontend/desktop/src/ui/window.rs:599:33 | 599 | let _ = self.event_loop.run(move |event, elwt| { | ^^^ | = note: `#[warn(deprecated)]` on by default
let imgui = &mut *imgui_;

if let Event::WindowEvent {
event: WindowEvent::RedrawRequested,
..
} = &event
{
if matches!(&*window_, WindowState::Hidden(_)) {
return;
}
}

if let Event::NewEvents(StartCause::Init) = &event {
let window = unsafe {
let WindowState::Hidden(window) = ManuallyDrop::take(&mut window_) else {
unreachable_unchecked()
if let Event::Resumed = &event {
if matches!(&*window_, WindowState::New(_)) {
let window = unsafe {
let WindowState::New(window) = ManuallyDrop::take(&mut window_) else {
unreachable_unchecked()
};
window
};
window
};

let gfx_surface =
GfxSurface::new(&window.window, &window.gfx_device, window.srgb_mode);
let imgui_gfx = imgui_wgpu::Renderer::new(
&window.gfx_device.device,
&window.gfx_device.queue,
imgui,
gfx_surface.config.format,
window.srgb_mode,
);

let mut window = Window {
window: window.window,
scale_factor: window.scale_factor,
last_frame: Instant::now(),
gfx_device: window.gfx_device,
gfx_surface,
imgui: window.imgui,
imgui_winit: window.imgui_winit,
imgui_gfx,
is_occluded: false,
#[cfg(target_os = "macos")]
macos_title_bar_is_transparent: window.macos_title_bar_is_hidden,
let mut window_attrs = WinitWindow::default_attributes()
.with_title(window.title)
.with_inner_size(LogicalSize::new(
window.default_logical_size.0,
window.default_logical_size.1,
));
#[cfg(target_os = "macos")]
macos_title_bar_height: 0.0,
};
if window.macos_title_bar_is_hidden {
window_attrs = window_attrs
.with_titlebar_transparent(true)
.with_fullsize_content_view(true);
}

let winit_window = elwt
.create_window(window_attrs)
.expect("couldn't create window");
let scale_factor = winit_window.scale_factor();

let imgui_state = ImGuiState::new(scale_factor, imgui);

#[cfg(target_os = "macos")]
window.update_macos_title_bar_height();
let mut imgui_winit = imgui_winit_support::WinitPlatform::init(imgui);
imgui_winit.attach_window(
imgui.io_mut(),
&winit_window,
imgui_winit_support::HiDpiMode::Default,
);

state_ = ManuallyDrop::new(Some(unsafe { ManuallyDrop::take(&mut init_state) }(
&mut window,
)));
window_ = ManuallyDrop::new(WindowState::Shown(window));
let gfx_surface =
GfxSurface::new(&winit_window, &window.gfx_device, window.srgb_mode);
let imgui_gfx = imgui_wgpu::Renderer::new(
&window.gfx_device.device,
&window.gfx_device.queue,
imgui,
gfx_surface.config.format,
window.srgb_mode,
);

let mut window = Window {
window: winit_window,
scale_factor,
last_frame: Instant::now(),
gfx_device: window.gfx_device,
gfx_surface,
imgui: imgui_state,
imgui_winit,
imgui_gfx,
is_occluded: false,
#[cfg(target_os = "macos")]
macos_title_bar_is_transparent: window.macos_title_bar_is_hidden,
#[cfg(target_os = "macos")]
macos_title_bar_height: 0.0,
};

#[cfg(target_os = "macos")]
window.update_macos_title_bar_height();

state_ =
ManuallyDrop::new(Some(unsafe { ManuallyDrop::take(&mut init_state) }(
&mut window,
)));
window_ = ManuallyDrop::new(WindowState::Shown(window));
}
}

let window = unsafe {
let WindowState::Shown(window) = &mut *window_ else {
unreachable_unchecked()
};
window
let WindowState::Shown(window) = &mut *window_ else {
return;
};
let state = unsafe { state_.as_mut().unwrap_unchecked() };

Expand All @@ -702,14 +688,6 @@ impl Builder {
let delta_time = now - window.last_frame;
window.last_frame = now;

let frame = window
.gfx_surface
.start_frame(&window.gfx_device, window.window.inner_size());
let mut encoder = window
.gfx_device
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });

if window.gfx_surface.format_changed {
window.imgui_gfx.change_swapchain_format(
&window.gfx_device.device,
Expand All @@ -729,6 +707,14 @@ impl Builder {
elwt.exit();
}

let frame = window
.gfx_surface
.start_frame(&window.gfx_device, window.window.inner_size());
let mut encoder = window
.gfx_device
.device
.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });

if draw(window, state, &frame, &mut encoder, delta_time) == ControlFlow::Exit {
elwt.exit();
}
Expand Down Expand Up @@ -756,11 +742,6 @@ impl Builder {
};

match event {
Event::NewEvents(StartCause::Init) => {
redraw();
window.window.set_visible(true);
}

Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
Expand Down
2 changes: 1 addition & 1 deletion frontend/web/crate/src/renderer_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dust_core::{
},
Scanline, SCREEN_HEIGHT,
},
utils::Bytes,
utils::mem_prelude::*,
};
use dust_soft_3d::{Renderer, RenderingData};
use std::{
Expand Down
2 changes: 1 addition & 1 deletion render/wgpu-2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ dust-core = { path = "../../core" }
emu-utils = { git = "https://github.com/kelpsyberry/emu-utils", features = ["triple-buffer"] }
dust-soft-2d-base = { path = "../soft-2d/base" }
proc-bitfield = { version = "0.4", features = ["nightly"] }
wgpu = "0.19"
wgpu = "22.0"
crossbeam-channel = "0.5"
parking_lot = "0.12"
3 changes: 3 additions & 0 deletions render/wgpu-2d/src/common/gfx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ impl GfxThreadData {
module: &shader_module,
entry_point: "vs_main",
buffers: &[],
compilation_options: Default::default(),
},

primitive: wgpu::PrimitiveState {
Expand All @@ -451,9 +452,11 @@ impl GfxThreadData {
blend: None,
write_mask: wgpu::ColorWrites::ALL,
})],
compilation_options: Default::default(),
}),

multiview: None,
cache: None,
});

(pipeline, color_output_3d_bg_layout)
Expand Down
Loading

0 comments on commit 6a3b248

Please sign in to comment.