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"
|
name = "gb-emu"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash",
|
|
||||||
"ash-window",
|
|
||||||
"bytemuck",
|
|
||||||
"clap",
|
"clap",
|
||||||
"cpal",
|
"cpal",
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"futures",
|
"futures",
|
||||||
"gb-emu-lib",
|
"gb-emu-lib",
|
||||||
"gilrs",
|
"gilrs",
|
||||||
"librashader",
|
|
||||||
"naga 0.13.0",
|
|
||||||
"nokhwa",
|
"nokhwa",
|
||||||
"pixels",
|
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"send_wrapper",
|
"send_wrapper",
|
||||||
"winit",
|
"winit",
|
||||||
|
@ -1243,15 +1237,20 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gb-emu-lib"
|
name = "gb-emu-lib"
|
||||||
version = "0.3.3"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"ash",
|
||||||
|
"ash-window",
|
||||||
"async-ringbuf",
|
"async-ringbuf",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"futures",
|
"futures",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"librashader",
|
||||||
|
"naga 0.13.0",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"once_cell",
|
"pixels",
|
||||||
"rand",
|
"rand",
|
||||||
|
"raw-window-handle",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
]
|
]
|
||||||
|
|
|
@ -5,19 +5,12 @@ edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["vulkan"]
|
default = ["vulkan"]
|
||||||
pixels = ["dep:pixels"]
|
pixels = ["gb-emu-lib/pixels-renderer"]
|
||||||
vulkan = [
|
vulkan = ["dep:raw-window-handle", "gb-emu-lib/vulkan-renderer"]
|
||||||
"dep:ash",
|
|
||||||
"dep:ash-window",
|
|
||||||
"dep:raw-window-handle",
|
|
||||||
"dep:naga",
|
|
||||||
# "dep:librashader-common",
|
|
||||||
"dep:librashader",
|
|
||||||
]
|
|
||||||
camera = ["dep:nokhwa", "dep:send_wrapper"]
|
camera = ["dep:nokhwa", "dep:send_wrapper"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gb-emu-lib = { path = "../lib" }
|
gb-emu-lib = { path = "../lib", default-features = false }
|
||||||
clap = { version = "4.1.8", features = ["derive"] }
|
clap = { version = "4.1.8", features = ["derive"] }
|
||||||
gilrs = "0.10"
|
gilrs = "0.10"
|
||||||
cpal = "0.15"
|
cpal = "0.15"
|
||||||
|
@ -29,17 +22,4 @@ nokhwa = { version = "0.10.3", features = [
|
||||||
send_wrapper = { version = "0.6.0", optional = true }
|
send_wrapper = { version = "0.6.0", optional = true }
|
||||||
winit = "0.28"
|
winit = "0.28"
|
||||||
winit_input_helper = "0.14"
|
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 }
|
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},
|
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::{
|
use gilrs::{
|
||||||
ff::{BaseEffect, BaseEffectType, EffectBuilder, Replay, Ticks},
|
ff::{BaseEffect, BaseEffectType, EffectBuilder, Replay, Ticks},
|
||||||
Button, Gilrs,
|
Button, Gilrs,
|
||||||
|
@ -20,22 +23,6 @@ use winit::{
|
||||||
};
|
};
|
||||||
use winit_input_helper::WinitInputHelper;
|
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 {
|
pub struct WindowInfo {
|
||||||
id: WindowId,
|
id: WindowId,
|
||||||
data: Arc<WindowData>,
|
data: Arc<WindowData>,
|
||||||
|
|
|
@ -1,19 +1,36 @@
|
||||||
[package]
|
[package]
|
||||||
name = "gb-emu-lib"
|
name = "gb-emu-lib"
|
||||||
version = "0.3.3"
|
version = "0.4.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
clocked-serial = []
|
clocked-serial = []
|
||||||
|
vulkan-renderer = [
|
||||||
|
"dep:ash",
|
||||||
|
"dep:ash-window",
|
||||||
|
"dep:raw-window-handle",
|
||||||
|
"dep:naga",
|
||||||
|
"dep:librashader",
|
||||||
|
]
|
||||||
|
pixels-renderer = ["dep:pixels"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
async-ringbuf = "0.1.2"
|
async-ringbuf = "0.1.2"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
once_cell = "1.17.1"
|
|
||||||
itertools = "0.10.5"
|
itertools = "0.10.5"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_with = "3.0"
|
serde_with = "3.0"
|
||||||
bytemuck = "1.13"
|
bytemuck = "1.13"
|
||||||
num-traits = "0.2"
|
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>> {
|
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_SRC_DIR: &str = "src/renderer/vulkan/shaders";
|
||||||
const SHADER_OUT_DIR: &str = "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) {}
|
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 struct AudioOutput {
|
||||||
pub sample_rate: f32,
|
pub sample_rate: f32,
|
||||||
pub send_rb: AsyncHeapProducer<[f32; 2]>,
|
pub send_rb: AsyncHeapProducer<[f32; 2]>,
|
||||||
|
|
|
@ -26,6 +26,12 @@ use std::{
|
||||||
sync::{mpsc::Receiver, Arc, Mutex},
|
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;
|
pub mod connect;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod processor;
|
mod processor;
|
||||||
|
|
|
@ -5,12 +5,12 @@ use pixels::{
|
||||||
Pixels, SurfaceTexture,
|
Pixels, SurfaceTexture,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ResolutionData;
|
use crate::connect::ResolutionData;
|
||||||
|
|
||||||
pub struct RendererBackendManager {}
|
pub struct RendererBackendManager {}
|
||||||
|
|
||||||
impl RendererBackendManager {
|
impl RendererBackendManager {
|
||||||
pub(super) fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {}
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,7 @@ use ash::{
|
||||||
};
|
};
|
||||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||||
|
|
||||||
use crate::window::ResolutionData;
|
use crate::connect::ResolutionData;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
utils::{find_memorytype_index, record_submit_commandbuffer},
|
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 librashader::runtime::vk::{FilterChain, FilterChainOptions, FrameOptions, VulkanObjects};
|
||||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle};
|
||||||
|
|
||||||
|
use crate::connect::ResolutionData;
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT},
|
types::{FramebufferData, SurfaceData, SwapchainData, Vertex, VulkanData, SHADER_INPUT_FORMAT},
|
||||||
utils::{
|
utils::{
|
||||||
|
@ -13,8 +15,6 @@ use self::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ResolutionData;
|
|
||||||
|
|
||||||
mod types;
|
mod types;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
Loading…
Add table
Reference in a new issue