gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
11.46k stars 855 forks source link

[naga] Introduce `HandleVec`. #5846

Closed jimblandy closed 1 week ago

jimblandy commented 1 week ago

Introduce a new type, HandleVec<T, U>, which is basically a Vec<U>, except that it's indexed by values of type Handle<T>. This gives us a more strictly typed way to build tables of data parallel to some other Arena.

Change naga::back::pipeline_constants to use HandleVec instead of Vec. This removes many calls to Handle::index, and makes the types more informative.

In naga::back::spv, change Writer and BlockContext to use HandleVec instead of Vec for various handle-indexed tables.