|
|
|
@ -4,39 +4,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern crate cgmath;
|
|
|
|
|
extern crate hprof;
|
|
|
|
|
extern crate image;
|
|
|
|
|
extern crate nalgebra as na;
|
|
|
|
|
extern crate rand;
|
|
|
|
|
extern crate time;
|
|
|
|
|
extern crate hprof;
|
|
|
|
|
|
|
|
|
|
use vulkano::sync;
|
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use vulkano::instance::debug::DebugCallback;
|
|
|
|
|
use vulkano::instance::Instance;
|
|
|
|
|
use vulkano::sync;
|
|
|
|
|
use vulkano::sync::GpuFuture;
|
|
|
|
|
use vulkano_win::VkSurfaceBuild;
|
|
|
|
|
use winit::dpi::LogicalSize;
|
|
|
|
|
use winit::event::{DeviceEvent, ElementState, Event, VirtualKeyCode, WindowEvent};
|
|
|
|
|
use winit::event_loop::{EventLoop, ControlFlow};
|
|
|
|
|
use winit::platform::unix::WindowBuilderExtUnix;
|
|
|
|
|
use winit::window::WindowBuilder;
|
|
|
|
|
|
|
|
|
|
use crate::util::load_raw;
|
|
|
|
|
|
|
|
|
|
use vulkano::instance::debug::DebugCallback;
|
|
|
|
|
use crate::compute::compu_frame::CompuFrame;
|
|
|
|
|
use crate::canvas::canvas_frame::{CanvasFrame, Drawable};
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
|
use crate::canvas::managed::handles::{CanvasTextureHandle, Handle, CanvasFontHandle};
|
|
|
|
|
use crate::util::vertex::{VertexTypes, TextureVertex3D};
|
|
|
|
|
use crate::canvas::managed::handles::{CanvasFontHandle, CanvasTextureHandle, Handle};
|
|
|
|
|
use crate::compute::compu_frame::CompuFrame;
|
|
|
|
|
use crate::compute::managed::handles::{CompuBufferHandle, CompuKernelHandle};
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
|
use crate::drawables::rect::Rect;
|
|
|
|
|
use crate::drawables::compu_sprite::CompuSprite;
|
|
|
|
|
use crate::drawables::rect::Rect;
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
|
use crate::drawables::text::Text;
|
|
|
|
|
use winit::window::{WindowBuilder};
|
|
|
|
|
use winit::dpi::LogicalSize;
|
|
|
|
|
use winit::event_loop::EventLoop;
|
|
|
|
|
use winit::event::{Event, WindowEvent, DeviceEvent, VirtualKeyCode, ElementState};
|
|
|
|
|
use winit::platform::unix::WindowBuilderExtUnix;
|
|
|
|
|
use crate::util::load_raw;
|
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexTypes};
|
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub mod util;
|
|
|
|
|
pub mod vkprocessor;
|
|
|
|
|
pub mod drawables;
|
|
|
|
@ -60,15 +59,14 @@ pub fn main() {
|
|
|
|
|
let mut events_loop = EventLoop::new();
|
|
|
|
|
|
|
|
|
|
let mut surface = WindowBuilder::new()
|
|
|
|
|
.with_inner_size(LogicalSize::new(800, 800));
|
|
|
|
|
// Some weird namespacing issue here
|
|
|
|
|
let mut surface = VkSurfaceBuild::build_vk_surface(surface.clone(), &events_loop, instance.clone()).unwrap();
|
|
|
|
|
.with_inner_size(LogicalSize::new(800, 800))
|
|
|
|
|
.build_vk_surface(&events_loop, instance.clone()).unwrap();
|
|
|
|
|
|
|
|
|
|
let mut processor = VkProcessor::new(&instance, surface.clone());
|
|
|
|
|
let mut processor = VkProcessor::new(instance.clone(), surface.clone());
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
let g = hprof::enter("vulkan preload");
|
|
|
|
|
processor.create_swapchain(surface.clone());
|
|
|
|
|
processor.create_swapchain(instance.clone(), surface.clone());
|
|
|
|
|
|
|
|
|
|
processor.preload_kernels();
|
|
|
|
|
processor.preload_shaders();
|
|
|
|
@ -129,54 +127,35 @@ pub fn main() {
|
|
|
|
|
|
|
|
|
|
let mut count = 0;
|
|
|
|
|
|
|
|
|
|
while let true = processor.is_open() {
|
|
|
|
|
// while let true = processor.is_open() {
|
|
|
|
|
//
|
|
|
|
|
// // Take care of our timing
|
|
|
|
|
// {
|
|
|
|
|
// elapsed_time = timer.elap_time();
|
|
|
|
|
// delta_time = elapsed_time - current_time;
|
|
|
|
|
// current_time = elapsed_time;
|
|
|
|
|
// if delta_time > 0.02 {
|
|
|
|
|
// delta_time = 0.02;
|
|
|
|
|
// }
|
|
|
|
|
// accumulator_time += delta_time;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// while (accumulator_time - step_size) >= step_size {
|
|
|
|
|
// accumulator_time -= step_size;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Take care of our timing
|
|
|
|
|
{
|
|
|
|
|
elapsed_time = timer.elap_time();
|
|
|
|
|
delta_time = elapsed_time - current_time;
|
|
|
|
|
current_time = elapsed_time;
|
|
|
|
|
if delta_time > 0.02 {
|
|
|
|
|
delta_time = 0.02;
|
|
|
|
|
}
|
|
|
|
|
accumulator_time += delta_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (accumulator_time - step_size) >= step_size {
|
|
|
|
|
accumulator_time -= step_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
|
match event {
|
|
|
|
|
Event::WindowEvent { event: WindowEvent::CloseRequested, .. } =>
|
|
|
|
|
{
|
|
|
|
|
exit = true;
|
|
|
|
|
*control_flow = ControlFlow::Exit
|
|
|
|
|
}
|
|
|
|
|
Event::WindowEvent { event: WindowEvent::Resized(_), .. } => {
|
|
|
|
|
processor.swapchain_recreate_needed = true;
|
|
|
|
|
}
|
|
|
|
|
Event::DeviceEvent { event: DeviceEvent::Key(keyboard_input), .. } => {
|
|
|
|
|
match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
|
VirtualKeyCode::A => {
|
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
|
// processor.save_edges_image();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => ()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Event::DeviceEvent { event: DeviceEvent::Button(mouse_input), .. } => {
|
|
|
|
|
// mouse_xy.x
|
|
|
|
|
// },
|
|
|
|
|
_ => ()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if exit {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event::MainEventsCleared => {
|
|
|
|
|
let mut canvas_frame = CanvasFrame::default();
|
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
|
canvas_frame.draw(&text_sprite);
|
|
|
|
@ -186,7 +165,6 @@ pub fn main() {
|
|
|
|
|
//compu_frame.add(compute_buffer.clone(), compute_kernel.clone());
|
|
|
|
|
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
let g = hprof::enter("Run");
|
|
|
|
|
processor.run(&surface.clone(),
|
|
|
|
@ -194,12 +172,27 @@ pub fn main() {
|
|
|
|
|
compu_frame);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Event::DeviceEvent { event: DeviceEvent::Key(keyboard_input), .. } => {
|
|
|
|
|
match keyboard_input.virtual_keycode.unwrap() {
|
|
|
|
|
VirtualKeyCode::A => {
|
|
|
|
|
if keyboard_input.state == ElementState::Pressed {
|
|
|
|
|
// processor.save_edges_image();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_ => ()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Event::DeviceEvent { event: DeviceEvent::Button(mouse_input), .. } => {
|
|
|
|
|
// mouse_xy.x
|
|
|
|
|
// },
|
|
|
|
|
_ => ()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
drop(l);
|
|
|
|
|
|
|
|
|
|
hprof::end_frame();
|
|
|
|
|
hprof::profiler().print_timing();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|