You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.9 KiB
57 lines
1.9 KiB
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<CompuBufferHandle>,
|
|
Arc<CompuKernelHandle>)>,
|
|
|
|
// Vec<(Buffer, Image, Kernel)>
|
|
pub swapped_to_image: Vec<(
|
|
Arc<CompuBufferHandle>,
|
|
Arc<CanvasImageHandle>,
|
|
Arc<CompuKernelHandle>)>,
|
|
|
|
// Vec<(Input Buffer, Output Buffer, Kernel)>
|
|
pub swapped_to_buffer: Vec<(
|
|
Arc<CompuBufferHandle>,
|
|
Arc<CompuBufferHandle>,
|
|
Arc<CompuKernelHandle>)>,
|
|
}
|
|
|
|
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<CompuBufferHandle>, kernel: Arc<CompuKernelHandle>) {
|
|
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<CompuBufferHandle>,
|
|
output_buffer: Arc<CompuBufferHandle>,
|
|
kernel: Arc<CompuKernelHandle>) {
|
|
self.swapped_to_buffer.push((input_buffer, output_buffer, kernel));
|
|
}
|
|
|
|
pub fn add_with_image_swap(&mut self,
|
|
buffer: Arc<CompuBufferHandle>,
|
|
kernel: Arc<CompuKernelHandle>,
|
|
sprite: &CompuSprite) {
|
|
self.swapped_to_image.push((buffer, sprite.get_image_handle().unwrap().clone(), kernel))
|
|
}
|
|
} |