![]() |
Qt 6.x
The Qt SDK
|
#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 |
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 () |
![]() | |
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 QRhiCommandBuffer * | currentFrameCommandBuffer ()=0 |
virtual QRhiRenderTarget * | currentFrameRenderTarget ()=0 |
virtual QRhiRenderTarget * | currentFrameRenderTarget (StereoTargetBuffer targetBuffer) |
virtual QSize | surfacePixelSize ()=0 |
virtual bool | isFormatSupported (Format f)=0 |
virtual QRhiRenderPassDescriptor * | newCompatibleRenderPassDescriptor ()=0 |
virtual bool | createOrResize ()=0 |
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size of the targeted surface. | |
virtual QRhiSwapChainHdrInfo | hdrInfo () |
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults | |
![]() | |
virtual | ~QRhiResource () |
Destructor. | |
virtual Type | resourceType () const =0 |
virtual void | destroy ()=0 |
Releases (or requests deferred releasing of) the underlying native graphics resources. | |
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 |
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 |
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 567 of file qrhivulkan_p.h.
QVkSwapChain::QVkSwapChain | ( | QRhiImplementation * | rhi | ) |
Definition at line 7446 of file qrhivulkan.cpp.
QVkSwapChain::~QVkSwapChain | ( | ) |
Definition at line 7453 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 7649 of file qrhivulkan.cpp.
References bufferCount, QVkRenderTargetData::colorAttCount, QRhiRenderBuffer::create(), QVkSwapChainRenderTarget::d, destroy(), QVkRenderTargetData::dpr, ds, QVkRenderTargetData::dsAttCount, 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, QRhiRenderBuffer::sampleCount(), QVkRenderTargetData::sampleCount, samples, QRhiRenderBuffer::setPixelSize(), QRhiRenderTarget::setRenderPassDescriptor(), surfacePixelSize(), QRhiRenderBuffer::UsedWithSwapChainOnly, QSize::width(), and window.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 7481 of file qrhivulkan.cpp.
References cbWrapper.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 7486 of file qrhivulkan.cpp.
References rtWrapper.
|
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 7458 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 7592 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 7524 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 7552 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 7491 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 634 of file qrhivulkan_p.h.
int QVkSwapChain::bufferCount = 0 |
Definition at line 590 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), createOrResize(), QRhiVulkan::endFrame(), QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
QVkCommandBuffer QVkSwapChain::cbWrapper |
Definition at line 600 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), currentFrameCommandBuffer(), QRhiVulkan::endFrame(), and QRhiVulkan::finish().
VkFormat QVkSwapChain::colorFormat = VK_FORMAT_B8G8R8A8_UNORM |
Definition at line 593 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::enqueueResourceUpdates(), and QRhiVulkan::recreateSwapChain().
VkColorSpaceKHR QVkSwapChain::colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR |
Definition at line 594 of file qrhivulkan_p.h.
Referenced by ensureSurface(), and QRhiVulkan::recreateSwapChain().
quint32 QVkSwapChain::currentFrameSlot = 0 |
Definition at line 631 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), QRhiVulkan::endFrame(), QRhiVulkan::finish(), and QRhiVulkan::recreateSwapChain().
quint32 QVkSwapChain::currentImageIndex = 0 |
Definition at line 630 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), QRhiVulkan::beginPass(), QRhiVulkan::endFrame(), QRhiVulkan::enqueueResourceUpdates(), and QRhiVulkan::recreateSwapChain().
QVkRenderBuffer* QVkSwapChain::ds = nullptr |
Definition at line 595 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), and createOrResize().
|
static |
Definition at line 584 of file qrhivulkan_p.h.
int QVkSwapChain::frameCount = 0 |
Definition at line 632 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 615 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), QRhiVulkan::beginPass(), createOrResize(), QRhiVulkan::endFrame(), QRhiVulkan::enqueueResourceUpdates(), QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
VkSurfaceKHR QVkSwapChain::lastConnectedSurface = VK_NULL_HANDLE |
Definition at line 592 of file qrhivulkan_p.h.
Referenced by destroy(), and QRhiVulkan::recreateSwapChain().
VkDeviceMemory QVkSwapChain::msaaImageMem = VK_NULL_HANDLE |
Definition at line 598 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
QSize QVkSwapChain::pixelSize |
Definition at line 587 of file qrhivulkan_p.h.
Referenced by createOrResize(), QRhiVulkan::enqueueResourceUpdates(), and QRhiVulkan::recreateSwapChain().
QVkSwapChainRenderTarget QVkSwapChain::rtWrapper |
Definition at line 599 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), createOrResize(), and currentFrameRenderTarget().
VkSampleCountFlagBits QVkSwapChain::samples = VK_SAMPLE_COUNT_1_BIT |
Definition at line 596 of file qrhivulkan_p.h.
Referenced by createOrResize(), and QRhiVulkan::recreateSwapChain().
VkSwapchainKHR QVkSwapChain::sc = VK_NULL_HANDLE |
Definition at line 589 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), destroy(), QRhiVulkan::endFrame(), QRhiVulkan::recreateSwapChain(), and QRhiVulkan::releaseSwapChainResources().
QVarLengthArray<VkPresentModeKHR, 8> QVkSwapChain::supportedPresentationModes |
Definition at line 597 of file qrhivulkan_p.h.
Referenced by ensureSurface(), and QRhiVulkan::recreateSwapChain().
bool QVkSwapChain::supportsReadback = false |
Definition at line 588 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::enqueueResourceUpdates(), and QRhiVulkan::recreateSwapChain().
VkSurfaceKHR QVkSwapChain::surface = VK_NULL_HANDLE |
Definition at line 591 of file qrhivulkan_p.h.
Referenced by destroy(), ensureSurface(), QRhiVulkan::recreateSwapChain(), and surfacePixelSize().
Definition at line 586 of file qrhivulkan_p.h.
Referenced by QRhiVulkan::beginFrame(), createOrResize(), and QRhiVulkan::endFrame().