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
16
Cargo.toml
16
Cargo.toml
|
@ -8,3 +8,19 @@ resolver = "2"
|
|||
lto = "fat"
|
||||
panic = "abort"
|
||||
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]
|
||||
default = ["vulkan"]
|
||||
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"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -24,11 +31,15 @@ winit = "0.28"
|
|||
winit_input_helper = "0.14"
|
||||
bytemuck = "1.13"
|
||||
pixels = { version = "0.12", optional = true }
|
||||
ash = { git = "https://github.com/ash-rs/ash", features = [
|
||||
"linked",
|
||||
], optional = true }
|
||||
ash-window = { git = "https://github.com/ash-rs/ash", 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"] }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::mem;
|
||||
use std::{mem, path::PathBuf};
|
||||
|
||||
use ash::{
|
||||
extensions::khr::{Surface, Swapchain},
|
||||
|
@ -6,6 +6,7 @@ use ash::{
|
|||
vk, Device, Entry, Instance,
|
||||
};
|
||||
use ash_window::enumerate_required_extensions;
|
||||
use librashader::runtime::vk::{FilterChain, FilterChainOptions, VulkanObjects};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
use winit::window::Window;
|
||||
|
||||
|
@ -20,11 +21,39 @@ pub struct WindowData {
|
|||
inner: VulkanWindowInner,
|
||||
}
|
||||
|
||||
pub struct WindowOptions {
|
||||
pub shader_path: PathBuf,
|
||||
}
|
||||
|
||||
impl WindowData {
|
||||
pub fn new(factor: u32, window: &Window) -> Self {
|
||||
Self {
|
||||
inner: unsafe { VulkanWindowInner::new(factor, window) },
|
||||
}
|
||||
pub fn new(factor: u32, window: &Window, options: WindowOptions) -> Self {
|
||||
let 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) {
|
||||
|
|
|
@ -23,6 +23,8 @@ mod renderer;
|
|||
|
||||
use renderer::WindowData;
|
||||
|
||||
use self::renderer::WindowOptions;
|
||||
|
||||
pub struct WindowInfo {
|
||||
id: WindowId,
|
||||
data: Arc<Mutex<WindowData>>,
|
||||
|
@ -114,7 +116,15 @@ impl WindowRenderer {
|
|||
|
||||
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 {
|
||||
id: window.id(),
|
||||
data: data.clone(),
|
||||
|
|
Loading…
Add table
Reference in a new issue