pub struct RenderAssets { /* private fields */ }Expand description
GPU 资产存储
管理所有已上传到 GPU 的网格、材质和渲染管线资源。
Implementations§
Source§impl RenderAssets
impl RenderAssets
Sourcepub fn upload_mesh<V: Vertex>(
&mut self,
device: &RenderDevice,
vertices: &[V],
indices: &[u16],
label: &str,
) -> MeshHandle
pub fn upload_mesh<V: Vertex>( &mut self, device: &RenderDevice, vertices: &[V], indices: &[u16], label: &str, ) -> MeshHandle
上传网格到 GPU 并返回句柄
Sourcepub fn upload_mesh_u32<V: Vertex>(
&mut self,
device: &RenderDevice,
vertices: &[V],
indices: &[u32],
label: &str,
) -> MeshHandle
pub fn upload_mesh_u32<V: Vertex>( &mut self, device: &RenderDevice, vertices: &[V], indices: &[u32], label: &str, ) -> MeshHandle
上传网格到 GPU(u32 索引)并返回句柄
Sourcepub fn register_pipeline(&mut self, pipeline: RenderPipeline) -> PipelineHandle
pub fn register_pipeline(&mut self, pipeline: RenderPipeline) -> PipelineHandle
注册渲染管线并返回句柄
注册后的管线可被多个材质共享引用。
Sourcepub fn create_material_with_pipeline(
&mut self,
pipeline_handle: PipelineHandle,
bind_group: BindGroup,
) -> MaterialHandle
pub fn create_material_with_pipeline( &mut self, pipeline_handle: PipelineHandle, bind_group: BindGroup, ) -> MaterialHandle
Sourcepub fn create_material(
&mut self,
pipeline: RenderPipeline,
bind_group: BindGroup,
) -> MaterialHandle
pub fn create_material( &mut self, pipeline: RenderPipeline, bind_group: BindGroup, ) -> MaterialHandle
创建材质并返回句柄(向后兼容 API)
内部自动注册管线并创建材质。适用于不需要管线共享的场景。
Sourcepub fn get_mesh(&self, handle: &MeshHandle) -> Option<&GpuMesh>
pub fn get_mesh(&self, handle: &MeshHandle) -> Option<&GpuMesh>
获取 GPU 网格
Sourcepub fn get_material(&self, handle: &MaterialHandle) -> Option<&GpuMaterial>
pub fn get_material(&self, handle: &MaterialHandle) -> Option<&GpuMaterial>
获取 GPU 材质
Sourcepub fn get_pipeline(&self, handle: &PipelineHandle) -> Option<&RenderPipeline>
pub fn get_pipeline(&self, handle: &PipelineHandle) -> Option<&RenderPipeline>
获取渲染管线
Sourcepub fn remove_mesh(&mut self, handle: &MeshHandle) -> bool
pub fn remove_mesh(&mut self, handle: &MeshHandle) -> bool
移除 GPU 网格资源,释放顶点和索引缓冲区
Sourcepub fn remove_material(&mut self, handle: &MaterialHandle) -> bool
pub fn remove_material(&mut self, handle: &MaterialHandle) -> bool
移除 GPU 材质资源,释放绑定组
Sourcepub fn remove_pipeline(&mut self, handle: &PipelineHandle) -> bool
pub fn remove_pipeline(&mut self, handle: &PipelineHandle) -> bool
移除渲染管线
注意:如果仍有材质引用此管线,那些材质的渲染将失败。 调用者应确保先移除所有引用此管线的材质。
Sourcepub fn mesh_count(&self) -> usize
pub fn mesh_count(&self) -> usize
已注册的网格数量
Sourcepub fn material_count(&self) -> usize
pub fn material_count(&self) -> usize
已注册的材质数量
Sourcepub fn pipeline_count(&self) -> usize
pub fn pipeline_count(&self) -> usize
已注册的管线数量
Trait Implementations§
Source§impl Default for RenderAssets
impl Default for RenderAssets
Source§fn default() -> RenderAssets
fn default() -> RenderAssets
Returns the “default value” for a type. Read more
impl Resource for RenderAssets
Auto Trait Implementations§
impl Freeze for RenderAssets
impl !RefUnwindSafe for RenderAssets
impl Send for RenderAssets
impl Sync for RenderAssets
impl Unpin for RenderAssets
impl UnsafeUnpin for RenderAssets
impl !UnwindSafe for RenderAssets
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self using data from the given World.