Diligent Engine
 
Loading...
Searching...
No Matches
Diligent.IDeviceContext Struct Referenceabstract

Device context interface. More...

#include <DeviceContext.h>

Inheritance diagram for Diligent.IDeviceContext:
Diligent.IObject Diligent::IDeviceContextD3D11 Diligent::IDeviceContextD3D12 Diligent::IDeviceContextGL Diligent::IDeviceContextMtl Diligent::IDeviceContextVk Diligent::IDeviceContextWebGPU Diligent::RefCountedObject< EngineWebGPUImplTraits::DeviceContextInterface > Diligent::ObjectBase< EngineWebGPUImplTraits::DeviceContextInterface > Diligent::DeviceContextBase< EngineWebGPUImplTraits > Diligent::DeviceContextWebGPUImpl

Public Member Functions

virtual const DeviceContextDesc &DILIGENT_CALL_TYPE GetDesc () const =0
 Returns the context description.
 
virtual void DILIGENT_CALL_TYPE Begin (Uint32 ImmediateContextId)=0
 Begins recording commands in the deferred context.
 
virtual void DILIGENT_CALL_TYPE SetPipelineState (IPipelineState *pPipelineState)=0
 Sets the pipeline state.
 
virtual void DILIGENT_CALL_TYPE TransitionShaderResources (IShaderResourceBinding *pShaderResourceBinding)=0
 
virtual void DILIGENT_CALL_TYPE CommitShaderResources (IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 Commits shader resources to the device context.
 
virtual void DILIGENT_CALL_TYPE SetStencilRef (Uint32 StencilRef)=0
 Sets the stencil reference value.
 
virtual void DILIGENT_CALL_TYPE SetBlendFactors (const float *pBlendFactors=nullptr)=0
 Sets the blend factors for alpha blending.
 
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=SET_VERTEX_BUFFERS_FLAG_NONE)=0
 Binds vertex buffers to the pipeline.
 
virtual void DILIGENT_CALL_TYPE InvalidateState ()=0
 Invalidates the cached context state.
 
