spirv_backend/support.rs: remove the re-export of DimensionedSlice

also add some docs
This commit is contained in:
2022-07-26 18:08:03 -07:00
parent dbd666d272
commit 00dcfb170a
2 changed files with 9 additions and 6 deletions

View File

@@ -1,12 +1,12 @@
use spirv_std::RuntimeArray;
use coremem_types::step::{StepEContext, StepHContext, VolumeSampleNeg, VolumeSamplePos};
use coremem_types::dim::DimensionedSlice;
use coremem_types::mat::Material;
use coremem_types::real::Real;
use coremem_types::step::SimMeta;
use coremem_types::step::{SimMeta, StepEContext, StepHContext, VolumeSampleNeg, VolumeSamplePos};
use coremem_types::vec::{Vec3, Vec3u};
use crate::support::{DimensionedSlice, SizedArray};
use crate::support::SizedArray;
pub(crate) fn step_h<R: Real, M: Material<R>>(
idx: Vec3u,

View File

@@ -1,16 +1,19 @@
use core::ops::{Index, IndexMut};
// TODO: remove this re-export
pub use coremem_types::dim::DimensionedSlice;
use spirv_std::RuntimeArray;
/// this is intended to wrap an unsized array with a length and provide safe indexing operations
/// into it. it behaves quite similar to a native rust slice, and ideally we'd just use that but
/// spirv support for slices is poor.
pub struct SizedArray<T> {
items: T,
len: usize,
}
impl<T> SizedArray<T> {
/// construct the slice from some other collection and the number of items in said collection.
/// safety: caller must validate that it's safe to index all `len` elements in the underlying
/// collection.
pub unsafe fn new(items: T, len: usize) -> Self {
Self { items, len }
}