Compare commits
21 Commits
0debae0678
...
f7cf960b62
Author | SHA1 | Date |
---|---|---|
|
f7cf960b62 | |
|
b888d1140a | |
|
7356287030 | |
|
b5e1711a56 | |
|
92ccc482ae | |
|
c4f17bfc13 | |
|
dfcfd17bfc | |
|
d16c5363da | |
|
a5676c20d1 | |
|
ba15dc77ae | |
|
ebe444870f | |
|
a461faf89d | |
|
a82389224f | |
|
600148c781 | |
|
4601f1b52f | |
|
57eebb5874 | |
|
75779f2b24 | |
|
6c9265cb78 | |
|
5f17469dc2 | |
|
db36332307 | |
|
8df05d923d |
|
@ -1763,7 +1763,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|||
|
||||
[[package]]
|
||||
name = "lemur"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"atoi",
|
||||
|
|
|
@ -4,7 +4,7 @@ description = "An emulator for the Virtual Boy."
|
|||
repository = "https://git.virtual-boy.com/PVB/lemur"
|
||||
publish = false
|
||||
license = "MIT"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
76
src/app.rs
76
src/app.rs
|
@ -40,6 +40,7 @@ fn load_icon() -> anyhow::Result<IconData> {
|
|||
|
||||
pub struct Application {
|
||||
icon: Option<Arc<IconData>>,
|
||||
wgpu: WgpuState,
|
||||
client: EmulatorClient,
|
||||
proxy: EventLoopProxy<UserEvent>,
|
||||
mappings: MappingProvider,
|
||||
|
@ -58,6 +59,7 @@ impl Application {
|
|||
proxy: EventLoopProxy<UserEvent>,
|
||||
debug_port: Option<u16>,
|
||||
) -> Self {
|
||||
let wgpu = WgpuState::new();
|
||||
let icon = load_icon().ok().map(Arc::new);
|
||||
let persistence = Persistence::new();
|
||||
let mappings = MappingProvider::new(persistence.clone());
|
||||
|
@ -71,6 +73,7 @@ impl Application {
|
|||
}
|
||||
Self {
|
||||
icon,
|
||||
wgpu,
|
||||
client,
|
||||
proxy,
|
||||
mappings,
|
||||
|
@ -91,7 +94,7 @@ impl Application {
|
|||
}
|
||||
self.viewports.insert(
|
||||
viewport_id,
|
||||
Viewport::new(event_loop, self.icon.clone(), window),
|
||||
Viewport::new(event_loop, &self.wgpu, self.icon.clone(), window),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +269,58 @@ impl ApplicationHandler<UserEvent> for Application {
|
|||
}
|
||||
}
|
||||
|
||||
struct WgpuState {
|
||||
instance: Arc<wgpu::Instance>,
|
||||
adapter: Arc<wgpu::Adapter>,
|
||||
device: Arc<wgpu::Device>,
|
||||
queue: Arc<wgpu::Queue>,
|
||||
}
|
||||
|
||||
impl WgpuState {
|
||||
fn new() -> Self {
|
||||
#[allow(unused_variables)]
|
||||
let egui_wgpu::WgpuConfiguration {
|
||||
wgpu_setup:
|
||||
egui_wgpu::WgpuSetup::CreateNew {
|
||||
supported_backends,
|
||||
device_descriptor,
|
||||
..
|
||||
},
|
||||
..
|
||||
} = egui_wgpu::WgpuConfiguration::default()
|
||||
else {
|
||||
panic!("required fields not found")
|
||||
};
|
||||
#[cfg(windows)]
|
||||
let supported_backends = wgpu::util::backend_bits_from_env()
|
||||
.unwrap_or((wgpu::Backends::PRIMARY | wgpu::Backends::GL) - wgpu::Backends::VULKAN);
|
||||
let instance = wgpu::Instance::new(wgpu::InstanceDescriptor {
|
||||
backends: supported_backends,
|
||||
..wgpu::InstanceDescriptor::default()
|
||||
});
|
||||
|
||||
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
|
||||
power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
compatible_surface: None,
|
||||
force_fallback_adapter: false,
|
||||
}))
|
||||
.expect("could not create adapter");
|
||||
|
||||
let trace_path = std::env::var("WGPU_TRACE");
|
||||
let (device, queue) = pollster::block_on(adapter.request_device(
|
||||
&(*device_descriptor)(&adapter),
|
||||
trace_path.ok().as_ref().map(std::path::Path::new),
|
||||
))
|
||||
.expect("could not request device");
|
||||
Self {
|
||||
instance: Arc::new(instance),
|
||||
adapter: Arc::new(adapter),
|
||||
device: Arc::new(device),
|
||||
queue: Arc::new(queue),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Viewport {
|
||||
painter: egui_wgpu::winit::Painter,
|
||||
ctx: Context,
|
||||
|
@ -279,6 +334,7 @@ struct Viewport {
|
|||
impl Viewport {
|
||||
pub fn new(
|
||||
event_loop: &ActiveEventLoop,
|
||||
wgpu: &WgpuState,
|
||||
icon: Option<Arc<IconData>>,
|
||||
mut app: Box<dyn AppWindow>,
|
||||
) -> Self {
|
||||
|
@ -302,20 +358,16 @@ impl Viewport {
|
|||
});
|
||||
egui_extras::install_image_loaders(&ctx);
|
||||
|
||||
#[allow(unused_mut)]
|
||||
let mut wgpu_config = egui_wgpu::WgpuConfiguration {
|
||||
let wgpu_config = egui_wgpu::WgpuConfiguration {
|
||||
present_mode: wgpu::PresentMode::AutoNoVsync,
|
||||
wgpu_setup: egui_wgpu::WgpuSetup::Existing {
|
||||
instance: wgpu.instance.clone(),
|
||||
adapter: wgpu.adapter.clone(),
|
||||
device: wgpu.device.clone(),
|
||||
queue: wgpu.queue.clone(),
|
||||
},
|
||||
..egui_wgpu::WgpuConfiguration::default()
|
||||
};
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let egui_wgpu::WgpuSetup::CreateNew {
|
||||
supported_backends, ..
|
||||
} = &mut wgpu_config.wgpu_setup
|
||||
{
|
||||
*supported_backends -= wgpu::Backends::VULKAN;
|
||||
}
|
||||
}
|
||||
|
||||
let mut painter =
|
||||
egui_wgpu::winit::Painter::new(ctx.clone(), wgpu_config, 1, None, false, true);
|
||||
|
|
Loading…
Reference in New Issue