LiteFX 0.4.1.2025
Computer Graphics Engine
|
Interface for a swap chain. More...
#include <rendering_api.hpp>
Inherited by LiteFX::Rendering::SwapChain< IDirectX12Image >, LiteFX::Rendering::SwapChain< IVulkanImage >, and LiteFX::Rendering::SwapChain< TImageInterface >.
Classes | |
struct | ResetEventArgs |
Event arguments for a ISwapChain::reseted event. More... | |
Public Member Functions | |
virtual | ~ISwapChain () noexcept=default |
SharedPtr< const TimingEvent > | registerTimingEvent (StringView name="") |
Creates a new instance of a TimingEvent. | |
virtual const Array< SharedPtr< const TimingEvent > > & | timingEvents () const =0 |
Returns all registered timing events. | |
virtual SharedPtr< const TimingEvent > | timingEvent (UInt32 queryId) const =0 |
Returns the timing event registered for queryId . | |
virtual UInt64 | readTimingEvent (SharedPtr< const TimingEvent > timingEvent) const =0 |
Reads the current time stamp value (in ticks) of a timing event. | |
virtual UInt32 | resolveQueryId (SharedPtr< const TimingEvent > timingEvent) const =0 |
Returns the query ID for the timing event. | |
virtual const IGraphicsDevice & | device () const =0 |
Returns the swap chain's parent device instance. | |
virtual Format | surfaceFormat () const noexcept=0 |
Returns the swap chain image format. | |
virtual UInt32 | buffers () const noexcept=0 |
Returns the number of images in the swap chain. | |
virtual const Size2d & | renderArea () const noexcept=0 |
Returns the size of the render area. | |
virtual bool | verticalSynchronization () const noexcept=0 |
Returns true , if vertical synchronization should be used, otherwise false . | |
virtual IImage * | image (UInt32 backBuffer) const =0 |
Returns the swap chain present image for backBuffer . | |
virtual const IImage & | image () const noexcept=0 |
Returns the current swap chain back buffer image. | |
Enumerable< IImage & > | images () const |
Returns an array of the swap chain present images. | |
virtual void | present (UInt64 fence) const =0 |
Queues a present that gets executed after fence has been signaled on the default graphics queue. | |
virtual Enumerable< Format > | getSurfaceFormats () const =0 |
Returns an array of supported formats, that can be drawn to the surface. | |
virtual void | reset (Format surfaceFormat, const Size2d &renderArea, UInt32 buffers, bool enableVsync=false)=0 |
Causes the swap chain to be re-created. All frame and command buffers will be invalidated and rebuilt. | |
virtual UInt32 | swapBackBuffer () const =0 |
Swaps the front buffer with the next back buffer in order. | |
Public Attributes | |
Event< EventArgs > | swapped |
Invoked, when the swap chain has swapped the back buffers. | |
Event< ResetEventArgs > | reseted |
Invoked, after the swap chain has been reseted. | |
Protected Member Functions | |
ISwapChain () noexcept=default | |
ISwapChain (ISwapChain &&) noexcept=default | |
ISwapChain (const ISwapChain &)=default | |
ISwapChain & | operator= (const ISwapChain &)=default |
ISwapChain & | operator= (ISwapChain &&) noexcept=default |
Interface for a swap chain.
|
protecteddefaultnoexcept |
|
protecteddefaultnoexcept |
|
protecteddefault |
|
virtualdefaultnoexcept |
|
pure virtualnoexcept |
Returns the number of images in the swap chain.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Returns the swap chain's parent device instance.
RuntimeException | Thrown, if the device is already released. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Returns an array of supported formats, that can be drawn to the surface.
surface
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtualnoexcept |
Returns the current swap chain back buffer image.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
Returns the swap chain present image for backBuffer .
backBuffer | The index of the back buffer for which to return the swap chain present image. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
inline |
Returns an array of the swap chain present images.
|
protecteddefault |
|
protecteddefaultnoexcept |
|
pure virtual |
Queues a present that gets executed after fence has been signaled on the default graphics queue.
You can use this overload in situations where you do not have an IRenderPass or IFrameBuffer to render into before presenting. Instead, you typically copy into the swap chain back buffer images directly (image). This copy is done in a command buffer that must be submitted to the default graphics queue. The swap chain can then wait for the copy to finish before presenting it. Example scenarios where this is useful are, where you want to write to the back buffer from a compute shader, that does not have an equivalent to render passes.
fence | The fence to pass on the default graphics queue after which the present is executed. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Reads the current time stamp value (in ticks) of a timing event.
In order to convert the number of ticks to (milli-)seconds, this value needs to be divided by IGraphicsDevice::ticksPerMillisecond. To improve precision, calculate the difference between two time stamps in ticks first and only then convert them to seconds.
timingEvent | The timing event to read the current value for. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
inlinenodiscard |
Creates a new instance of a TimingEvent.
Note that registering a new timing event does invalidate previously registered events, i.e. they do not return meaningful time stamps for the next frame. Timing events should only be registered during application startup, before the first frame is rendered.
name | The name of the timing event. |
|
pure virtualnoexcept |
Returns the size of the render area.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Causes the swap chain to be re-created. All frame and command buffers will be invalidated and rebuilt.
There is no guarantee, that the swap chain images will end up in the exact format, as specified by surfaceFormat . If the format itself is not supported, a compatible format may be looked up. If the lookup fails, the method may raise an exception.
Similarly, it is not guaranteed, that the number of images returned by images matches the number specified in buffers . A swap chain may require a minimum number of images or may constraint a maximum number of images. In both cases, buffers will be clamped.
surfaceFormat | The swap chain image format. |
renderArea | The dimensions of the frame buffers. |
buffers | The number of buffers in the swap chain. |
enableVsync | true , if vertical synchronization should be used, otherwise false . |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Returns the query ID for the timing event.
timingEvent | The timing event to return the query ID for. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtualnoexcept |
Returns the swap chain image format.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
nodiscardpure virtual |
Swaps the front buffer with the next back buffer in order.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Returns the timing event registered for queryId .
queryId | The query ID of the timing event. |
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtual |
Returns all registered timing events.
Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
pure virtualnoexcept |
Returns true
, if vertical synchronization should be used, otherwise false
.
true
, if vertical synchronization should be used, otherwise false
.Implemented in LiteFX::Rendering::Backends::DirectX12SwapChain, and LiteFX::Rendering::Backends::VulkanSwapChain.
|
mutable |
Invoked, after the swap chain has been reseted.
Invoked, when the swap chain has swapped the back buffers.