Module rafx_framework::render_features
source · Expand description
Part of rafx-framework
. Handles extracting, preparing, and writing draw calls
Modules§
Structs§
- A
JobContext
is definable by eachRenderFeature
. It is used to bundle any expensive work, like acquiring locks or other resources, into fewer call-sites for any work occurring on the same thread. TheJobContext
will not be shared between threads. UseDefaultJobContext
if theRenderFeature
does not need to acquire resources. - An
ExtractJob
implements theRenderFeatureExtractJob
trait by wrapping an instance of anExtractJobEntryPoints
type defined at compile-time. TheExtractJob
contains the frame packet and presents the correct context (likeExtractPerFrameContext
) to each entry point defined inExtractJobEntryPoints
. - Read documentation on
FramePacketData
. - A
PrepareJob
implements theRenderFeaturePrepareJob
trait by wrapping an instance of anPrepareJobEntryPoints
type defined at compile-time. ThePrepareJob
contains the frame & submit packets and presents the correct context (likePreparePerFrameContext
) to each entry point defined inRenderFeaturePrepareJob
. - The sorted
SubmitNode
s for eachRenderView
andRenderPhase
with all relevantRenderFeature
’sRenderFeatureWriteJob
s. - A type-erased struct representing some
RenderFeature
’sSubmitNode
. ThePreparedRenderData
will iterate through the sorted slice ofRenderFeatureSubmitNode
in aViewPhaseSubmitNodeBlock
and call the functions on theRenderFeatureWriteJob
specified by theRenderFeatureIndex
. - Holds references to resources valid for the entirety of the
extract
step as represented by the'extract
lifetime.RenderFeatureExtractJob
s should cache any resources needed from theRenderJobExtractContext
during theirnew
function. - Holds references to resources valid for the entirety of the
prepare
step as represented by the'prepare
lifetime.RenderFeaturePrepareJob
s should cache any resources needed from theRenderJobPrepareContext
during theirnew
function. - Holds references to resources valid for the entirety of the
write
step as represented by the'write
lifetime.RenderFeatureWriteJob
s should cache any resources needed from theRenderJobWriteContext
during theirnew
function. - A reference to a
RenderObject
with a reference-counted pointer. When the last instance of aRenderObjectHandle
is dropped, the referencedRenderObject
will be freed from theRenderObjectSet
. This is returned byregister_render_object
on theRenderObjectSet
and may be used to query or mutate theRenderObject
with theget
orget_mut
methods. - A weak
RenderObjectHandle
. This is a reference to aRenderObject
that is not used in reference-counting by theRenderObjectSet
. Create aRenderObjectId
with theas_id()
method on aRenderObjectHandle
. TheRenderObject
can be queried with theget_id
method on theRenderObjectSet
. - A specific
Entity
andRenderObject
represented by theObjectId
andRenderObjectId
. ARenderObject
is associated with a particularRenderFeature
by theRenderFeatureIndex
. TheFramePacket
only contains uniqueRenderObjectInstance
s. - A specific
RenderObjectInstance
as viewed by someRenderView
. - Use
RenderObjectsJobContext
if theRenderFeature
only needs to lock aRenderObjectsMap
. - The
Renderer
processesRenderView
s during the execution of theRenderGraph
. EachRenderView
is associated with a specificViewFrustum
in the game world. TheRenderView
may be registered for specificRenderFeature
s by aRenderFeatureMask
orRenderPhase
s by theRenderPhaseMask
. If aRenderView
is not registered for aRenderFeature
orRenderPhase
then it will not be processed by that feature or phase. - The
RenderObject
s visible to a specificRenderView
for the current frame. EachRenderObject
is represented by aRenderViewObject
with theObjectId
returned by theVisibilityObject
and aRenderObjectId
. If aVisibilityObject
has multipleRenderObject
s associated with it, the results will be returned as 0 or moreRenderViewObject
s. The visibleRenderObject
s will only containRenderObject
s associated with aRenderFeature
included by theRenderView
’sRenderFeatureMask
. - Each
SubmitNode
contains the data needed for theRenderFeature
’sRenderFeatureWriteJob
to render a draw call by referencing data in the frame packet, submit packet, render objects set, or some other storage.SubmitNode
s will be sorted by theRenderPhase
after they are combined into aViewPhaseSubmitNodeBlock
. - The
SubmitNodeBlock
is a collection ofSubmitNode
associated with a particularRenderFeature
,RenderView
, andRenderPhase
. There should be a 1:1 mapping betweenSubmitNode
s and draw calls from theRenderFeature
’sWriteJob
. TheRenderer
will combine allSubmitNodeBlock
s sharing the sameRenderView
andRenderPhase
into a sortedViewPhaseSubmitNodeBlock
. - Read documentation on
SubmitPacketData
. - Read documentation on
FramePacketData
. - A combination of a particular
RenderView
andRenderPhase
. TheViewPhaseSubmitNodeBlock
s in thePreparedRenderData
are indexed by theViewPhase
. - The
ViewPhaseSubmitNodeBlock
is a collection ofRenderFeatureSubmitNode
associated with a particularRenderView
, andRenderPhase
. In other words, theViewPhaseSubmitNodeBlock
is the combination of all the feature-specificRenderFeatureSubmitNodeBlock
s with the sameRenderView
andRenderPhase
. - Read documentation on
SubmitPacketData
. - Determines the visible
RenderObject
s in a givenRenderView
and returns the results in theRenderViewVisibilityQuery
. It is thread-safe to callquery_visibility
on multipleRenderView
s simultaneously.
Constants§
Traits§
ExtractJobEntryPoints
provides a generic set of callbacks for aRenderFeature
compatible with theExtractJob
struct. This simplifies the work of implementing theRenderFeatureExtractJob
trait.- The
FramePacket
is the data that must be extracted from either theAssetManager
or the game’sWorld
during theExtract
step. After theExtract
step has finished, there is no more access allowed to either theAssetManager
or the game’sWorld
. TheFramePacket
must be considered immutable after theExtract
step has finished. PrepareJobEntryPoints
provides a generic set of callbacks for aRenderFeature
compatible with thePrepareJob
struct. This simplifies the work of implementing theRenderFeaturePrepareJob
trait.- A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeExtractJob
and theExtractJobEntryPoints
for implementation details. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeFramePacket
andViewPacket
for implementation details. - Provides
as_concrete
method to downcast as a concrete type. - Provides
into_concrete
method to downcast into a concrete type. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeePrepareJob
and thePrepareJobEntryPoints
for implementation details. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeSubmitNodeBlock
for implementation details. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeSubmitPacket
andViewSubmitPacket
for implementation details. - Provides
as_concrete
method to downcast as a concrete type. - Provides
into_concrete
method to downcast into a concrete type. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeViewPacket
for implementation details. - Provides
as_concrete
method to downcast as a concrete type. - Provides
into_concrete
method to downcast into a concrete type. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. SeeViewSubmitPacket
for implementation details. - Provides
as_concrete
method to downcast as a concrete type. - Provides
into_concrete
method to downcast into a concrete type. - A type-erased trait used by the
Renderer
,RenderFrameJob
, andRendererThreadPool
to control the workload of the rendering process without identifying specific types used in eachRenderFeature
’s frame packet or workload. - The
SubmitPacket
is the data that must be prepared from in order for theRenderFeature
’sWriteJob
to create each draw call. The draw calls may reference data in either theFramePacket
or theSubmitPacket
. Each draw call is represented by exactly 1SubmitNode
. In order to allocate theSubmitPacket
, theRenderFeature
is given a reference to the populatedFramePacket
from that frame. TheRenderFeature
must size theSubmitPacket
appropriately. TheSubmitPacket
must be considered immutable after thePrepare
step has finished.
Type Aliases§
- The
ID
of a registeredRenderFeatureFlag
. - The
ID
of a registeredRenderFeature
. - The
ID
of aRenderObjectInstance
in a specificFramePacket
for the current frame. - The
ID
of aRenderObjectInstance
in a specificViewPacket
for the current frame. - The
ID
of a registeredRenderPhase
. - The total number of submit nodes needed by each
RenderView
. TheRenderView
is represented by theRenderViewIndex
key and the count of submit nodes are contained by aVec<usize>
where the count at each indexI
corresponds to theRenderPhase
withRenderPhaseIndex
equal toI
. - A collection containing all
SubmitNode
s across allRenderFeature
s matching aRenderView
andRenderPhase
where theSubmitNode
s are sorted by theRenderPhase
’s sort function. TheRenderView
andRenderPhase
pair is represented by theViewPhase
key and theSubmitNode
s are contained by theViewPhaseSubmitNodeBlock
. - The
ID
of aSubmitNode
in a specificRenderFeature
in the current frame. - The sort function used by a particular
RenderPhase
. This is usually one of the following: - A generic key usable by the
SubmitNodeSortFunction
for the purpose of sorting the collection ofRenderFeatureSubmitNode
in a particularViewPhase
. This can be used to minimize state changes in the rendering pipeline, e.g. by setting the bits of the key so that higher bits represent more expensive state changes like shaders and lower bits represent cheaper state changes like uniforms. - The index of a
RenderView
in thisRenderFeature
’sFramePacket
for the current frame.