Files
phy/bevy_render/render_phase/index.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

41 lines
17 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="The modular rendering abstraction responsible for queuing, preparing, sorting and drawing entities as part of separate render phases."><title>bevy_render::render_phase - 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 mod"><!--[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="#">Module render_<wbr>phase</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate bevy_<wbr>render</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></span><h1>Module <span>render_phase</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_phase/mod.rs.html#1-1126">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The modular rendering abstraction responsible for queuing, preparing, sorting and drawing
entities as part of separate render phases.</p>
<p>In Bevy each view (camera, or shadow-casting light, etc.) has one or multiple render phases
(e.g. opaque, transparent, shadow, etc).
They are used to queue entities for rendering.
Multiple phases might be required due to different sorting/batching behaviors
(e.g. opaque: front to back, transparent: back to front) or because one phase depends on
the rendered texture of the previous phase (e.g. for screen-space reflections).</p>
<p>To draw an entity, a corresponding <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a> has to be added to one or multiple of these
render phases for each view that it is visible in.
This must be done in the <a href="../enum.RenderSet.html#variant.Queue" title="variant bevy_render::RenderSet::Queue"><code>RenderSet::Queue</code></a>.
After that the render phase sorts them in the <a href="../enum.RenderSet.html#variant.PhaseSort" title="variant bevy_render::RenderSet::PhaseSort"><code>RenderSet::PhaseSort</code></a>.
Finally the items are rendered using a single <a href="struct.TrackedRenderPass.html" title="struct bevy_render::render_phase::TrackedRenderPass"><code>TrackedRenderPass</code></a>, during
the <a href="../enum.RenderSet.html#variant.Render" title="variant bevy_render::RenderSet::Render"><code>RenderSet::Render</code></a>.</p>
<p>Therefore each phase item is assigned a <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function.
These set up the state of the <a href="struct.TrackedRenderPass.html" title="struct bevy_render::render_phase::TrackedRenderPass"><code>TrackedRenderPass</code></a> (i.e. select the
<a href="../render_resource/struct.RenderPipeline.html" title="struct bevy_render::render_resource::RenderPipeline"><code>RenderPipeline</code></a>, configure the
<a href="../render_resource/struct.BindGroup.html" title="struct bevy_render::render_resource::BindGroup"><code>BindGroup</code></a>s, etc.) and then issue a draw call,
for the corresponding item.</p>
<p>The <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function trait can either be implemented directly or such a function can be
created by composing multiple <a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a>s.</p>
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.BinnedRenderPhase.html" title="struct bevy_render::render_phase::BinnedRenderPhase">Binned<wbr>Render<wbr>Phase</a></div><div class="desc docblock-short">A collection of all rendering instructions, that will be executed by the GPU, for a
single render phase for a single view.</div></li><li><div class="item-name"><a class="struct" href="struct.BinnedRenderPhaseBatch.html" title="struct bevy_render::render_phase::BinnedRenderPhaseBatch">Binned<wbr>Render<wbr>Phase<wbr>Batch</a></div><div class="desc docblock-short">Information about a single batch of entities rendered using binned phase
items.</div></li><li><div class="item-name"><a class="struct" href="struct.BinnedRenderPhasePlugin.html" title="struct bevy_render::render_phase::BinnedRenderPhasePlugin">Binned<wbr>Render<wbr>Phase<wbr>Plugin</a></div><div class="desc docblock-short">A convenient abstraction for adding all the systems necessary for a binned
render phase to the render app.</div></li><li><div class="item-name"><a class="struct" href="struct.DrawFunctionId.html" title="struct bevy_render::render_phase::DrawFunctionId">Draw<wbr>Function<wbr>Id</a></div><div class="desc docblock-short">An identifier for a <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function stored in <a href="struct.DrawFunctions.html" title="struct bevy_render::render_phase::DrawFunctions"><code>DrawFunctions</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.DrawFunctions.html" title="struct bevy_render::render_phase::DrawFunctions">Draw<wbr>Functions</a></div><div class="desc docblock-short">Stores all draw functions for the <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a> type hidden behind a reader-writer lock.</div></li><li><div class="item-name"><a class="struct" href="struct.DrawFunctionsInternal.html" title="struct bevy_render::render_phase::DrawFunctionsInternal">Draw<wbr>Functions<wbr>Internal</a></div><div class="desc docblock-short">Stores all <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> functions for the <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a> type.</div></li><li><div class="item-name"><a class="struct" href="struct.PhaseItemExtraIndex.html" title="struct bevy_render::render_phase::PhaseItemExtraIndex">Phase<wbr>Item<wbr>Extra<wbr>Index</a></div><div class="desc docblock-short">The “extra index” associated with some <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a>s, alongside the
indirect instance index.</div></li><li><div class="item-name"><a class="struct" href="struct.RenderCommandState.html" title="struct bevy_render::render_phase::RenderCommandState">Render<wbr>Command<wbr>State</a></div><div class="desc docblock-short">Wraps a <a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a> into a state so that it can be used as a <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function.</div></li><li><div class="item-name"><a class="struct" href="struct.SetItemPipeline.html" title="struct bevy_render::render_phase::SetItemPipeline">SetItem<wbr>Pipeline</a></div><div class="desc docblock-short">A <a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a> that sets the pipeline for the <a href="trait.CachedRenderPipelinePhaseItem.html" title="trait bevy_render::render_phase::CachedRenderPipelinePhaseItem"><code>CachedRenderPipelinePhaseItem</code></a>.</div></li><li><div class="item-name"><a class="struct" href="struct.SortedRenderPhase.html" title="struct bevy_render::render_phase::SortedRenderPhase">Sorted<wbr>Render<wbr>Phase</a></div><div class="desc docblock-short">A collection of all items to be rendered that will be encoded to GPU
commands for a single render phase for a single view.</div></li><li><div class="item-name"><a class="struct" href="struct.SortedRenderPhasePlugin.html" title="struct bevy_render::render_phase::SortedRenderPhasePlugin">Sorted<wbr>Render<wbr>Phase<wbr>Plugin</a></div><div class="desc docblock-short">A convenient abstraction for adding all the systems necessary for a sorted
render phase to the render app.</div></li><li><div class="item-name"><a class="struct" href="struct.TrackedRenderPass.html" title="struct bevy_render::render_phase::TrackedRenderPass">Tracked<wbr>Render<wbr>Pass</a></div><div class="desc docblock-short">A <a href="../../wgpu/api/render_pass/struct.RenderPass.html" title="struct wgpu::api::render_pass::RenderPass"><code>RenderPass</code></a>, which tracks the current pipeline state to skip redundant operations.</div></li><li><div class="item-name"><a class="struct" href="struct.UnbatchableBinnedEntities.html" title="struct bevy_render::render_phase::UnbatchableBinnedEntities">Unbatchable<wbr>Binned<wbr>Entities</a></div><div class="desc docblock-short">Information about the unbatchable entities in a bin.</div></li><li><div class="item-name"><a class="struct" href="struct.ViewBinnedRenderPhases.html" title="struct bevy_render::render_phase::ViewBinnedRenderPhases">View<wbr>Binned<wbr>Render<wbr>Phases</a></div><div class="desc docblock-short">Stores the rendering instructions for a single phase that uses bins in all
views.</div></li><li><div class="item-name"><a class="struct" href="struct.ViewRangefinder3d.html" title="struct bevy_render::render_phase::ViewRangefinder3d">View<wbr>Rangefinder3d</a></div><div class="desc docblock-short">A distance calculator for the draw order of <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a>s.</div></li><li><div class="item-name"><a class="struct" href="struct.ViewSortedRenderPhases.html" title="struct bevy_render::render_phase::ViewSortedRenderPhases">View<wbr>Sorted<wbr>Render<wbr>Phases</a></div><div class="desc docblock-short">Stores the rendering instructions for a single phase that sorts items in all
views.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.BinnedRenderPhaseType.html" title="enum bevy_render::render_phase::BinnedRenderPhaseType">Binned<wbr>Render<wbr>Phase<wbr>Type</a></div><div class="desc docblock-short">Identifies the list within <a href="struct.BinnedRenderPhase.html" title="struct bevy_render::render_phase::BinnedRenderPhase"><code>BinnedRenderPhase</code></a> that a phase item is to be
placed in.</div></li><li><div class="item-name"><a class="enum" href="enum.DrawError.html" title="enum bevy_render::render_phase::DrawError">Draw<wbr>Error</a></div></li><li><div class="item-name"><a class="enum" href="enum.RenderCommandResult.html" title="enum bevy_render::render_phase::RenderCommandResult">Render<wbr>Command<wbr>Result</a></div><div class="desc docblock-short">The result of a <a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a>.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.AddRenderCommand.html" title="trait bevy_render::render_phase::AddRenderCommand">AddRender<wbr>Command</a></div><div class="desc docblock-short">Registers a <a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a> as a <a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> function.
They are stored inside the <a href="struct.DrawFunctions.html" title="struct bevy_render::render_phase::DrawFunctions"><code>DrawFunctions</code></a> resource of the app.</div></li><li><div class="item-name"><a class="trait" href="trait.BinnedPhaseItem.html" title="trait bevy_render::render_phase::BinnedPhaseItem">Binned<wbr>Phase<wbr>Item</a></div><div class="desc docblock-short">Represents phase items that are placed into bins. The <code>BinKey</code> specifies
which bin theyre to be placed in. Bin keys are sorted, and items within the
same bin are eligible to be batched together. The elements within the bins
arent themselves sorted.</div></li><li><div class="item-name"><a class="trait" href="trait.CachedRenderPipelinePhaseItem.html" title="trait bevy_render::render_phase::CachedRenderPipelinePhaseItem">Cached<wbr>Render<wbr>Pipeline<wbr>Phase<wbr>Item</a></div><div class="desc docblock-short">A <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a> item, that automatically sets the appropriate render pipeline,
cached in the <a href="../render_resource/struct.PipelineCache.html" title="struct bevy_render::render_resource::PipelineCache"><code>PipelineCache</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.Draw.html" title="trait bevy_render::render_phase::Draw">Draw</a></div><div class="desc docblock-short">A draw function used to draw <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a>s.</div></li><li><div class="item-name"><a class="trait" href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem">Phase<wbr>Item</a></div><div class="desc docblock-short">An item (entity of the render world) which will be drawn to a texture or the screen,
as part of a render phase.</div></li><li><div class="item-name"><a class="trait" href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand">Render<wbr>Command</a></div><div class="desc docblock-short"><a href="trait.RenderCommand.html" title="trait bevy_render::render_phase::RenderCommand"><code>RenderCommand</code></a>s are modular standardized pieces of render logic that can be composed into
<a href="trait.Draw.html" title="trait bevy_render::render_phase::Draw"><code>Draw</code></a> functions.</div></li><li><div class="item-name"><a class="trait" href="trait.SortedPhaseItem.html" title="trait bevy_render::render_phase::SortedPhaseItem">Sorted<wbr>Phase<wbr>Item</a></div><div class="desc docblock-short">Represents phase items that must be sorted. The <code>SortKey</code> specifies the
order that these items are drawn in. These are placed into a single array,
and the array as a whole is then sorted.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.sort_phase_system.html" title="fn bevy_render::render_phase::sort_phase_system">sort_<wbr>phase_<wbr>system</a></div><div class="desc docblock-short">This system sorts the <a href="trait.PhaseItem.html" title="trait bevy_render::render_phase::PhaseItem"><code>PhaseItem</code></a>s of all <a href="struct.SortedRenderPhase.html" title="struct bevy_render::render_phase::SortedRenderPhase"><code>SortedRenderPhase</code></a>s of this
type.</div></li></ul></section></div></main></body></html>