ezEngine  Milestone 7
ezRenderContext Class Reference

Classes

struct  MaterialParam
 
struct  ShaderVertexDecl
 
struct  Statistics
 

Public Member Functions

void SetGALContext (ezGALContext *pContext)
 
ezGALContextGetGALContext () const
 
void SetShaderPermutationVariable (const char *szVariable, const char *szValue)
 
void BindTexture (const ezTempHashedString &sSlotName, const ezTextureResourceHandle &hTexture)
 
void SetMaterialState (const ezMaterialResourceHandle &hMaterial)
 
void BindConstantBuffer (const ezTempHashedString &sSlotName, const ezConstantBufferResourceHandle &hConstantBuffer)
 
void BindMeshBuffer (const ezMeshBufferResourceHandle &hMeshBuffer)
 
void DrawMeshBuffer (ezUInt32 uiPrimitiveCount=0xFFFFFFFF, ezUInt32 uiFirstPrimitive=0, ezUInt32 uiInstanceCount=1)
 
ezResult ApplyContextStates (bool bForce=false)
 
Statistics GetAndResetStatistics ()
 
void BindShader (ezShaderResourceHandle hShader, ezBitflags< ezShaderBindFlags > flags=ezShaderBindFlags::Default)
 Sets the currently active shader on the given render context. If pContext is null, the state is set for the primary context. More...
 
ezGALShaderHandle GetActiveGALShader ()
 Evaluates the currently active shader program and then returns that. Can be used to determine the shader that needs to be used to create a vertex declaration.
 
template<typename STRUCT >
STRUCT * BeginModifyConstantBuffer (ezConstantBufferResourceHandle hConstantBuffer)
 
void EndModifyConstantBuffer ()
 

Static Public Member Functions

static ezRenderContextGetDefaultInstance ()
 
static ezRenderContextCreateInstance ()
 
static void DestroyInstance (ezRenderContext *pRenderer)
 
static void ConfigureShaderSystem (const char *szActivePlatform, bool bEnableRuntimeCompilation, const char *szShaderCacheDirectory="ShaderCache", const char *szPermVarSubDirectory="Shaders/PermutationVars")
 
static const ezStringGetPermutationVarSubDirectory ()
 
static const ezStringGetActiveShaderPlatform ()
 
static const ezStringGetShaderCacheDirectory ()
 
static bool IsRuntimeShaderCompilationEnabled ()
 
static void LoadShaderPermutationVarConfig (const char *szVariable)
 
static const
ezPermutationGenerator
GetGeneratorForShaderPermutation (ezUInt32 uiPermutationHash)
 
static void PreloadShaderPermutations (ezShaderResourceHandle hShader, const ezPermutationGenerator &Generator, ezTime tShouldBeAvailableIn)
 
static
ezShaderPermutationResourceHandle 
PreloadSingleShaderPermutation (ezShaderResourceHandle hShader, const ezHybridArray< ezPermutationGenerator::PermutationVar, 16 > &UsedPermVars, ezTime tShouldBeAvailableIn)
 
static GlobalConstants & WriteGlobalConstants ()
 
static const GlobalConstants & ReadGlobalConstants ()
 
static void SetMaterialParameter (const ezTempHashedString &sName, const float &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec2 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec3 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec4 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezColor &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezInt32 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec2I32 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec3I32 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVec4I32 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezMat4 &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezTransform &value)
 
static void SetMaterialParameter (const ezTempHashedString &sName, const ezVariant &value)
 
static const MaterialParamGetMaterialParameterPointer (ezUInt32 uiNameHash)
 

Private Member Functions

 EZ_MAKE_SUBSYSTEM_STARTUP_FRIEND (Graphics, RendererContext)
 
ezUInt8 * InternalBeginModifyConstantBuffer (ezConstantBufferResourceHandle hConstantBuffer)
 
void UploadGlobalConstants ()
 
