From 878b37c3e023e2f312ca55a229ed5b3506f2f0d5 Mon Sep 17 00:00:00 2001 From: mitchellhansen Date: Wed, 28 Aug 2019 23:17:04 -0700 Subject: [PATCH] cleaned loop. Compiles. Refactoring Canvas next --- src/compu_wip.rs | 34 ++++++++++++++++------------------ src/vkprocessor.rs | 17 ++++------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/compu_wip.rs b/src/compu_wip.rs index 08cded7c..5c3db7e9 100644 --- a/src/compu_wip.rs +++ b/src/compu_wip.rs @@ -50,10 +50,10 @@ impl CompuSprite { CompuSprite { vertices: [ - (position.0, position.1), // top left + (position.0, position.1), // top left (position.0, position.1 + fsize.1), // bottom left (position.0 + fsize.0, position.1 + fsize.1), // bottom right - (position.0, position.1), // top left + (position.0, position.1), // top left (position.0 + fsize.0, position.1 + fsize.1), // bottom right (position.0 + fsize.0, position.1), // top right ], @@ -215,15 +215,6 @@ impl CompuState { mut command_buffer: AutoCommandBufferBuilder, canvas: &Canvas) -> AutoCommandBufferBuilder { -/* - let mut command_buffer,, = command_buffer.dispatch([100, 100, 1], - self.compute_kernel.clone().unwrap().clone().get_pipeline(), - self.compute_image.clone().unwrap().clone() - .get_descriptor_set(self.compute_kernel.clone().unwrap().clone().get_pipeline()).clone(), ()).unwrap() - - .copy_buffer_to_image(self.compute_image.clone().unwrap().clone().rw_buffers.get(0).unwrap().clone(), - self.compute_image.clone().unwrap().clone().get_swap_buffer().clone()).unwrap(); -*/ // i = (Buffer, Kernel) for i in compute_frame.pure_compute { @@ -260,17 +251,24 @@ impl CompuState { // i = (Input Buffer, Output Buffer, Kernel) + // Input buffer -> Kernel -> Output buffer for i in compute_frame.swapped_to_buffer { - let buffer_id = (*i.0).clone() as usize; - let kernel_id = (*i.1).clone() as usize; + let input_buffer_id = (*i.0).clone() as usize; + let output_buffer_id = (*i.1).clone() as usize; + let kernel_id = (*i.2).clone() as usize; - let buffer = self.compute_buffers.get(buffer_id).unwrap(); - let kernel = self.kernels.get(buffer_id).unwrap(); + let input_buffer = self.compute_buffers.get(input_buffer_id).unwrap(); + let output_buffer = self.compute_buffers.get(output_buffer_id).unwrap(); + let kernel = self.kernels.get(kernel_id).unwrap(); - let p = kernel.clone().get_pipeline(); - let d = buffer.get_descriptor_set(kernel.clone().get_pipeline()); + let pipeline = kernel.clone().get_pipeline(); + let descriptor_set = input_buffer.get_descriptor_set(kernel.clone().get_pipeline()); - command_buffer = command_buffer.dispatch([100,100,1], p, d, ()).unwrap() + command_buffer = command_buffer + .dispatch([100,100,1], pipeline, descriptor_set, ()).unwrap() + .copy_buffer( + input_buffer.io_buffers.get(1).unwrap().clone(), + output_buffer.io_buffers.get(0).unwrap().clone()).unwrap(); } command_buffer diff --git a/src/vkprocessor.rs b/src/vkprocessor.rs index 03477371..3fc5c35b 100644 --- a/src/vkprocessor.rs +++ b/src/vkprocessor.rs @@ -213,25 +213,16 @@ impl<'a> VkProcessor<'a> { Err(err) => panic!("{:?}", err) }; - let xy = self.compute_image.clone().unwrap().get_size(); - let mut command_buffer = - AutoCommandBufferBuilder::primary_one_time_submit(self.device.clone(), self.queue.family()) - .unwrap() - - .dispatch([xy.0, xy.1, 1], - self.compute_kernel.clone().unwrap().clone().get_pipeline(), - self.compute_image.clone().unwrap().clone() - .get_descriptor_set(self.compute_kernel.clone().unwrap().clone().get_pipeline()).clone(), ()).unwrap() - - .copy_buffer_to_image(self.compute_image.clone().unwrap().clone().rw_buffers.get(0).unwrap().clone(), - self.compute_image.clone().unwrap().clone().get_swap_buffer().clone()).unwrap(); + AutoCommandBufferBuilder::primary_one_time_submit(self.device.clone(), self.queue.family()).unwrap(); - // ditto with the compuframe + // Add the compute commands let mut command_buffer = self.compute_state.compute_commands(compute_frame, command_buffer, &self.canvas); + // Add the draw commands let mut command_buffer = self.canvas.draw_commands(command_buffer, framebuffers, image_num); + // And build let command_buffer = command_buffer.build().unwrap(); // Wait on the previous frame, then execute the command buffer and present the image