ezEngine Release 26.9
Loading...
Searching...
No Matches
ezRenderContext Class Reference

Classes

class  CommandEncoderScope
 
struct  Statistics
 

Public Types

using RenderingScope = CommandEncoderScope< 0 >
 
using ComputeScope = CommandEncoderScope< 1 >
 

Public Member Functions

Statistics GetAndResetStatistics ()
 
void BeginRendering (const ezGALRenderingSetup &renderingSetup, const ezRectFloat &viewport, const char *szName="", bool bStereoRendering=false)
 
void EndRendering ()
 
void BeginCompute (const char *szName="")
 
void EndCompute ()
 
EZ_ALWAYS_INLINE ezGALCommandEncoderGetCommandEncoder ()
 
void SetShaderPermutationVariable (const char *szName, const ezTempHashedString &sValue)
 
void SetShaderPermutationVariable (const ezHashedString &sName, const ezHashedString &sValue)
 
void BindMaterial (const ezMaterialResourceHandle &hMaterial)
 
ezBindGroupBuilderGetBindGroup (ezUInt32 uiBindGroup=0)
 
void ResetBindGroup (ezUInt32 uiBindGroup)
 
void ResetBindGroups ()
 
void SetPushConstants (ezTempHashedString sSlotName, ezArrayPtr< const ezUInt8 > data)
 Sets push constants to the given data block. Note that for platforms that don't support push constants, this is emulated via a constant buffer. Thus, a slot name must be provided as well which matches the name of the BEGIN_PUSH_CONSTANTS block in the shader.
 
template<typename T >
EZ_ALWAYS_INLINE void SetPushConstants (ezTempHashedString sSlotName, const T &constants)
 
void BindShader (const ezShaderResourceHandle &hShader, ezBitflags< ezShaderBindFlags > flags=ezShaderBindFlags::Default)
 Sets the currently active shader on the given render context.
 
void SetBlendState (ezGALBlendStateHandle hBlendState)
 
void SetDepthStencilState (ezGALDepthStencilStateHandle hDepthStencilState)
 
void SetRasterizerState (ezGALRasterizerStateHandle hRasterizerState)
 
void SetStencilRefValue (ezUInt8 uiStencilRefValue)
 
void BindMeshBuffer (const ezMeshBufferResourceHandle &hMeshBuffer, ezGALBufferHandle hDataOffsetsBuffer={}, ezUInt32 uiFirstDataOffset=0)
 
void BindMeshBuffer (const ezDynamicMeshBufferResourceHandle &hDynamicMeshBuffer, ezGALBufferHandle hDataOffsetsBuffer={}, ezUInt32 uiFirstDataOffset=0)
 
void BindMeshBuffer (ezArrayPtr< const ezGALBufferHandle > vertexBuffers, ezGALBufferHandle hIndexBuffer, ezArrayPtr< const ezGALVertexAttribute > vertexAttributes, ezGALPrimitiveTopology::Enum topology, ezUInt32 uiPrimitiveCount, ezGALBufferHandle hDataOffsetsBuffer={}, ezUInt32 uiFirstDataOffset=0)
 
EZ_ALWAYS_INLINE void BindNullMeshBuffer (ezGALPrimitiveTopology::Enum topology, ezUInt32 uiPrimitiveCount, ezGALBufferHandle hDataOffsetsBuffer={}, ezUInt32 uiFirstDataOffset=0)
 
void BindVertexBuffer (ezGALBufferHandle hVertexBuffer, ezUInt32 uiSlot, ezEnum< ezGALVertexBindingRate > rate=ezGALVertexBindingRate::Vertex, ezUInt32 uiOffset=0)
 
void SetVertexAttributes (ezArrayPtr< ezGALVertexAttribute > vertexAttributes)
 
ezResult DrawMeshBuffer (ezUInt32 uiPrimitiveCount=0xFFFFFFFF, ezUInt32 uiFirstPrimitive=0, ezUInt32 uiInstanceCount=1)
 
ezResult Dispatch (ezUInt32 uiThreadGroupCountX, ezUInt32 uiThreadGroupCountY=1, ezUInt32 uiThreadGroupCountZ=1)
 
ezResult ApplyContextStates (bool bForce=false)
 
ezGlobalConstants & WriteGlobalConstants ()
 
const ezGlobalConstants & ReadGlobalConstants () const
 
void SetGlobalAndWorldTimeConstants (ezTime worldTime)
 
void SetDefaultTextureQuality (ezGALTextureQuality::Enum quality, bool bForce=false)
 Sets the texture filtering quality for all quality-adjustable samplers.
 
