From 6eca607ca3a167ad2c5aefdb50fcf611834d527d Mon Sep 17 00:00:00 2001 From: Tom Gowan Date: Fri, 26 Apr 2019 21:52:18 +1000 Subject: [PATCH] fixes --- Cargo.toml | 7 ++----- src/layouts.rs | 1 + src/watch.rs | 45 +++++++++++++++++++++++++++------------------ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 39bea5e..a557f5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,12 +8,9 @@ edition = "2018" notify = "4" shaderc = "0.3" spirv-reflect = "0.2" -vulkano = "0.11" +vulkano = { git = "https://github.com/mitchmindtree/vulkano", branch = "nannou_patches" } [dev-dependencies] -vulkano = "0.11" +vulkano = { git = "https://github.com/mitchmindtree/vulkano", branch = "nannou_patches" } color-backtrace = "0.1" difference = "2" - -[patch.crates-io] -vulkano = { git = "https://github.com/mitchmindtree/vulkano", branch = "nannou_patches" } diff --git a/src/layouts.rs b/src/layouts.rs index 789f918..f315047 100644 --- a/src/layouts.rs +++ b/src/layouts.rs @@ -1,5 +1,6 @@ use crate::vk; use vk::pipeline::shader::*; +pub use vk::pipeline::shader::ShaderInterfaceDef; use vk::descriptor::descriptor::*; use vk::descriptor::pipeline_layout::*; use crate::reflection::LayoutData; diff --git a/src/watch.rs b/src/watch.rs index 8b855de..52ddebd 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -1,12 +1,12 @@ -use std::sync::mpsc; +use crate::error::Error; +use crate::layouts::Entry; +use crate::CompiledShaders; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; +use std::path::{Path, PathBuf}; +use std::sync::mpsc; +use std::sync::mpsc::{Receiver, Sender}; use std::thread; use std::time::Duration; -use std::path::{Path, PathBuf}; -use crate::layouts::Entry; -use crate::CompiledShaders; -use std::sync::mpsc::{Sender, Receiver}; -use crate::error::Error; pub struct Watch { _handler: Handler, @@ -26,18 +26,24 @@ pub struct Message { impl Watch { pub fn new(vertex: T, fragment: T) -> Self - where + where T: AsRef, - { - let (handler, rx) = create_watch(vertex.as_ref().to_path_buf(), fragment.as_ref().to_path_buf()); - Watch{_handler: handler, rx} + { + let (handler, rx) = create_watch( + vertex.as_ref().to_path_buf(), + fragment.as_ref().to_path_buf(), + ); + Watch { + _handler: handler, + rx, } + } } impl Loader { fn create(vertex: PathBuf, fragment: PathBuf) -> (Self, Receiver>) { - let (tx, rx) = mpsc::channel(); - let loader = Loader{ + let (tx, rx) = mpsc::channel(); + let loader = Loader { vertex, fragment, tx, @@ -50,8 +56,8 @@ impl Loader { match crate::load(&self.vertex, &self.fragment) { Ok(shaders) => { let entry = crate::parse(&shaders); - self.tx.send(Ok(Message{ shaders, entry })).ok() - }, + self.tx.send(Ok(Message { shaders, entry })).ok() + } Err(e) => self.tx.send(Err(e)).ok(), }; } @@ -72,8 +78,10 @@ impl Drop for Handler { } } - -fn create_watch(vert_path: PathBuf, frag_path: PathBuf) -> (Handler, mpsc::Receiver>) { +fn create_watch( + vert_path: PathBuf, + frag_path: PathBuf, +) -> (Handler, mpsc::Receiver>) { let (notify_tx, notify_rx) = mpsc::channel(); let (thread_tx, thread_rx) = mpsc::channel(); let mut watcher: RecommendedWatcher = @@ -86,14 +94,15 @@ fn create_watch(vert_path: PathBuf, frag_path: PathBuf) -> (Handler, mpsc::Recei .watch(&frag_path, RecursiveMode::NonRecursive) .expect("failed to add fragment shader to notify"); - let (loader, rx) = Loader::create(vert_path, frag_path); let handle = thread::spawn(move || 'watch_loop: loop { if let Ok(_) = thread_rx.try_recv() { break 'watch_loop; } - if let Ok(notify::DebouncedEvent::Create(_)) = notify_rx.recv_timeout(Duration::from_secs(1)) { + if let Ok(notify::DebouncedEvent::Create(_)) = + notify_rx.recv_timeout(Duration::from_secs(1)) + { loader.reload(); } });