minimal example of 15ms lag
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
use vulkano::command_buffer::{AutoCommandBufferBuilder, DynamicState};
|
||||
use vulkano::device::{Device, DeviceExtensions, QueuesIter, Queue};
|
||||
use vulkano::instance::{Instance, PhysicalDevice};
|
||||
use vulkano::sync::{GpuFuture, FlushError};
|
||||
use vulkano::sync::{GpuFuture, FlushError, NowFuture};
|
||||
use vulkano::sync::now;
|
||||
use vulkano::sync;
|
||||
use std::sync::Arc;
|
||||
use vulkano::swapchain::{Swapchain, PresentMode, SurfaceTransform, Surface, SwapchainCreationError, AcquireError, Capabilities};
|
||||
use vulkano::image::swapchain::SwapchainImage;
|
||||
use winit::{Window};
|
||||
use winit::Window;
|
||||
use crate::compu_state::CompuState;
|
||||
use vulkano::image::ImageUsage;
|
||||
use crate::compu_frame::CompuFrame;
|
||||
@@ -16,7 +17,6 @@ use crate::compu_kernel::{CompuKernel, CompuKernelHandle};
|
||||
use crate::compu_buffer::{CompuBuffers, CompuBufferHandle};
|
||||
|
||||
pub struct VkProcessor<'a> {
|
||||
|
||||
// Vulkan state fields
|
||||
pub instance: Arc<Instance>,
|
||||
pub physical: PhysicalDevice<'a>,
|
||||
@@ -38,7 +38,6 @@ pub struct VkProcessor<'a> {
|
||||
|
||||
|
||||
impl<'a> VkProcessor<'a> {
|
||||
|
||||
pub fn new(instance: &'a Arc<Instance>, surface: &'a Arc<Surface<Window>>) -> VkProcessor<'a> {
|
||||
let physical = PhysicalDevice::enumerate(instance).next().unwrap();
|
||||
|
||||
@@ -141,10 +140,7 @@ impl<'a> VkProcessor<'a> {
|
||||
self.compute_state.new_kernel(String::from("simple-homogenize.compute"), self.device.clone());
|
||||
self.compute_state.new_kernel(String::from("simple-edge.compute"), self.device.clone());
|
||||
}
|
||||
pub fn preload_shaders(&mut self) {
|
||||
|
||||
}
|
||||
|
||||
pub fn preload_shaders(&mut self) {}
|
||||
pub fn get_texture_handle(&self, texture_name: String) -> Option<Arc<CanvasTextureHandle>> {
|
||||
self.canvas.get_texture_handle(texture_name)
|
||||
}
|
||||
@@ -183,10 +179,11 @@ impl<'a> VkProcessor<'a> {
|
||||
compute_frame: CompuFrame,
|
||||
)
|
||||
-> Box<dyn GpuFuture> {
|
||||
{
|
||||
let g = hprof::enter("Waiting at queue");
|
||||
self.queue.wait();
|
||||
}
|
||||
|
||||
// take the canvas frame and create the vertex buffers
|
||||
// TODO: This performs gpu buffer creation. Shouldn't be in hotpath
|
||||
self.canvas.draw(canvas_frame);
|
||||
|
||||
let mut framebuffers =
|
||||
self.canvas.window_size_dependent_setup(&self.swapchain_images.clone().unwrap().clone());
|
||||
@@ -214,20 +211,33 @@ impl<'a> VkProcessor<'a> {
|
||||
Err(err) => panic!("{:?}", err)
|
||||
};
|
||||
|
||||
let future = frame_future.join(acquire_future);
|
||||
{
|
||||
let g = hprof::enter("Canvas creates GPU buffers");
|
||||
// take the canvas frame and create the vertex buffers
|
||||
// TODO: This performs gpu buffer creation. Shouldn't be in hotpath
|
||||
self.canvas.draw(canvas_frame);
|
||||
}
|
||||
|
||||
let mut command_buffer =
|
||||
AutoCommandBufferBuilder::primary_one_time_submit(self.device.clone(), self.queue.family()).unwrap();
|
||||
|
||||
let g = hprof::enter("Push compute commands to command buffer");
|
||||
// Add the compute commands
|
||||
let mut command_buffer = self.compute_state.compute_commands(compute_frame, command_buffer, &self.canvas);
|
||||
// let mut command_buffer = self.compute_state.compute_commands(compute_frame, command_buffer, &self.canvas);
|
||||
drop(g);
|
||||
|
||||
let g = hprof::enter("Push draw commands to command buffer");
|
||||
// Add the draw commands
|
||||
let mut command_buffer = self.canvas.draw_commands(command_buffer, framebuffers, image_num);
|
||||
// let mut command_buffer = self.canvas.draw_commands(command_buffer, framebuffers, image_num);
|
||||
drop(g);
|
||||
|
||||
// And build
|
||||
let command_buffer = command_buffer.build().unwrap();
|
||||
|
||||
// Wait on the previous frame, then execute the command buffer and present the image
|
||||
let future = frame_future.join(acquire_future)
|
||||
|
||||
let future = future //frame_future.join(acquire_future)
|
||||
.then_execute(self.queue.clone(), command_buffer).unwrap()
|
||||
.then_swapchain_present(self.queue.clone(), self.swapchain.clone().unwrap().clone(), image_num)
|
||||
.then_signal_fence_and_flush();
|
||||
|
||||
Reference in New Issue
Block a user