34 lines
20 KiB
HTML
34 lines
20 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Describes how an asset gets extracted and prepared for rendering."><title>RenderAsset in bevy_render::render_asset - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="bevy_render" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://bevyengine.org/assets/icon.png"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../bevy_render/index.html"><img src="https://bevyengine.org/assets/icon.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../bevy_render/index.html"><img src="https://bevyengine.org/assets/icon.png" alt="logo"></a><h2><a href="../../bevy_render/index.html">bevy_<wbr>render</a><span class="version">0.15.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Render<wbr>Asset</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Param" title="Param">Param</a></li><li><a href="#associatedtype.SourceAsset" title="SourceAsset">SourceAsset</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.prepare_asset" title="prepare_asset">prepare_asset</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.asset_usage" title="asset_usage">asset_usage</a></li><li><a href="#method.byte_len" title="byte_len">byte_len</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bevy_<wbr>render::<wbr>render_<wbr>asset</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">bevy_render</a>::<wbr><a href="index.html">render_asset</a></span><h1>Trait <span class="trait">RenderAsset</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/bevy_render/render_asset.rs.html#36-66">Source</a> </span></div><pre class="rust item-decl"><code>pub trait RenderAsset:
|
|
<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>
|
|
+ <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>
|
|
+ 'static
|
|
+ <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
|
|
type <a href="#associatedtype.SourceAsset" class="associatedtype">SourceAsset</a>: <a class="trait" href="../../bevy_asset/trait.Asset.html" title="trait bevy_asset::Asset">Asset</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>;
|
|
type <a href="#associatedtype.Param" class="associatedtype">Param</a>: <a class="trait" href="../../bevy_ecs/system/system_param/trait.SystemParam.html" title="trait bevy_ecs::system::system_param::SystemParam">SystemParam</a>;
|
|
|
|
// Required method
|
|
fn <a href="#tymethod.prepare_asset" class="fn">prepare_asset</a>(
|
|
source_asset: Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>,
|
|
param: &mut <a class="type" href="../../bevy_ecs/system/system_param/type.SystemParamItem.html" title="type bevy_ecs::system::system_param::SystemParamItem">SystemParamItem</a><'_, '_, Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.Param" title="type bevy_render::render_asset::RenderAsset::Param">Param</a>>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, <a class="enum" href="enum.PrepareAssetError.html" title="enum bevy_render::render_asset::PrepareAssetError">PrepareAssetError</a><Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>>>;
|
|
|
|
// Provided methods
|
|
fn <a href="#method.asset_usage" class="fn">asset_usage</a>(_source_asset: &Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>) -> <a class="struct" href="struct.RenderAssetUsages.html" title="struct bevy_render::render_asset::RenderAssetUsages">RenderAssetUsages</a> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.byte_len" class="fn">byte_len</a>(source_asset: &Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>> { ... }
|
|
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Describes how an asset gets extracted and prepared for rendering.</p>
|
|
<p>In the <a href="../struct.ExtractSchedule.html" title="struct bevy_render::ExtractSchedule"><code>ExtractSchedule</code></a> step the <a href="trait.RenderAsset.html#associatedtype.SourceAsset" title="associated type bevy_render::render_asset::RenderAsset::SourceAsset"><code>RenderAsset::SourceAsset</code></a> is transferred
|
|
from the “main world” into the “render world”.</p>
|
|
<p>After that in the <a href="../enum.RenderSet.html#variant.PrepareAssets" title="variant bevy_render::RenderSet::PrepareAssets"><code>RenderSet::PrepareAssets</code></a> step the extracted asset
|
|
is transformed into its GPU-representation of type <a href="trait.RenderAsset.html" title="trait bevy_render::render_asset::RenderAsset"><code>RenderAsset</code></a>.</p>
|
|
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.SourceAsset" class="method"><a class="src rightside" href="../../src/bevy_render/render_asset.rs.html#38">Source</a><h4 class="code-header">type <a href="#associatedtype.SourceAsset" class="associatedtype">SourceAsset</a>: <a class="trait" href="../../bevy_asset/trait.Asset.html" title="trait bevy_asset::Asset">Asset</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></h4></section></summary><div class="docblock"><p>The representation of the asset in the “main world”.</p>
|
|
</div></details><details class="toggle" open><summary><section id="associatedtype.Param" class="method"><a class="src rightside" href="../../src/bevy_render/render_asset.rs.html#43">Source</a><h4 class="code-header">type <a href="#associatedtype.Param" class="associatedtype">Param</a>: <a class="trait" href="../../bevy_ecs/system/system_param/trait.SystemParam.html" title="trait bevy_ecs::system::system_param::SystemParam">SystemParam</a></h4></section></summary><div class="docblock"><p>Specifies all ECS data required by <a href="trait.RenderAsset.html#tymethod.prepare_asset" title="associated function bevy_render::render_asset::RenderAsset::prepare_asset"><code>RenderAsset::prepare_asset</code></a>.</p>
|
|
<p>For convenience use the <a href="../../bevy_ecs/system/system_param/lifetimeless/index.html" title="mod bevy_ecs::system::system_param::lifetimeless"><code>lifetimeless</code></a> <a href="../../bevy_ecs/system/system_param/trait.SystemParam.html" title="trait bevy_ecs::system::system_param::SystemParam"><code>SystemParam</code></a>.</p>
|
|
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.prepare_asset" class="method"><a class="src rightside" href="../../src/bevy_render/render_asset.rs.html#62-65">Source</a><h4 class="code-header">fn <a href="#tymethod.prepare_asset" class="fn">prepare_asset</a>(
|
|
source_asset: Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>,
|
|
param: &mut <a class="type" href="../../bevy_ecs/system/system_param/type.SystemParamItem.html" title="type bevy_ecs::system::system_param::SystemParamItem">SystemParamItem</a><'_, '_, Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.Param" title="type bevy_render::render_asset::RenderAsset::Param">Param</a>>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, <a class="enum" href="enum.PrepareAssetError.html" title="enum bevy_render::render_asset::PrepareAssetError">PrepareAssetError</a><Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>>></h4></section></summary><div class="docblock"><p>Prepares the <a href="trait.RenderAsset.html#associatedtype.SourceAsset" title="associated type bevy_render::render_asset::RenderAsset::SourceAsset"><code>RenderAsset::SourceAsset</code></a> for the GPU by transforming it into a <a href="trait.RenderAsset.html" title="trait bevy_render::render_asset::RenderAsset"><code>RenderAsset</code></a>.</p>
|
|
<p>ECS data may be accessed via <code>param</code>.</p>
|
|
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.asset_usage" class="method"><a class="src rightside" href="../../src/bevy_render/render_asset.rs.html#47-49">Source</a><h4 class="code-header">fn <a href="#method.asset_usage" class="fn">asset_usage</a>(_source_asset: &Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>) -> <a class="struct" href="struct.RenderAssetUsages.html" title="struct bevy_render::render_asset::RenderAssetUsages">RenderAssetUsages</a></h4></section></summary><div class="docblock"><p>Whether or not to unload the asset after extracting it to the render world.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.byte_len" class="method"><a class="src rightside" href="../../src/bevy_render/render_asset.rs.html#55-57">Source</a><h4 class="code-header">fn <a href="#method.byte_len" class="fn">byte_len</a>(source_asset: &Self::<a class="associatedtype" href="trait.RenderAsset.html#associatedtype.SourceAsset" title="type bevy_render::render_asset::RenderAsset::SourceAsset">SourceAsset</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>></h4></section></summary><div class="docblock"><p>Size of the data the asset will upload to the gpu. Specifying a return value
|
|
will allow the asset to be throttled via <a href="struct.RenderAssetBytesPerFrame.html" title="struct bevy_render::render_asset::RenderAssetBytesPerFrame"><code>RenderAssetBytesPerFrame</code></a>.</p>
|
|
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.0/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-RenderAsset-for-RenderMesh" class="impl"><a class="src rightside" href="../../src/bevy_render/mesh/mod.rs.html#145-209">Source</a><a href="#impl-RenderAsset-for-RenderMesh" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.RenderAsset.html" title="trait bevy_render::render_asset::RenderAsset">RenderAsset</a> for <a class="struct" href="../mesh/struct.RenderMesh.html" title="struct bevy_render::mesh::RenderMesh">RenderMesh</a></h3></section></summary><div class="impl-items"><section id="associatedtype.SourceAsset-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/mesh/mod.rs.html#146">Source</a><a href="#associatedtype.SourceAsset-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.SourceAsset" class="associatedtype">SourceAsset</a> = <a class="struct" href="../mesh/struct.Mesh.html" title="struct bevy_render::mesh::Mesh">Mesh</a></h4></section><section id="associatedtype.Param-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/mesh/mod.rs.html#147-150">Source</a><a href="#associatedtype.Param-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Param" class="associatedtype">Param</a> = (<a class="struct" href="../../bevy_ecs/change_detection/struct.Res.html" title="struct bevy_ecs::change_detection::Res">Res</a><'static, <a class="struct" href="struct.RenderAssets.html" title="struct bevy_render::render_asset::RenderAssets">RenderAssets</a><<a class="struct" href="../texture/struct.GpuImage.html" title="struct bevy_render::texture::GpuImage">GpuImage</a>>>, <a class="struct" href="../../bevy_ecs/change_detection/struct.ResMut.html" title="struct bevy_ecs::change_detection::ResMut">ResMut</a><'static, <a class="struct" href="../mesh/struct.MeshVertexBufferLayouts.html" title="struct bevy_render::mesh::MeshVertexBufferLayouts">MeshVertexBufferLayouts</a>>)</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-RenderAsset-for-GpuShaderStorageBuffer" class="impl"><a class="src rightside" href="../../src/bevy_render/storage.rs.html#107-134">Source</a><a href="#impl-RenderAsset-for-GpuShaderStorageBuffer" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.RenderAsset.html" title="trait bevy_render::render_asset::RenderAsset">RenderAsset</a> for <a class="struct" href="../storage/struct.GpuShaderStorageBuffer.html" title="struct bevy_render::storage::GpuShaderStorageBuffer">GpuShaderStorageBuffer</a></h3></section></summary><div class="impl-items"><section id="associatedtype.SourceAsset-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/storage.rs.html#108">Source</a><a href="#associatedtype.SourceAsset-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.SourceAsset" class="associatedtype">SourceAsset</a> = <a class="struct" href="../storage/struct.ShaderStorageBuffer.html" title="struct bevy_render::storage::ShaderStorageBuffer">ShaderStorageBuffer</a></h4></section><section id="associatedtype.Param-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/storage.rs.html#109">Source</a><a href="#associatedtype.Param-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Param" class="associatedtype">Param</a> = <a class="struct" href="../../bevy_ecs/change_detection/struct.Res.html" title="struct bevy_ecs::change_detection::Res">Res</a><'static, <a class="struct" href="../renderer/struct.RenderDevice.html" title="struct bevy_render::renderer::RenderDevice">RenderDevice</a>></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-RenderAsset-for-GpuImage" class="impl"><a class="src rightside" href="../../src/bevy_render/texture/gpu_image.rs.html#23-78">Source</a><a href="#impl-RenderAsset-for-GpuImage" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.RenderAsset.html" title="trait bevy_render::render_asset::RenderAsset">RenderAsset</a> for <a class="struct" href="../texture/struct.GpuImage.html" title="struct bevy_render::texture::GpuImage">GpuImage</a></h3></section></summary><div class="impl-items"><section id="associatedtype.SourceAsset-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/texture/gpu_image.rs.html#24">Source</a><a href="#associatedtype.SourceAsset-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.SourceAsset" class="associatedtype">SourceAsset</a> = <a class="struct" href="../../bevy_image/image/struct.Image.html" title="struct bevy_image::image::Image">Image</a></h4></section><section id="associatedtype.Param-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/bevy_render/texture/gpu_image.rs.html#25-29">Source</a><a href="#associatedtype.Param-3" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Param" class="associatedtype">Param</a> = (<a class="struct" href="../../bevy_ecs/change_detection/struct.Res.html" title="struct bevy_ecs::change_detection::Res">Res</a><'static, <a class="struct" href="../renderer/struct.RenderDevice.html" title="struct bevy_render::renderer::RenderDevice">RenderDevice</a>>, <a class="struct" href="../../bevy_ecs/change_detection/struct.Res.html" title="struct bevy_ecs::change_detection::Res">Res</a><'static, <a class="struct" href="../renderer/struct.RenderQueue.html" title="struct bevy_render::renderer::RenderQueue">RenderQueue</a>>, <a class="struct" href="../../bevy_ecs/change_detection/struct.Res.html" title="struct bevy_ecs::change_detection::Res">Res</a><'static, <a class="struct" href="../render_resource/struct.DefaultImageSampler.html" title="struct bevy_render::render_resource::DefaultImageSampler">DefaultImageSampler</a>>)</h4></section></div></details></div><script src="../../trait.impl/bevy_render/render_asset/trait.RenderAsset.js" async></script></section></div></main></body></html> |