Open 3D Engine Atom Gem API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Types | Public Member Functions | Friends | List of all members
AZ::RPI::DynamicDrawContext Class Reference

#include <DynamicDrawContext.h>

Inherits intrusive_base.

Classes

struct  VertexChannel
 

Public Types

enum  DrawStateOptions : uint32_t {
  PrimitiveType = AZ_BIT(0), DepthState = AZ_BIT(1), StencilState = AZ_BIT(2), FaceCullMode = AZ_BIT(3),
  BlendMode = AZ_BIT(4)
}
 

Public Member Functions

void InitShaderWithVariant (Data::Asset< ShaderAsset > shaderAsset, const ShaderOptionList *optionAndValues)
 
void InitShaderWithVariant (Data::Instance< Shader > shader, const ShaderOptionList *optionAndValues)
 
void InitShader (Data::Asset< ShaderAsset > shaderAsset)
 
void InitShader (Data::Instance< Shader > shader)
 
void InitVertexFormat (const AZStd::vector< VertexChannel > &vertexChannels)
 Initialize input stream layout with vertex channel information.
 
void InitDrawListTag (RHI::DrawListTag drawListTag)
 Initialize draw list tag of this.
 
void CustomizePipelineState (AZStd::function< void(Ptr< PipelineStateForDraw >)> updatePipelineState)
 
void AddDrawStateOptions (DrawStateOptions options)
 
void SetOutputScope (Scene *scene)
 
void SetOutputScope (RenderPipeline *pipeline)
 
void SetOutputScope (RasterPass *pass)
 
void EndInit ()
 Finalize and validate initialization. Any initialization functions should be called before EndInit is called.
 
bool IsReady ()
 Return if this DynamicDrawContext is ready to add draw calls.
 
bool HasDrawStateOptions (DrawStateOptions options)
 Return if some draw state options change are enabled.
 
ShaderVariantId UseShaderVariant (const ShaderOptionList &optionAndValues)
 
void SetDepthState (RHI::DepthState depthState)
 Set DepthState if DrawStateOptions::DepthState option is enabled.
 
void SetStencilState (RHI::StencilState stencilState)
 Set StencilState if DrawStateOptions::StencilState option is enabled.
 
void SetCullMode (RHI::CullMode cullMode)
 Set CullMode if DrawStateOptions::FaceCullMode option is enabled.
 
void SetTarget0BlendState (RHI::TargetBlendState blendState)
 Set TargetBlendState for target 0 if DrawStateOptions::BlendMode option is enabled.
 
void SetPrimitiveType (RHI::PrimitiveTopology topology)
 Set PrimitiveType if DrawStateOptions::PrimitiveType option is enabled.
 
void SetShaderVariant (ShaderVariantId shaderVariantId)
 
void SetScissor (RHI::Scissor scissor)
 
void UnsetScissor ()
 
void SetViewport (RHI::Viewport viewport)
 
void UnsetViewport ()
 
void SetStencilReference (uint8_t stencilRef)
 Set stencil reference for following draws which are added to this DynamicDrawContext.
 
uint8_t GetStencilReference () const
 Get the current stencil reference.
 
void DrawIndexed (const void *vertexData, uint32_t vertexCount, const void *indexData, uint32_t indexCount, RHI::IndexFormat indexFormat, Data::Instance< ShaderResourceGroup > drawSrg=nullptr)
 
void DrawLinear (const void *vertexData, uint32_t vertexCount, Data::Instance< ShaderResourceGroup > drawSrg)
 
uint32_t GetPerVertexDataSize ()
 Get per vertex size. The size was evaluated when vertex format was set.
 
RHI::DrawListTag GetDrawListTag ()
 Get DrawListTag of this DynamicDrawContext.
 
Data::Instance< ShaderResourceGroupNewDrawSrg ()
 
Data::Instance< ShaderResourceGroupGetPerContextSrg ()
 Get per context srg.
 
bool IsVertexSizeValid (uint32_t vertexSize)
 return whether the vertex data size is valid
 
const Data::Instance< Shader > & GetShader () const
 Get the shader which is associated with this DynamicDrawContext.
 
void SetSortKey (RHI::DrawItemSortKey key)
 
RHI::DrawItemSortKey GetSortKey () const
 Get the current sort key.
 

Friends

class DynamicDrawSystem
 

Detailed Description

This class helps setup dynamic draw data as well as provide draw functions to draw dynamic items. The draw calls added to the context are only valid for one frame. DynamicDrawContext is only associated with

Member Function Documentation

◆ AddDrawStateOptions()

void AZ::RPI::DynamicDrawContext::AddDrawStateOptions ( DrawStateOptions  options)

