![]() |
Qt 6.x
The Qt SDK
|
#include <qrhimetal_p.h>
Public Member Functions | |
QMetalSwapChain (QRhiImplementation *rhi) | |
~QMetalSwapChain () | |
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. | |
virtual QRhiSwapChainHdrInfo | hdrInfo () override |
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults | |
void | chooseFormats () |
void | waitUntilCompleted (int slot) |
![]() | |
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 |
int | currentFrameSlot = 0 |
int | frameCount = 0 |
int | samples = 1 |
QMetalSwapChainRenderTarget | rtWrapper |
QMetalCommandBuffer | cbWrapper |
QMetalRenderBuffer * | ds = nullptr |
QMetalSwapChainData * | d = nullptr |
Definition at line 292 of file qrhimetal_p.h.
QMetalSwapChain::QMetalSwapChain | ( | QRhiImplementation * | rhi | ) |
Definition at line 6075 of file qrhimetal.mm.
References d, i, QMetalSwapChainData::msaaTex, QMTL_FRAMES_IN_FLIGHT, and QMetalSwapChainData::sem.
QMetalSwapChain::~QMetalSwapChain | ( | ) |
void QMetalSwapChain::chooseFormats | ( | ) |
Definition at line 6218 of file qrhimetal.mm.
References QRhiTexture::BGRA8, QMetalSwapChainData::colorFormat, d, QRhiSwapChain::HDRExtendedSrgbLinear, QRhiSwapChain::m_flags, QRhiSwapChain::m_format, QRhiSwapChain::m_sampleCount, QRHI_RES_RHI, QRhiTexture::RGBA16F, QMetalSwapChainData::rhiColorFormat, and QRhiSwapChain::sRGB.
Referenced by createOrResize(), and newCompatibleRenderPassDescriptor().
|
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 6243 of file qrhimetal.mm.
References chooseFormats(), QMetalRenderTargetData::colorAttCount, QMetalSwapChainData::colorFormat, QRhiRenderBuffer::create(), QMetalSwapChainData::curDrawable, currentFrameSlot, QMetalSwapChainRenderTarget::d, d, desc, destroy(), QMetalRenderTargetData::dpr, ds, QMetalRenderTargetData::dsAttCount, QRhiRenderBuffer::flags(), frameCount, QRhiSwapChain::HDRExtendedSrgbLinear, QSize::height(), i, init(), iOS, QMetalSwapChainData::lastGpuTime, QMetalSwapChainData::layer, QRhiSwapChain::m_currentPixelSize, QRhiSwapChain::m_depthStencil, QRhiSwapChain::m_flags, QRhiSwapChain::m_format, QRhiSwapChain::m_proxyData, QRhiSwapChain::m_renderPassDesc, QRhiSwapChain::m_sampleCount, QRhiSwapChain::m_window, QRhi::Metal, QSurface::MetalSurface, QMetalSwapChainData::msaaTex, QRhiSwapChain::NoVSync, QRhiRenderBuffer::pixelSize(), QMetalRenderTargetData::pixelSize, pixelSize, Q_ASSERT, qCDebug, qEnvironmentVariableIntValue(), QMTL_FRAMES_IN_FLIGHT, QRHI_RES, QRHI_RES_RHI, qWarning, release(), rtWrapper, QRhiRenderBuffer::sampleCount(), QMetalRenderTargetData::sampleCount, samples, QMetalSwapChainData::sem, QRhiRenderBuffer::setPixelSize(), QRhiRenderTarget::setRenderPassDescriptor(), QRhiSwapChain::SurfaceHasNonPreMulAlpha, QRhiSwapChain::SurfaceHasPreMulAlpha, QWindow::surfaceType(), QRhiSwapChain::UsedAsTransferSource, QRhiRenderBuffer::UsedWithSwapChainOnly, view, QSize::width(), and window.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 6131 of file qrhimetal.mm.
References cbWrapper.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 6136 of file qrhimetal.mm.
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 6093 of file qrhimetal.mm.
References QMetalSwapChainData::curDrawable, d, i, QMetalSwapChainData::layer, QMetalSwapChainData::msaaTex, QMTL_FRAMES_IN_FLIGHT, QRHI_RES_RHI, release(), QMetalSwapChainData::sem, and waitUntilCompleted().
Referenced by ~QMetalSwapChain(), and createOrResize().
|
overridevirtual |
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
Set to true when the data in the QRhiSwapChainHdrInfo consists entirely of the hard-coded default values, for example because there is no way to query the relevant information with a given graphics API or platform. (or because querying it can be achieved only by means, e.g. platform APIs in some other area, that are out of scope for the QRhi layer of the Qt graphics stack to handle)
\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:
Whereas for macOS/iOS, the current maximum and potential maximum color component values are provided:
The returned struct is always the default one if createOrResize() has not been successfully called yet.
Reimplemented from QRhiSwapChain.
Definition at line 6405 of file qrhimetal.mm.
References QRhiSwapChainHdrInfo::ColorComponentValue, info, iOS, QRhiSwapChain::m_window, screen, and view.
Referenced by isFormatSupported().
|
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 6181 of file qrhimetal.mm.
References QRhiSwapChainHdrInfo::colorComponentValue, QRhiSwapChain::HDRExtendedSrgbLinear, hdrInfo(), iOS, QRhiSwapChainHdrInfo::limits, QRhiSwapChainHdrInfo::maxPotentialColorComponentValue, 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 6192 of file qrhimetal.mm.
References chooseFormats(), QMetalRenderPassDescriptor::colorAttachmentCount, QMetalSwapChainData::colorFormat, QMetalRenderPassDescriptor::colorFormat, d, QMetalRenderPassDescriptor::dsFormat, QMetalRenderPassDescriptor::hasDepthStencil, QRhiSwapChain::m_depthStencil, QRhiResource::m_rhi, QRHI_RES_RHI, and QMetalRenderPassDescriptor::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 6166 of file qrhimetal.mm.
References d, QMetalSwapChainData::layer, QRhiSwapChain::m_proxyData, QRhiSwapChain::m_window, QRhi::Metal, and Q_ASSERT.
void QMetalSwapChain::waitUntilCompleted | ( | int | slot | ) |
Definition at line 6232 of file qrhimetal.mm.
References d, sem, and QMetalSwapChainData::sem.
Referenced by destroy().
QMetalCommandBuffer QMetalSwapChain::cbWrapper |
Definition at line 318 of file qrhimetal_p.h.
Referenced by QRhiMetal::beginFrame(), currentFrameCommandBuffer(), QRhiMetal::endFrame(), and QRhiMetal::finish().
int QMetalSwapChain::currentFrameSlot = 0 |
Definition at line 314 of file qrhimetal_p.h.
Referenced by QRhiMetal::beginFrame(), createOrResize(), and QRhiMetal::endFrame().
QMetalSwapChainData* QMetalSwapChain::d = nullptr |
Definition at line 320 of file qrhimetal_p.h.
Referenced by QMetalSwapChain(), ~QMetalSwapChain(), QRhiMetal::beginFrame(), QRhiMetal::beginPass(), chooseFormats(), createOrResize(), destroy(), QRhiMetal::endFrame(), QRhiMetal::finish(), newCompatibleRenderPassDescriptor(), surfacePixelSize(), and waitUntilCompleted().
QMetalRenderBuffer* QMetalSwapChain::ds = nullptr |
Definition at line 319 of file qrhimetal_p.h.
Referenced by QRhiMetal::beginFrame(), and createOrResize().
int QMetalSwapChain::frameCount = 0 |
Definition at line 315 of file qrhimetal_p.h.
Referenced by createOrResize(), and QRhiMetal::endFrame().
QSize QMetalSwapChain::pixelSize |
Definition at line 313 of file qrhimetal_p.h.
Referenced by createOrResize().
QMetalSwapChainRenderTarget QMetalSwapChain::rtWrapper |
Definition at line 317 of file qrhimetal_p.h.
Referenced by QRhiMetal::beginFrame(), createOrResize(), and currentFrameRenderTarget().
int QMetalSwapChain::samples = 1 |
Definition at line 316 of file qrhimetal_p.h.
Referenced by QRhiMetal::beginFrame(), and createOrResize().
Definition at line 312 of file qrhimetal_p.h.
Referenced by createOrResize().