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
58
59
60
61
62
use std::sync::Arc;
use crate::canvas::managed::handles::{CanvasImageHandle};
use crate::compute::managed::handles::{CompuKernelHandle, CompuBufferHandle};
use crate::drawables::compu_sprite::CompuSprite;
use crate::canvas::canvas_frame::Drawable;
use crate::util::vertex::VertexTypes;
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) {
if let VertexTypes::ImageType(a, b) = sprite.get() {
self.swapped_to_image.push((buffer, b, kernel))
}
}
}