ezEngine Release 25.08
Loading...
Searching...
No Matches
ezGALCommandEncoder Class Reference

Public Member Functions

 ezGALCommandEncoder (ezGALDevice &ref_device, ezGALCommandEncoderCommonPlatformInterface &ref_commonImpl)
 
void SetBindGroup (ezUInt32 uiBindGroup, const ezGALBindGroupCreationDescription &bindGroup)
 Sets a bind group to the given bind group index. Preferably, bindGroup should be created via ezBindGroupBuilder::CreateBindGroup.
 
void SetPushConstants (ezArrayPtr< const ezUInt8 > data)
 
ezGALTimestampHandle InsertTimestamp ()
 
ezGALOcclusionHandle BeginOcclusionQuery (ezEnum< ezGALQueryType > type)
 Starts an occlusion query. This function must be called within a render scope and EndOcclusionQuery must be called within the same scope. Only one occlusion query can be active at any given time.
 
void EndOcclusionQuery (ezGALOcclusionHandle hOcclusion)
 Ends an occlusion query. The given handle must afterwards be passed into the ezGALDevice::GetOcclusionQueryResult function, which needs to be repeated every frame until results are ready.
 
ezGALFenceHandle InsertFence ()
 
void CopyBuffer (ezGALBufferHandle hDest, ezGALBufferHandle hSource)
 
void CopyBufferRegion (ezGALBufferHandle hDest, ezUInt32 uiDestOffset, ezGALBufferHandle hSource, ezUInt32 uiSourceOffset, ezUInt32 uiByteCount)
 
void UpdateBuffer (ezGALBufferHandle hDest, ezUInt32 uiDestOffset, ezArrayPtr< const ezUInt8 > sourceData, ezGALUpdateMode::Enum updateMode=ezGALUpdateMode::TransientConstantBuffer)
 
void CopyTexture (ezGALTextureHandle hDest, ezGALTextureHandle hSource)
 
void CopyTextureRegion (ezGALTextureHandle hDest, const ezGALTextureSubresource &destinationSubResource, const ezVec3U32 &vDestinationPoint, ezGALTextureHandle hSource, const ezGALTextureSubresource &sourceSubResource, const ezBoundingBoxu32 &box)
 
void UpdateTexture (ezGALTextureHandle hDest, const ezGALTextureSubresource &destinationSubResource, const ezBoundingBoxu32 &destinationBox, const ezGALSystemMemoryDescription &sourceData)
 
void ResolveTexture (ezGALTextureHandle hDest, const ezGALTextureSubresource &destinationSubResource, ezGALTextureHandle hSource, const ezGALTextureSubresource &sourceSubResource)
 
void ReadbackTexture (ezGALReadbackTextureHandle hDestination, ezGALTextureHandle hSource)
 
void ReadbackBuffer (ezGALReadbackBufferHandle hDestination, ezGALBufferHandle hSource)
 
void GenerateMipMaps (ezGALTextureHandle hTexture, ezGALTextureRange range)
 
void Flush ()
 Submits all pending work to the GPU. Call this if you want to wait for a fence or some other kind of GPU synchronization to take place to ensure the work is actually submitted to the GPU.
 
void PushMarker (const char *szMarker)
 
void PopMarker ()
 
void InsertEventMarker (const char *szMarker)
 
void BeginCompute (const char *szName="")
 
void EndCompute ()
 
ezResult Dispatch (ezUInt32 uiThreadGroupCountX, ezUInt32 uiThreadGroupCountY, ezUInt32 uiThreadGroupCountZ)
 
ezResult DispatchIndirect (ezGALBufferHandle hIndirectArgumentBuffer, ezUInt32 uiArgumentOffsetInBytes)
 
void BeginRendering (const ezGALRenderingSetup &renderingSetup, const char *szName="")
 
void EndRendering ()
 
bool IsInRenderingScope () const
 
void Clear (const ezColor &clearColor, ezUInt32 uiRenderTargetClearMask=0xFFFFFFFFu, bool bClearDepth=true, bool bClearStencil=true, float fDepthClear=1.0f, ezUInt8 uiStencilClear=0x0u)
 Clears active rendertargets.
 
ezResult Draw (ezUInt32 uiVertexCount, ezUInt32 uiStartVertex)
 
ezResult DrawIndexed (ezUInt32 uiIndexCount, ezUInt32 uiStartIndex)
 
ezResult DrawIndexedInstanced (ezUInt32 uiIndexCountPerInstance, ezUInt32 uiInstanceCount, ezUInt32 uiStartIndex)
 
ezResult DrawIndexedInstancedIndirect (ezGALBufferHandle hIndirectArgumentBuffer, ezUInt32 uiArgumentOffsetInBytes)
 
ezResult DrawInstanced (ezUInt32 uiVertexCountPerInstance, ezUInt32 uiInstanceCount, ezUInt32 uiStartVertex)
 
