GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::Swapchain Class Reference

Render target texture holding a chain of images leading to a window to be presented to. More...

#include <GREM/graphics/Swapchain.hpp>

Inheritance diagram for grem::graphics::Swapchain:

Public Member Functions

 Swapchain (Device &device, Window &window, const SwapchainOptions &options={})
 Construct a swapchain.
 ~Swapchain ()=default
 Destructor.
 Swapchain (const Swapchain &)=delete
 Copying a swapchain is not allowed.
 Swapchain (Swapchain &&)=delete
 Moving a swapchain is not allowed.
Swapchain & operator= (const Swapchain &)=delete
 Copying a swapchain is not allowed.
Swapchain & operator= (Swapchain &&)=delete
 Moving a swapchain is not allowed.
void pasteImage (Extent3D imageSize, const void *pixels, Offset3D destinationOffset, Region3D sourceRegion)=delete
 Directly modifying a swapchain is not allowed.
void pasteImage (Extent3D imageSize, const void *pixels, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})=delete
 Directly modifying a swapchain is not allowed.
void pasteTexture (const Texture &texture, Offset3D destinationOffset, Region3D sourceRegion)=delete
 Directly modifying a swapchain is not allowed.
void pasteTexture (const Texture &texture, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})=delete
 Directly modifying a swapchain is not allowed.
void fill (const ClearValues &values={})=delete
 Directly modifying a swapchain is not allowed.
void generateMipmap ()=delete
 Directly modifying a swapchain is not allowed.
Texture copy () const =delete
 Copying a swapchain is not allowed.
Texture copyWithSamplerOptions (Optional< TextureSamplerOptions > newSamplerOptions) const =delete
 Copying a swapchain is not allowed.
void setVerticalSynchronizationEnabled (bool useVerticalSynchronization)
 Enable or disable vertical synchronization.
void setMaxBufferedFrameCount (uint32_t maxBufferedFrameCount)
 Set the maximum buffered frame count.
bool isVerticalSynchronizationEnabled () const
 Check if vertical synchronization is enabled.
uint32_t getMaxBufferedFrameCount () const
 Get the maximum buffered frame count.
Public Member Functions inherited from grem::graphics::Texture
 Texture () noexcept=default
 Construct an empty texture without a value.
 Texture (Device &device, const resource::ImageView &image, const TextureImageUploadOptions &options={}, Optional< TextureSamplerOptions > samplerOptions=TextureSamplerOptions{})
 Construct a new texture and allocate GPU memory for storing a copy of an image.
 operator bool () const noexcept
 Check if the texture has a value.
void pasteImage (Extent3D imageSize, const void *pixels, Offset3D destinationOffset, Region3D sourceRegion)
 Copy all or part of an array of layers of 2D image data into the texture at a specific position.
void pasteImage (Extent3D imageSize, const void *pixels, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})
 Copy all of an array of layers of 2D image data into the texture at a specific position.
void pasteTexture (const Texture &texture, Offset3D destinationOffset, Region3D sourceRegion)
 Copy all or part of the image data of another 2D or 2D array texture into the texture at a specific position.
void pasteTexture (const Texture &texture, Offset3D destinationOffset={.x=0,.y=0,.z=0}, Offset3D sourceOffset={.x=0,.y=0,.z=0})
 Copy all of the image data of another 2D or 2D array texture into the texture at a specific position.
void fill (const ClearValues &values={})
 Fill all allocated texture data with specific values.
void fill (TextureSubresource subresource, const ClearValues &values={})
 Fill a subresource of the texture with specific values.
void generateMipmap ()
 Generate a mipmap, with the maximum possible number of mip levels, for the texture based on the highest quality mip level.
Texture copy () const
 Create a new texture object, allocate GPU memory and copy the image data of this texture onto it.
Texture copyWithSamplerOptions (Optional< TextureSamplerOptions > newSamplerOptions) const
 Create a new texture object with new sampler options, allocate GPU memory and copy the image data of this texture onto it.
resource::Image downloadImage (const TextureImageDownloadOptions &downloadOptions={}) const
 Download a copy of all or part of the image stored in the texture.
 operator TextureSubresourceReference () noexcept
 Get a reference to the first subresource of the texture.
 operator TextureSubresourceConstReference () const noexcept
 Get a read-only reference to the first subresource of the texture.
TextureSubresourceReference getSubresource (TextureSubresource subresource) noexcept
 Get a reference to a subresource of the texture.
TextureSubresourceConstReference getSubresource (TextureSubresource subresource) const noexcept
 Get a read-only reference to a subresource of the texture.
 operator TextureRegion2DReference () noexcept
 Get a reference to the first 2D layer region of the texture.
 operator TextureRegion2DConstReference () const noexcept
 Get a read-only reference to the first 2D layer region of the texture.
TextureRegion2DReference getRegion2D (TextureRegion2D region) noexcept
 Get a reference to a 2D region of the texture.