Enable draw state changes for this DynamicDrawContext. This function can only be called before EndInit() is called

◆ CustomizePipelineState()

void AZ::RPI::DynamicDrawContext::CustomizePipelineState ( AZStd::function< void(Ptr< PipelineStateForDraw >)>  updatePipelineState)

Customize pipeline state through a function This function is intended to do pipeline state customization after all initialization function calls but before EndInit

◆ DrawIndexed()

void AZ::RPI::DynamicDrawContext::DrawIndexed ( const void *  vertexData,
uint32_t  vertexCount,
const void *  indexData,
uint32_t  indexCount,
RHI::IndexFormat  indexFormat,
Data::Instance< ShaderResourceGroup drawSrg = nullptr 
)

Draw Indexed primitives with vertex and index data and per draw srg The per draw srg need to be provided if it's required by shader.

◆ DrawLinear()

void AZ::RPI::DynamicDrawContext::DrawLinear ( const void *  vertexData,
uint32_t  vertexCount,
Data::Instance< ShaderResourceGroup drawSrg 
)

Draw linear indexed primitives with vertex data and per draw srg The per draw srg need to be provided if it's required by shader.

◆ InitShader()

void AZ::RPI::DynamicDrawContext::InitShader ( Data::Asset< ShaderAsset shaderAsset)

Initialize this context with the input shader/shader asset. DynamicDrawContext initialized with this function may use shader variant later (AddShaderVariant and SetShaderVariant).

◆ InitShaderWithVariant()

void AZ::RPI::DynamicDrawContext::InitShaderWithVariant ( Data::Asset< ShaderAsset shaderAsset,
const ShaderOptionList *  optionAndValues 
)

Initialize this context with the input shader/shader asset with only one shader variant DynamicDrawContext initialized with this function can't use other variant later (AddShaderVariant and SetShaderVariant).

◆ NewDrawSrg()

Data::Instance<ShaderResourceGroup> AZ::RPI::DynamicDrawContext::NewDrawSrg ( )

Create a draw srg Note: the draw srg can only be used in the current frame. It can't be cached and used for following frames.

◆ SetOutputScope()

void AZ::RPI::DynamicDrawContext::SetOutputScope ( Scene scene)

Call any one of these functions to decide which scope this DynamicDrawContext may draw to. One of the function has to be called once before EndInit() is called. After DynamicDrawContext is initialized, the output scope can be changed. But it has to be called after existing draw calls are submitted. @Param scene Draw calls made with this DynamicDrawContext will be submit to this scene @Param pipeline Draw calls made with this DynamicDrawContext will be submit to this render pipeline @Param pass Draw calls made with this DynamicDrawContext will only be submit to this pass

◆ SetScissor()

void AZ::RPI::DynamicDrawContext::SetScissor ( RHI::Scissor  scissor)

Setup scissor for following draws which are added to this DynamicDrawContext Note: it won't effect any draws submitted out of this DynamicDrawContext

◆ SetShaderVariant()

void AZ::RPI::DynamicDrawContext::SetShaderVariant ( ShaderVariantId  shaderVariantId)

Set the shader variant as the current variant which is used for any following draw calls. Note, SetShaderVariant() needs to be called before NewDrawSrg() if a draw srg is used in following draw calls.

◆ SetSortKey()

void AZ::RPI::DynamicDrawContext::SetSortKey ( RHI::DrawItemSortKey  key)

Set the sort key for the next draw. Note: The sort key will be increased by 1 whenever the a draw function is called.

◆ SetViewport()

void AZ::RPI::DynamicDrawContext::SetViewport ( RHI::Viewport  viewport)

Setup viewport for following draws which are added to this DynamicDrawContext Note: it won't effect any draws submitted out of this DynamicDrawContext

◆ UnsetScissor()

void AZ::RPI::DynamicDrawContext::UnsetScissor ( )

Remove per draw scissor for draws added to this DynamicDrawContext Without per draw scissor, the scissor setup in pass is usually used.

◆ UnsetViewport()

void AZ::RPI::DynamicDrawContext::UnsetViewport ( )

Remove per draw viewport for draws added to this DynamicDrawContext Without per draw viewport, the viewport setup in pass is usually used.

◆ UseShaderVariant()

ShaderVariantId AZ::RPI::DynamicDrawContext::UseShaderVariant ( const ShaderOptionList &  optionAndValues)

Tell DynamicDrawContext it will use the shader variant specified by ShaderOptionList. The returned ShaderVariantId can be used via SetShaderVariant() before making any draw calls. Note, if the DynamicDrawContext was initialized with default shader variant, it won't return a valid variant Id.


The documentation for this class was generated from the following file: