lets not consume the canvasframe

master
mitchellhansen 4 years ago
parent 0caa685b23
commit 0f760878da

@ -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<ColorVertex3D> = Vec::default();
let mut textured_vertex_buffer: HashMap<Arc<CanvasTextureHandle>, Vec<TextureVertex3D>> = HashMap::new();
@ -394,13 +394,13 @@ impl CanvasState {
let mut text_vertex_buffer: Vec<ColorVertex3D> = 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);

@ -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;

@ -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);
}
}
_ => ()

@ -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<Surface<Window>>,
canvas_frame: CanvasFrame,
compute_frame: CompuFrame,
canvas_frame: &CanvasFrame,
compute_frame: &CompuFrame,
) {
{
let g = hprof::enter("Waiting at queue");

Loading…
Cancel
Save