Trait bevy::render::render_asset::RenderAsset

pub trait RenderAsset: Sized + Send + Sync + 'static {
    type SourceAsset: Asset + Clone;
    type Param: SystemParam;

    // Required method
    fn prepare_asset(
        source_asset: Self::SourceAsset,
        param: &mut <Self::Param as SystemParam>::Item<'_, '_>
    ) -> Result<Self, PrepareAssetError<Self::SourceAsset>>;

    // Provided methods
    fn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages { ... }
    fn byte_len(source_asset: &Self::SourceAsset) -> Option<usize> { ... }
}
Expand description

Describes how an asset gets extracted and prepared for rendering.

In the ExtractSchedule step the RenderAsset::SourceAsset is transferred from the “main world” into the “render world”.

After that in the RenderSet::PrepareAssets step the extracted asset is transformed into its GPU-representation of type RenderAsset.

Required Associated Types§

type SourceAsset: Asset + Clone

The representation of the asset in the “main world”.

type Param: SystemParam

Specifies all ECS data required by RenderAsset::prepare_asset.

For convenience use the lifetimeless SystemParam.

Required Methods§

fn prepare_asset( source_asset: Self::SourceAsset, param: &mut <Self::Param as SystemParam>::Item<'_, '_> ) -> Result<Self, PrepareAssetError<Self::SourceAsset>>

Prepares the RenderAsset::SourceAsset for the GPU by transforming it into a RenderAsset.

ECS data may be accessed via param.

Provided Methods§

fn asset_usage(_source_asset: &Self::SourceAsset) -> RenderAssetUsages

Whether or not to unload the asset after extracting it to the render world.

fn byte_len(source_asset: &Self::SourceAsset) -> Option<usize>

Size of the data the asset will upload to the gpu. Specifying a return value will allow the asset to be throttled via RenderAssetBytesPerFrame.

Object Safety§

This trait is not object safe.

Implementors§

§

impl RenderAsset for GpuMesh

§

impl RenderAsset for GpuImage

§

type SourceAsset = Image

§

type Param = (Res<'static, RenderDevice>, Res<'static, RenderQueue>, Res<'static, DefaultImageSampler>)

§

impl<M> RenderAsset for PreparedMaterial<M>
where M: Material,

§

type SourceAsset = M

§

type Param = (Res<'static, RenderDevice>, Res<'static, RenderAssets<GpuImage>>, Res<'static, FallbackImage>, Res<'static, MaterialPipeline<M>>, Res<'static, DefaultOpaqueRendererMethod>, Res<'static, Msaa>)

§

impl<M> RenderAsset for PreparedMaterial2d<M>
where M: Material2d,

§

type SourceAsset = M

§

type Param = (Res<'static, RenderDevice>, Res<'static, RenderAssets<GpuImage>>, Res<'static, FallbackImage>, Res<'static, Material2dPipeline<M>>)

§

impl<M> RenderAsset for PreparedUiMaterial<M>
where M: UiMaterial,

§

type SourceAsset = M

§

type Param = (Res<'static, RenderDevice>, Res<'static, RenderAssets<GpuImage>>, Res<'static, FallbackImage>, Res<'static, UiMaterialPipeline<M>>)