vyre-conform 0.1.0

Conformance suite for vyre backends — proves byte-identical output to CPU reference
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Byte-to-word padding utilities for GPU buffer upload.
//!
//! wgpu buffer uploads are most naturally expressed in `u32` words. This module
//! pads arbitrary byte slices to little-endian words so the backend can create
//! storage buffers without per-byte CPU overhead.

/// Pad bytes to u32 words (little-endian, zero-padded).
pub(super) fn pad_to_words(bytes: &[u8]) -> Vec<u32> {
    let mut words = vec![0u32; bytes.len().div_ceil(4).max(1)];
    for (i, &byte) in bytes.iter().enumerate() {
        words[i / 4] |= u32::from(byte) << ((i % 4) * 8);
    }
    words
}