move renderers to gb-emu-lib
This commit is contained in:
parent
ae9c35ed9a
commit
7407bae39d
13 changed files with 54 additions and 56 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -1222,19 +1222,13 @@ dependencies = [
|
|||
name = "gb-emu"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"ash-window",
|
||||
"bytemuck",
|
||||
"clap",
|
||||
"cpal",
|
||||
"ctrlc",
|
||||
"futures",
|
||||
"gb-emu-lib",
|
||||
"gilrs",
|
||||
"librashader",
|
||||
"naga 0.13.0",
|
||||
"nokhwa",
|
||||
"pixels",
|
||||
"raw-window-handle",
|
||||
"send_wrapper",
|
||||
"winit",
|
||||
|
@ -1243,15 +1237,20 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gb-emu-lib"
|
||||
version = "0.3.3"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"ash",
|
||||
"ash-window",
|
||||
"async-ringbuf",
|
||||
"bytemuck",
|
||||
"futures",
|
||||
"itertools",
|
||||
"librashader",
|
||||
"naga 0.13.0",
|
||||
"num-traits",
|
||||
"once_cell",
|
||||
"pixels",
|
||||
"rand",
|
||||
"raw-window-handle",
|
||||
"serde",
|
||||
"serde_with",
|
||||
]
|
||||
|
|
|
@ -5,19 +5,12 @@ edition = "2021"
|
|||
|
||||
[features]
|
||||
default = ["vulkan"]
|
||||
pixels = ["dep:pixels"]
|
||||
vulkan = [
|
||||
"dep:ash",
|
||||
"dep:ash-window",
|
||||
"dep:raw-window-handle",
|
||||
"dep:naga",
|
||||
# "dep:librashader-common",
|
||||
"dep:librashader",
|
||||
]
|
||||
pixels = ["gb-emu-lib/pixels-renderer"]
|
||||
vulkan = ["dep:raw-window-handle", "gb-emu-lib/vulkan-renderer"]
|
||||
camera = ["dep:nokhwa", "dep:send_wrapper"]
|
||||
|
||||
[dependencies]
|
||||
gb-emu-lib = { path = "../lib" }
|
||||
gb-emu-lib = { path = "../lib", default-features = false }
|
||||
clap = { version = "4.1.8", features = ["derive"] }
|
||||
gilrs = "0.10"
|
||||
cpal = "0.15"
|
||||
|
@ -29,17 +22,4 @@ nokhwa = { version = "0.10.3", features = [
|
|||
send_wrapper = { version = "0.6.0", optional = true }
|
||||
winit = "0.28"
|
||||
winit_input_helper = "0.14"
|
||||
bytemuck = "1.13"
|
||||
pixels = { version = "0.12", optional = true }
|
||||
ash = { version = "0.37", features = ["linked"], optional = true }
|
||||
ash-window = { version = "0.12", optional = true }
|
||||
raw-window-handle = { version = "0.5", optional = true }
|
||||
# librashader-common = { version = "0.1", optional = true, default-features = false, features = [
|
||||
# "vulkan",
|
||||
# ] }
|
||||
librashader = { version = "0.1", optional = true, default-features = false, features = [
|
||||
"runtime-vk",
|
||||
] }
|
||||
|
||||
[build-dependencies]
|
||||
naga = { version = "0.13", optional = true, features = ["wgsl-in", "spv-out"] }
|
||||
|
|
|
@ -4,7 +4,10 @@ use std::{
|
|||
sync::{mpsc::Sender, Arc, Mutex, RwLock},
|
||||
};
|
||||
|
||||
use gb_emu_lib::connect::{EmulatorMessage, JoypadState, Renderer};
|
||||
use gb_emu_lib::{
|
||||
connect::{EmulatorMessage, JoypadState, Renderer, ResolutionData},
|
||||
renderer::{RendererBackend, RendererBackendManager, WindowOptions},
|
||||
};
|
||||
use gilrs::{
|
||||
ff::{BaseEffect, BaseEffectType, EffectBuilder, Replay, Ticks},
|
||||
Button, Gilrs,
|
||||
|
@ -20,22 +23,6 @@ use winit::{
|
|||
};
|
||||
use winit_input_helper::WinitInputHelper;
|
||||
|
||||
#[cfg_attr(feature = "pixels", path = "renderer/pixels.rs")]
|
||||
#[cfg_attr(feature = "vulkan", path = "renderer/vulkan/vulkan.rs")]
|
||||
mod renderer;
|
||||
|
||||
use renderer::RendererBackend;
|
||||
|
||||
use self::renderer::{RendererBackendManager, WindowOptions};
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ResolutionData {
|
||||
real_width: u32,
|
||||
real_height: u32,
|
||||
scaled_width: u32,
|
||||
scaled_height: u32,
|
||||
}
|
||||
|
||||
pub struct WindowInfo {
|
||||
id: WindowId,
|
||||
data: Arc<WindowData>,
|
||||
|
|
|
@ -1,19 +1,36 @@
|
|||
[package]
|
||||
name = "gb-emu-lib"
|
||||
version = "0.3.3"
|
||||
version = "0.4.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
clocked-serial = []
|
||||
vulkan-renderer = [
|
||||
"dep:ash",
|
||||
"dep:ash-window",
|
||||
"dep:raw-window-handle",
|
||||
"dep:naga",
|
||||
"dep:librashader",
|
||||
]
|
||||
pixels-renderer = ["dep:pixels"]
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
async-ringbuf = "0.1.2"
|
||||
futures = "0.3"
|
||||
once_cell = "1.17.1"
|
||||
itertools = "0.10.5"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_with = "3.0"
|
||||
bytemuck = "1.13"
|
||||
num-traits = "0.2"
|
||||
pixels = { version = "0.12", optional = true }
|
||||
ash = { version = "0.37", features = ["linked"], optional = true }
|
||||
ash-window = { version = "0.12", optional = true }
|
||||
raw-window-handle = { version = "0.5", optional = true }
|
||||
librashader = { version = "0.1", optional = true, default-features = false, features = [
|
||||
"runtime-vk",
|
||||
] }
|
||||
|
||||
[build-dependencies]
|
||||
naga = { version = "0.13", optional = true, features = ["wgsl-in", "spv-out"] }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[cfg(feature = "vulkan")]
|
||||
#[cfg(feature = "vulkan-renderer")]
|
||||
{
|
||||
const SHADER_SRC_DIR: &str = "src/renderer/vulkan/shaders";
|
||||
const SHADER_OUT_DIR: &str = "shaders";
|
BIN
lib/shaders/shader.spv
Normal file
BIN
lib/shaders/shader.spv
Normal file
Binary file not shown.
|
@ -38,6 +38,15 @@ pub trait Renderer<Format: From<Colour>> {
|
|||
fn set_rumble(&mut self, _rumbling: bool) {}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "vulkan-renderer", feature = "pixels-renderer"))]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ResolutionData {
|
||||
pub real_width: u32,
|
||||
pub real_height: u32,
|
||||
pub scaled_width: u32,
|
||||
pub scaled_height: u32,
|
||||
}
|
||||
|
||||
pub struct AudioOutput {
|
||||
pub sample_rate: f32,
|
||||
pub send_rb: AsyncHeapProducer<[f32; 2]>,
|
||||
|
|
|
@ -26,6 +26,12 @@ use std::{
|
|||
sync::{mpsc::Receiver, Arc, Mutex},
|
||||
};
|
||||
|
||||
#[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;
|
||||
|
||||
pub mod connect;
|
||||
mod constants;
|
||||
mod processor;
|
||||
|
|
|
@ -5,12 +5,12 @@ use pixels::{
|
|||
Pixels, SurfaceTexture,
|
||||
};
|
||||
|
||||
use super::ResolutionData;
|
||||
use crate::connect::ResolutionData;
|
||||
|
||||
pub struct RendererBackendManager {}
|
||||
|
||||
impl RendererBackendManager {
|
||||
pub(super) fn new() -> Self {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ use ash::{
|
|||
};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
|
||||
use crate::window::ResolutionData;
|
||||
use crate::connect::ResolutionData;
|
||||
|
||||
use super::{
|
||||
utils::{find_memorytype_index, record_submit_commandbuffer},
|
|
@ -5,6 +5,8 @@ use ash_window::enumerate_required_extensions;
|
|||
use librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
||||
|
||||
use crate::connect::ResolutionData;
|
||||
|
||||
use self::{
|
||||
types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT},
|
||||
utils::{
|
||||
|
@ -13,8 +15,6 @@ use self::{
|
|||
},
|
||||
};
|
||||
|
||||
use super::ResolutionData;
|
||||
|
||||
mod types;
|
||||
mod utils;
|
||||
|
Loading…
Add table
Reference in a new issue