dont have that weird chain of shader path
This commit is contained in:
parent
d4bc05b803
commit
141d213cb3
2 changed files with 15 additions and 18 deletions
|
@ -81,6 +81,7 @@ struct Configs {
|
|||
}
|
||||
|
||||
static CONFIGS: OnceLock<Configs> = OnceLock::new();
|
||||
static IS_CGB: OnceLock<bool> = OnceLock::new();
|
||||
|
||||
fn access_config<'a>() -> &'a Configs {
|
||||
CONFIGS.get_or_init(|| {
|
||||
|
@ -106,7 +107,6 @@ pub struct GameboyEmu {
|
|||
frame_receiver: Arc<FrameReceiver>,
|
||||
key_handler: Arc<JoypadSender>,
|
||||
params: Arc<EmuParams>,
|
||||
shader_path: Arc<Mutex<Option<PathBuf>>>,
|
||||
}
|
||||
|
||||
type Frame = Vec<[u8; 4]>;
|
||||
|
@ -258,7 +258,6 @@ impl Plugin for GameboyEmu {
|
|||
Some(Box::new(Emulator::new(
|
||||
self.frame_receiver.clone(),
|
||||
self.key_handler.clone(),
|
||||
self.shader_path.clone(),
|
||||
size,
|
||||
)))
|
||||
}
|
||||
|
@ -289,13 +288,8 @@ impl Plugin for GameboyEmu {
|
|||
.load(gb_emu_lib::connect::SramType::None, NoCamera::default())
|
||||
.expect("failed to load rom");
|
||||
|
||||
let shader_path =
|
||||
if rom.rom_type == CgbRomType::CgbOnly || configs.emu_config.prefer_cgb {
|
||||
configs.emu_config.vulkan_config.cgb_shader_path.as_ref()
|
||||
} else {
|
||||
configs.emu_config.vulkan_config.dmg_shader_path.as_ref()
|
||||
}
|
||||
.map(|v| configs.config_dir.join(v));
|
||||
let _ =
|
||||
IS_CGB.set(rom.rom_type == CgbRomType::CgbOnly || configs.emu_config.prefer_cgb);
|
||||
|
||||
let (sender, receiver) = channel::<EmulatorMessage>();
|
||||
|
||||
|
@ -309,7 +303,6 @@ impl Plugin for GameboyEmu {
|
|||
|
||||
*self.frame_receiver.lock().unwrap() = Some(frame_receiver);
|
||||
*self.key_handler.lock().unwrap() = Some(key_handler);
|
||||
*self.shader_path.lock().unwrap() = shader_path;
|
||||
|
||||
let (serial_tx, gb_serial_rx) = mpsc::channel::<u8>();
|
||||
let serial_target = SerialTarget::Custom {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{
|
|||
path::PathBuf,
|
||||
sync::{
|
||||
mpsc::{self, Receiver, Sender},
|
||||
Arc, Mutex,
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -14,12 +14,11 @@ use gb_emu_lib::{
|
|||
use keyboard_types::{Code, KeyState};
|
||||
use nih_plug::prelude::*;
|
||||
|
||||
use crate::{access_config, Frame, FrameReceiver, JoypadInfo, JoypadSender};
|
||||
use crate::{access_config, Frame, FrameReceiver, JoypadInfo, JoypadSender, IS_CGB};
|
||||
|
||||
pub struct Emulator {
|
||||
frame_receiver: Arc<FrameReceiver>,
|
||||
joypad_sender: Arc<JoypadSender>,
|
||||
shader_path: Arc<Mutex<Option<PathBuf>>>,
|
||||
size: Size,
|
||||
}
|
||||
|
||||
|
@ -27,13 +26,11 @@ impl Emulator {
|
|||
pub fn new(
|
||||
frame_receiver: Arc<FrameReceiver>,
|
||||
joypad_sender: Arc<JoypadSender>,
|
||||
shader_path: Arc<Mutex<Option<PathBuf>>>,
|
||||
size: Size,
|
||||
) -> Self {
|
||||
Self {
|
||||
frame_receiver,
|
||||
joypad_sender,
|
||||
shader_path,
|
||||
size,
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +57,16 @@ impl Editor for Emulator {
|
|||
// )
|
||||
// };
|
||||
|
||||
let config = access_config();
|
||||
|
||||
#[cfg(feature = "vulkan")]
|
||||
let shader_path = self.shader_path.lock().unwrap().clone();
|
||||
// let shader_path = None;
|
||||
let shader_path = if IS_CGB.get().is_some_and(|v| *v) {
|
||||
config.emu_config.vulkan_config.cgb_shader_path.as_ref()
|
||||
} else {
|
||||
config.emu_config.vulkan_config.dmg_shader_path.as_ref()
|
||||
}
|
||||
.map(|p| config.config_dir.join(p));
|
||||
|
||||
let scale_factor = access_config().vst_config.scale_factor;
|
||||
|
||||
let size = Size::new(
|
||||
|
@ -92,7 +96,6 @@ impl Editor for Emulator {
|
|||
Box::new(Self::new(
|
||||
self.frame_receiver.clone(),
|
||||
self.joypad_sender.clone(),
|
||||
self.shader_path.clone(),
|
||||
size,
|
||||
))
|
||||
}
|
||||
|
@ -206,6 +209,7 @@ impl WindowHandler for EmulatorWindow {
|
|||
EventStatus::Ignored
|
||||
}
|
||||
}
|
||||
Event::Window(WindowEvent::WillClose) => EventStatus::Ignored,
|
||||
_ => EventStatus::Ignored,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue