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

#include <ResourceStateTracker.h>

Classes

struct  SubResourceState
 
struct  TextureState
 

Public Member Functions

 ezGALResourceStateTracker (ezGALDevice *pDevice)
 
 ezGALResourceStateTracker (const ezGALResourceStateTracker &)=delete
 
ezGALResourceStateTrackeroperator= (const ezGALResourceStateTracker &)=delete
 
void Clear ()
 
Initial State
void SetInitialTextureState (ezGALTextureHandle hTexture, ezBitflags< ezGALResourceState > state, ezBitflags< ezGALShaderStageFlags > stages=ezGALShaderStageFlags::Auto)
 
void SetInitialBufferState (ezGALBufferHandle hBuffer, ezBitflags< ezGALResourceState > state, ezBitflags< ezGALShaderStageFlags > stages=ezGALShaderStageFlags::Auto)
 Overrides the tracked state for a buffer and clears tracked stage flags.
 
State Transitions
void ChangeState (ezGALTextureHandle hTexture, ezGALTextureRange range, ezBitflags< ezGALResourceState > newState, ezBitflags< ezGALShaderStageFlags > stage, const ezDelegate< void(const ezGALTextureBarrier &)> &barrierCallback)
 
void ChangeState (ezGALBufferHandle hBuffer, ezBitflags< ezGALResourceState > newState, ezBitflags< ezGALShaderStageFlags > stage, const ezDelegate< void(const ezGALBufferBarrier &)> &barrierCallback)
 
void RevertTextureState (const ezDelegate< void(const ezGALTextureBarrier &)> &barrierCallback)
 
void RevertBufferState (const ezDelegate< void(const ezGALBufferBarrier &)> &barrierCallback)
 Transitions all tracked buffers back to their default state (ezGALBufferCreationDescription::GetDefaultState).
 

State Verification

const SubResourceStateGetBufferState (ezGALBufferHandle hBuffer) const
 
const TextureStateGetTextureState (ezGALTextureHandle hTexture) const
 
static bool IsTextureBarrierNeeded (const SubResourceState &oldState, const SubResourceState &newState, bool bForceUAVBarrier=true)
 
static bool IsBufferBarrierNeeded (const SubResourceState &oldState, const SubResourceState &newState, bool bForceUAVBarrier=true)
 
static bool AreStagesCovered (ezBitflags< ezGALShaderStageFlags > coveredStages, ezBitflags< ezGALShaderStageFlags > requiredStages)
 

Detailed Description

Tracks texture and buffer states and emits barriers through callbacks when synchronization is required.

For resources that are first seen without an explicit initial state, the tracker starts from the resource default state (ezGAL*CreationDescription::GetDefaultState) with stage Auto.

Barrier emission is callback-based: callbacks are only invoked when a barrier is needed. A barrier is required when the state changes, or when the previous state contains ezGALResourceState::UnorderedAccess (UAV write-after-write). States cannot be tracked across frames and before the frame end all resources must be reverted to their default state via RevertTextureState / RevertBufferState.

Member Function Documentation

◆ ChangeState() [1/2]

void ezGALResourceStateTracker::ChangeState ( ezGALBufferHandle  hBuffer,
ezBitflags< ezGALResourceState newState,
ezBitflags< ezGALShaderStageFlags stage,
const ezDelegate< void(const ezGALBufferBarrier &)> &  barrierCallback 
)

Transitions a buffer to the given state.

The callback is invoked only when a barrier is required.

◆ ChangeState() [2/2]

void ezGALResourceStateTracker::ChangeState ( ezGALTextureHandle  hTexture,
ezGALTextureRange  range,
ezBitflags< ezGALResourceState newState,
ezBitflags< ezGALShaderStageFlags stage,
const ezDelegate< void(const ezGALTextureBarrier &)> &  barrierCallback 
)

Transitions a texture range to the given state.

If range uses EZ_GAL_ALL_* sentinels they are resolved against the full texture range. The callback is invoked once per emitted barrier.

◆ RevertTextureState()

void ezGALResourceStateTracker::RevertTextureState ( const ezDelegate< void(const ezGALTextureBarrier &)> &  barrierCallback)

Transitions all tracked textures back to their default state (ezGALTextureCreationDescription::GetDefaultState).

Emits full-resource barriers for compressed texture entries and per-subresource barriers for expanded entries.

◆ SetInitialTextureState()

void ezGALResourceStateTracker::SetInitialTextureState ( ezGALTextureHandle  hTexture,
ezBitflags< ezGALResourceState state,
ezBitflags< ezGALShaderStageFlags stages = ezGALShaderStageFlags::Auto 
)

Overrides the tracked state for a texture.

Resets tracking to a single compressed entry that represents the full resource and clears tracked stage flags.


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