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
5 years ago
|
use crate::canvas::canvas_state::{CanvasImageHandle, Drawable};
|
||
5 years ago
|
use std::sync::Arc;
|
||
5 years ago
|
use crate::compute::compu_sprite::CompuSprite;
|
||
|
use crate::compute::compu_kernel::{CompuKernel, CompuKernelHandle};
|
||
|
use crate::compute::compu_buffer::{CompuBuffers, CompuBufferHandle};
|
||
5 years ago
|
|
||
|
pub struct CompuFrame {
|
||
|
// Vec<(Buffer, Kernel)>
|
||
5 years ago
|
pub pure_compute: Vec<(
|
||
5 years ago
|
Arc<CompuBufferHandle>,
|
||
|
Arc<CompuKernelHandle>)>,
|
||
|
|
||
|
// Vec<(Buffer, Image, Kernel)>
|
||
5 years ago
|
pub swapped_to_image: Vec<(
|
||
5 years ago
|
Arc<CompuBufferHandle>,
|
||
5 years ago
|
Arc<CanvasImageHandle>,
|
||
5 years ago
|
Arc<CompuKernelHandle>)>,
|
||
|
|
||
|
// Vec<(Input Buffer, Output Buffer, Kernel)>
|
||
5 years ago
|
pub swapped_to_buffer: Vec<(
|
||
5 years ago
|
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));
|
||
|
}
|
||
|
|
||
|
/*
|
||
5 years ago
|
INPUT_BUFFER -> input -> kernel -> output
|
||
5 years ago
|
v------------------^
|
||
5 years ago
|
OUTPUT_BUFFER -> input X kernel X output
|
||
5 years ago
|
*/
|
||
|
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) {
|
||
5 years ago
|
self.swapped_to_image.push((buffer, sprite.get_image_handle().unwrap().clone(), kernel))
|
||
5 years ago
|
}
|
||
|
}
|