spirv_backend/support.rs: remove the re-export of DimensionedSlice
also add some docs
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
use spirv_std::RuntimeArray;
|
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::mat::Material;
|
||||||
use coremem_types::real::Real;
|
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 coremem_types::vec::{Vec3, Vec3u};
|
||||||
|
|
||||||
use crate::support::{DimensionedSlice, SizedArray};
|
use crate::support::SizedArray;
|
||||||
|
|
||||||
pub(crate) fn step_h<R: Real, M: Material<R>>(
|
pub(crate) fn step_h<R: Real, M: Material<R>>(
|
||||||
idx: Vec3u,
|
idx: Vec3u,
|
||||||
|
@@ -1,16 +1,19 @@
|
|||||||
use core::ops::{Index, IndexMut};
|
use core::ops::{Index, IndexMut};
|
||||||
|
|
||||||
// TODO: remove this re-export
|
|
||||||
pub use coremem_types::dim::DimensionedSlice;
|
|
||||||
|
|
||||||
use spirv_std::RuntimeArray;
|
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> {
|
pub struct SizedArray<T> {
|
||||||
items: T,
|
items: T,
|
||||||
len: usize,
|
len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> SizedArray<T> {
|
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 {
|
pub unsafe fn new(items: T, len: usize) -> Self {
|
||||||
Self { items, len }
|
Self { items, len }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user