window options beginning
This commit is contained in:
parent
361112d2d1
commit
249c3be4c8
5 changed files with 792 additions and 331 deletions
1033
Cargo.lock
generated
1033
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
18
Cargo.toml
18
Cargo.toml
|
@ -7,4 +7,20 @@ resolver = "2"
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
librashader = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-common = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-presets = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-preprocess = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-reflect = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-runtime = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# librashader-runtime-d3d11 = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# librashader-runtime-d3d12 = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# librashader-runtime-gl = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-runtime-vk = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
librashader-cache = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# librashader-capi = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# librashader-build-script = { git = "https://github.com/italicsjenga/librashader" }
|
||||||
|
# ash = { git = "https://github.com/ash-rs/ash" }
|
||||||
|
|
|
@ -6,7 +6,14 @@ edition = "2021"
|
||||||
[features]
|
[features]
|
||||||
default = ["vulkan"]
|
default = ["vulkan"]
|
||||||
pixels = ["dep:pixels"]
|
pixels = ["dep:pixels"]
|
||||||
vulkan = ["dep:ash", "dep:ash-window", "dep:raw-window-handle", "dep:naga"]
|
vulkan = [
|
||||||
|
"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]
|
||||||
|
@ -24,11 +31,15 @@ winit = "0.28"
|
||||||
winit_input_helper = "0.14"
|
winit_input_helper = "0.14"
|
||||||
bytemuck = "1.13"
|
bytemuck = "1.13"
|
||||||
pixels = { version = "0.12", optional = true }
|
pixels = { version = "0.12", optional = true }
|
||||||
ash = { git = "https://github.com/ash-rs/ash", features = [
|
ash = { version = "0.37", features = ["linked"], optional = true }
|
||||||
"linked",
|
ash-window = { version = "0.12", optional = true }
|
||||||
], optional = true }
|
|
||||||
ash-window = { git = "https://github.com/ash-rs/ash", 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]
|
[build-dependencies]
|
||||||
naga = { version = "0.13", optional = true, features = ["wgsl-in", "spv-out"] }
|
naga = { version = "0.13", optional = true, features = ["wgsl-in", "spv-out"] }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::mem;
|
use std::{mem, path::PathBuf};
|
||||||
|
|
||||||
use ash::{
|
use ash::{
|
||||||
extensions::khr::{Surface, Swapchain},
|
extensions::khr::{Surface, Swapchain},
|
||||||
|
@ -6,6 +6,7 @@ use ash::{
|
||||||
vk, Device, Entry, Instance,
|
vk, Device, Entry, Instance,
|
||||||
};
|
};
|
||||||
use ash_window::enumerate_required_extensions;
|
use ash_window::enumerate_required_extensions;
|
||||||
|
use librashader::runtime::vk::{FilterChain, FilterChainOptions, VulkanObjects};
|
||||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||||
use winit::window::Window;
|
use winit::window::Window;
|
||||||
|
|
||||||
|
@ -20,11 +21,39 @@ pub struct WindowData {
|
||||||
inner: VulkanWindowInner,
|
inner: VulkanWindowInner,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct WindowOptions {
|
||||||
|
pub shader_path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
impl WindowData {
|
impl WindowData {
|
||||||
pub fn new(factor: u32, window: &Window) -> Self {
|
pub fn new(factor: u32, window: &Window, options: WindowOptions) -> Self {
|
||||||
Self {
|
let inner = unsafe { VulkanWindowInner::new(factor, window) };
|
||||||
inner: unsafe { VulkanWindowInner::new(factor, window) },
|
|
||||||
}
|
// let filter_chain_options = FilterChainOptions {
|
||||||
|
// frames_in_flight: 0,
|
||||||
|
// force_no_mipmaps: false,
|
||||||
|
// use_render_pass: true,
|
||||||
|
// disable_cache: false,
|
||||||
|
// };
|
||||||
|
// let physical_device = unsafe {
|
||||||
|
// inner
|
||||||
|
// .instance
|
||||||
|
// .enumerate_physical_devices()
|
||||||
|
// .unwrap()
|
||||||
|
// .first()
|
||||||
|
// .unwrap()
|
||||||
|
// };
|
||||||
|
// let vulkan = VulkanObjects::try_from((
|
||||||
|
// *physical_device,
|
||||||
|
// inner.instance.clone(),
|
||||||
|
// inner.device.clone(),
|
||||||
|
// ))
|
||||||
|
// .unwrap();
|
||||||
|
// let filter_chain = unsafe {
|
||||||
|
// FilterChain::load_from_path(options.shader_path, vulkan, Some(&filter_chain_options))
|
||||||
|
// }
|
||||||
|
// .unwrap();
|
||||||
|
Self { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, width: u32, height: u32, factor: u32, window: &Window) {
|
pub fn resize(&mut self, width: u32, height: u32, factor: u32, window: &Window) {
|
||||||
|
|
|
@ -23,6 +23,8 @@ mod renderer;
|
||||||
|
|
||||||
use renderer::WindowData;
|
use renderer::WindowData;
|
||||||
|
|
||||||
|
use self::renderer::WindowOptions;
|
||||||
|
|
||||||
pub struct WindowInfo {
|
pub struct WindowInfo {
|
||||||
id: WindowId,
|
id: WindowId,
|
||||||
data: Arc<Mutex<WindowData>>,
|
data: Arc<Mutex<WindowData>>,
|
||||||
|
@ -114,7 +116,15 @@ impl WindowRenderer {
|
||||||
|
|
||||||
let real_factor = (window.scale_factor() * factor as f64) as usize;
|
let real_factor = (window.scale_factor() * factor as f64) as usize;
|
||||||
|
|
||||||
let data = Arc::new(Mutex::new(WindowData::new(real_factor as u32, &window)));
|
let options = WindowOptions {
|
||||||
|
shader_path: std::path::PathBuf::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let data = Arc::new(Mutex::new(WindowData::new(
|
||||||
|
real_factor as u32,
|
||||||
|
&window,
|
||||||
|
options,
|
||||||
|
)));
|
||||||
let info = WindowInfo {
|
let info = WindowInfo {
|
||||||
id: window.id(),
|
id: window.id(),
|
||||||
data: data.clone(),
|
data: data.clone(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue