Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::DeviceContextBase< EngineImplTraits > Class Template Referenceabstract

Base implementation of the device context. More...

#include <DeviceContextBase.hpp>

Inheritance diagram for Diligent::DeviceContextBase< EngineImplTraits >:
Diligent::ObjectBase< EngineImplTraits::DeviceContextInterface > Diligent::RefCountedObject< EngineImplTraits::DeviceContextInterface > Diligent::DeviceContextNextGenBase< EngineD3D12ImplTraits > Diligent::DeviceContextNextGenBase< EngineVkImplTraits > Diligent::DeviceContextNextGenBase< EngineImplTraits > Diligent::DeviceContextD3D12Impl Diligent::DeviceContextVkImpl

Classes

struct  CommittedShaderResources
 Committed shader resources for each resource signature. More...
 

Public Member Functions

 DeviceContextBase (IReferenceCounters *pRefCounters, DeviceImplType *pRenderDevice, const DeviceContextDesc &Desc)
 
virtual const DeviceContextDesc &DILIGENT_CALL_TYPE GetDesc () const override final
 Implementation of IDeviceContext::GetDesc().
 
virtual void DILIGENT_CALL_TYPE SetRenderTargets (Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override final
 Implementation of IDeviceContext::SetRenderTargets().
 
virtual void DILIGENT_CALL_TYPE SetVertexBuffers (Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer *const *ppBuffers, const Uint64 *pOffsets, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, SET_VERTEX_BUFFERS_FLAGS Flags) override=0
 
void CommitShaderResources (IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int)
 Base implementation of IDeviceContext::CommitShaderResources(); validates parameters.
 
virtual void DILIGENT_CALL_TYPE SetIndexBuffer (IBuffer *pIndexBuffer, Uint64 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override=0
 Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buffer.
 
void SetViewports (Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight)
 Caches the viewports.
 
void SetScissorRects (Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight)
 Caches the scissor rects.
 
virtual void DILIGENT_CALL_TYPE UpdateBuffer (IBuffer *pBuffer, Uint64 Offset, Uint64 Size, const void *pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override=0
 Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters.
 
virtual void DILIGENT_CALL_TYPE CopyBuffer (IBuffer *pSrcBuffer, Uint64 SrcOffset, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, IBuffer *pDstBuffer, Uint64 DstOffset, Uint64 Size, RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override=0
 Base implementation of IDeviceContext::CopyBuffer(); validates input parameters.
 
virtual void DILIGENT_CALL_TYPE MapBuffer (IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid &pMappedData) override=0
 Base implementation of IDeviceContext::MapBuffer(); validates input parameters.
 
virtual void DILIGENT_CALL_TYPE UnmapBuffer (IBuffer *pBuffer, MAP_TYPE MapType) override=0
 Base implementation of IDeviceContext::UnmapBuffer()
 
virtual void DILIGENT_CALL_TYPE UpdateTexture (ITexture *pTexture, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) override=0
 Base implementation of IDeviceContext::UpdateData(); validates input parameters.
 
virtual void DILIGENT_CALL_TYPE CopyTexture (const CopyTextureAttribs &CopyAttribs) override=0
 Base implementation of IDeviceContext::CopyTexture(); validates input parameters.
 
virtual void DILIGENT_CALL_TYPE MapTextureSubresource (ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice, MAP_TYPE MapType, MAP_FLAGS MapFlags, const Box *pMapRegion, MappedTextureSubresource &MappedData) override=0
 Base implementation of IDeviceContext::MapTextureSubresource()
 
virtual void DILIGENT_CALL_TYPE UnmapTextureSubresource (ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice) override=0
 Base implementation of IDeviceContext::UnmapTextureSubresource()
 
virtual void DILIGENT_CALL_TYPE SetUserData (IObject *pUserData) override final
 Implementation of IDeviceContext::SetUserData.
 
virtual IObject *DILIGENT_CALL_TYPE GetUserData () const override final
 Implementation of IDeviceContext::GetUserData.
 
virtual void DILIGENT_CALL_TYPE DispatchTile (const DispatchTileAttribs &Attribs) override
 Base implementation of IDeviceContext::DispatchTile.
 
virtual void DILIGENT_CALL_TYPE GetTileSize (Uint32 &TileSizeX, Uint32 &TileSizeY) override
 Base implementation of IDeviceContext::GetTileSize.
 
void GetPipelineState (IPipelineState **ppPSO, float *BlendFactors, Uint32 &StencilRef)
 Returns currently bound pipeline state and blend factors.
 
void GetRenderTargets (Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV)
 Returns currently bound render targets.
 
void GetViewports (Uint32 &NumViewports, Viewport *pViewports)
 Returns currently set viewports.
 
IRenderDeviceGetDevice ()
 Returns the render device.
 
bool UnbindTextureFromFramebuffer (TextureImplType *pTexture, bool bShowMessage)
 

Protected Member Functions

bool SetRenderTargets (const SetRenderTargetsAttribs &Attribs)
 
bool SetSubpassRenderTargets ()
 Initializes render targets for the current subpass.
 
void ClearStateCache ()
 Clears all cached resources.
 
bool CheckIfBoundAsRenderTarget (TextureImplType *pTexture)
 Checks if the texture is currently bound as a render target.
 
bool CheckIfBoundAsDepthStencil (TextureImplType *pTexture)
 Checks if the texture is currently bound as depth-stencil buffer.
 
void UpdateAttachmentStates (Uint32 SubpassIndex)
 Updates the states of render pass attachments to match states within the given subpass.
 

Protected Attributes

RefCntAutoPtr< DeviceImplType > m_pDevice
 Strong reference to the device.
 
VertexStreamInfo< BufferImplType > m_VertexStreams [MAX_BUFFER_SLOTS]
 Vertex streams. Every stream holds strong reference to the buffer.
 
Uint32 m_NumVertexStreams = 0
 Number of bound vertex streams.
 
RefCntAutoPtr< PipelineStateImplType > m_pPipelineState
 
RefCntAutoPtr< BufferImplType > m_pIndexBuffer
 
Uint64 m_IndexDataStartOffset = 0
 Offset from the beginning of the index buffer to the start of the index data, in bytes.
 
Uint32 m_StencilRef = 0
 Current stencil reference value.
 
Float32 m_BlendFactors [4] = {-1, -1, -1, -1}
 Current blend factors.
 
Viewport m_Viewports [MAX_VIEWPORTS]
 Current viewports.
 
Uint32 m_NumViewports = 0
 Number of current viewports.
 
Rect m_ScissorRects [MAX_VIEWPORTS]
 Current scissor rects.
 
Uint32 m_NumScissorRects = 0
 Number of current scissor rects.
 
RefCntAutoPtr< TextureViewImplType > m_pBoundRenderTargets [MAX_RENDER_TARGETS]
 
Uint32 m_NumBoundRenderTargets = 0
 Number of bound render targets.
 
Uint32 m_FramebufferWidth = 0
 Width of the currently bound framebuffer.
 
Uint32 m_FramebufferHeight = 0
 Height of the currently bound framebuffer.
 
Uint32 m_FramebufferSlices = 0
 Number of array slices in the currently bound framebuffer.
 
Uint32 m_FramebufferSamples = 0
 Number of samples in the currently bound framebuffer.
 
RefCntAutoPtr< TextureViewImplType > m_pBoundDepthStencil
 
RefCntAutoPtr< FramebufferImplType > m_pBoundFramebuffer
 Strong reference to the bound framebuffer.
 
RefCntAutoPtr< RenderPassImplType > m_pActiveRenderPass
 Strong reference to the render pass.
 
RefCntAutoPtr< ITextureViewm_pBoundShadingRateMap
 
Uint32 m_SubpassIndex = 0
 Current subpass index.
 
RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE
 Render pass attachments transition mode.
 

Detailed Description

template<typename EngineImplTraits>
class Diligent::DeviceContextBase< EngineImplTraits >

Base implementation of the device context.

Template Parameters
EngineImplTraits- Engine implementation traits that define specific implementation details (texture implementation type, buffer implementation type, etc.)
Remarks
Device context keeps strong references to all objects currently bound to the pipeline: buffers, textures, states, SRBs, etc. The context also keeps strong references to the device and the swap chain.

Constructor & Destructor Documentation

◆ DeviceContextBase()

template<typename EngineImplTraits>
Diligent::DeviceContextBase< EngineImplTraits >::DeviceContextBase ( IReferenceCounters * pRefCounters,
DeviceImplType * pRenderDevice,
const DeviceContextDesc & Desc )
inline
Parameters
pRefCounters- Reference counters object that controls the lifetime of this device context.
pRenderDevice- Render device.
Desc- Context description, see Diligent::DeviceContextDesc.

Member Function Documentation

◆ SetRenderTargets()

template<typename ImplementationTraits>
bool Diligent::DeviceContextBase< ImplementationTraits >::SetRenderTargets ( const SetRenderTargetsAttribs & Attribs)
inlineprotected

Caches the render target and depth stencil views. Returns true if any view is different from the cached value and false otherwise.

◆ SetVertexBuffers()

template<typename ImplementationTraits>
void Diligent::DeviceContextBase< ImplementationTraits >::SetVertexBuffers ( Uint32 StartSlot,
Uint32 NumBuffersSet,
IBuffer *const * ppBuffers,
const Uint64 * pOffsets,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
SET_VERTEX_BUFFERS_FLAGS Flags )
inlineoverridepure virtual

Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and caches references to the buffers.

Implemented in Diligent::DeviceContextD3D11Impl, Diligent::DeviceContextD3D12Impl, Diligent::DeviceContextGLImpl, Diligent::DeviceContextVkImpl, and Diligent::DeviceContextWebGPUImpl.

◆ UnbindTextureFromFramebuffer()

template<typename ImplementationTraits>
bool Diligent::DeviceContextBase< ImplementationTraits >::UnbindTextureFromFramebuffer ( TextureImplType * pTexture,
bool bShowMessage )

Checks if a texture is bound as a render target or depth-stencil buffer and resets render targets if it is.

Member Data Documentation

◆ m_pBoundDepthStencil

template<typename EngineImplTraits>
RefCntAutoPtr<TextureViewImplType> Diligent::DeviceContextBase< EngineImplTraits >::m_pBoundDepthStencil
protected

Strong references to the bound depth stencil view. Use final texture view implementation type to avoid virtual calls to AddRef()/Release()

◆ m_pBoundRenderTargets

template<typename EngineImplTraits>
RefCntAutoPtr<TextureViewImplType> Diligent::DeviceContextBase< EngineImplTraits >::m_pBoundRenderTargets[MAX_RENDER_TARGETS]
protected

Vector of strong references to the bound render targets. Use final texture view implementation type to avoid virtual calls to AddRef()/Release()

◆ m_pBoundShadingRateMap

template<typename EngineImplTraits>
RefCntAutoPtr<ITextureView> Diligent::DeviceContextBase< EngineImplTraits >::m_pBoundShadingRateMap
protected

Strong reference to the variable rate shading view. Implementation may be TextureViewImplType or IRasterizationRateMapMtl.

◆ m_pIndexBuffer

template<typename EngineImplTraits>
RefCntAutoPtr<BufferImplType> Diligent::DeviceContextBase< EngineImplTraits >::m_pIndexBuffer
protected

Strong reference to the bound index buffer. Use final buffer implementation type to avoid virtual calls to AddRef()/Release()

◆ m_pPipelineState

template<typename EngineImplTraits>
RefCntAutoPtr<PipelineStateImplType> Diligent::DeviceContextBase< EngineImplTraits >::m_pPipelineState
protected

Strong reference to the bound pipeline state object. Use final PSO implementation type to avoid virtual calls to AddRef()/Release(). We need to keep strong reference as we examine previous pipeline state in SetPipelineState()