diff --git a/src/canvas/canvas_state.rs b/src/canvas/canvas_state.rs index 046b14ae..3c28c5a9 100644 --- a/src/canvas/canvas_state.rs +++ b/src/canvas/canvas_state.rs @@ -385,7 +385,7 @@ impl CanvasState { } /// Consume and allocate the canvas frame data to the GPU - pub fn allocate(&mut self, canvas_frame: CanvasFrame) -> CanvasFrameAllocation { + pub fn allocate(&mut self, canvas_frame: &CanvasFrame) -> CanvasFrameAllocation { let mut colored_vertex_buffer: Vec = Vec::default(); let mut textured_vertex_buffer: HashMap, Vec> = HashMap::new(); @@ -394,13 +394,13 @@ impl CanvasState { let mut text_vertex_buffer: Vec = Vec::new(); // separate the mux of vertex containers back out - for value in canvas_frame.map { + for value in &canvas_frame.map { match value { VertexType::TextureType(vertices, handle) => { - textured_vertex_buffer.entry(handle).or_insert(vertices.clone()).extend(vertices); + textured_vertex_buffer.entry(handle.clone()).or_insert(vertices.clone()).extend(vertices); } VertexType::ImageType(vertices, handle) => { - image_vertex_buffer.entry(handle).or_insert(vertices.clone()).extend(vertices); + image_vertex_buffer.entry(handle.clone()).or_insert(vertices.clone()).extend(vertices); } VertexType::ColorType(vertices) => { colored_vertex_buffer.extend(vertices); diff --git a/src/compute/compu_state.rs b/src/compute/compu_state.rs index b84b6c18..cbeeea9c 100644 --- a/src/compute/compu_state.rs +++ b/src/compute/compu_state.rs @@ -90,12 +90,12 @@ impl CompuState { } pub fn compute_commands(&mut self, - compute_frame: CompuFrame, + compute_frame: &CompuFrame, mut command_buffer: &mut AutoCommandBufferBuilder, canvas: &CanvasState) { // i = (Buffer, Kernel) - for i in compute_frame.pure_compute { + for i in &compute_frame.pure_compute { let buffer_id = (*i.0).clone().get_handle() as usize; let kernel_id = (*i.1).clone().get_handle() as usize; @@ -112,7 +112,7 @@ impl CompuState { } // i = (Buffer, Image, Kernel) - for i in compute_frame.swapped_to_image { + for i in &compute_frame.swapped_to_image { let buffer_id = (*i.0).clone().get_handle() as usize; let image_id = i.1.clone(); let kernel_id = (*i.2).clone().handle as usize; @@ -140,7 +140,7 @@ impl CompuState { // 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 input_buffer_id = (*i.0).clone().get_handle() as usize; let output_buffer_id = (*i.1).clone().get_handle() as usize; let kernel_id = (*i.2).clone().handle as usize; diff --git a/src/main.rs b/src/main.rs index 3150b2b7..de72609a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -235,7 +235,8 @@ pub fn main() { } }); - let mut event_stack = Vec::new(); + + let mut canvas_frame = CanvasFrame::default(); // Events loop is borrowed from the surface events_loop.run(move |event, _, control_flow| { @@ -255,14 +256,13 @@ pub fn main() { device_id, state, button, modifiers }, .. } => { - event_stack.push(event.clone()); + } Event::UserEvent(TrEvent::KeyHeldEvent {}) => {} Event::UserEvent(TrEvent::MouseHeldEvent {}) => {} Event::UserEvent(TrEvent::GamepadEvent { gil_event }) => {} Event::DeviceEvent { event: DeviceEvent::Key(keyboard_input), .. } => { - event_stack.push(event); match keyboard_input.virtual_keycode.unwrap() { VirtualKeyCode::A => { @@ -299,7 +299,7 @@ pub fn main() { // accumulator_time -= step_size; // } - let mut canvas_frame = CanvasFrame::default(); + canvas_frame.draw(&funky_sprite); canvas_frame.draw(&compu_sprite1); canvas_frame.draw(&slider); @@ -311,8 +311,8 @@ pub fn main() { { let g = hprof::enter("Run"); processor.run(&surface.clone(), - canvas_frame, - compu_frame); + &canvas_frame, + &compu_frame); } } _ => () diff --git a/src/vkprocessor.rs b/src/vkprocessor.rs index b2f64176..9e7aac68 100644 --- a/src/vkprocessor.rs +++ b/src/vkprocessor.rs @@ -231,8 +231,8 @@ impl VkProcessor { /// Run the VKprocessor for a single frame, consuming the Canvas/Compu Frames pub fn run(&mut self, surface: &Arc>, - canvas_frame: CanvasFrame, - compute_frame: CompuFrame, + canvas_frame: &CanvasFrame, + compute_frame: &CompuFrame, ) { { let g = hprof::enter("Waiting at queue");