From 80850d3405b3d4500494bcd74fb9e70d13dcfb33 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Wed, 7 Feb 2024 15:51:37 +1100 Subject: [PATCH] proper modules on renderer --- frontend-common/src/window/winit_manager.rs | 9 +++++---- gb-vst/src/plugin/ui.rs | 9 ++++++--- gui/src/macos/cacao_window_manager.rs | 2 +- lib/src/lib.rs | 4 ---- lib/src/renderer/mod.rs | 4 ++++ lib/src/renderer/vulkan/{vulkan.rs => mod.rs} | 0 6 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 lib/src/renderer/mod.rs rename lib/src/renderer/vulkan/{vulkan.rs => mod.rs} (100%) diff --git a/frontend-common/src/window/winit_manager.rs b/frontend-common/src/window/winit_manager.rs index 0cf3dae..56bb5d0 100644 --- a/frontend-common/src/window/winit_manager.rs +++ b/frontend-common/src/window/winit_manager.rs @@ -8,10 +8,11 @@ use std::{ }; use cpal::Stream; -use gb_emu_lib::{ - connect::{EmulatorMessage, JoypadState, RendererMessage, ResolutionData}, - renderer::{RendererBackend, RendererBackendManager, WindowOptions}, -}; +use gb_emu_lib::connect::{EmulatorMessage, JoypadState, RendererMessage, ResolutionData}; +#[cfg(feature = "pixels")] +use gb_emu_lib::renderer::pixels::{RendererBackend, RendererBackendManager, WindowOptions}; +#[cfg(feature = "vulkan")] +use gb_emu_lib::renderer::vulkan::{RendererBackend, RendererBackendManager, WindowOptions}; use gilrs::{Button, Gilrs}; use image::ImageBuffer; #[cfg(feature = "vulkan")] diff --git a/gb-vst/src/plugin/ui.rs b/gb-vst/src/plugin/ui.rs index 859d641..0161ff2 100644 --- a/gb-vst/src/plugin/ui.rs +++ b/gb-vst/src/plugin/ui.rs @@ -3,10 +3,13 @@ use std::sync::{Arc, Mutex}; use baseview::{ Event, EventStatus, Size, Window, WindowEvent, WindowHandle, WindowHandler, WindowOpenOptions, }; -use gb_emu_lib::{ - connect::{JoypadButtons, JoypadState, RendererMessage, ResolutionData, HEIGHT, WIDTH}, - renderer::{RendererBackend, RendererBackendManager, WindowOptions}, +use gb_emu_lib::connect::{ + JoypadButtons, JoypadState, RendererMessage, ResolutionData, HEIGHT, WIDTH, }; +#[cfg(feature = "pixels")] +use gb_emu_lib::renderer::pixels::{RendererBackend, RendererBackendManager, WindowOptions}; +#[cfg(feature = "vulkan")] +use gb_emu_lib::renderer::vulkan::{RendererBackend, RendererBackendManager, WindowOptions}; use keyboard_types::{Code, KeyState}; use nih_plug::prelude::*; diff --git a/gui/src/macos/cacao_window_manager.rs b/gui/src/macos/cacao_window_manager.rs index 46b96e7..2ae2692 100644 --- a/gui/src/macos/cacao_window_manager.rs +++ b/gui/src/macos/cacao_window_manager.rs @@ -24,7 +24,7 @@ use frontend_common::{ }; use gb_emu_lib::{ connect::{EmulatorMessage, JoypadButtons, JoypadState, RendererMessage, ResolutionData}, - renderer::{RendererBackend, RendererBackendManager, WindowOptions}, + renderer::vulkan::{RendererBackend, RendererBackendManager, WindowOptions}, }; use objc::{ class, msg_send, msg_send_id, diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 50dce23..6361e1b 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -11,10 +11,6 @@ use std::sync::mpsc::Receiver; #[cfg(all(feature = "vulkan", feature = "pixels"))] compile_error!("select only one rendering backend!"); -#[allow(unused_attributes)] -#[cfg(any(feature = "vulkan-renderer", feature = "pixels-renderer"))] -#[cfg_attr(feature = "pixels-renderer", path = "renderer/pixels.rs")] -#[cfg_attr(feature = "vulkan-renderer", path = "renderer/vulkan/vulkan.rs")] pub mod renderer; #[cfg(feature = "config")] diff --git a/lib/src/renderer/mod.rs b/lib/src/renderer/mod.rs new file mode 100644 index 0000000..7a1ff33 --- /dev/null +++ b/lib/src/renderer/mod.rs @@ -0,0 +1,4 @@ +#[cfg(feature = "pixels-renderer")] +pub mod pixels; +#[cfg(feature = "vulkan-renderer")] +pub mod vulkan; diff --git a/lib/src/renderer/vulkan/vulkan.rs b/lib/src/renderer/vulkan/mod.rs similarity index 100% rename from lib/src/renderer/vulkan/vulkan.rs rename to lib/src/renderer/vulkan/mod.rs