1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::canvas::{CanvasImageHandle, Drawable};
use std::sync::Arc;
use crate::compu_sprite::CompuSprite;
use crate::compu_kernel::{CompuKernel, CompuKernelHandle};
use crate::compu_buffer::{CompuBuffers, CompuBufferHandle};
pub struct CompuFrame {
pub pure_compute: Vec<(
Arc<CompuBufferHandle>,
Arc<CompuKernelHandle>)>,
pub swapped_to_image: Vec<(
Arc<CompuBufferHandle>,
Arc<CanvasImageHandle>,
Arc<CompuKernelHandle>)>,
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));
}
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))
}
}