gpu-handle-types 0.1.0

Typed, owned native GPU resource handles (Vulkan, D3D11/12, Metal, OpenGL, CUDA, OpenCL, DMA-BUF, IOSurface, AHardwareBuffer, WebGPU, ...), cross-API sync points and video pixel formats, for passing GPU resources between libraries.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// SPDX-License-Identifier: MIT OR Apache-2.0

use gpu_handle_types::GpuResource;

/// Regression guard — `GpuResource` must stay stack-only. If a future
/// variant accidentally embeds a `Vec` / `Box` the size jumps past any
/// reasonable cap and this test fails.
#[test]
fn gpu_resource_size_is_bounded() {
    let sz = std::mem::size_of::<GpuResource>();
    // The largest variants are the Vulkan opaque-export carriers (~150
    // bytes with their acquire-sync side channels) and
    // `CpuPlanes(CpuPlaneSet)`, whose fixed-arity `[Option<CpuPlane>; 4]`
    // is ~128 bytes. Anything up to 160 is within this crate's design
    // budget; this guard still catches accidental `Vec<u8>` additions.
    assert!(sz <= 160, "GpuResource is {sz} bytes — did a heap-carrying variant sneak in?");
}