cleaned loop. Compiles. Refactoring Canvas next

master
mitchellhansen 5 years ago
parent 66d11e22c0
commit 878b37c3e0

@ -50,10 +50,10 @@ impl CompuSprite {
CompuSprite { CompuSprite {
vertices: [ vertices: [
(position.0, position.1), // top left (position.0, position.1), // top left
(position.0, position.1 + fsize.1), // bottom left (position.0, position.1 + fsize.1), // bottom left
(position.0 + fsize.0, position.1 + fsize.1), // bottom right (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 + fsize.1), // bottom right
(position.0 + fsize.0, position.1), // top right (position.0 + fsize.0, position.1), // top right
], ],
@ -215,15 +215,6 @@ impl CompuState {
mut command_buffer: AutoCommandBufferBuilder, mut command_buffer: AutoCommandBufferBuilder,
canvas: &Canvas) canvas: &Canvas)
-> AutoCommandBufferBuilder { -> 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) // i = (Buffer, Kernel)
for i in compute_frame.pure_compute { for i in compute_frame.pure_compute {
@ -260,17 +251,24 @@ impl CompuState {
// i = (Input Buffer, Output Buffer, Kernel) // i = (Input Buffer, Output Buffer, Kernel)
// Input buffer -> Kernel -> Output buffer
for i in compute_frame.swapped_to_buffer { for i in compute_frame.swapped_to_buffer {
let buffer_id = (*i.0).clone() as usize; let input_buffer_id = (*i.0).clone() as usize;
let kernel_id = (*i.1).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 input_buffer = self.compute_buffers.get(input_buffer_id).unwrap();
let kernel = self.kernels.get(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 pipeline = kernel.clone().get_pipeline();
let d = buffer.get_descriptor_set(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 command_buffer

@ -213,25 +213,16 @@ impl<'a> VkProcessor<'a> {
Err(err) => panic!("{:?}", err) Err(err) => panic!("{:?}", err)
}; };
let xy = self.compute_image.clone().unwrap().get_size();
let mut command_buffer = let mut command_buffer =
AutoCommandBufferBuilder::primary_one_time_submit(self.device.clone(), self.queue.family()) AutoCommandBufferBuilder::primary_one_time_submit(self.device.clone(), self.queue.family()).unwrap();
.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();
// ditto with the compuframe // 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);
// 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);
// And build
let command_buffer = command_buffer.build().unwrap(); let command_buffer = command_buffer.build().unwrap();
// Wait on the previous frame, then execute the command buffer and present the image // Wait on the previous frame, then execute the command buffer and present the image

Loading…
Cancel
Save