void ApplyTextureBindings (ezGALShaderStage::Enum stage, const ezShaderStageBinary *pBinary)
 
void ApplyConstantBufferBindings (const ezShaderStageBinary *pBinary)
 

Static Private Member Functions

static void OnEngineShutdown ()
 
static void OnCoreShutdown ()
 
static ezResult BuildVertexDeclaration (ezGALShaderHandle hShader, const ezVertexDeclarationInfo &decl, ezGALVertexDeclarationHandle &out_Declaration)
 
static MaterialParamInternalSetMaterialParameter (const ezTempHashedString &sName, ezShaderMaterialParamCB::MaterialParameter::Type type, ezUInt32 uiMaxArrayElements)
 

Private Attributes

Statistics m_Statistics
 
ezBitflags< ezRenderContextFlagsm_StateFlags
 
ezShaderResourceHandle m_hActiveShader
 
ezGALShaderHandle m_hActiveGALShader
 
ezMap< ezString, ezStringm_PermutationVariables
 
ezPermutationGenerator m_PermGenerator
 
ezShaderPermutationResourceHandle m_hActiveShaderPermutation
 
ezConstantBufferResourcem_pCurrentlyModifyingBuffer
 
ezBitflags< ezShaderBindFlagsm_ShaderBindFlags
 
ezMeshBufferResourceHandle m_hMeshBuffer
 
ezUInt32 m_uiMeshBufferPrimitiveCount
 
ezHashTable< ezUInt32,
ezTextureResourceHandle
m_BoundTextures
 
ezHashTable< ezUInt32,
ezConstantBufferResourceHandle
m_BoundConstantBuffers
 
ezGALContextm_pGALContext
 

Static Private Attributes

static ezRenderContexts_DefaultInstance = nullptr
 
static ezHybridArray
< ezRenderContext *, 4 > 
s_Instances
 
static ezPermutationGenerator s_AllowedPermutations
 
static bool s_bEnableRuntimeCompilation = false
 
static ezString s_sPlatform
 
static ezString s_sPermVarSubDir
 
static ezString s_ShaderCacheDirectory = "ShaderCache"
 
static ezMap< ezUInt32,
ezPermutationGenerator
s_PermutationHashCache
 
static ezMap< ShaderVertexDecl,
ezGALVertexDeclarationHandle
s_GALVertexDeclarations
 
static ezUInt64 s_LastMaterialParamModification = 1
 
static bool s_bGlobalConstantsModified = true
 
static GlobalConstants s_GlobalConstants
 
static
ezConstantBufferResourceHandle 
s_hGlobalConstantBuffer
 

Friends

class ezMemoryUtils
 

Class Documentation

struct ezRenderContext::MaterialParam
Class Members
ezUInt64 m_LastModification
Type m_Type
ezUInt8 m_uiArrayElements
ezUInt16 m_uiDataSize

Member Function Documentation

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

Sets the currently active shader on the given render context. If pContext is null, the state is set for the primary context.

This function has no effect until the next drawcall on the context.

const ezRenderContext::MaterialParam * ezRenderContext::GetMaterialParameterPointer ( ezUInt32  uiNameHash)
static
Todo:
Array versions of material parameters
Todo:
Return array, not data pointer ? (only required, if array size may grow later on)
ezShaderPermutationResourceHandle ezRenderContext::PreloadSingleShaderPermutation ( ezShaderResourceHandle  hShader,
const ezHybridArray< ezPermutationGenerator::PermutationVar, 16 > &  UsedPermVars,
ezTime  tShouldBeAvailableIn 
)
static
Todo:
Mutex
void ezRenderContext::SetMaterialParameter ( const ezTempHashedString sName,
const ezVariant value 
)
static
Todo:
Int vector
void ezRenderContext::SetShaderPermutationVariable ( const char *  szVariable,
const char *  szValue 
)
Todo:
Could we use hashed variable names here ?

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