ezResult DrawInstancedIndirect (ezGALBufferHandle hIndirectArgumentBuffer, ezUInt32 uiArgumentOffsetInBytes)
 
void SetIndexBuffer (ezGALBufferHandle hIndexBuffer)
 
void SetVertexBuffer (ezUInt32 uiSlot, ezGALBufferHandle hVertexBuffer, ezUInt32 uiOffset=0)
 
void SetGraphicsPipeline (ezGALGraphicsPipelineHandle hGraphicsPipeline)
 
void SetComputePipeline (ezGALComputePipelineHandle hComputePipeline)
 
void SetViewport (const ezRectFloat &rect, float fMinDepth=0.0f, float fMaxDepth=1.0f)
 
void SetScissorRect (const ezRectU32 &rect)
 
void SetStencilReference (ezUInt8 uiStencilRefValue)
 
EZ_ALWAYS_INLINE ezGALDeviceGetDevice ()
 
void InvalidateState ()
 
const ezGALCommandEncoderStatsGetStats () const
 
void ResetStats ()
 

Protected Member Functions

void GALStaticDeviceEventHandler (const ezGALDeviceEvent &e)
 
void AssertRenderingThread ()
 
void AssertOutsideRenderingScope ()
 

Friends

class ezGALDevice
 
class ezMemoryUtils
 

Member Function Documentation

◆ BeginOcclusionQuery()

ezGALOcclusionHandle ezGALCommandEncoder::BeginOcclusionQuery ( ezEnum< ezGALQueryType type)

Starts an occlusion query. This function must be called within a render scope and EndOcclusionQuery must be called within the same scope. Only one occlusion query can be active at any given time.

Parameters
typeThe type of the occlusion query.
Returns
A handle to be passed into EndOcclusionQuery.
See also
EndOcclusionQuery

◆ Clear()

void ezGALCommandEncoder::Clear ( const ezColor clearColor,
ezUInt32  uiRenderTargetClearMask = 0xFFFFFFFFu,
bool  bClearDepth = true,
bool  bClearStencil = true,
float  fDepthClear = 1.0f,
ezUInt8  uiStencilClear = 0x0u 
)

Clears active rendertargets.

Parameters
uiRenderTargetClearMaskEach bit represents a bound color target. If all bits are set, all bound color targets will be cleared.

◆ EndOcclusionQuery()

void ezGALCommandEncoder::EndOcclusionQuery ( ezGALOcclusionHandle  hOcclusion)

Ends an occlusion query. The given handle must afterwards be passed into the ezGALDevice::GetOcclusionQueryResult function, which needs to be repeated every frame until results are ready.

Parameters
hOcclusionValue returned by the previous call to BeginOcclusionQuery.
See also
ezGALDevice::GetOcclusionQueryResult

◆ InsertFence()

ezGALFenceHandle ezGALCommandEncoder::InsertFence ( )

Inserts a fence. You need to flush commands to the GPU in order to be able to wait for a fence by either ending a frame or calling ezCommandEncoder::Flush explicitly.

Returns
A handle to be passed into ezGALDevice::GetFenceResult.
See also
ezGALDevice::GetFenceResult

◆ InsertTimestamp()

ezGALTimestampHandle ezGALCommandEncoder::InsertTimestamp ( )

Inserts a timestamp.

Returns
A handle to be passed into ezGALDevice::GetTimestampResult.

◆ SetBindGroup()

void ezGALCommandEncoder::SetBindGroup ( ezUInt32  uiBindGroup,
const ezGALBindGroupCreationDescription bindGroup 
)

Sets a bind group to the given bind group index. Preferably, bindGroup should be created via ezBindGroupBuilder::CreateBindGroup.

This function binds a collection of resources (buffers, textures, samplers) to a specific bind group index. In debug builds, it performs extensive validation of each ezGALBindGroupItem against the layout's ezShaderResourceBinding to ensure:

General Validation:

  • Bind group layout matches the number of provided items
  • All resource handles are valid (non-null)

Buffer Validation:

  • Buffer handles are valid and match expected binding types
  • Constant buffers: No texel format override, zero offset, full buffer size
  • Structured/Texel/ByteAddress buffers: Proper usage flags, correct element alignment
  • Buffer ranges: Offset/size alignment with element boundaries, bounds checking
  • Access permissions: SRV/UAV flags match buffer usage flags

Texture Validation:

  • Texture handles are valid with proper view format compatibility
  • Array slice counts match binding requirements (e.g. 1 for non-arrays, multiple of 6 for cubes)
  • MSAA sample counts match between texture and binding
  • Access permissions: SRV/UAV flags match texture capabilities
  • Texture ranges: Mip levels and array slices within bounds
  • Make sure no proxy texture is present
Parameters
uiBindGroupThe bind group slot index to set
bindGroupDescription containing the layout and resource items to bind

◆ SetIndexBuffer()

void ezGALCommandEncoder::SetIndexBuffer ( ezGALBufferHandle  hIndexBuffer)
Todo:
Assert on index buffer type (if non nullptr)

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