TextureRegion2DConstReference getRegion2D (TextureRegion2D region) const noexcept
 Get a read-only reference to a 2D region of the texture.
TextureRegion3DReference getRegion3D (TextureRegion3D region) noexcept
 Get a reference to a 3D region of the texture.
TextureRegion3DConstReference getRegion3D (TextureRegion3D region) const noexcept
 Get a read-only reference to a 3D region of the texture.
TextureType getType () const noexcept
 Get the type of the texture.
TextureFormat getInternalFormat () const noexcept
 Get the internal texture format of this texture.
Extent2D getSize2D () const noexcept
 Get the size, in texels, of the 2D image data stored in this texture.
Extent3D getSize3D () const noexcept
 Get the size, in texels, and the depth, in layers, of the 3D image data stored in this texture.
uint32_t getWidth () const noexcept
 Get the width, in texels, of the image data stored in this texture.
uint32_t getHeight () const noexcept
 Get the height, in texels, of the image data stored in this texture.
uint32_t getDepth () const noexcept
 Get the depth, in layers, of the image data stored in this texture.
uint32_t getMipLevelCount () const noexcept
 Get the number of mip levels of the texture.
uint32_t getMaxMultisampleCount () const noexcept
 Get the maximum multisample count of the texture.
Optional< TextureSamplerOptions > getSamplerOptions () const noexcept
 Get the configuration options of this texture's associated sampler.
SharedPointer< TextureImplementation > lock () const noexcept
 Get a lock for the underlying resource implementation.
TextureImplementation * get () noexcept
 Get a pointer to the underlying resource implementation.
const TextureImplementation * get () const noexcept
 Get a pointer to the underlying resource implementation.

Additional Inherited Members

Static Public Member Functions inherited from grem::graphics::Texture
static constexpr TextureAspects getFormatAspects (TextureFormat internalFormat)
 Get the set of texture aspects of an internal texture format.
static constexpr resource::ImageType getImageType (TextureType type)
 Get the image type corresponding to a texture type.
static constexpr resource::ImageFormat getImageFormat (TextureFormat internalFormat)
 Get the image format corresponding to an internal texture format.
static constexpr TextureType getType (resource::ImageType type) noexcept
 Get the texture type corresponding to an image type.
static constexpr bool hasInternalSRGBFormat (resource::ImageFormat format) noexcept
 Check if an image format has a corresponding internal texture format that uses the sRGB transfer function.
static constexpr Color::TransferFunction getTransferFunction (TextureFormat internalFormat) noexcept
 Get the transfer function of an internal texture format.
static constexpr TextureFormat getInternalFormat (resource::ImageFormat format, Color::TransferFunction transferFunction) noexcept
 Get the internal texture format corresponding to an image format.
static constexpr TextureFormat getRawFormat (TextureFormat internalFormat) noexcept
 Get the raw format corresponding to a specific internal texture format.
static constexpr TextureFormat getUncompressedFormat (TextureFormat internalFormat) noexcept
 Get the uncompressed format corresponding to a specific internal texture format.
static constexpr bool isCompatibleFormat (TextureFormat internalFormat, resource::ImageFormat format) noexcept
 Check if a specific image format is directly compatible with an internal texture format.
static constexpr bool isRGBAColorFormat (TextureFormat internalFormat) noexcept
 Check if a specific internal texture format is an RGBA color format with an alpha channel.
static constexpr bool isRawFormat (TextureFormat internalFormat) noexcept
 Check if a specific internal texture format is a raw format.
static constexpr bool isPackedFormat (TextureFormat internalFormat) noexcept
 Check if a specific internal texture format is a bit-packed format.
static constexpr bool isCompressedFormat (TextureFormat internalFormat) noexcept
 Check if a specific internal texture format is a compressed format.
static constexpr bool isFramebufferCompatibleFormat (TextureFormat internalFormat) noexcept
 Check if a specific internal texture format is framebuffer-compatible.
static Texture create (Device &device, TextureType type, TextureFormat internalFormat, Extent3D size, uint32_t mipLevelCount, const void *pixels, Optional< TextureSamplerOptions > samplerOptions=TextureSamplerOptions{})
 Create a new texture object and allocate GPU memory for storing image data.
static Texture create (Device &device, TextureType type, TextureFormat internalFormat, Extent3D size, uint32_t mipLevelCount, const UndefinedClearValues &values, Optional< TextureSamplerOptions > samplerOptions=TextureSamplerOptions{})
 Create a new texture object and allocate uninitialized GPU memory for storing image data.
static Texture create (Device &device, TextureType type, TextureFormat internalFormat, Extent3D size, uint32_t mipLevelCount, const ClearValues &values, Optional< TextureSamplerOptions > samplerOptions=TextureSamplerOptions{})
 Create a new texture object and allocate GPU memory for storing image data, initialized to specific values.
static Texture createRenderbuffer (Device &device, TextureFormat internalFormat, Extent2D size, uint32_t maxMultisampleCount, const UndefinedClearValues &values)
 Create a new unsampled texture object and allocate uninitialized GPU memory for storing potentially multisampled 2D image data.
static Texture createRenderbuffer (Device &device, TextureFormat internalFormat, Extent2D size, uint32_t maxMultisampleCount, const ClearValues &values)
 Create a new unsampled texture object and allocate GPU memory for storing potentially multisampled 2D image data, initialized to specific values.

Detailed Description

Render target texture holding a chain of images leading to a window to be presented to.

Constructor & Destructor Documentation

◆ Swapchain() [1/3]

grem::graphics::Swapchain::Swapchain ( Device & device,
Window & window,
const SwapchainOptions & options = {} )

Construct a swapchain.

Parameters
devicedevice to create the swapchain for. Must outlive the swapchain.
windowwindow that the swapchain presents to.
optionsinitial configuration of the swapchain, see SwapchainOptions.

◆ ~Swapchain()

grem::graphics::Swapchain::~Swapchain ( )
default

Destructor.

◆ Swapchain() [2/3]

grem::graphics::Swapchain::Swapchain ( const Swapchain & )
delete

Copying a swapchain is not allowed.

◆ Swapchain() [3/3]

grem::graphics::Swapchain::Swapchain ( Swapchain && )
delete

Moving a swapchain is not allowed.

Member Function Documentation

◆ operator=() [1/2]

Swapchain & grem::graphics::Swapchain::operator= ( const Swapchain & )
delete

Copying a swapchain is not allowed.

◆ operator=() [2/2]

Swapchain & grem::graphics::Swapchain::operator= ( Swapchain && )
delete

Moving a swapchain is not allowed.

◆ pasteImage() [1/2]

void grem::graphics::Swapchain::pasteImage ( Extent3D imageSize,
const void * pixels,
Offset3D destinationOffset,
Region3D sourceRegion )
delete

Directly modifying a swapchain is not allowed.

◆ pasteImage() [2/2]

void grem::graphics::Swapchain::pasteImage ( Extent3D imageSize,
const void * pixels,
Offset3D destinationOffset = {.x=0,.y=0,.z=0},
Offset3D sourceOffset = {.x=0,.y=0,.z=0} )
delete

Directly modifying a swapchain is not allowed.

◆ pasteTexture() [1/2]

void grem::graphics::Swapchain::pasteTexture ( const Texture & texture,
Offset3D destinationOffset,
Region3D sourceRegion )
delete

Directly modifying a swapchain is not allowed.

◆ pasteTexture() [2/2]

void grem::graphics::Swapchain::pasteTexture ( const Texture & texture,
Offset3D destinationOffset = {.x=0,.y=0,.z=0},
Offset3D sourceOffset = {.x=0,.y=0,.z=0} )
delete

Directly modifying a swapchain is not allowed.

◆ fill()

void grem::graphics::Swapchain::fill ( const ClearValues & values = {})
delete

Directly modifying a swapchain is not allowed.

◆ generateMipmap()

void grem::graphics::Swapchain::generateMipmap ( )
delete

Directly modifying a swapchain is not allowed.

◆ copy()

Texture grem::graphics::Swapchain::copy ( ) const
nodiscarddelete

Copying a swapchain is not allowed.

◆ copyWithSamplerOptions()

Texture grem::graphics::Swapchain::copyWithSamplerOptions ( Optional< TextureSamplerOptions > newSamplerOptions) const
nodiscarddelete

Copying a swapchain is not allowed.

◆ setVerticalSynchronizationEnabled()

void grem::graphics::Swapchain::setVerticalSynchronizationEnabled ( bool useVerticalSynchronization)

Enable or disable vertical synchronization.

Parameters
useVerticalSynchronizationtrue to enable VSync, false to disable.
See also
SwapchainOptions::useVerticalSynchronization
isVerticalSynchronizationEnabled()

◆ setMaxBufferedFrameCount()

void grem::graphics::Swapchain::setMaxBufferedFrameCount ( uint32_t maxBufferedFrameCount)

Set the maximum buffered frame count.

Parameters
maxBufferedFrameCountnew maximum number of buffered frames.
Note
This function only has an effect on certain graphics backends.
See also
SwapchainOptions::maxBufferedFrameCount
getMaxBufferedFrameCount()

◆ isVerticalSynchronizationEnabled()

bool grem::graphics::Swapchain::isVerticalSynchronizationEnabled ( ) const
nodiscard

Check if vertical synchronization is enabled.

Returns
true if VSync is enabled, false otherwise.
See also
SwapchainOptions::useVerticalSynchronization
setVerticalSynchronizationEnabled()

◆ getMaxBufferedFrameCount()

uint32_t grem::graphics::Swapchain::getMaxBufferedFrameCount ( ) const
nodiscard

Get the maximum buffered frame count.

Returns
the maximum number of buffered frames, or 0 if the current graphics backend does not support limiting the number of buffered frames.
See also
SwapchainOptions::maxBufferedFrameCount
setMaxBufferedFrameCount()

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