HAC
Hardware Accelerated Computing API via the GPU, built on top of wgpu for achieving great portability.
Stability
This crate works pretty fine for various simple use-cases (see examples), but it exposes lots of wgpu functionality that hasn't been tested and may possibly not even work, use those features at your own risk.
TODO
- Figure out an elegant way to reuse wgpu's BindGroupLayouts
- Generalize the use case for swapping the same 2 images
- Improve the
CommandQueue - Explore and add more features for Images
Cargo features
from_image: allows the creation ofImages using the image crate (currently supports rgba8 only).
Example: Add arrays
use Rng;
// wgpu's default `max_workgroups_per_dimension`
// can be changed using `hac::Limits` on Context creation
const N: usize = 1 << 16 - 1;
const KERNEL_SOURCE: &'static str = r#"
struct ComputeInput {
// wgsl builtin variables can be found in the following link
// https://www.w3.org/TR/WGSL/#builtin-values
@builtin(global_invocation_id) id: vec3<u32>,
}
@group(0) @binding(0)
var<storage, read> a: array<f32>;
@group(0) @binding(1)
var<storage, read> b: array<f32>;
@group(0) @binding(2)
var<storage, read_write> c: array<f32>;
@compute @workgroup_size(1)
fn main(input: ComputeInput) {
let i = input.id.x;
c[i] = a[i] + b[i];
}"#;