vyre-wgpu 0.1.0

wgpu backend for vyre IR — implements VyreBackend, owns GPU runtime, buffer pool, pipeline cache
Documentation
//! Doc.

use vyre::error::{Error, Result};

#[repr(C)]
#[derive(Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
pub(crate) struct DfaParams {
    pub(super) input_len: u32,
    pub(super) state_count: u32,
    pub(super) max_matches: u32,
    pub(super) _pad: u32,
}

pub(crate) fn checked_input_len(input: &[u8]) -> Result<u32> {
    u32::try_from(input.len()).map_err(|source| Error::Dfa {
        message: format!(
            "DFA input length {} exceeds u32::MAX: {source}. Fix: scan chunks smaller than 4 GiB.",
            input.len()
        ),
    })
}

pub(crate) fn dispatch_groups(input_len: u32) -> u32 {
    if input_len == 0 {
        0
    } else {
        1
    }
}