Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::ISwapChain Struct Referenceabstract

Swap chain interface. More...

#include <SwapChain.h>

Inheritance diagram for Diligent::ISwapChain:
Diligent.IObject Diligent::RefCountedObject< ISwapChain > Diligent::ISwapChainD3D11 Diligent::ISwapChainD3D12 Diligent::ISwapChainGL Diligent::ISwapChainMtl Diligent::ISwapChainVk Diligent::ISwapChainWebGPU Diligent::ObjectBase< ISwapChain > Diligent::RefCountedObject< ISwapChainWebGPU > Diligent::SwapChainBase< ISwapChain > Diligent::ObjectBase< ISwapChainWebGPU > Diligent::SwapChainBase< ISwapChainWebGPU > Diligent::SwapChainWebGPUImpl

Public Member Functions

virtual void DILIGENT_CALL_TYPE Present (Uint32 SyncInterval=1)=0
 Presents a rendered image to the user.
 
virtual const SwapChainDesc &DILIGENT_CALL_TYPE GetDesc () const =0
 Returns the swap chain description.
 
virtual void DILIGENT_CALL_TYPE Resize (Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewTransform=SURFACE_TRANSFORM_OPTIMAL)=0
 Changes the swap chain size.
 
virtual void DILIGENT_CALL_TYPE SetFullscreenMode (const DisplayModeAttribs &DisplayMode)=0
 Sets fullscreen mode (only supported on Win32 platform)
 
virtual void DILIGENT_CALL_TYPE SetWindowedMode ()=0
 Sets windowed mode (only supported on Win32 platform)
 
virtual void DILIGENT_CALL_TYPE SetMaximumFrameLatency (Uint32 MaxLatency)=0
 Sets the maximum number of frames that the swap chain is allowed to queue for rendering.
 
virtual ITextureView *DILIGENT_CALL_TYPE GetCurrentBackBufferRTV ()=0
 Returns render target view of the current back buffer in the swap chain.
 
virtual ITextureView *DILIGENT_CALL_TYPE GetDepthBufferDSV ()=0
 Returns depth-stencil view of the depth buffer.
 
- 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

Swap chain interface.

The swap chain is created by a platform-dependent function

Member Function Documentation

◆ GetCurrentBackBufferRTV()

virtual ITextureView *DILIGENT_CALL_TYPE Diligent::ISwapChain::GetCurrentBackBufferRTV ( )
pure virtual

Returns render target view of the current back buffer in the swap chain.

For Direct3D12 and Vulkan backends, the function returns different pointer for every offscreen buffer in the swap chain (flipped by every call to ISwapChain::Present()). For Direct3D11 backend it always returns the same pointer. For OpenGL/GLES backends the method returns null.

The method does NOT increment the reference counter of the returned object, so Release() must not be called.

Implemented in Diligent::ISwapChainD3D11, and Diligent::SwapChainWebGPUImpl.

◆ GetDepthBufferDSV()

virtual ITextureView *DILIGENT_CALL_TYPE Diligent::ISwapChain::GetDepthBufferDSV ( )
pure virtual

Returns depth-stencil view of the depth buffer.

The method does NOT increment the reference counter of the returned object, so Release() must not be called.

Implemented in Diligent::ISwapChainD3D11, and Diligent::SwapChainWebGPUImpl.

◆ Resize()

virtual void DILIGENT_CALL_TYPE Diligent::ISwapChain::Resize ( Uint32 NewWidth,
Uint32 NewHeight,
SURFACE_TRANSFORM NewTransform = SURFACE_TRANSFORM_OPTIMAL )
pure virtual

Changes the swap chain size.

Parameters
[in]NewWidth- New logical swap chain width (not accounting for pre-transform), in pixels.
[in]NewHeight- New logical swap chain height (not accounting for pre-transform), in pixels.
[in]NewTransform- New surface transform, see Diligent::SURFACE_TRANSFORM.
Note
When resizing non-primary swap chains, the engine unbinds the swap chain buffers from the output.

New width and height should not account for surface pre-transform. For example, if the window size is 1920 x 1080, but the surface is pre-rotated by 90 degrees, NewWidth should still be 1920, and NewHeight should still be 1080. It is highly recommended to always use Diligent::SURFACE_TRANSFORM_OPTIMAL to let the engine select the most optimal pre-transform. However Diligent::SURFACE_TRANSFORM_ROTATE_90 will also work in the scenario above. After the swap chain has been resized, its actual width will be 1080, actual height will be 1920, and PreTransform will be Diligent::SURFACE_TRANSFORM_ROTATE_90.

Implemented in Diligent::SwapChainWebGPUImpl.

◆ SetMaximumFrameLatency()

virtual void DILIGENT_CALL_TYPE Diligent::ISwapChain::SetMaximumFrameLatency ( Uint32 MaxLatency)
pure virtual

Sets the maximum number of frames that the swap chain is allowed to queue for rendering.

This value is only relevant for D3D11 and D3D12 backends and ignored for others. By default it matches the number of buffers in the swap chain. For example, for a 2-buffer swap chain, the CPU can enqueue frames 0 and 1, but Present command of frame 2 will block until frame 0 is presented. If in the example above the maximum frame latency is set to 1, then Present command of frame 1 will block until Present of frame 0 is complete.