diff --git a/gb-vst/Cargo.toml b/gb-vst/Cargo.toml index c4b2c5d..cddf377 100644 --- a/gb-vst/Cargo.toml +++ b/gb-vst/Cargo.toml @@ -8,13 +8,15 @@ name = "vst" crate-type = ["cdylib", "rlib"] [features] -default = [] +default = ["vulkan"] +pixels = ["gb-emu-lib/pixels-renderer"] +vulkan = ["dep:raw-window-handle", "gb-emu-lib/vulkan-static"] [dependencies] -gb-emu-lib = { path = "../lib", features = ["vulkan-renderer", "config"] } +gb-emu-lib = { path = "../lib", features = ["config"] } nih_plug = { path = "../vendored/nih-plug", features = ["standalone"] } baseview = { path = "../vendored/baseview" } async-ringbuf = "0.1" futures = "0.3" keyboard-types = "0.6.2" -raw-window-handle = "0.5" +raw-window-handle = { version = "0.5", optional = true } diff --git a/gb-vst/src/ui.rs b/gb-vst/src/ui.rs index d4d4972..3a13a6e 100644 --- a/gb-vst/src/ui.rs +++ b/gb-vst/src/ui.rs @@ -15,7 +15,6 @@ use gb_emu_lib::{ }; use keyboard_types::{Code, KeyState}; use nih_plug::prelude::*; -use raw_window_handle::HasRawDisplayHandle; use crate::{Frame, FrameReceiver, JoypadInfo, JoypadSender}; @@ -62,6 +61,7 @@ impl Editor for Emulator { // ) // }; + #[cfg(feature = "vulkan")] let shader_path = self.shader_path.lock().unwrap().clone(); // let shader_path = None; @@ -73,7 +73,15 @@ impl Editor for Emulator { scale: baseview::WindowScalePolicy::SystemScaleFactor, gl_config: None, }, - |w| EmulatorWindow::new(w, fr_cloned, js_cloned, shader_path), + |w| { + EmulatorWindow::new( + w, + fr_cloned, + js_cloned, + #[cfg(feature = "vulkan")] + shader_path, + ) + }, ); Box::new(Self::new( self.frame_receiver.clone(), @@ -110,7 +118,7 @@ impl EmulatorWindow { window: &mut Window, frame_receiver: Arc, joypad_sender: Arc, - shader_path: Option, + #[cfg(feature = "vulkan")] shader_path: Option, ) -> Self { let info = WindowInfo::from_logical_size( Size::new(WIDTH as f64, HEIGHT as f64), @@ -125,14 +133,20 @@ impl EmulatorWindow { scaled_height: HEIGHT as u32, }; - let manager = Arc::new(RendererBackendManager::new(window.raw_display_handle())); + #[cfg(feature = "vulkan")] + let (manager, window_options) = { + use raw_window_handle::HasRawDisplayHandle; + ( + Arc::new(RendererBackendManager::new(window.raw_display_handle())), + WindowOptions { shader_path }, + ) + }; + #[cfg(feature = "pixels")] + let (manager, window_options) = + { (Arc::new(RendererBackendManager::new()), WindowOptions {}) }; - let renderer = RendererBackend::new( - current_resolution, - window, - WindowOptions { shader_path }, - manager.clone(), - ); + let renderer = + RendererBackend::new(current_resolution, window, window_options, manager.clone()); Self { renderer,