[−][src]Macro em::get_buffer_key
A macro for getting key to access a Buffer
in the buffers
field of a Gpu
.
Given a value data
, you can get the *const [f32]
index with get_buffer_key!(data)
.
Note that data
must have an as_slice()
method defined for its type. As an example data
could be of type Vec
.
This should really only be used if you want to drop down to low-level OpenCL for maximum performance gain.
Here's a quick example.
#[gpu_use] // this inserts a "let gpu = Gpu { ... };" at the start of the main function fn main() { let data = vec![0.0; 1000]; gpu_do!(load(data)); let buffer: &ocl::Buffer<f32> = gpu.buffers.get(&get_buffer_key!(data)).unwrap(); // do something with buffer... }