![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include <qrhivulkan_p.h>
Classes | |
struct | FrameResources |
struct | ImageResources |
Public Member Functions | |
QVkSwapChain (QRhiImplementation *rhi) | |
~QVkSwapChain () | |
void | destroy () override |
Releases (or requests deferred releasing of) the underlying native graphics resources. | |
QRhiCommandBuffer * | currentFrameCommandBuffer () override |
QRhiRenderTarget * | currentFrameRenderTarget () override |
QRhiRenderTarget * | currentFrameRenderTarget (StereoTargetBuffer targetBuffer) override |
QSize | surfacePixelSize () override |
bool | isFormatSupported (Format f) override |
QRhiSwapChainHdrInfo | hdrInfo () override |
\variable QRhiSwapChainHdrInfo::limitsType | |
QRhiRenderPassDescriptor * | newCompatibleRenderPassDescriptor () override |
bool | createOrResize () override |
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size of the targeted surface. | |
bool | ensureSurface () |
Public Member Functions inherited from QRhiSwapChain | |
QRhiResource::Type | resourceType () const override |
QWindow * | window () const |
void | setWindow (QWindow *window) |
Sets the window. | |
QRhiSwapChainProxyData | proxyData () const |
void | setProxyData (const QRhiSwapChainProxyData &d) |
Sets the proxy data d. | |
Flags | flags () const |
void | setFlags (Flags f) |
Sets the flags f. | |
Format | format () const |
void | setFormat (Format f) |
Sets the format f. | |
QRhiRenderBuffer * | depthStencil () const |
void | setDepthStencil (QRhiRenderBuffer *ds) |
Sets the renderbuffer ds for use as a depth-stencil buffer. | |
int | sampleCount () const |
void | setSampleCount (int samples) |
Sets the sample count. | |
QRhiRenderPassDescriptor * | renderPassDescriptor () const |
void | setRenderPassDescriptor (QRhiRenderPassDescriptor *desc) |
Associates with the QRhiRenderPassDescriptor desc. | |
QRhiShadingRateMap * | shadingRateMap () const |
void | setShadingRateMap (QRhiShadingRateMap *map) |
Associates with the specified QRhiShadingRateMap map. | |
QSize | currentPixelSize () const |
Public Member Functions inherited from QRhiResource | |
virtual | ~QRhiResource () |
Destructor. | |
void | deleteLater () |
When called without a frame being recorded, this function is equivalent to deleting the object. | |
QByteArray | name () const |
void | setName (const QByteArray &name) |
Sets a name for the object. | |
quint64 | globalResourceId () const |
QRhi * | rhi () const |
Public Attributes | |
QWindow * | window = nullptr |
QSize | pixelSize |
bool | supportsReadback = false |
bool | stereo = false |
VkSwapchainKHR | sc = VK_NULL_HANDLE |
int | bufferCount = 0 |
VkSurfaceKHR | surface = VK_NULL_HANDLE |
VkSurfaceKHR | lastConnectedSurface = VK_NULL_HANDLE |
VkFormat | colorFormat = VK_FORMAT_B8G8R8A8_UNORM |
VkColorSpaceKHR | colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR |
QVkRenderBuffer * | ds = nullptr |
VkSampleCountFlagBits | samples = VK_SAMPLE_COUNT_1_BIT |
QVarLengthArray< VkPresentModeKHR, 8 > | supportedPresentationModes |
VkDeviceMemory | msaaImageMem = VK_NULL_HANDLE |
QVkSwapChainRenderTarget | rtWrapper |
QVkSwapChainRenderTarget | rtWrapperRight |
QVkCommandBuffer | cbWrapper |
VkImageView | shadingRateMapView = VK_NULL_HANDLE |
QVarLengthArray< ImageResources, EXPECTED_MAX_BUFFER_COUNT > | imageRes |
struct QVkSwapChain::FrameResources | frameRes [QVK_FRAMES_IN_FLIGHT] |
quint32 | currentImageIndex = 0 |
quint32 | currentFrameSlot = 0 |
int | frameCount = 0 |
Static Public Attributes | |
static const quint32 | EXPECTED_MAX_BUFFER_COUNT = 4 |
Friends | |
class | QRhiVulkan |
Definition at line 599 of file qrhivulkan_p.h.
QVkSwapChain::QVkSwapChain | ( | QRhiImplementation * | rhi | ) |
Definition at line 8618 of file qrhivulkan.cpp.
References QVkSwapChain().
Referenced by QVkSwapChain().
QVkSwapChain::~QVkSwapChain | ( | ) |
Definition at line 8626 of file qrhivulkan.cpp.
References destroy().
|
overridevirtual |
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size of the targeted surface.
Call this whenever the size of the target surface is different than before.
true
when successful, false
when a graphics operation failed. Regardless of the return value, calling destroy() is always safe. Implements QRhiSwapChain.
Definition at line 8843 of file qrhivulkan.cpp.
References bufferCount, destroy(), QRhiVulkan::df, ds, frameCount, QRhiVulkan::recreateSwapChain(), and stereo.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 8654 of file qrhivulkan.cpp.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 8659 of file qrhivulkan.cpp.
|
overridevirtual |
When stereoscopic rendering is not supported, the return value will be the default target. It is supported by all hardware backends except for Metal, in combination with \l QSurfaceFormat::StereoBuffers, assuming it is supported by the graphics and display driver stack at run time. Metal and Null backends are going to return the default render target from this overload.
Reimplemented from QRhiSwapChain.
Definition at line 8664 of file qrhivulkan.cpp.
|
overridevirtual |
Releases (or requests deferred releasing of) the underlying native graphics resources.
Safe to call multiple times, subsequent invocations will be a no-op then.
Once destroy() is called, the QRhiResource instance can be reused, by calling create()
again. That will then result in creating new native graphics resources underneath.
The QRhiResource destructor also performs the same task, so calling this function is not necessary before deleting a QRhiResource.
Implements QRhiResource.
Definition at line 8631 of file qrhivulkan.cpp.
References QVK_FRAMES_IN_FLIGHT, QRhiVulkan::releaseSwapChainResources(), and QVkSwapChain::FrameResources::timestampQueryIndex.
Referenced by ~QVkSwapChain(), and createOrResize().
bool QVkSwapChain::ensureSurface | ( | ) |
Definition at line 8786 of file qrhivulkan.cpp.
Referenced by newCompatibleRenderPassDescriptor(), and surfacePixelSize().
|
overridevirtual |
\variable QRhiSwapChainHdrInfo::limitsType
With Metal on macOS/iOS, there is no luminance values exposed in the platform APIs. Instead, the maximum color component value, that would be 1.0 in a non-HDR setup, is provided. This value indicates what kind of information is available in \l limits.
\variable QRhiSwapChainHdrInfo::limits
Contains the actual values queried from the graphics API or the platform. The type of data is indicated by \l limitsType. This is therefore a union. There are currently two options:
Luminance values in nits:
On Windows the minimum and maximum luminance depends on the screen brightness. While not relevant for desktops, on laptops the screen brightness may change at any time. Increasing brightness implies decreased maximum luminance. In addition, the results may also be dependent on the HDR Content Brightness set in Windows Settings' System/Display/HDR view, if there is such a setting.
Note however that the changes made to the laptop screen's brightness or in the system settings while the application is running are not necessarily reflected in the returned values, meaning calling hdrInfo() again may still return the same luminance range as before for the rest of the process' lifetime. The exact behavior is up to DXGI and Qt has no control over it.
For macOS/iOS, the current maximum and potential maximum color component values are provided:
The value may depend on the screen brightness, which on laptops means that the result may change in the next call to hdrInfo() if the brightness was changed in the meantime. The maximum screen brightness implies a maximum color value of 1.0.
\variable QRhiSwapChainHdrInfo::luminanceBehavior
Describes the platform's presumed behavior with regards to color values.
\variable QRhiSwapChainHdrInfo::sdrWhiteLevel
On Windows this is the dynamic SDR white level in nits. The value is dependent on the screen brightness (on laptops), and the SDR or HDR Content Brightness settings in the Windows settings' System/Display/HDR view.
To perform white level correction for non-HDR (SDR) content, such as 2D UI elemenents, multiply the final color with sdrWhiteLevel / 80.0 whenever \l luminanceBehavior is SceneReferred. (assuming Windows and a linear extended sRGB (scRGB) color space)
On other platforms the value is always a pre-defined value, 200. This may not match the system's actual SDR white level, but the value of this variable is not relevant in practice when the \l luminanceBehavior is DisplayReferred, because then the color component value of 1.0 refers to the SDR white by default.
Do not assume that this is a cheap operation. Depending on the platform, this function makes various platform queries which may have a performance impact.
Reimplemented from QRhiSwapChain.
Definition at line 8733 of file qrhivulkan.cpp.
|
overridevirtual |
The main use of this function is to call it before the first createOrResize() after the window is already set. This allow the QRhi backends to perform platform or windowing system specific queries to determine if the window (and the screen it is on) is capable of true HDR output with the specified format.
When the format is reported as supported, call setFormat() to set the requested format and call createOrResize(). Be aware of the consequences however: successfully requesting a HDR format will involve having to deal with a different color space, possibly doing white level correction for non-HDR-aware content, adjusting tonemapping methods, adjusting offscreen render target settings, etc.
Implements QRhiSwapChain.
Definition at line 8705 of file qrhivulkan.cpp.
|
overridevirtual |
The returned value is used in two ways: it can be passed to setRenderPassDescriptor() and QRhiGraphicsPipeline::setRenderPassDescriptor(). A render pass descriptor describes the attachments (color, depth/stencil) and the load/store behavior that can be affected by flags(). A QRhiGraphicsPipeline can only be used in combination with a swapchain that has a \l{QRhiRenderPassDescriptor::isCompatible()}{compatible} QRhiRenderPassDescriptor set.
Implements QRhiSwapChain.
Definition at line 8745 of file qrhivulkan.cpp.
References ensureSurface(), QVkRenderPassDescriptor::ownsRp, and QVkRenderPassDescriptor::updateSerializedFormat().
|
overridevirtual |
{QWindow::size() * QWindow::devicePixelRatio()}. With some graphics APIs and windowing system interfaces (for example, Vulkan) there is a theoretical possibility for a surface to assume a size different from the associated window. To support these cases, {rendering logic must always base size-derived calculations (such as, viewports) on the size reported from QRhiSwapChain, and never on the size queried from QWindow}.Implements QRhiSwapChain.
Definition at line 8669 of file qrhivulkan.cpp.
References ensureSurface().
|
friend |
Definition at line 669 of file qrhivulkan_p.h.
int QVkSwapChain::bufferCount = 0 |
Definition at line 625 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), createOrResize(), QRhiVulkan::endFrame(), QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
QVkCommandBuffer QVkSwapChain::cbWrapper |
Definition at line 636 of file qrhivulkan_p.h.
VkFormat QVkSwapChain::colorFormat = VK_FORMAT_B8G8R8A8_UNORM |
Definition at line 628 of file qrhivulkan_p.h.
VkColorSpaceKHR QVkSwapChain::colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR |
Definition at line 629 of file qrhivulkan_p.h.
quint32 QVkSwapChain::currentFrameSlot = 0 |
Definition at line 666 of file qrhivulkan_p.h.
quint32 QVkSwapChain::currentImageIndex = 0 |
Definition at line 665 of file qrhivulkan_p.h.
QVkRenderBuffer* QVkSwapChain::ds = nullptr |
Definition at line 630 of file qrhivulkan_p.h.
Referenced by createOrResize().
|
static |
Definition at line 618 of file qrhivulkan_p.h.
int QVkSwapChain::frameCount = 0 |
Definition at line 667 of file qrhivulkan_p.h.
Referenced by createOrResize(), and QRhiVulkan::endFrame().
struct QVkSwapChain::FrameResources QVkSwapChain::frameRes[QVK_FRAMES_IN_FLIGHT] |
QVarLengthArray<ImageResources, EXPECTED_MAX_BUFFER_COUNT> QVkSwapChain::imageRes |
Definition at line 653 of file qrhivulkan_p.h.
VkSurfaceKHR QVkSwapChain::lastConnectedSurface = VK_NULL_HANDLE |
Definition at line 627 of file qrhivulkan_p.h.
VkDeviceMemory QVkSwapChain::msaaImageMem = VK_NULL_HANDLE |
Definition at line 633 of file qrhivulkan_p.h.
QSize QVkSwapChain::pixelSize |
Definition at line 621 of file qrhivulkan_p.h.
QVkSwapChainRenderTarget QVkSwapChain::rtWrapper |
Definition at line 634 of file qrhivulkan_p.h.
QVkSwapChainRenderTarget QVkSwapChain::rtWrapperRight |
Definition at line 635 of file qrhivulkan_p.h.
VkSampleCountFlagBits QVkSwapChain::samples = VK_SAMPLE_COUNT_1_BIT |
Definition at line 631 of file qrhivulkan_p.h.
VkSwapchainKHR QVkSwapChain::sc = VK_NULL_HANDLE |
Definition at line 624 of file qrhivulkan_p.h.
VkImageView QVkSwapChain::shadingRateMapView = VK_NULL_HANDLE |
Definition at line 637 of file qrhivulkan_p.h.
bool QVkSwapChain::stereo = false |
Definition at line 623 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), createOrResize(), QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
QVarLengthArray<VkPresentModeKHR, 8> QVkSwapChain::supportedPresentationModes |
Definition at line 632 of file qrhivulkan_p.h.
bool QVkSwapChain::supportsReadback = false |
Definition at line 622 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::enqueueResourceUpdates().
VkSurfaceKHR QVkSwapChain::surface = VK_NULL_HANDLE |
Definition at line 626 of file qrhivulkan_p.h.
QWindow* QVkSwapChain::window = nullptr |
Definition at line 620 of file qrhivulkan_p.h.