CopperSpice API
1.9.2
|
Subclass of QWindow to perform Vulkan rendering. More...
Public Typedefs | |
using | VulkanFlags = QFlags< VulkanOptions > |
Public Types | |
enum | VulkanOptions : uint32_t |
Public Types inherited from QWindow | |
enum | AncestorMode |
enum | Visibility |
Public Types inherited from QSurface | |
enum | SurfaceClass |
enum | SurfaceType |
Public Methods | |
QVulkanWindow (QWindow *parent=nullptr) | |
~QVulkanWindow () | |
QVector< VkPhysicalDeviceProperties > | availablePhysicalDevices () |
QMatrix4x4 | clipCorrectionMatrix () |
VkFormat | colorFormat () const |
int | concurrentFrameCount () const |
virtual QVulkanWindowRenderer * | createRenderer () |
VkCommandBuffer | currentCommandBuffer () const |
int | currentFrame () const |
VkFramebuffer | currentFramebuffer () const |
int | currentSwapChainImageIndex () const |
VkRenderPass | defaultRenderPass () const |
VkFormat | depthStencilFormat () const |
VkImage | depthStencilImage () const |
VkImageView | depthStencilImageView () const |
VkDevice | device () const |
uint32_t | deviceLocalMemoryIndex () const |
void | exposeEvent (QExposeEvent *event) override |
QVulkanWindow::VulkanFlags | flags () const |
void | frameReady () |
VkCommandPool | graphicsCommandPool () const |
VkQueue | graphicsQueue () const |
uint32_t | graphicsQueueFamilyIndex () const |
uint32_t | hostVisibleMemoryIndex () const |
bool | isValid () const |
VkImage | msaaColorImage (int idx) const |
VkImageView | msaaColorImageView (int idx) const |
VkPhysicalDevice | physicalDevice () const |
const VkPhysicalDeviceProperties * | physicalDeviceProperties () const |
VkSampleCountFlagBits | sampleCountFlagBits () const |
void | setDeviceExtensions (const QStringList &extensions) |
void | setFlags (QVulkanWindow::VulkanFlags flags) |
void | setPhysicalDeviceIndex (int idx) |
void | setPreferredColorFormats (const QVector< VkFormat > &formats) |
void | setSampleCount (int sampleCount) |
QVector< QVulkanExtensionProperties > | supportedDeviceExtensions () |
QVector< int > | supportedSampleCounts () |
VkImage | swapChainImage (int idx) const |
int | swapChainImageCount () const |
QSize | swapChainImageSize () const |
VkImageView | swapChainImageView (int idx) const |
Public Methods inherited from QWindow | |
QWindow (QScreen *screen=nullptr) | |
QWindow (QWindow *parent) | |
virtual | ~QWindow () |
QSize | baseSize () const |
Qt::ScreenOrientation | contentOrientation () const |
void | create () |
QCursor | cursor () const |
void | destroy () |
qreal | devicePixelRatio () const |
QString | filePath () const |
Qt::WindowFlags | flags () const |
virtual QObject * | focusObject () const |
QSurfaceFormat | format () const override |
QRect | frameGeometry () const |
QMargins | frameMargins () const |
QPoint | framePosition () const |
QRect | geometry () const |
int | height () const |
QIcon | icon () const |
bool | isActive () const |
bool | isAncestorOf (const QWindow *child, AncestorMode mode=IncludeTransients) const |
bool | isExposed () const |
bool | isModal () const |
bool | isTopLevel () const |
bool | isVisible () const |
QPoint | mapFromGlobal (const QPoint &pos) const |
QPoint | mapToGlobal (const QPoint &pos) const |
QRegion | mask () const |
int | maximumHeight () const |
QSize | maximumSize () const |
int | maximumWidth () const |
int | minimumHeight () const |
QSize | minimumSize () const |
int | minimumWidth () const |
Qt::WindowModality | modality () const |
qreal | opacity () const |
QWindow * | parent () const |
QPoint | position () const |
void | reportContentOrientationChange (Qt::ScreenOrientation orientation) |
QSurfaceFormat | requestedFormat () const |
void | resize (const QSize &newSize) |
void | resize (int w, int h) |
QScreen * | screen () const |
void | setBaseSize (const QSize &size) |
void | setCursor (const QCursor &cursor) |
void | setFilePath (const QString &filePath) |
void | setFlags (Qt::WindowFlags flags) |
void | setFormat (const QSurfaceFormat &format) |
void | setFramePosition (const QPoint &point) |
void | setGeometry (const QRect &rect) |
void | setGeometry (int x_pos, int y_pos, int w, int h) |
void | setIcon (const QIcon &icon) |
bool | setKeyboardGrabEnabled (bool grab) |
void | setMask (const QRegion ®ion) |
void | setMaximumSize (const QSize &size) |
void | setMinimumSize (const QSize &size) |
void | setModality (Qt::WindowModality modality) |
bool | setMouseGrabEnabled (bool grab) |
void | setOpacity (qreal level) |
void | setParent (QWindow *parent) |
void | setPosition (const QPoint &pt) |
void | setPosition (int x_pos, int y_pos) |
void | setScreen (QScreen *screen) |
void | setSizeIncrement (const QSize &size) |
void | setSurfaceType (SurfaceType surfaceType) |
void | setTransientParent (QWindow *parent) |
void | setVisibility (Visibility v) |
void | setVulkanInstance (QVulkanInstance *instance) |
void | setWindowState (Qt::WindowState state) |
QSize | size () const override |
QSize | sizeIncrement () const |
SurfaceType | surfaceType () const override |
QString | title () const |
QWindow * | transientParent () const |
Qt::WindowType | type () const |
void | unsetCursor () |
Visibility | visibility () const |
QVulkanInstance * | vulkanInstance () const |
int | width () const |
Qt::WindowState | windowState () const |
WId | winId () const |
int | x () const |
int | y () const |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Public Methods inherited from QSurface | |
virtual | ~QSurface () |
bool | supportsOpenGL () const |
SurfaceClass | surfaceClass () const |
Static Public Members | |
static constexpr const int | MAX_CONCURRENT_FRAME_COUNT = 10 |
Additional Inherited Members | |
Public Signals inherited from QWindow | |
void | activeChanged () |
void | contentOrientationChanged (Qt::ScreenOrientation orientation) |
void | focusObjectChanged (QObject *object) |
void | heightChanged (int newHeight) |
void | maximumHeightChanged (int newMaxHeight) |
void | maximumWidthChanged (int newMaxWidth) |
void | minimumHeightChanged (int newMinHeight) |
void | minimumWidthChanged (int newMinWidth) |
void | modalityChanged (Qt::WindowModality modality) |
void | opacityChanged (qreal newOpacity) |
void | screenChanged (QScreen *screen) |
void | visibilityChanged (QWindow::Visibility newVisibility) |
void | visibleChanged (bool newVisible) |
void | widthChanged (int newWidth) |
void | windowStateChanged (Qt::WindowState windowState) |
void | windowTitleChanged (const QString &newTitle) |
void | xChanged (int newX) |
void | yChanged (int newY) |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots inherited from QWindow | |
void | alert (int msec) |
bool | close () |
void | hide () |
void | lower () |
void | raise () |
void | requestActivate () |
void | requestUpdate () |
void | setHeight (int height) |
void | setMaximumHeight (int height) |
void | setMaximumWidth (int width) |
void | setMinimumHeight (int height) |
void | setMinimumWidth (int width) |
void | setTitle (const QString &title) |
void | setVisible (bool visible) |
void | setWidth (int width) |
void | setX (int x_value) |
void | setY (int y_value) |
void | show () |
void | showFullScreen () |
void | showMaximized () |
void | showMinimized () |
void | showNormal () |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QWindow | |
static QWindow * | fromWinId (WId id) |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Protected Methods inherited from QWindow | |
bool | event (QEvent *event) override |
virtual void | focusInEvent (QFocusEvent *event) |
virtual void | focusOutEvent (QFocusEvent *event) |
virtual void | hideEvent (QHideEvent *event) |
virtual void | keyPressEvent (QKeyEvent *event) |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
virtual void | mousePressEvent (QMouseEvent *event) |
virtual void | mouseReleaseEvent (QMouseEvent *event) |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, long *result) |
virtual void | resizeEvent (QResizeEvent *event) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
virtual void | touchEvent (QTouchEvent *event) |
virtual void | wheelEvent (QWheelEvent *event) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Methods inherited from QSurface | |
QSurface (SurfaceClass type) | |
Properties inherited from QWindow | |
active | |
contentOrientation | |
flags | |
height | |
maximumHeight | |
maximumWidth | |
minimumHeight | |
minimumWidth | |
modality | |
opacity | |
title | |
visibility | |
visible | |
width | |
x | |
y | |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
QVulkanWindow is a Vulkan capable QWindow that manages a Vulkan device, a graphics queue, a command pool and buffer, a depth stencil image and a double-buffered FIFO swapchain, while taking care of correct behavior when it comes to events like resize, special situations like not having a device queue supporting both graphics and presentation, device lost scenarios, and additional functionality like reading the rendered content back. Conceptually it is the counterpart of QOpenGLWindow in the Vulkan system.
QVulkanWindow does not always eliminate the need to implement a fully custom QWindow subclass as it will not necessarily be sufficient in advanced use cases.
QVulkanWindow can be embedded into QWidget based user interfaces via QWidget::createWindowContainer(). This approach has a number of limitations.
The following is a typical application using QVulkanWindow.
The following explains the funcionality of example shown above.
Critical errors are printed via qWarning() automatically.
There are two notable differences to be aware of: First, with Vulkan Y points down the screen in clip space, while OpenGL uses an upwards pointing Y axis. Second, the standard OpenGL projection matrix assume a near and far plane values of -1 and 1, while Vulkan prefers 0 and 1.
In order to help applications migrate from OpenGL-based code without having to flip Y coordinates in the vertex data, and to allow using QMatrix4x4 methods like QMatrix4x4::perspective() while keeping the Vulkan viewport's minDepth and maxDepth set to 0 and 1, QVulkanWindow provides a correction matrix retrievable by calling clipCorrectionMatrix().
While disabled by default, multisample antialiasing is fully supported by QVulkanWindow. Additional color buffers and resolving into the swapchain's non-multisample buffers are all managed automatically.
To query the supported sample counts, call supportedSampleCounts(). When the returned set contains 4, 8, ..., passing one of those values to setSampleCount() requests multisample rendering.
Unlike QSurfaceFormat::setSamples(), the list of supported sample counts are exposed to the applications in advance and there is no automatic falling back to lower sample counts in setSampleCount(). If the requested value is not supported, a warning is shown and a no multisampling will be used.
While many applications will be fine with the default behavior of QVulkanWindow when it comes to swapchain image formats, setPreferredColorFormats() allows requesting a pre-defined format. This is useful most notably when working in the sRGB color space. Passing a format like VK_FORMAT_B8G8R8A8_SRGB results in choosing an sRGB format, when available.
During application development it can be extremely valuable to have the Vulkan validation layers enabled. As shown in the example code above, calling QVulkanInstance::setLayers() on the QVulkanInstance before QVulkanInstance::create() enables validation, assuming the Vulkan driver stack in the system contains the necessary layers.
To enable instance layers call QVulkanInstance::setLayers() before creating the QVulkanInstance. To query what instance layer are available call QVulkanInstance::supportedLayers(). To enable device extensions, call setDeviceExtensions() early on when setting up the QVulkanWindow. To query what device extensions are available, call supportedDeviceExtensions().
Specifying an unsupported layer or extension is handled gracefully: this will not fail instance or device creation, but the layer or extension request is rather ignored.
QVulkanWindow enables all Vulkan 1.1 features which are reported as supported from vkGetPhysicalDeviceFeatures().
Typedef for QFlags<VulkanOptions> which contains an OR combination of VulkanOptions values.
Refer to QVulkanWindow::VulkanOptions for the enum documentation.
enum QVulkanWindow::VulkanOptions : uint32_t |
This enum describes the flags that can be passed to setFlags().
Constant | Value | Description |
---|---|---|
QVulkanWindow::PersistentResources | 0x0001 | Ensures no graphics resources are released when the window becomes unexposed. The default behavior is to release everything and reinitialize later when it becomes visible again. |
QVulkanWindow::QVulkanWindow | ( | QWindow * | parent = nullptr | ) |
Constructs a new QVulkanWindow with the given parent. The surface type is set to QSurface::VulkanSurface.
QVulkanWindow::~QVulkanWindow | ( | ) |
Destroys the QVulkanWindow.
QVector< VkPhysicalDeviceProperties > QVulkanWindow::availablePhysicalDevices | ( | ) |
Returns the list of properties for the supported physical devices in the system.
This method can be called before making the window visible.
QMatrix4x4 QVulkanWindow::clipCorrectionMatrix | ( | ) |
Returns a QMatrix4x4 that can be used to correct for coordinate system differences between OpenGL and Vulkan.
By pre-multiplying the projection matrix with this matrix, applications can continue to assume that Y is pointing upwards, and can set minDepth and maxDepth in the viewport to 0 and 1, respectively, without having to do any further corrections to the vertex Z positions. Geometry from OpenGL applications can then be used as-is, assuming a rasterization state matching the OpenGL culling and front face settings.
VkFormat QVulkanWindow::colorFormat | ( | ) | const |
Returns the color buffer format used by the swapchain.
int QVulkanWindow::concurrentFrameCount | ( | ) | const |
Returns the number of frames which can be potentially active at the same time. This value is constant for the entire lifetime of the QVulkanWindow.
|
virtual |
Returns a new instance of QVulkanWindowRenderer. This method is called once during the lifetime of the window, at some point after making it visible for the first time. The default implementation returns null and so no rendering will be performed apart from clearing the buffers.
The window takes ownership of the returned renderer object.
VkCommandBuffer QVulkanWindow::currentCommandBuffer | ( | ) | const |
Returns The active command buffer for the current swap chain image. Implementations of QVulkanWindowRenderer::startNextFrame() are expected to add commands to this command buffer.
int QVulkanWindow::currentFrame | ( | ) | const |
Returns the current frame index in the range [0, concurrentFrameCount() - 1].
Renderer implementations will have to ensure that uniform data and other dynamic resources exist in multiple copies, in order to prevent frame N altering the data used by the still-active frames N - 1, N - 2, ... N - concurrentFrameCount() + 1.
To avoid relying on dynamic array sizes, applications can use MAX_CONCURRENT_FRAME_COUNT when declaring arrays. This is guaranteed to be always equal to or greater than the value returned from concurrentFrameCount(). Such arrays can then be indexed by the value returned from this function.
This method must only be called from within startNextFrame() and in case of asynchronous command generation, up until the call to frameReady().
VkFramebuffer QVulkanWindow::currentFramebuffer | ( | ) | const |
Returns a VkFramebuffer for the current swapchain image using the default render pass.
The framebuffer has two attachments (color, depth-stencil) when multisampling is not in use, and three (color resolve, depth-stencil, multisample color) when sampleCountFlagBits() is greater than VK_SAMPLE_COUNT_1_BIT. Renderers must take this into account, for example when providing clear values.
int QVulkanWindow::currentSwapChainImageIndex | ( | ) | const |
Returns the current swap chain image index in the range [0, swapChainImageCount() - 1].
VkRenderPass QVulkanWindow::defaultRenderPass | ( | ) | const |
Returns a typical render pass with one sub-pass.
VkFormat QVulkanWindow::depthStencilFormat | ( | ) | const |
Returns the format used by the depth stencil buffers.
VkImage QVulkanWindow::depthStencilImage | ( | ) | const |
Returns the depth-stencil image.
VkImageView QVulkanWindow::depthStencilImageView | ( | ) | const |
Returns the depth-stencil image view.
VkDevice QVulkanWindow::device | ( | ) | const |
Returns the active logical device.
uint32_t QVulkanWindow::deviceLocalMemoryIndex | ( | ) | const |
Returns a device local memory type index suitable for general use.
|
overridevirtual |
The expose event is sent by the window system whenever the QWindow exposure changes. The application can start rendering into the window with QBackingStore and QOpenGLContext as soon as it gets an exposeEvent() such that isExposed() is true.
If the window is moved off screen, is made totally obscured by another window, iconified or similar, this function might be called and the value of isExposed() might change to false. When this happens, an application should stop its rendering as it is no longer visible to the user.
A resize event will always be sent before the expose event the first time a window is shown.
Reimplemented from QWindow::exposeEvent()
QVulkanWindow::VulkanFlags QVulkanWindow::flags | ( | ) | const |
Return the requested flags.
void QVulkanWindow::frameReady | ( | ) |
This method must be called exactly once in response to each invocation of the QVulkanWindowRenderer::startNextFrame() implementation. At the time of this call, the main command buffer, exposed via currentCommandBuffer(), must have all necessary rendering commands added to it since this method will trigger submitting the commands and queuing the present command.
VkCommandPool QVulkanWindow::graphicsCommandPool | ( | ) | const |
Returns the active graphics command pool.
VkQueue QVulkanWindow::graphicsQueue | ( | ) | const |
Returns the active graphics queue.
uint32_t QVulkanWindow::graphicsQueueFamilyIndex | ( | ) | const |
Returns the family index of the active graphics queue.
uint32_t QVulkanWindow::hostVisibleMemoryIndex | ( | ) | const |
Returns a host visible memory type index suitable for general use. The returned memory type will be both host visible and coherent. In addition, it will also be cached, if possible.
bool QVulkanWindow::isValid | ( | ) | const |
Returns true if this window has successfully initialized all Vulkan resources, including the swapchain.
VkImage QVulkanWindow::msaaColorImage | ( | int | idx | ) | const |
Returns the specified multisample color image, or VK_NULL_HANDLE if multisampling is not in use. The given idx must be in the range [0, swapChainImageCount() - 1].
VkImageView QVulkanWindow::msaaColorImageView | ( | int | idx | ) | const |
Returns the specified multisample color image view, or VK_NULL_HANDLE if multisampling is not in use. The given idx must be in the range [0, swapChainImageCount() - 1].
VkPhysicalDevice QVulkanWindow::physicalDevice | ( | ) | const |
Returns the active physical device.
const VkPhysicalDeviceProperties * QVulkanWindow::physicalDeviceProperties | ( | ) | const |
Returns a pointer to the properties for the active physical device.
VkSampleCountFlagBits QVulkanWindow::sampleCountFlagBits | ( | ) | const |
Returns the current sample count as a VkSampleCountFlagBits value. When targeting the default render target, the rasterizationSamples field of VkPipelineMultisampleStateCreateInfo must be set to this value.
void QVulkanWindow::setDeviceExtensions | ( | const QStringList & | extensions | ) |
Sets the list of device extensions to be enabled. Unsupported extensions are ignored. The swapchain extension will always be added automatically, no need to include it in this list.
void QVulkanWindow::setFlags | ( | QVulkanWindow::VulkanFlags | flags | ) |
Configures the behavior based on the provided flags.
void QVulkanWindow::setPhysicalDeviceIndex | ( | int | idx | ) |
Requests the usage of the physical device with index idx. The index corresponds to the list returned from availablePhysicalDevices().
By default the first physical device is used.
void QVulkanWindow::setPreferredColorFormats | ( | const QVector< VkFormat > & | formats | ) |
Sets the preferred formats of the swapchain. By default no application-preferred format is set. In this case the surface's preferred format will be used or, in absence of that, VK_FORMAT_B8G8R8A8_UNORM.
The list in formats is ordered. If the first format is not supported, the second will be considered, and so on. When no formats in the list are supported, the behavior is the same as in the default case.
To query the actual format after initialization, call colorFormat().
void QVulkanWindow::setSampleCount | ( | int | sampleCount | ) |
Requests multisample antialiasing with the given sampleCount. The valid values are 1, 2, 4, 8, ... up until the maximum value supported by the physical device.
When the sample count is greater than 1, QVulkanWindow will create a multisample color buffer instead of simply targeting the swapchain's images. The rendering in the multisample buffer will get resolved into the non-multisample buffers at the end of each frame.
To examine the list of supported sample counts, call supportedSampleCounts().
When setting up the rendering pipeline, call sampleCountFlagBits() to query the active sample count as a VkSampleCountFlagBits value.
QVector< QVulkanExtensionProperties > QVulkanWindow::supportedDeviceExtensions | ( | ) |
Returns the list of the extensions that are supported by logical devices created from the physical device selected by setPhysicalDeviceIndex().
This method can be called before making the window visible.
QVector< int > QVulkanWindow::supportedSampleCounts | ( | ) |
Returns the set of supported sample counts when using the physical device selected by setPhysicalDeviceIndex(), as a sorted list.
By default QVulkanWindow uses a sample count of 1. By calling setSampleCount() with a different value (2, 4, 8, ...) from the set returned by this method, multisample anti-aliasing can be requested.
This method can be called before making the window visible.
VkImage QVulkanWindow::swapChainImage | ( | int | idx | ) | const |
Returns the specified swap chain image. The given idx must be in the range [0, swapChainImageCount() - 1].
It is only valid to call this method between calling QVulkanWindowRenderer::initSwapChainResources() and QVulkanWindowRenderer::releaseSwapChainResources().
int QVulkanWindow::swapChainImageCount | ( | ) | const |
Returns the number of images in the swap chain. Calling this method is required when providing a custom render pass and framebuffer. The framebuffer is specific to the current swapchain image and hence the application must provide multiple framebuffers.
It is only valid to call this method between calling QVulkanWindowRenderer::initSwapChainResources() and QVulkanWindowRenderer::releaseSwapChainResources().
QSize QVulkanWindow::swapChainImageSize | ( | ) | const |
Returns the image size of the swapchain. This usually matches the size of the window, but may also differ in case vkGetPhysicalDeviceSurfaceCapabilitiesKHR reports a fixed size.
It is only valid to call this method between calling QVulkanWindowRenderer::initSwapChainResources() and QVulkanWindowRenderer::releaseSwapChainResources().
VkImageView QVulkanWindow::swapChainImageView | ( | int | idx | ) | const |
Returns the specified swap chain image view. The given idx must be in the range [0, swapChainImageCount() - 1].
It is only valid to call this method between calling QVulkanWindowRenderer::initSwapChainResources() and QVulkanWindowRenderer::releaseSwapChainResources().
|
deprecatedstaticconstexpr |
A constant value which is always equal to or greater than the maximum value of concurrentFrameCount().