virtual void DILIGENT_CALL_TYPE SetIndexBuffer (IBuffer *pIndexBuffer, Uint64 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 Binds an index buffer to the pipeline.
 
virtual void DILIGENT_CALL_TYPE SetViewports (Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight)=0
 Sets an array of viewports.
 
virtual void DILIGENT_CALL_TYPE SetScissorRects (Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight)=0
 Sets active scissor rects.
 
virtual void DILIGENT_CALL_TYPE SetRenderTargets (Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 
virtual void DILIGENT_CALL_TYPE SetRenderTargetsExt (const SetRenderTargetsAttribs &Attribs)=0
 
virtual void DILIGENT_CALL_TYPE BeginRenderPass (const BeginRenderPassAttribs &Attribs)=0
 Begins a new render pass.
 
virtual void DILIGENT_CALL_TYPE NextSubpass ()=0
 Transitions to the next subpass in the render pass instance.
 
virtual void DILIGENT_CALL_TYPE EndRenderPass ()=0
 Ends current render pass.
 
virtual void DILIGENT_CALL_TYPE Draw (const DrawAttribs &Attribs)=0
 Executes a draw command.
 
virtual void DILIGENT_CALL_TYPE DrawIndexed (const DrawIndexedAttribs &Attribs)=0
 Executes an indexed draw command.
 
virtual void DILIGENT_CALL_TYPE DrawIndirect (const DrawIndirectAttribs &Attribs)=0
 Executes an indirect draw command.
 
virtual void DILIGENT_CALL_TYPE DrawIndexedIndirect (const DrawIndexedIndirectAttribs &Attribs)=0
 Executes an indexed indirect draw command.
 
virtual void DILIGENT_CALL_TYPE DrawMesh (const DrawMeshAttribs &Attribs)=0
 Executes a mesh draw command.
 
virtual void DILIGENT_CALL_TYPE DrawMeshIndirect (const DrawMeshIndirectAttribs &Attribs)=0
 Executes an indirect mesh draw command.
 
virtual void DILIGENT_CALL_TYPE MultiDraw (const MultiDrawAttribs &Attribs)=0
 Executes a multi-draw command.
 
virtual void DILIGENT_CALL_TYPE MultiDrawIndexed (const MultiDrawIndexedAttribs &Attribs)=0
 Executes an indexed multi-draw command.
 
virtual void DILIGENT_CALL_TYPE DispatchCompute (const DispatchComputeAttribs &Attribs)=0
 Executes a dispatch compute command.
 
virtual void DILIGENT_CALL_TYPE DispatchComputeIndirect (const DispatchComputeIndirectAttribs &Attribs)=0
 Executes an indirect dispatch compute command.
 
virtual void DILIGENT_CALL_TYPE DispatchTile (const DispatchTileAttribs &Attribs)=0
 Executes a dispatch tile command.
 
virtual void DILIGENT_CALL_TYPE GetTileSize (Uint32 &TileSizeX, Uint32 &TileSizeY)=0
 Returns current render pass tile size.
 
virtual void DILIGENT_CALL_TYPE ClearDepthStencil (ITextureView *pView, CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, float fDepth, Uint8 Stencil, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 Clears a depth-stencil view.
 
virtual void DILIGENT_CALL_TYPE ClearRenderTarget (ITextureView *pView, const void *RGBA, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 Clears a render target view.
 
virtual void DILIGENT_CALL_TYPE FinishCommandList (ICommandList **ppCommandList)=0
 Finishes recording commands and generates a command list.
 
virtual void DILIGENT_CALL_TYPE ExecuteCommandLists (Uint32 NumCommandLists, ICommandList *const *ppCommandLists)=0
 Submits an array of recorded command lists for execution.
 
virtual void DILIGENT_CALL_TYPE EnqueueSignal (IFence *pFence, Uint64 Value)=0
 Tells the GPU to set a fence to a specified value after all previous work has completed.
 
virtual void DILIGENT_CALL_TYPE DeviceWaitForFence (IFence *pFence, Uint64 Value)=0
 Waits until the specified fence reaches or exceeds the specified value, on the device.
 
virtual void DILIGENT_CALL_TYPE WaitForIdle ()=0
 Submits all outstanding commands for execution to the GPU and waits until they are complete.
 
virtual void DILIGENT_CALL_TYPE BeginQuery (IQuery *pQuery)=0
 Marks the beginning of a query.
 
virtual void DILIGENT_CALL_TYPE EndQuery (IQuery *pQuery)=0
 Marks the end of a query.
 
virtual void DILIGENT_CALL_TYPE Flush ()=0
 Submits all pending commands in the context for execution to the command queue.
 
virtual void DILIGENT_CALL_TYPE UpdateBuffer (IBuffer *pBuffer, Uint64 Offset, Uint64 Size, const void *pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)=0
 Updates the data in the buffer.
 
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)=0
 Copies the data from one buffer to another.
 
virtual void DILIGENT_CALL_TYPE MapBuffer (IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid &pMappedData)=0
 Maps the buffer.
 
virtual void DILIGENT_CALL_TYPE UnmapBuffer (IBuffer *pBuffer, MAP_TYPE MapType)=0
 Unmaps the previously mapped buffer.
 
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)=0
 Updates the data in the texture.
 
virtual void DILIGENT_CALL_TYPE CopyTexture (const CopyTextureAttribs &CopyAttribs)=0
 Copies data from one texture to another.
 
virtual void DILIGENT_CALL_TYPE MapTextureSubresource (ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice, MAP_TYPE MapType, MAP_FLAGS MapFlags, const Box *pMapRegion, MappedTextureSubresource &MappedData)=0
 Maps the texture subresource.
 
virtual void DILIGENT_CALL_TYPE UnmapTextureSubresource (ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice)=0
 Unmaps the texture subresource.
 
virtual void DILIGENT_CALL_TYPE GenerateMips (ITextureView *pTextureView)=0
 Generates a mipmap chain.
 
virtual void DILIGENT_CALL_TYPE FinishFrame ()=0
 Finishes the current frame and releases dynamic resources allocated by the context.
 
virtual Uint64 DILIGENT_CALL_TYPE GetFrameNumber () const =0
 Returns the current frame number.
 
virtual void DILIGENT_CALL_TYPE TransitionResourceStates (Uint32 BarrierCount, const StateTransitionDesc *pResourceBarriers)=0
 Transitions resource states.
 
virtual void DILIGENT_CALL_TYPE ResolveTextureSubresource (ITexture *pSrcTexture, ITexture *pDstTexture, const ResolveTextureSubresourceAttribs &ResolveAttribs)=0
 Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource.
 
virtual void DILIGENT_CALL_TYPE BuildBLAS (const BuildBLASAttribs &Attribs)=0
 Builds a bottom-level acceleration structure with the specified geometries.
 
virtual void DILIGENT_CALL_TYPE BuildTLAS (const BuildTLASAttribs &Attribs)=0
 Builds a top-level acceleration structure with the specified instances.
 
virtual void DILIGENT_CALL_TYPE CopyBLAS (const CopyBLASAttribs &Attribs)=0
 Copies data from one acceleration structure to another.
 
virtual void DILIGENT_CALL_TYPE CopyTLAS (const CopyTLASAttribs &Attribs)=0
 Copies data from one acceleration structure to another.
 
virtual void DILIGENT_CALL_TYPE WriteBLASCompactedSize (const WriteBLASCompactedSizeAttribs &Attribs)=0
 Writes a bottom-level acceleration structure memory size required for compacting operation to a buffer.
 
virtual void DILIGENT_CALL_TYPE WriteTLASCompactedSize (const WriteTLASCompactedSizeAttribs &Attribs)=0
 Writes a top-level acceleration structure memory size required for compacting operation to a buffer.
 
virtual void DILIGENT_CALL_TYPE TraceRays (const TraceRaysAttribs &Attribs)=0
 Executes a trace rays command.
 
virtual void DILIGENT_CALL_TYPE TraceRaysIndirect (const TraceRaysIndirectAttribs &Attribs)=0
 Executes an indirect trace rays command.
 
virtual void DILIGENT_CALL_TYPE UpdateSBT (IShaderBindingTable *pSBT, const UpdateIndirectRTBufferAttribs *pUpdateIndirectBufferAttribs=nullptr)=0
 Updates SBT with the pending data that were recorded in IShaderBindingTable::Bind*** calls.
 
virtual void DILIGENT_CALL_TYPE SetUserData (IObject *pUserData)=0
 Stores a pointer to the user-provided data object.
 
virtual IObject *DILIGENT_CALL_TYPE GetUserData () const =0
 Returns a pointer to the user data object previously.
 
virtual void DILIGENT_CALL_TYPE BeginDebugGroup (const Char *Name, const float *pColor=nullptr)=0
 Begins a debug group with name and color.
 
virtual void DILIGENT_CALL_TYPE EndDebugGroup ()=0
 Ends a debug group that was previously started with BeginDebugGroup().
 
virtual void DILIGENT_CALL_TYPE InsertDebugLabel (const Char *Label, const float *pColor=nullptr)=0
 Inserts a debug label with name and color.
 
virtual ICommandQueue *DILIGENT_CALL_TYPE LockCommandQueue ()=0
 Locks the internal mutex and returns a pointer to the command queue that is associated with this device context.
 
virtual void DILIGENT_CALL_TYPE UnlockCommandQueue ()=0
 Unlocks the command queue that was previously locked by LockCommandQueue().
 
virtual void DILIGENT_CALL_TYPE SetShadingRate (SHADING_RATE BaseRate, SHADING_RATE_COMBINER PrimitiveCombiner, SHADING_RATE_COMBINER TextureCombiner)=0
 Sets the shading base rate and combiners.
 
virtual void DILIGENT_CALL_TYPE BindSparseResourceMemory (const BindSparseResourceMemoryAttribs &Attribs)=0
 Binds or unbinds memory objects to sparse buffer and sparse textures.
 
virtual void DILIGENT_CALL_TYPE ClearStats ()=0
 Clears the device context statistics.
 
virtual const DeviceContextStats &DILIGENT_CALL_TYPE GetStats () const =0
 Returns the device context statistics, see Diligent::DeviceContextStats.
 
- Public Member Functions inherited from Diligent.IObject
virtual void DILIGENT_CALL_TYPE QueryInterface (const INTERFACE_ID &IID, IObject **ppInterface)=0
 Queries the specific interface.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE AddRef ()=0
 Increments the number of strong references by 1.
 
virtual ReferenceCounterValueType DILIGENT_CALL_TYPE Release ()=0
 
virtual IReferenceCounters *DILIGENT_CALL_TYPE GetReferenceCounters () const =0
 

Detailed Description

Device context interface.

Remarks
Device context keeps strong references to all objects currently bound to the pipeline: buffers, states, samplers, shaders, etc. The context also keeps strong reference to the device and the swap chain.

Member Function Documentation

◆ Begin()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.Begin ( Uint32 ImmediateContextId)
pure virtual

Begins recording commands in the deferred context.

This method must be called before any command in the deferred context may be recorded.

Parameters
[in]ImmediateContextId- the ID of the immediate context where commands from this deferred context will be executed, see Diligent::DeviceContextDesc::ContextId.
Warning
Command list recorded by the context must not be submitted to any other immediate context other than one identified by ImmediateContextId.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BeginDebugGroup()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BeginDebugGroup ( const Char * Name,
const float * pColor = nullptr )
pure virtual

Begins a debug group with name and color.

External debug tools may use this information when displaying context commands.

Parameters
[in]Name- Group name.
[in]pColor- Region color.
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BeginQuery()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BeginQuery ( IQuery * pQuery)
pure virtual

Marks the beginning of a query.

Parameters
[in]pQuery- A pointer to a query object.
Remarks
Only immediate contexts can begin a query.

Vulkan requires that a query must either begin and end inside the same subpass of a render pass instance, or must both begin and end outside of a render pass instance. This means that an application must either begin and end a query while preserving render targets, or begin it when no render targets are bound to the context. In the latter case the engine will automatically end the render pass, if needed, when the query is ended. Also note that resource transitions must be performed outside of a render pass, and may thus require ending current render pass. To explicitly end current render pass, call SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE).

Warning
OpenGL and Vulkan do not support nested queries of the same type.
Note
On some devices, queries for a single draw or dispatch command may not be supported. In this case, the query will begin at the next available moment (for example, when the next render pass begins or ends).
Remarks
Supported contexts for graphics queries: graphics. Supported contexts for time queries: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BeginRenderPass()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BeginRenderPass ( const BeginRenderPassAttribs & Attribs)
pure virtual

Begins a new render pass.

Parameters
[in]Attribs- The command attributes, see Diligent::BeginRenderPassAttribs for details.
Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BindSparseResourceMemory()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BindSparseResourceMemory ( const BindSparseResourceMemoryAttribs & Attribs)
pure virtual

Binds or unbinds memory objects to sparse buffer and sparse textures.

Parameters
[in]Attribs- command attributes, see Diligent::BindSparseResourceMemoryAttribs.
  • Metal backend: since resource uses a single preallocated memory storage, memory offset is ignored and the driver acquires any free memory block from the storage. If there is no free memory in the storage, the region remains unbound. Access to the device memory object on the GPU side must be explicitly synchronized using fences.
  • Direct3D12, Vulkan and Metal backends require explicitly synchronizing access to the resource using fences or by WaitForIdle().

This command implicitly calls Flush().

Remarks
This command may only be executed by immediate context whose internal queue supports COMMAND_QUEUE_TYPE_SPARSE_BINDING.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BuildBLAS()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BuildBLAS ( const BuildBLASAttribs & Attribs)
pure virtual

Builds a bottom-level acceleration structure with the specified geometries.

Parameters
[in]Attribs- Structure describing build BLAS command attributes, see Diligent::BuildBLASAttribs for details.
Note
Don't call build or copy operation on the same BLAS in a different contexts, because BLAS has CPU-side data that will not match with GPU-side, so shader binding were incorrect.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ BuildTLAS()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.BuildTLAS ( const BuildTLASAttribs & Attribs)
pure virtual

Builds a top-level acceleration structure with the specified instances.

Parameters
[in]Attribs- Structure describing build TLAS command attributes, see Diligent::BuildTLASAttribs for details.
Note
Don't call build or copy operation on the same TLAS in a different contexts, because TLAS has CPU-side data that will not match with GPU-side, so shader binding were incorrect.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ ClearDepthStencil()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.ClearDepthStencil ( ITextureView * pView,
CLEAR_DEPTH_STENCIL_FLAGS ClearFlags,
float fDepth,
Uint8 Stencil,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Clears a depth-stencil view.

Parameters
[in]pView- Pointer to ITextureView interface to clear. The view type must be Diligent::TEXTURE_VIEW_DEPTH_STENCIL.
[in]StateTransitionMode- state transition mode of the depth-stencil buffer to clear.
[in]ClearFlags- Indicates which parts of the buffer to clear, see Diligent::CLEAR_DEPTH_STENCIL_FLAGS.
[in]fDepth- Value to clear depth part of the view with.
[in]Stencil- Value to clear stencil part of the view with.
Remarks
The full extent of the view is always cleared. Viewport and scissor settings are not applied.
Note
The depth-stencil view must be bound to the pipeline for clear operation to be performed.

When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will transition the state of the texture to the state required by clear operation. In Direct3D12, this state is always Diligent::RESOURCE_STATE_DEPTH_WRITE, however in Vulkan the state depends on whether the depth buffer is bound to the pipeline.

Resource state transitioning is not thread-safe, so no other thread is allowed to read or write the state of resources used by the command.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ ClearRenderTarget()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.ClearRenderTarget ( ITextureView * pView,
const void * RGBA,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Clears a render target view.

Parameters
[in]pView- Pointer to ITextureView interface to clear. The view type must be Diligent::TEXTURE_VIEW_RENDER_TARGET.
[in]RGBA- A 4-component array that represents the color to fill the render target with:
  • Float values for floating point render target formats.
  • Uint32 values for unsigned integer render target formats.
  • Int32 values for signed integer render target formats. If nullptr is provided, the default array {0,0,0,0} will be used.
[in]StateTransitionMode- Defines required state transitions (see Diligent::RESOURCE_STATE_TRANSITION_MODE)

The full extent of the view is always cleared. Viewport and scissor settings are not applied.

Note
The render target view must be bound to the pipeline for clear operation to be performed in OpenGL backend.

When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will transition the texture to the state required by the command. Resource state transitioning is not thread safe, so no other thread is allowed to read or write the states of the same textures.

If the application intends to use the same resource in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

In D3D12 backend, clearing render targets requires textures to always be transitioned to Diligent::RESOURCE_STATE_RENDER_TARGET state. In Vulkan backend however this depends on whether a render pass has been started. To clear render target outside of a render pass, the texture must be transitioned to Diligent::RESOURCE_STATE_COPY_DEST state. Inside a render pass it must be in Diligent::RESOURCE_STATE_RENDER_TARGET state. When using Diligent::RESOURCE_STATE_TRANSITION_TRANSITION mode, the engine takes care of proper resource state transition, otherwise it is the responsibility of the application.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ CommitShaderResources()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.CommitShaderResources ( IShaderResourceBinding * pShaderResourceBinding,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Commits shader resources to the device context.

Parameters
[in]pShaderResourceBinding- Shader resource binding whose resources will be committed. If pipeline state contains no shader resources, this parameter can be null.
[in]StateTransitionMode- State transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE).

If Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION mode is used, the engine will also transition all shader resources to required states. If the flag is not set, it is assumed that all resources are already in correct states.
Resources can be explicitly transitioned to required states by calling TransitionShaderResources() or TransitionResourceStates().

Remarks
Automatic resource state transitioning is not thread-safe.

If the application intends to use the same resources in other threads simultaneously, it should manage the states manually by setting the state to Diligent::RESOURCE_STATE_UNKNOWN (which will disable automatic state management) using IBuffer::SetState() or ITexture::SetState() and explicitly transitioning the states with TransitionResourceStates().

If an application calls any method that changes the state of any resource after it has been committed, the application is responsible for transitioning the resource back to correct state using one of the available methods before issuing the next draw or dispatch command.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ CopyBLAS()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.CopyBLAS ( const CopyBLASAttribs & Attribs)
pure virtual

Copies data from one acceleration structure to another.

Parameters
[in]Attribs- Structure describing copy BLAS command attributes, see Diligent::CopyBLASAttribs for details.
Note
Don't call build or copy operation on the same BLAS in a different contexts, because BLAS has CPU-side data that will not match with GPU-side, so shader binding were incorrect.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ CopyBuffer()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.CopyBuffer ( IBuffer * pSrcBuffer,
Uint64 SrcOffset,
RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
IBuffer * pDstBuffer,
Uint64 DstOffset,
Uint64 Size,
RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode )
pure virtual

Copies the data from one buffer to another.

Parameters
[in]pSrcBuffer- Source buffer to copy data from.
[in]SrcOffset- Offset in bytes from the beginning of the source buffer to the beginning of data to copy.
[in]SrcBufferTransitionMode- State transition mode of the source buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
[in]pDstBuffer- Destination buffer to copy data to.
[in]DstOffset- Offset in bytes from the beginning of the destination buffer to the beginning of the destination region.
[in]Size- Size in bytes of data to copy.
[in]DstBufferTransitionMode- State transition mode of the destination buffer (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ CopyTexture()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.CopyTexture ( const CopyTextureAttribs & CopyAttribs)
pure virtual

Copies data from one texture to another.

Parameters
[in]CopyAttribs- Structure describing copy command attributes, see Diligent::CopyTextureAttribs for details.
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ CopyTLAS()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.CopyTLAS ( const CopyTLASAttribs & Attribs)
pure virtual

Copies data from one acceleration structure to another.

Parameters
[in]Attribs- Structure describing copy TLAS command attributes, see Diligent::CopyTLASAttribs for details.
Note
Don't call build or copy operation on the same TLAS in a different contexts, because TLAS has CPU-side data that will not match with GPU-side, so shader binding were incorrect.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DeviceWaitForFence()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DeviceWaitForFence ( IFence * pFence,
Uint64 Value )
pure virtual

Waits until the specified fence reaches or exceeds the specified value, on the device.

Parameters
[in]pFence- The fence to wait. Fence must be created with type FENCE_TYPE_GENERAL.
[in]Value- The value that the context is waiting for the fence to reach.

If NativeFence feature is not enabled (see Diligent::DeviceFeatures) then Value must be less than or equal to the last signaled or pending value. Value becomes pending when the context is flushed. Waiting for a value that is greater than any pending value will cause a deadlock.

Note
If NativeFence feature is enabled then waiting for a value that is greater than any pending value will cause a GPU stall.

In Direct3D12 and Vulkan backend, the access to the fence is thread-safe.

Remarks
Wait is only allowed for immediate contexts.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DispatchCompute()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DispatchCompute ( const DispatchComputeAttribs & Attribs)
pure virtual

Executes a dispatch compute command.

Parameters
[in]Attribs- Dispatch command attributes, see Diligent::DispatchComputeAttribs for details.

In Metal, the compute group sizes are defined by the dispatch command rather than by the compute shader. When the shader is compiled from HLSL or GLSL, the engine will use the group size information from the shader. When using MSL, an application should provide the compute group dimensions through MtlThreadGroupSizeX, MtlThreadGroupSizeY, and MtlThreadGroupSizeZ members.

Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DispatchComputeIndirect()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DispatchComputeIndirect ( const DispatchComputeIndirectAttribs & Attribs)
pure virtual

Executes an indirect dispatch compute command.

Parameters
[in]Attribs- The command attributes, see Diligent::DispatchComputeIndirectAttribs for details.

If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method may transition the state of indirect dispatch arguments buffer. This is not a thread safe operation, so no other thread is allowed to read or write the state of the same resource.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

In Metal, the compute group sizes are defined by the dispatch command rather than by the compute shader. When the shader is compiled from HLSL or GLSL, the engine will use the group size information from the shader. When using MSL, an application should provide the compute group dimensions through MtlThreadGroupSizeX, MtlThreadGroupSizeY, and MtlThreadGroupSizeZ members.

Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DispatchTile()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DispatchTile ( const DispatchTileAttribs & Attribs)
pure virtual

Executes a dispatch tile command.

Parameters
[in]Attribs- The command attributes, see Diligent::DispatchTileAttribs for details.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >.

◆ Draw()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.Draw ( const DrawAttribs & Attribs)
pure virtual

Executes a draw command.

Parameters
[in]Attribs- Draw command attributes, see Diligent::DrawAttribs for details.

If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex buffers, so no other threads are allowed to alter the states of the same resources. It is OK to read these states.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DrawIndexed()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DrawIndexed ( const DrawIndexedAttribs & Attribs)
pure virtual

Executes an indexed draw command.

Parameters
[in]Attribs- Draw command attributes, see Diligent::DrawIndexedAttribs for details.

If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index buffers, so no other threads are allowed to alter the states of the same resources. It is OK to read these states.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DrawIndexedIndirect()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DrawIndexedIndirect ( const DrawIndexedIndirectAttribs & Attribs)
pure virtual

Executes an indexed indirect draw command.

Parameters
[in]Attribs- Structure describing the command attributes, see Diligent::DrawIndexedIndirectAttribs for details.

Draw command arguments are read from the attributes buffer at the offset given by Attribs.IndirectDrawArgsOffset. If Attribs.DrawCount > 1, the arguments for command N will be read at the offset

Attribs.IndirectDrawArgsOffset + N * Attribs.IndirectDrawArgsStride.

If pCountBuffer is not null, the number of commands to execute will be read from the buffer at the offset given by Attribs.CounterOffset. The number of commands will be the lesser of the value read from the buffer and Attribs.DrawCount:

NumCommands = min(CountBuffer[Attribs.CounterOffset], Attribs.DrawCount)

If Attribs.IndirectAttribsBufferStateTransitionMode or Attribs.CounterBufferStateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method may transition the state of the indirect draw arguments buffer, and the state of the counter buffer . This is not a thread safe operation, so no other thread is allowed to read or write the state of the buffer.

If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index buffers, so no other threads are allowed to alter the states of the same resources. It is OK to read these states.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
In OpenGL backend, index buffer offset set by SetIndexBuffer() can't be applied in indirect draw command and must be zero.
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DrawIndirect()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DrawIndirect ( const DrawIndirectAttribs & Attribs)
pure virtual

Executes an indirect draw command.

Parameters
[in]Attribs- Structure describing the command attributes, see Diligent::DrawIndirectAttribs for details.

Draw command arguments are read from the attributes buffer at the offset given by Attribs.IndirectDrawArgsOffset. If Attribs.DrawCount > 1, the arguments for command N will be read at the offset

Attribs.IndirectDrawArgsOffset + N * Attribs.IndirectDrawArgsStride.

If pCountBuffer is not null, the number of commands to execute will be read from the buffer at the offset given by Attribs.CounterOffset. The number of commands will be the lesser of the value read from the buffer and Attribs.DrawCount:

NumCommands = min(CountBuffer[Attribs.CounterOffset], Attribs.DrawCount)

If Attribs.IndirectAttribsBufferStateTransitionMode or Attribs.CounterBufferStateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method may transition the state of the indirect draw arguments buffer, and the state of the counter buffer . This is not a thread safe operation, so no other thread is allowed to read or write the state of the buffer.

If Diligent::DRAW_FLAG_VERIFY_STATES flag is set, the method reads the state of vertex/index buffers, so no other threads are allowed to alter the states of the same resources. It is OK to read these states.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DrawMesh()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DrawMesh ( const DrawMeshAttribs & Attribs)
pure virtual

Executes a mesh draw command.

Parameters
[in]Attribs- Draw command attributes, see Diligent::DrawMeshAttribs for details.

For compatibility between Direct3D12 and Vulkan, only a single work group dimension is used. Also in the shader, numthreads and local_size attributes must define only the first dimension, for example: [numthreads(ThreadCount, 1, 1)] or layout(local_size_x = ThreadCount) in.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ DrawMeshIndirect()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.DrawMeshIndirect ( const DrawMeshIndirectAttribs & Attribs)
pure virtual

Executes an indirect mesh draw command.

Parameters
[in]Attribs- Structure describing the command attributes, see Diligent::DrawMeshIndirectAttribs for details.

For compatibility between Direct3D12 and Vulkan and with direct call (DrawMesh) use the first element in the structure, for example:

  • Direct3D12 {TaskCount, 1, 1}
  • Vulkan {TaskCount, 0}.

If IndirectAttribsBufferStateTransitionMode member is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method may transition the state of the indirect draw arguments buffer. This is not a thread safe operation, so no other thread is allowed to read or write the state of the buffer.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ EndQuery()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.EndQuery ( IQuery * pQuery)
pure virtual

Marks the end of a query.

Parameters
[in]pQuery- A pointer to a query object.
Remarks
A query must be ended by the same context that began it.

In Direct3D12 and Vulkan, queries (except for timestamp queries) cannot span command list boundaries, so the engine will never flush the context even if the number of commands exceeds the user-specified limit when there is an active query. It is an error to explicitly flush the context while a query is active.

All queries must be ended when FinishFrame() is called.

Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ EndRenderPass()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.EndRenderPass ( )
pure virtual

Ends current render pass.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ EnqueueSignal()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.EnqueueSignal ( IFence * pFence,
Uint64 Value )
pure virtual

Tells the GPU to set a fence to a specified value after all previous work has completed.

Parameters
[in]pFence- The fence to signal.
[in]Value- The value to set the fence to. This value must be greater than the previously signaled value on the same fence.
Note
The method does not flush the context (an application can do this explicitly if needed) and the fence will be signaled only when the command context is flushed next time. If an application needs to wait for the fence in a loop, it must flush the context after signalling the fence.
  • In Direct3D11 backend, the access to the fence is not thread-safe and must be externally synchronized.
  • In Direct3D12 and Vulkan backends, the access to the fence is thread-safe.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ ExecuteCommandLists()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.ExecuteCommandLists ( Uint32 NumCommandLists,
ICommandList *const * ppCommandLists )
pure virtual

Submits an array of recorded command lists for execution.

Parameters
[in]NumCommandLists- The number of command lists to execute.
[in]ppCommandLists- Pointer to the array of NumCommandLists command lists to execute.
Remarks
After a command list is executed, it is no longer valid and must be released.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ FinishCommandList()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.FinishCommandList ( ICommandList ** ppCommandList)
pure virtual

Finishes recording commands and generates a command list.

Parameters
[out]ppCommandList- Memory location where pointer to the recorded command list will be written.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ FinishFrame()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.FinishFrame ( )
pure virtual

Finishes the current frame and releases dynamic resources allocated by the context.

For immediate context, this method is called automatically by ISwapChain::Present() of the primary swap chain, but can also be called explicitly. For deferred contexts, the method must be called by the application to release dynamic resources. The method has some overhead, so it is better to call it once per frame, though it can be called with different frequency. Note that unless the GPU is idled, the resources may actually be released several frames after the one they were used in last time.

Note
After the call all dynamic resources become invalid and must be written again before the next use. Also, all committed resources become invalid.

For deferred contexts, this method must be called after all command lists referencing dynamic resources have been executed through immediate context.

The method does not Flush() the context.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ Flush()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.Flush ( )
pure virtual

Submits all pending commands in the context for execution to the command queue.

Only immediate contexts can be flushed.

Internally the method resets the state of the current command list/buffer. When the next draw command is issued, the engine will restore all states (rebind render targets and depth-stencil buffer as well as index and vertex buffers, restore viewports and scissor rects, etc.) except for the pipeline state and shader resource bindings. An application must explicitly reset the PSO and bind all required shader resources after flushing the context.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ GenerateMips()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.GenerateMips ( ITextureView * pTextureView)
pure virtual

Generates a mipmap chain.

Parameters
[in]pTextureView- Texture view to generate mip maps for.
Remarks
This function can only be called for a shader resource view. The texture must be created with Diligent::MISC_TEXTURE_FLAG_GENERATE_MIPS flag.
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ GetFrameNumber()

virtual Uint64 DILIGENT_CALL_TYPE Diligent.IDeviceContext.GetFrameNumber ( ) const
pure virtual

Returns the current frame number.

Note
The frame number is incremented every time FinishFrame() is called.

◆ GetTileSize()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.GetTileSize ( Uint32 & TileSizeX,
Uint32 & TileSizeY )
pure virtual

Returns current render pass tile size.

Parameters
[out]TileSizeX- Tile size in X direction.
[out]TileSizeY- Tile size in Y direction.
Remarks
Result will be zero if there are no active render pass or render targets.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >.

◆ GetUserData()

virtual IObject *DILIGENT_CALL_TYPE Diligent.IDeviceContext.GetUserData ( ) const
pure virtual

Returns a pointer to the user data object previously.

set with SetUserData() method.

Returns
The pointer to the user data object.
Remarks
The method does NOT call AddRef() for the object being returned.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >.

◆ InsertDebugLabel()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.InsertDebugLabel ( const Char * Label,
const float * pColor = nullptr )
pure virtual

Inserts a debug label with name and color.

External debug tools may use this information when displaying context commands.

Parameters
[in]Label- Label name.
[in]pColor- Label color.
Remarks
Supported contexts: graphics, compute, transfer. Not supported in Metal backend.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ InvalidateState()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.InvalidateState ( )
pure virtual

Invalidates the cached context state.

This method should be called by an application to invalidate internal cached states.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ LockCommandQueue()

virtual ICommandQueue *DILIGENT_CALL_TYPE Diligent.IDeviceContext.LockCommandQueue ( )
pure virtual

Locks the internal mutex and returns a pointer to the command queue that is associated with this device context.

Returns
A pointer to ICommandQueue interface of the command queue associated with the context.

Only immediate device contexts have associated command queues.

The engine locks the internal mutex to prevent simultaneous access to the command queue. An application must release the lock by calling UnlockCommandQueue() when it is done working with the queue or the engine will not be able to submit any command list to the queue. Nested calls to LockCommandQueue() are not allowed. The queue pointer never changes while the context is alive, so an application may cache and use the pointer if it does not need to prevent potential simultaneous access to the queue from other threads.

The engine manages the lifetimes of command queues and all other device objects, so an application must not call AddRef/Release methods on the returned interface.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ MapBuffer()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.MapBuffer ( IBuffer * pBuffer,
MAP_TYPE MapType,
MAP_FLAGS MapFlags,
PVoid & pMappedData )
pure virtual

Maps the buffer.

Parameters
[in]pBuffer- Pointer to the buffer to map.
[in]MapType- Type of the map operation. See Diligent::MAP_TYPE.
[in]MapFlags- Special map flags. See Diligent::MAP_FLAGS.
[out]pMappedData- Reference to the void pointer to store the address of the mapped region.
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ MapTextureSubresource()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.MapTextureSubresource ( ITexture * pTexture,
Uint32 MipLevel,
Uint32 ArraySlice,
MAP_TYPE MapType,
MAP_FLAGS MapFlags,
const Box * pMapRegion,
MappedTextureSubresource & MappedData )
pure virtual

Maps the texture subresource.

Parameters
[in]pTexture- Pointer to the texture to map.
[in]MipLevel- Mip level to map.
[in]ArraySlice- Array slice to map. This parameter must be 0 for non-array textures.
[in]MapType- Type of the map operation. See Diligent::MAP_TYPE.
[in]MapFlags- Special map flags. See Diligent::MAP_FLAGS.
[in]pMapRegion- Texture region to map. If this parameter is null, the entire subresource is mapped.
[out]MappedData- Mapped texture region data

This method is supported in D3D11, D3D12 and Vulkan backends. In D3D11 backend, only the entire subresource can be mapped, so pMapRegion must either be null, or cover the entire subresource. In D3D11 and Vulkan backends, dynamic textures are no different from non-dynamic textures, and mapping with MAP_FLAG_DISCARD has exactly the same behavior.

Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ MultiDraw()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.MultiDraw ( const MultiDrawAttribs & Attribs)
pure virtual

Executes a multi-draw command.

Parameters
[in]Attribs- Multi-draw command attributes, see Diligent::MultiDrawAttribs for details.

If the device does not support the NativeMultiDraw feature, the method will emulate it by issuing a sequence of individual draw commands. Note that draw command index is only available in the shader when the NativeMultiDraw feature is supported.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ MultiDrawIndexed()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.MultiDrawIndexed ( const MultiDrawIndexedAttribs & Attribs)
pure virtual

Executes an indexed multi-draw command.

Parameters
[in]Attribs- Multi-draw command attributes, see Diligent::MultiDrawIndexedAttribs for details.

If the device does not support the NativeMultiDraw feature, the method will emulate it by issuing a sequence of individual draw commands. Note that draw command index is only available in the shader when the NativeMultiDraw feature is supported.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ NextSubpass()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.NextSubpass ( )
pure virtual

Transitions to the next subpass in the render pass instance.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ ResolveTextureSubresource()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.ResolveTextureSubresource ( ITexture * pSrcTexture,
ITexture * pDstTexture,
const ResolveTextureSubresourceAttribs & ResolveAttribs )
pure virtual

Resolves a multi-sampled texture subresource into a non-multi-sampled texture subresource.

Parameters
[in]pSrcTexture- Source multi-sampled texture.
[in]pDstTexture- Destination non-multi-sampled texture.
[in]ResolveAttribs- Resolve command attributes, see Diligent::ResolveTextureSubresourceAttribs for details.
Remarks
Supported contexts: graphics.ResolveTextureSubresource

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetBlendFactors()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetBlendFactors ( const float * pBlendFactors = nullptr)
pure virtual

Sets the blend factors for alpha blending.

Parameters
[in]pBlendFactors- Array of four blend factors, one for each RGBA component. These factors are used if the blend state uses one of the Diligent::BLEND_FACTOR_BLEND_FACTOR or Diligent::BLEND_FACTOR_INV_BLEND_FACTOR blend factors. If nullptr is provided, default blend factors array {1, 1, 1, 1} will be used.
Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetIndexBuffer()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetIndexBuffer ( IBuffer * pIndexBuffer,
Uint64 ByteOffset,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Binds an index buffer to the pipeline.

Parameters
[in]pIndexBuffer- Pointer to the index buffer. The buffer must have been created with the Diligent::BIND_INDEX_BUFFER flag.
[in]ByteOffset- Offset from the beginning of the buffer to the start of index data.
[in]StateTransitionMode- State transition mode for the index buffer to bind (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
Remarks
The device context keeps strong reference to the index buffer. Thus an index buffer object cannot be released until it is unbound from the context.

When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will transition the buffer to Diligent::RESOURCE_STATE_INDEX_BUFFER (if its state is not unknown). Resource state transitioning is not thread-safe, so no other thread is allowed to read or write the state of the buffer.

If the application intends to use the same resource in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ SetPipelineState()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetPipelineState ( IPipelineState * pPipelineState)
pure virtual

Sets the pipeline state.

Parameters
[in]pPipelineState- Pointer to IPipelineState interface to bind to the context.
Remarks
  • Supported contexts for graphics and mesh pipeline: graphics.
  • Supported contexts for compute and ray tracing pipeline: graphics and compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetRenderTargets()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetRenderTargets ( Uint32 NumRenderTargets,
ITextureView * ppRenderTargets[],
ITextureView * pDepthStencil,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Binds one or more render targets and the depth-stencil buffer to the context. It also sets the viewport to match the first non-null render target or depth-stencil buffer.

Parameters
[in]NumRenderTargets- Number of render targets to bind.
[in]ppRenderTargets- Array of pointers to ITextureView that represent the render targets to bind to the device. The type of each view in the array must be Diligent::TEXTURE_VIEW_RENDER_TARGET.
[in]pDepthStencil- Pointer to the ITextureView that represents the depth stencil to bind to the device. The view type must be Diligent::TEXTURE_VIEW_DEPTH_STENCIL or Diligent::TEXTURE_VIEW_READ_ONLY_DEPTH_STENCIL.
[in]StateTransitionMode- State transition mode of the render targets and depth stencil buffer being set (see Diligent::RESOURCE_STATE_TRANSITION_MODE).

The device context will keep strong references to all bound render target and depth-stencil views. Thus these views (and consequently referenced textures) cannot be released until they are unbound from the context.

Any render targets not defined by this call are set to nullptr.

When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will transition all render targets in known states to Diligent::RESOURCE_STATE_RENDER_TARGET, and the depth-stencil buffer to Diligent::RESOURCE_STATE_DEPTH_WRITE state. Resource state transitioning is not thread-safe, so no other thread is allowed to read or write the states of resources used by the command.

If the application intends to use the same resource in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >.

◆ SetRenderTargetsExt()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetRenderTargetsExt ( const SetRenderTargetsAttribs & Attribs)
pure virtual

Binds one or more render targets, the depth-stencil buffer and shading rate map to the context. It also sets the viewport to match the first non-null render target or depth-stencil buffer.

Parameters
[in]Attribs- The command attributes, see Diligent::SetRenderTargetsAttribs for details.

The device context will keep strong references to all bound render target and depth-stencil views as well as to shading rate map. Thus these views (and consequently referenced textures) cannot be released until they are unbound from the context.

Any render targets not defined by this call are set to nullptr.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetScissorRects()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetScissorRects ( Uint32 NumRects,
const Rect * pRects,
Uint32 RTWidth,
Uint32 RTHeight )
pure virtual

Sets active scissor rects.

Parameters
[in]NumRects- Number of scissor rectangles to set.
[in]pRects- An array of Rect structures describing the scissor rectangles to bind.
[in]RTWidth- Render target width. If 0 is provided, width of the currently bound render target will be used.
[in]RTHeight- Render target height. If 0 is provided, height of the currently bound render target will be used.
Remarks
DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin is in the left bottom corner of the screen with Y axis pointing up. Render target size is required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.

All scissor rects must be set atomically as one operation. Any rects not defined by the call are disabled.
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetShadingRate()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetShadingRate ( SHADING_RATE BaseRate,
SHADING_RATE_COMBINER PrimitiveCombiner,
SHADING_RATE_COMBINER TextureCombiner )
pure virtual

Sets the shading base rate and combiners.

Parameters
[in]BaseRate- Base shading rate used for combiner operations.
[in]PrimitiveCombiner- Combiner operation for the per primitive shading rate (the output of the vertex or geometry shader).
[in]TextureCombiner- Combiner operation for texture-based shading rate (fetched from the shading rate texture), see SetRenderTargetsAttribs::pShadingRateMap and SubpassDesc::pShadingRateAttachment.

The final shading rate is calculated before the triangle is rasterized by the following algorithm:

PrimitiveRate = ApplyCombiner(PrimitiveCombiner, BaseRate, PerPrimitiveRate)
FinalRate     = ApplyCombiner(TextureCombiner, PrimitiveRate, TextureRate)

Where

PerPrimitiveRate - vertex shader output value (HLSL: SV_ShadingRate; GLSL: gl_PrimitiveShadingRateEXT).
TextureRate      - texel value from the shading rate texture, see SetRenderTargetsAttribs::pShadingRateMap.

SHADING_RATE ApplyCombiner(SHADING_RATE_COMBINER Combiner, SHADING_RATE OriginalRate, SHADING_RATE NewRate)
{
    switch (Combiner)
    {
        case SHADING_RATE_COMBINER_PASSTHROUGH: return OriginalRate;
        case SHADING_RATE_COMBINER_OVERRIDE:    return NewRate;
        case SHADING_RATE_COMBINER_MIN:         return Min(OriginalRate, NewRate);
        case SHADING_RATE_COMBINER_MAX:         return Max(OriginalRate, NewRate);
        case SHADING_RATE_COMBINER_SUM:         return OriginalRate + NewRate;
        case SHADING_RATE_COMBINER_MUL:         return OriginalRate * NewRate;
    }
}
Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetStencilRef()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetStencilRef ( Uint32 StencilRef)
pure virtual

Sets the stencil reference value.

Parameters
[in]StencilRef- Stencil reference value.
Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ SetUserData()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetUserData ( IObject * pUserData)
pure virtual

Stores a pointer to the user-provided data object.

The pointer may later be retrieved through GetUserData().

Parameters
[in]pUserData- Pointer to the user data object to store.
Note
The method is not thread-safe and an application must externally synchronize the access.

The method keeps strong reference to the user data object. If an application needs to release the object, it should call SetUserData(nullptr);

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >.

◆ SetVertexBuffers()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetVertexBuffers ( Uint32 StartSlot,
Uint32 NumBuffersSet,
IBuffer *const * ppBuffers,
const Uint64 * pOffsets,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
SET_VERTEX_BUFFERS_FLAGS Flags = SET_VERTEX_BUFFERS_FLAG_NONE )
pure virtual

Binds vertex buffers to the pipeline.

Parameters
[in]StartSlot- The first input slot for binding. The first vertex buffer is explicitly bound to the start slot; each additional vertex buffer in the array is implicitly bound to each subsequent input slot.
[in]NumBuffersSet- The number of vertex buffers in the array.
[in]ppBuffers- A pointer to an array of vertex buffers. The buffers must have been created with the Diligent::BIND_VERTEX_BUFFER flag.
[in]pOffsets- Pointer to an array of offset values; one offset value for each buffer in the vertex-buffer array. Each offset is the number of bytes between the first element of a vertex buffer and the first element that will be used. If this parameter is nullptr, zero offsets for all buffers will be used.
[in]StateTransitionMode- State transition mode for buffers being set (see Diligent::RESOURCE_STATE_TRANSITION_MODE).
[in]Flags- Additional flags. See Diligent::SET_VERTEX_BUFFERS_FLAGS for a list of allowed values.

The device context keeps strong references to all bound vertex buffers. Thus a buffer cannot be released until it is unbound from the context.
It is suggested to specify Diligent::SET_VERTEX_BUFFERS_FLAG_RESET flag whenever possible. This will assure that no buffers from previous draw calls are bound to the pipeline.

When StateTransitionMode is Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION, the method will transition all buffers in known states to Diligent::RESOURCE_STATE_VERTEX_BUFFER. Resource state transitioning is not thread-safe, so no other thread is allowed to read or write the states of these buffers.

If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ SetViewports()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.SetViewports ( Uint32 NumViewports,
const Viewport * pViewports,
Uint32 RTWidth,
Uint32 RTHeight )
pure virtual

Sets an array of viewports.

Parameters
[in]NumViewports- Number of viewports to set.
[in]pViewports- An array of Viewport structures describing the viewports to bind.
[in]RTWidth- Render target width. If 0 is provided, width of the currently bound render target will be used.
[in]RTHeight- Render target height. If 0 is provided, height of the currently bound render target will be used.

DirectX and OpenGL use different window coordinate systems. In DirectX, the coordinate system origin is in the left top corner of the screen with Y axis pointing down. In OpenGL, the origin is in the left bottom corner of the screen with Y axis pointing up. Render target size is required to convert viewport from DirectX to OpenGL coordinate system if OpenGL device is used.

All viewports must be set atomically as one operation. Any viewports not defined by the call are disabled.

You can set the viewport size to match the currently bound render target using the following call:

pContext->SetViewports(1, nullptr, 0, 0);
Remarks
Supported contexts: graphics.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ TraceRays()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.TraceRays ( const TraceRaysAttribs & Attribs)
pure virtual

Executes a trace rays command.

Parameters
[in]Attribs- Trace rays command attributes, see Diligent::TraceRaysAttribs for details.
Note
The method is not thread-safe. An application must externally synchronize the access to the shader binding table (SBT) passed as an argument to the function. The function does not modify the state of the SBT and can be executed in parallel with other functions that don't modify the SBT (e.g. TraceRaysIndirect).
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ TraceRaysIndirect()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.TraceRaysIndirect ( const TraceRaysIndirectAttribs & Attribs)
pure virtual

Executes an indirect trace rays command.

Parameters
[in]Attribs- Indirect trace rays command attributes, see Diligent::TraceRaysIndirectAttribs.
Note
The method is not thread-safe. An application must externally synchronize the access to the shader binding table (SBT) passed as an argument to the function. The function does not modify the state of the SBT and can be executed in parallel with other functions that don't modify the SBT (e.g. TraceRays).
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ TransitionResourceStates()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.TransitionResourceStates ( Uint32 BarrierCount,
const StateTransitionDesc * pResourceBarriers )
pure virtual

Transitions resource states.

Parameters
[in]BarrierCount- Number of barriers in pResourceBarriers array
[in]pResourceBarriers- Pointer to the array of resource barriers

When both old and new states are Diligent::RESOURCE_STATE_UNORDERED_ACCESS, the engine executes UAV barrier on the resource. The barrier makes sure that all UAV accesses (reads or writes) are complete before any future UAV accesses (read or write) can begin.
There are two main usage scenarios for this method:

  1. An application knows specifics of resource state transitions not available to the engine. For example, only single mip level needs to be transitioned.
  2. An application manages resource states in multiple threads in parallel.

The method always reads the states of all resources to transition. If the state of a resource is managed by multiple threads in parallel, the resource must first be transitioned to unknown state (Diligent::RESOURCE_STATE_UNKNOWN) to disable automatic state management in the engine.

When StateTransitionDesc::UpdateResourceState is set to true, the method may update the state of the corresponding resource which is not thread-safe. No other threads should read or write the state of that resource.

Note
Resource states for shader access (e.g. Diligent::RESOURCE_STATE_CONSTANT_BUFFER, Diligent::RESOURCE_STATE_UNORDERED_ACCESS, Diligent::RESOURCE_STATE_SHADER_RESOURCE) may map to different native state depending on what context type is used (see DeviceContextDesc::ContextType). To synchronize write access in compute shader in compute context with a pixel shader read in graphics context, an application should call TransitionResourceStates() in graphics context. Using TransitionResourceStates() with NewState = Diligent::RESOURCE_STATE_SHADER_RESOURCE will not invalidate cache in graphics shaders and may cause undefined behaviour.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ TransitionShaderResources()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.TransitionShaderResources ( IShaderResourceBinding * pShaderResourceBinding)
pure virtual

Transitions shader resources to the states required by Draw or Dispatch command.

Parameters
[in]pShaderResourceBinding- Shader resource binding whose resources will be transitioned.

This method explicitly transitions all resources except ones in unknown state to the states required by Draw or Dispatch command. If this method was called, there is no need to use Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION when calling CommitShaderResources()

Remarks
Resource state transitioning is not thread-safe. As the method may alter the states of resources referenced by the shader resource binding, no other thread is allowed to read or write these states.
If the application intends to use the same resources in other threads simultaneously, it needs to explicitly manage the states using TransitionResourceStates() method.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ UnmapBuffer()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.UnmapBuffer ( IBuffer * pBuffer,
MAP_TYPE MapType )
pure virtual

Unmaps the previously mapped buffer.

Parameters
[in]pBuffer- Pointer to the buffer to unmap.
[in]MapType- Type of the map operation. This parameter must match the type that was provided to the Map() method.
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ UnmapTextureSubresource()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.UnmapTextureSubresource ( ITexture * pTexture,
Uint32 MipLevel,
Uint32 ArraySlice )
pure virtual

Unmaps the texture subresource.

Parameters
[in]pTexture- Pointer to the texture to unmap.
[in]MipLevel- Mip level to unmap.
[in]ArraySlice- Array slice to unmap. This parameter must be 0 for non-array textures.
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ UpdateBuffer()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.UpdateBuffer ( IBuffer * pBuffer,
Uint64 Offset,
Uint64 Size,
const void * pData,
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode )
pure virtual

Updates the data in the buffer.

Parameters
[in]pBuffer- Pointer to the buffer to update.
[in]Offset- Offset in bytes from the beginning of the buffer to the update region.
[in]Size- Size in bytes of the data region to update.
[in]pData- Pointer to the data to write to the buffer.
[in]StateTransitionMode- Buffer state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ UpdateSBT()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.UpdateSBT ( IShaderBindingTable * pSBT,
const UpdateIndirectRTBufferAttribs * pUpdateIndirectBufferAttribs = nullptr )
pure virtual

Updates SBT with the pending data that were recorded in IShaderBindingTable::Bind*** calls.

Parameters
[in]pSBT- Shader binding table that will be updated if there are pending data.
[in]pUpdateIndirectBufferAttribs- Indirect ray tracing attributes buffer update attributes (optional, may be null).

When pUpdateIndirectBufferAttribs is not null, the indirect ray tracing attributes will be written to the pAttribsBuffer buffer specified by the structure and can be used by TraceRaysIndirect() command. In Direct3D12 backend, the pAttribsBuffer buffer will be initialized with D3D12_DISPATCH_RAYS_DESC structure that contains GPU addresses of the ray tracing shaders in the first 88 bytes and 12 bytes for dimension (see TraceRaysIndirect() description).

In Vulkan backend, the pAttribsBuffer buffer will not be modified, because the SBT is used directly in TraceRaysIndirect().

Remarks
The method is not thread-safe. An application must externally synchronize the access to the shader binding table (SBT) passed as an argument to the function. The function modifies the data in the SBT and must not run in parallel with any other command that uses the same SBT.
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ UpdateTexture()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.UpdateTexture ( ITexture * pTexture,
Uint32 MipLevel,
Uint32 Slice,
const Box & DstBox,
const TextureSubResData & SubresData,
RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode )
pure virtual

Updates the data in the texture.

Parameters
[in]pTexture- Pointer to the device context interface to be used to perform the operation.
[in]MipLevel- Mip level of the texture subresource to update.
[in]Slice- Array slice. Should be 0 for non-array textures.
[in]DstBox- Destination region on the texture to update.
[in]SubresData- Source data to copy to the texture.
[in]SrcBufferTransitionMode- If pSrcBuffer member of TextureSubResData structure is not null, this parameter defines state transition mode of the source buffer. If pSrcBuffer is null, this parameter is ignored.
[in]TextureTransitionMode- Texture state transition mode (see Diligent::RESOURCE_STATE_TRANSITION_MODE)
Remarks
Supported contexts: graphics, compute, transfer.

Implemented in Diligent::DeviceContextBase< EngineWebGPUImplTraits >, and Diligent::DeviceContextWebGPUImpl.

◆ WaitForIdle()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.WaitForIdle ( )
pure virtual

Submits all outstanding commands for execution to the GPU and waits until they are complete.

Note
The method blocks the execution of the calling thread until the wait is complete.

Only immediate contexts can be idled.

The methods implicitly flushes the context (see Flush()), so an application must explicitly reset the PSO and bind all required shader resources after idling the context.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ WriteBLASCompactedSize()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.WriteBLASCompactedSize ( const WriteBLASCompactedSizeAttribs & Attribs)
pure virtual

Writes a bottom-level acceleration structure memory size required for compacting operation to a buffer.

Parameters
[in]Attribs- Structure describing write BLAS compacted size command attributes, see Diligent::WriteBLASCompactedSizeAttribs for details.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.

◆ WriteTLASCompactedSize()

virtual void DILIGENT_CALL_TYPE Diligent.IDeviceContext.WriteTLASCompactedSize ( const WriteTLASCompactedSizeAttribs & Attribs)
pure virtual

Writes a top-level acceleration structure memory size required for compacting operation to a buffer.

Parameters
[in]Attribs- Structure describing write TLAS compacted size command attributes, see Diligent::WriteTLASCompactedSizeAttribs for details.
Remarks
Supported contexts: graphics, compute.

Implemented in Diligent::DeviceContextWebGPUImpl.