#include <DynamicDrawContext.h>
Inherits AZStd::intrusive_base.
Classes | |
struct | VertexChannel |
Public Types | |
enum class | 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 | |
AZ_RTTI (AZ::RPI::DynamicDrawContext, "{9F6645D7-2C64-4963-BAAB-5144E92F61E2}") | |
AZ_CLASS_ALLOCATOR (DynamicDrawContext, AZ::SystemAllocator) | |
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< ShaderResourceGroup > | NewDrawSrg () |
Data::Instance< ShaderResourceGroup > | GetPerContextSrg () |
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 |
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
void AZ::RPI::DynamicDrawContext::AddDrawStateOptions | ( | DrawStateOptions | options | ) |
Enable draw state changes for this DynamicDrawContext. This function can only be called before EndInit() is called
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
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.
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.
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).
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).
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.
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
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
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.
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.
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
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.
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.
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.