Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
#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 |
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. | |
QSize | currentPixelSize () const |
virtual QRhiSwapChainHdrInfo | hdrInfo () |
\variable QRhiSwapChainHdrInfo::limitsType | |
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 |
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 574 of file qrhivulkan_p.h.
QVkSwapChain::QVkSwapChain | ( | QRhiImplementation * | rhi | ) |
Definition at line 7882 of file qrhivulkan.cpp.
QVkSwapChain::~QVkSwapChain | ( | ) |
Definition at line 7890 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 8094 of file qrhivulkan.cpp.
References bufferCount, QVkRenderTargetData::colorAttCount, QRhiRenderBuffer::create(), QVkSwapChainRenderTarget::d, destroy(), QVkRenderTargetData::dpr, ds, QVkRenderTargetData::dsAttCount, QVkRenderTargetData::dsResolveAttCount, QRhiRenderBuffer::flags(), frameCount, QSize::height(), i, imageRes, QVkRenderBuffer::imageView, QRhiSwapChain::m_currentPixelSize, QRhiSwapChain::m_depthStencil, QRhiSwapChain::m_renderPassDesc, QRhiSwapChain::m_sampleCount, QRhiSwapChain::m_window, QRhiRenderBuffer::pixelSize(), QVkRenderTargetData::pixelSize, pixelSize, Q_ASSERT, QRHI_RES, QRHI_RES_RHI, qWarning, QVkRenderTargetData::resolveAttCount, QVkRenderPassDescriptor::rp, QVkRenderTargetData::rp, rtWrapper, rtWrapperRight, QRhiRenderBuffer::sampleCount(), QVkRenderTargetData::sampleCount, samples, QRhiRenderBuffer::setPixelSize(), QRhiRenderTarget::setRenderPassDescriptor(), stereo, surfacePixelSize(), QRhiRenderBuffer::UsedWithSwapChainOnly, QSize::width(), and window.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 7918 of file qrhivulkan.cpp.
References cbWrapper.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 7923 of file qrhivulkan.cpp.
References rtWrapper.
|
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 7928 of file qrhivulkan.cpp.
References QRhiSwapChain::LeftBuffer, rtWrapper, rtWrapperRight, and stereo.
|
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 7895 of file qrhivulkan.cpp.
References frame, frameRes, i, lastConnectedSurface, QRHI_RES_RHI, QVK_FRAMES_IN_FLIGHT, sc, and surface.
Referenced by ~QVkSwapChain(), and createOrResize().
bool QVkSwapChain::ensureSurface | ( | ) |
Definition at line 8037 of file qrhivulkan.cpp.
References colorSpace, QVarLengthArray< T, Prealloc >::data(), hdrFormatMatchesVkSurfaceFormat(), i, isSrgbFormat(), QRhiSwapChain::m_flags, QRhiSwapChain::m_format, QRhiSwapChain::m_sampleCount, QRhiSwapChain::m_window, ok, Q_ASSERT, QRHI_RES_RHI, qWarning, QVarLengthArray< T, Prealloc >::resize(), QRhiSwapChain::SDR, QRhiSwapChain::sRGB, supportedPresentationModes, and surface.
Referenced by newCompatibleRenderPassDescriptor(), and surfacePixelSize().
|
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 7969 of file qrhivulkan.cpp.
References hdrFormatMatchesVkSurfaceFormat(), i, QRhiSwapChain::m_window, QRHI_RES_RHI, qWarning, and QRhiSwapChain::SDR.
|
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 7997 of file qrhivulkan.cpp.
References ensureSurface(), QRhiSwapChain::m_depthStencil, QRhiResource::m_rhi, QVkRenderPassDescriptor::ownsRp, QRHI_RES_RHI, 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 7933 of file qrhivulkan.cpp.
References ensureSurface(), QRhiSwapChain::m_window, Q_ASSERT, QRHI_RES_RHI, QWindow::size(), and surface.
Referenced by createOrResize().
|
friend |
Definition at line 644 of file qrhivulkan_p.h.
int QVkSwapChain::bufferCount = 0 |
Definition at line 599 of file qrhivulkan_p.h.
Referenced by createOrResize().
QVkCommandBuffer QVkSwapChain::cbWrapper |
Definition at line 610 of file qrhivulkan_p.h.
Referenced by currentFrameCommandBuffer(), and QRhiVulkan::finish().
VkFormat QVkSwapChain::colorFormat = VK_FORMAT_B8G8R8A8_UNORM |
Definition at line 602 of file qrhivulkan_p.h.
VkColorSpaceKHR QVkSwapChain::colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR |
Definition at line 603 of file qrhivulkan_p.h.
Referenced by ensureSurface().
quint32 QVkSwapChain::currentFrameSlot = 0 |
Definition at line 641 of file qrhivulkan_p.h.
quint32 QVkSwapChain::currentImageIndex = 0 |
Definition at line 640 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginPass().
QVkRenderBuffer* QVkSwapChain::ds = nullptr |
Definition at line 604 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), and createOrResize().
|
static |
Definition at line 592 of file qrhivulkan_p.h.
int QVkSwapChain::frameCount = 0 |
Definition at line 642 of file qrhivulkan_p.h.
Referenced by createOrResize().
struct QVkSwapChain::FrameResources QVkSwapChain::frameRes[QVK_FRAMES_IN_FLIGHT] |
Referenced by destroy().
QVarLengthArray<ImageResources, EXPECTED_MAX_BUFFER_COUNT> QVkSwapChain::imageRes |
Definition at line 625 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginPass(), and createOrResize().
VkSurfaceKHR QVkSwapChain::lastConnectedSurface = VK_NULL_HANDLE |
Definition at line 601 of file qrhivulkan_p.h.
Referenced by destroy().
VkDeviceMemory QVkSwapChain::msaaImageMem = VK_NULL_HANDLE |
Definition at line 607 of file qrhivulkan_p.h.
QSize QVkSwapChain::pixelSize |
Definition at line 595 of file qrhivulkan_p.h.
Referenced by createOrResize().
QVkSwapChainRenderTarget QVkSwapChain::rtWrapper |
Definition at line 608 of file qrhivulkan_p.h.
Referenced by createOrResize(), currentFrameRenderTarget(), and currentFrameRenderTarget().
QVkSwapChainRenderTarget QVkSwapChain::rtWrapperRight |
Definition at line 609 of file qrhivulkan_p.h.
Referenced by createOrResize(), and currentFrameRenderTarget().
VkSampleCountFlagBits QVkSwapChain::samples = VK_SAMPLE_COUNT_1_BIT |
Definition at line 605 of file qrhivulkan_p.h.
Referenced by createOrResize().
VkSwapchainKHR QVkSwapChain::sc = VK_NULL_HANDLE |
Definition at line 598 of file qrhivulkan_p.h.
Referenced by destroy().
bool QVkSwapChain::stereo = false |
Definition at line 597 of file qrhivulkan_p.h.
Referenced by createOrResize(), and currentFrameRenderTarget().
QVarLengthArray<VkPresentModeKHR, 8> QVkSwapChain::supportedPresentationModes |
Definition at line 606 of file qrhivulkan_p.h.
Referenced by ensureSurface().
bool QVkSwapChain::supportsReadback = false |
Definition at line 596 of file qrhivulkan_p.h.
VkSurfaceKHR QVkSwapChain::surface = VK_NULL_HANDLE |
Definition at line 600 of file qrhivulkan_p.h.
Referenced by destroy(), ensureSurface(), and surfacePixelSize().
Definition at line 594 of file qrhivulkan_p.h.
Referenced by createOrResize().