![]() |
Qt 6.x
The Qt SDK
|
#include <qrhid3d11_p.h>
Public Member Functions | |
QD3D11SwapChain (QRhiImplementation *rhi) | |
~QD3D11SwapChain () | |
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 |
QRhiSwapChainHdrInfo | hdrInfo () override |
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults | |
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. | |
void | releaseBuffers () |
bool | newColorBuffer (const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc, ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const |
![]() | |
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 |
QD3D11SwapChainRenderTarget | rt |
QD3D11CommandBuffer | cb |
DXGI_FORMAT | colorFormat |
DXGI_FORMAT | srgbAdjustedColorFormat |
IDXGISwapChain * | swapChain = nullptr |
UINT | swapChainFlags = 0 |
ID3D11Texture2D * | backBufferTex |
ID3D11RenderTargetView * | backBufferRtv |
ID3D11Texture2D * | msaaTex [BUFFER_COUNT] |
ID3D11RenderTargetView * | msaaRtv [BUFFER_COUNT] |
DXGI_SAMPLE_DESC | sampleDesc |
int | currentFrameSlot = 0 |
int | frameCount = 0 |
QD3D11RenderBuffer * | ds = nullptr |
UINT | swapInterval = 1 |
IDCompositionTarget * | dcompTarget = nullptr |
IDCompositionVisual * | dcompVisual = nullptr |
QD3D11Timestamps | timestamps |
Static Public Attributes | |
static const int | BUFFER_COUNT = QD3D11_SWAPCHAIN_BUFFER_COUNT |
Definition at line 574 of file qrhid3d11_p.h.
QD3D11SwapChain::QD3D11SwapChain | ( | QRhiImplementation * | rhi | ) |
Definition at line 4783 of file qrhid3d11.cpp.
References backBufferRtv, backBufferTex, BUFFER_COUNT, i, msaaRtv, and msaaTex.
QD3D11SwapChain::~QD3D11SwapChain | ( | ) |
Definition at line 4796 of file qrhid3d11.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 4997 of file qrhid3d11.cpp.
References QSurfaceFormat::alphaBufferSize(), backBufferRtv, backBufferTex, BUFFER_COUNT, QD3D11RenderTargetData::colorAttCount, colorFormat, QRhiRenderBuffer::create(), currentFrameSlot, QD3D11SwapChainRenderTarget::d, dcompTarget, dcompVisual, DEFAULT_FORMAT, DEFAULT_SRGB_FORMAT, desc, destroy(), QD3D11RenderTargetData::dpr, ds, QD3D11RenderTargetData::dsAttCount, QRhi::EnableTimestamps, QRhiRenderBuffer::flags(), frameCount, QRhiSwapChain::HDR10, QRhiSwapChain::HDRExtendedSrgbLinear, QSize::height(), i, QSize::isEmpty(), QRhiSwapChain::m_currentPixelSize, QRhiSwapChain::m_depthStencil, QRhiSwapChain::m_flags, QRhiSwapChain::m_format, QRhiSwapChain::m_renderPassDesc, QRhiSwapChain::m_sampleCount, QRhiSwapChain::m_window, msaaRtv, msaaTex, newColorBuffer(), QRhiSwapChain::NoVSync, outputDesc1ForWindow(), QRhiRenderBuffer::pixelSize(), QD3D11RenderTargetData::pixelSize, pixelSize, QD3D11Timestamps::prepare(), qPrintable, QRHI_RES, QRHI_RES_RHI, qWarning, releaseBuffers(), QD3D11RenderTargetData::rp, rt, QRhiRenderBuffer::sampleCount(), QD3D11RenderTargetData::sampleCount, sampleDesc, QRhiSwapChain::SDR, QRhiRenderBuffer::setPixelSize(), QRhiRenderTarget::setRenderPassDescriptor(), QRhiSwapChain::sRGB, srgbAdjustedColorFormat, QRhiSwapChain::SurfaceHasNonPreMulAlpha, QRhiSwapChain::SurfaceHasPreMulAlpha, surfacePixelSize(), swapChain, swapChainFlags, swapInterval, timestamps, QRhiRenderBuffer::UsedWithSwapChainOnly, QSize::width(), and window.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 4850 of file qrhid3d11.cpp.
References cb.
|
overridevirtual |
Implements QRhiSwapChain.
Definition at line 4855 of file qrhid3d11.cpp.
References rt.
|
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 4823 of file qrhid3d11.cpp.
References dcompTarget, dcompVisual, QD3D11Timestamps::destroy(), QRHI_RES_RHI, releaseBuffers(), swapChain, and timestamps.
Referenced by ~QD3D11SwapChain(), 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 4924 of file qrhid3d11.cpp.
References QRhiSwapChain::hdrInfo(), info, QRhiSwapChainHdrInfo::LuminanceInNits, QRhiSwapChain::m_window, outputDesc1ForWindow(), and QRHI_RES_RHI.
|
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 4904 of file qrhid3d11.cpp.
References QRhiSwapChain::HDR10, QRhiSwapChain::HDRExtendedSrgbLinear, QRhiSwapChain::m_window, outputDesc1ForWindow(), QRHI_RES_RHI, qWarning, and QRhiSwapChain::SDR.
bool QD3D11SwapChain::newColorBuffer | ( | const QSize & | size, |
DXGI_FORMAT | format, | ||
DXGI_SAMPLE_DESC | sampleDesc, | ||
ID3D11Texture2D ** | tex, | ||
ID3D11RenderTargetView ** | rtv | ||
) | const |
Definition at line 4948 of file qrhid3d11.cpp.
References desc, QRhiSwapChain::format(), qPrintable, QRHI_RES_RHI, qWarning, and sampleDesc.
Referenced by createOrResize().
|
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 4940 of file qrhid3d11.cpp.
References QRhiResource::m_rhi, and QRHI_RES_RHI.
void QD3D11SwapChain::releaseBuffers | ( | ) |
Definition at line 4801 of file qrhid3d11.cpp.
References backBufferRtv, backBufferTex, BUFFER_COUNT, i, msaaRtv, and msaaTex.
Referenced by createOrResize(), and destroy().
|
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 4860 of file qrhid3d11.cpp.
References QRhiSwapChain::m_window, Q_ASSERT, and QWindow::size().
Referenced by createOrResize().
ID3D11RenderTargetView* QD3D11SwapChain::backBufferRtv |
Definition at line 603 of file qrhid3d11_p.h.
Referenced by QD3D11SwapChain(), QRhiD3D11::beginFrame(), createOrResize(), and releaseBuffers().
ID3D11Texture2D* QD3D11SwapChain::backBufferTex |
Definition at line 602 of file qrhid3d11_p.h.
Referenced by QD3D11SwapChain(), createOrResize(), QRhiD3D11::endFrame(), QRhiD3D11::enqueueResourceUpdates(), and releaseBuffers().
|
static |
Definition at line 604 of file qrhid3d11_p.h.
Referenced by QD3D11SwapChain(), createOrResize(), QRhiD3D11::endFrame(), QRhiD3D11::executeCommandBuffer(), and releaseBuffers().
QD3D11CommandBuffer QD3D11SwapChain::cb |
Definition at line 597 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), currentFrameCommandBuffer(), and QRhiD3D11::endFrame().
DXGI_FORMAT QD3D11SwapChain::colorFormat |
Definition at line 598 of file qrhid3d11_p.h.
Referenced by createOrResize(), QRhiD3D11::endFrame(), and QRhiD3D11::enqueueResourceUpdates().
int QD3D11SwapChain::currentFrameSlot = 0 |
Definition at line 608 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), createOrResize(), QRhiD3D11::endFrame(), QRhiD3D11::enqueueResourceUpdates(), and QRhiD3D11::executeCommandBuffer().
IDCompositionTarget* QD3D11SwapChain::dcompTarget = nullptr |
Definition at line 612 of file qrhid3d11_p.h.
Referenced by createOrResize(), destroy(), and QRhiD3D11::endFrame().
IDCompositionVisual* QD3D11SwapChain::dcompVisual = nullptr |
Definition at line 613 of file qrhid3d11_p.h.
Referenced by createOrResize(), destroy(), and QRhiD3D11::endFrame().
QD3D11RenderBuffer* QD3D11SwapChain::ds = nullptr |
Definition at line 610 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), and createOrResize().
int QD3D11SwapChain::frameCount = 0 |
Definition at line 609 of file qrhid3d11_p.h.
Referenced by createOrResize(), and QRhiD3D11::endFrame().
ID3D11RenderTargetView* QD3D11SwapChain::msaaRtv[BUFFER_COUNT] |
Definition at line 606 of file qrhid3d11_p.h.
Referenced by QD3D11SwapChain(), QRhiD3D11::beginFrame(), createOrResize(), and releaseBuffers().
ID3D11Texture2D* QD3D11SwapChain::msaaTex[BUFFER_COUNT] |
Definition at line 605 of file qrhid3d11_p.h.
Referenced by QD3D11SwapChain(), createOrResize(), QRhiD3D11::endFrame(), QRhiD3D11::enqueueResourceUpdates(), and releaseBuffers().
QSize QD3D11SwapChain::pixelSize |
Definition at line 595 of file qrhid3d11_p.h.
Referenced by createOrResize(), and QRhiD3D11::enqueueResourceUpdates().
QD3D11SwapChainRenderTarget QD3D11SwapChain::rt |
Definition at line 596 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), createOrResize(), currentFrameRenderTarget(), and QRhiD3D11::executeCommandBuffer().
DXGI_SAMPLE_DESC QD3D11SwapChain::sampleDesc |
Definition at line 607 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), createOrResize(), QRhiD3D11::endFrame(), QRhiD3D11::enqueueResourceUpdates(), and newColorBuffer().
DXGI_FORMAT QD3D11SwapChain::srgbAdjustedColorFormat |
Definition at line 599 of file qrhid3d11_p.h.
Referenced by createOrResize().
IDXGISwapChain* QD3D11SwapChain::swapChain = nullptr |
Definition at line 600 of file qrhid3d11_p.h.
Referenced by createOrResize(), destroy(), and QRhiD3D11::endFrame().
UINT QD3D11SwapChain::swapChainFlags = 0 |
Definition at line 601 of file qrhid3d11_p.h.
Referenced by createOrResize(), and QRhiD3D11::endFrame().
UINT QD3D11SwapChain::swapInterval = 1 |
Definition at line 611 of file qrhid3d11_p.h.
Referenced by createOrResize(), and QRhiD3D11::endFrame().
QD3D11Timestamps QD3D11SwapChain::timestamps |
Definition at line 614 of file qrhid3d11_p.h.
Referenced by QRhiD3D11::beginFrame(), createOrResize(), destroy(), QRhiD3D11::endFrame(), and QRhiD3D11::executeCommandBuffer().
Definition at line 594 of file qrhid3d11_p.h.
Referenced by createOrResize().