     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 {
        // 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) {

            if let VertexTypes::ImageType(a, b) = sprite.get() {
                self.swapped_to_image.push((buffer, b, kernel))
            }

        }
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)