ezGALTextureQuality::Enum GetDefaultTextureQuality () const
 Returns the texture filter mode that is used by default for textures.
 
void SetAllowAsyncShaderLoading (bool bAllow)
 Set async shader loading. During runtime all shaders should be preloaded so this is off by default.
 
bool GetAllowAsyncShaderLoading ()
 Returns async shader loading. During runtime all shaders should be preloaded so this is off by default.
 

Static Public Member Functions

static ezRenderContextGetDefaultInstance ()
 
static ezRenderContextCreateInstance (ezGALCommandEncoder *pCommandEncoder)
 
static void DestroyInstance (ezRenderContext *pRenderer)
 
static EZ_ALWAYS_INLINE RenderingScope BeginRenderingScope (const ezRenderViewContext &viewContext, const ezGALRenderingSetup &renderingSetup, const char *szName="", bool bStereoRendering=false)
 
static EZ_ALWAYS_INLINE ComputeScope BeginComputeScope (const ezRenderViewContext &viewContext, const char *szName="")
 
template<typename T >
static EZ_ALWAYS_INLINE ezConstantBufferStorageHandle CreateConstantBufferStorage ()
 
template<typename T >
static EZ_FORCE_INLINE ezConstantBufferStorageHandle CreateConstantBufferStorage (ezConstantBufferStorage< T > *&out_pStorage)
 
static EZ_FORCE_INLINE ezConstantBufferStorageHandle CreateConstantBufferStorage (ezUInt32 uiSizeInBytes)
 
static ezConstantBufferStorageHandle CreateConstantBufferStorage (ezUInt32 uiSizeInBytes, ezConstantBufferStorageBase *&out_pStorage)
 
static void DeleteConstantBufferStorage (ezConstantBufferStorageHandle &inout_hStorage)
 
template<typename T >
static EZ_FORCE_INLINE bool TryGetConstantBufferStorage (ezConstantBufferStorageHandle hStorage, ezConstantBufferStorage< T > *&out_pStorage)
 
static bool TryGetConstantBufferStorage (ezConstantBufferStorageHandle hStorage, ezConstantBufferStorageBase *&out_pStorage)
 
static void MarktConstantBufferStorageModified (ezConstantBufferStorageBase *pDirtyStorage)
 
template<typename T >
static EZ_FORCE_INLINE T * GetConstantBufferData (ezConstantBufferStorageHandle hStorage)
 
static ezGALSamplerStateCreationDescription GetDefaultSamplerState (ezBitflags< ezDefaultSamplerFlags > flags)
 

Friends

class ezMemoryUtils
 

Member Function Documentation

◆ BindShader()

void ezRenderContext::BindShader ( const ezShaderResourceHandle hShader,
ezBitflags< ezShaderBindFlags flags = ezShaderBindFlags::Default 
)

Sets the currently active shader on the given render context.

This function has no effect until the next draw or dispatch call on the context.

◆ SetDefaultTextureQuality()

void ezRenderContext::SetDefaultTextureQuality ( ezGALTextureQuality::Enum  quality,
bool  bForce = false 
)

Sets the texture filtering quality for all quality-adjustable samplers.

The default quality is Anisotropic4x and is controlled via the Rendering.TextureQuality CVar. Changing quality triggers immediate recreation of all affected sampler states. Pass bForce = true to force recreation even if the quality value did not change.

◆ SetPushConstants() [1/2]

template<typename T >
EZ_ALWAYS_INLINE void ezRenderContext::SetPushConstants ( ezTempHashedString  sSlotName,
const T &  constants 
)
inline

Templated version of SetPushConstants.

Template Parameters
TType of the push constants struct.
Parameters
sSlotNameName of the BEGIN_PUSH_CONSTANTS block in the shader.
constantsInstance of type T that contains the push constants.

◆ SetPushConstants() [2/2]

void ezRenderContext::SetPushConstants ( ezTempHashedString  sSlotName,
ezArrayPtr< const ezUInt8 >  data 
)

Sets push constants to the given data block. Note that for platforms that don't support push constants, this is emulated via a constant buffer. Thus, a slot name must be provided as well which matches the name of the BEGIN_PUSH_CONSTANTS block in the shader.

Parameters
sSlotNameName of the BEGIN_PUSH_CONSTANTS block in the shader.
dataData of the push constants. If more than 128 bytes, ezGALDeviceCapabilities::m_uiMaxPushConstantsSize should be checked to ensure the data block is not too big for the platform.

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