use crate::canvas::canvas_state::{CanvasImageHandle, Drawable}; use std::sync::Arc; use crate::compute::compu_sprite::CompuSprite; use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle}; use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle}; pub struct CompuFrame { // Vec<(Buffer, Kernel)> pub pure_compute: Vec<( Arc, Arc)>, // Vec<(Buffer, Image, Kernel)> pub swapped_to_image: Vec<( Arc, Arc, Arc)>, // Vec<(Input Buffer, Output Buffer, Kernel)> pub swapped_to_buffer: Vec<( Arc, Arc, Arc)>, } impl CompuFrame { pub fn new() -> CompuFrame { CompuFrame { pure_compute: vec![], swapped_to_image: vec![], swapped_to_buffer: vec![], } } pub fn add(&mut self, buffer: Arc, kernel: Arc) { self.pure_compute.push((buffer, kernel)); } /* INPUT_BUFFER -> input -> kernel -> output v------------------^ OUTPUT_BUFFER -> input X kernel X output */ pub fn add_chained(&mut self, input_buffer: Arc, output_buffer: Arc, kernel: Arc) { self.swapped_to_buffer.push((input_buffer, output_buffer, kernel)); } pub fn add_with_image_swap(&mut self, buffer: Arc, kernel: Arc, sprite: &CompuSprite) { self.swapped_to_image.push((buffer, sprite.get_image_handle().unwrap().clone(), kernel)) } }