pub struct MaterialStore { /* private fields */ }Expand description
Render-thread GPU storage for packed material bytes, one GrowableBuffer
per stride (materials whose packed size differs get separate buffers -
see ursus_materials::pack::aos::AosLayout, which this store mirrors
on the GPU side).
For V1, exactly one stride is expected to be in use at a time (mesh.frag
/ depth_prepass.frag / shadow.frag all declare a single
set = 1, binding = 0 MaterialBuffer), so descriptor_set binds the
first stride’s buffer to that slot. Supporting multiple simultaneous
strides on the GPU side (multiple bindings, or a technique-driven choice
of which to bind) is future work - see the architecture doc’s SoA/
multi-strategy discussion.
Implementations§
Source§impl MaterialStore
impl MaterialStore
pub fn new( device: Device, physical_device: PhysicalDevice, instance: Instance, descriptors: &mut DescriptorAllocator, ) -> Result<Self>
pub fn descriptor_set(&self) -> DescriptorSetId
Sourcepub fn upload(
&mut self,
handle: MaterialHandle,
bytes: &[u8],
descriptors: &DescriptorAllocator,
) -> Result<()>
pub fn upload( &mut self, handle: MaterialHandle, bytes: &[u8], descriptors: &DescriptorAllocator, ) -> Result<()>
Writes bytes (this material’s full packed data, bytes.len() is
its stride) for handle, growing/creating the stride’s buffer as
needed, re-uploading that stride’s whole bucket to the GPU, and - if
this is the first stride seen, or the bound stride’s buffer just
reallocated - (re)binding descriptor_set to point at it.
pub fn index_of(&self, handle: MaterialHandle) -> Option<(usize, usize)>
pub fn buffer_for_stride(&self, stride: usize) -> Option<Buffer>
pub fn strides(&self) -> impl Iterator<Item = usize> + '_
Auto Trait Implementations§
impl Freeze for MaterialStore
impl RefUnwindSafe for MaterialStore
impl Send for MaterialStore
impl Sync for MaterialStore
impl Unpin for MaterialStore
impl UnsafeUnpin for MaterialStore
impl UnwindSafe for MaterialStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more