8#include <QtQuick/private/qquickitem_p.h>
9#include <QtQuick/private/qquickwindow_p.h>
11#include <QtGui/qwindow.h>
14#include <QtGui/private/qvulkandefaultinstance_p.h>
17#include <QOperatingSystemVersion>
20#include <QStandardPaths>
24#include <QOffscreenSurface>
27#include <dxgiformat.h>
34QSGRhiSupport::QSGRhiSupport()
38void QSGRhiSupport::applySettings()
42 m_settingsApplied =
true;
50 if (m_requested.valid) {
52 switch (m_requested.api) {
72 Q_ASSERT_X(
false,
"QSGRhiSupport",
"Internal error: unhandled GraphicsApi type");
95 qWarning(
"Unknown key \"%s\" for QSG_RHI_BACKEND, falling back to default backend.",
100#elif QT_CONFIG(metal)
102#elif QT_CONFIG(opengl)
110 adjustToPlatformQuirks();
121void QSGRhiSupport::adjustToPlatformQuirks()
131 qCDebug(QSG_LOG_INFO,
"Metal does not seem to be supported. Falling back to OpenGL.");
147#define GL_BGRA 0x80E1
167#define GL_RG16 0x822C
175#define GL_RGBA8 0x8058
179#define GL_RGBA32F 0x8814
183#define GL_RGBA16F 0x881A
187#define GL_R16F 0x822D
191#define GL_R32F 0x822E
194#ifndef GL_DEPTH_COMPONENT16
195#define GL_DEPTH_COMPONENT16 0x81A5
198#ifndef GL_DEPTH_COMPONENT24
199#define GL_DEPTH_COMPONENT24 0x81A6
202#ifndef GL_DEPTH_COMPONENT32F
203#define GL_DEPTH_COMPONENT32F 0x8CAC
206#ifndef GL_DEPTH24_STENCIL8
207#define GL_DEPTH24_STENCIL8 0x88F0
210#ifndef GL_DEPTH_STENCIL
211#define GL_DEPTH_STENCIL 0x84F9
215#define GL_RGB10_A2 0x8059
219#define GL_SRGB_ALPHA 0x8C42
222#ifndef GL_SRGB8_ALPHA8
223#define GL_SRGB8_ALPHA8 0x8C43
277 case GL_DEPTH_COMPONENT:
309 case VK_FORMAT_R8G8B8A8_SRGB:
312 case VK_FORMAT_R8G8B8A8_UNORM:
313 case VK_FORMAT_UNDEFINED:
316 case VK_FORMAT_B8G8R8A8_SRGB:
319 case VK_FORMAT_B8G8R8A8_UNORM:
322 case VK_FORMAT_R8_SRGB:
325 case VK_FORMAT_R8_UNORM:
328 case VK_FORMAT_R8G8_SRGB:
331 case VK_FORMAT_R8G8_UNORM:
334 case VK_FORMAT_R16_UNORM:
337 case VK_FORMAT_R16G16_UNORM:
340 case VK_FORMAT_R16G16B16A16_SFLOAT:
343 case VK_FORMAT_R32G32B32A32_SFLOAT:
346 case VK_FORMAT_R16_SFLOAT:
349 case VK_FORMAT_R32_SFLOAT:
352 case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
354 case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
357 case VK_FORMAT_D16_UNORM:
360 case VK_FORMAT_X8_D24_UNORM_PACK32:
363 case VK_FORMAT_D24_UNORM_S8_UINT:
366 case VK_FORMAT_D32_SFLOAT:
369 case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
372 case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
375 case VK_FORMAT_BC2_SRGB_BLOCK:
378 case VK_FORMAT_BC2_UNORM_BLOCK:
381 case VK_FORMAT_BC3_SRGB_BLOCK:
384 case VK_FORMAT_BC3_UNORM_BLOCK:
387 case VK_FORMAT_BC4_UNORM_BLOCK:
390 case VK_FORMAT_BC5_UNORM_BLOCK:
393 case VK_FORMAT_BC6H_UFLOAT_BLOCK:
396 case VK_FORMAT_BC7_SRGB_BLOCK:
399 case VK_FORMAT_BC7_UNORM_BLOCK:
402 case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
405 case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
408 case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
411 case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
414 case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
417 case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
420 case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
423 case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
426 case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
429 case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
432 case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
435 case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
438 case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
441 case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
444 case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
447 case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
450 case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
453 case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
456 case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
459 case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
462 case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
465 case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
468 case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
471 case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
474 case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
477 case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
480 case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
483 case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
486 case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
489 case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
492 case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
495 case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
498 case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
501 case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
520 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
523 case DXGI_FORMAT_R8G8B8A8_UNORM:
524 case DXGI_FORMAT_UNKNOWN:
527 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
530 case DXGI_FORMAT_B8G8R8A8_UNORM:
533 case DXGI_FORMAT_R8_UNORM:
536 case DXGI_FORMAT_R8G8_UNORM:
539 case DXGI_FORMAT_R16_UNORM:
542 case DXGI_FORMAT_R16G16_UNORM:
545 case DXGI_FORMAT_R16G16B16A16_FLOAT:
548 case DXGI_FORMAT_R32G32B32A32_FLOAT:
551 case DXGI_FORMAT_R16_FLOAT:
554 case DXGI_FORMAT_R32_FLOAT:
557 case DXGI_FORMAT_R10G10B10A2_UNORM:
560 case DXGI_FORMAT_R16_TYPELESS:
563 case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
566 case DXGI_FORMAT_D24_UNORM_S8_UINT:
569 case DXGI_FORMAT_R32_TYPELESS:
572 case DXGI_FORMAT_BC1_UNORM_SRGB:
575 case DXGI_FORMAT_BC1_UNORM:
578 case DXGI_FORMAT_BC2_UNORM_SRGB:
581 case DXGI_FORMAT_BC2_UNORM:
584 case DXGI_FORMAT_BC3_UNORM_SRGB:
587 case DXGI_FORMAT_BC3_UNORM:
590 case DXGI_FORMAT_BC4_UNORM:
593 case DXGI_FORMAT_BC5_UNORM:
596 case DXGI_FORMAT_BC6H_UF16:
599 case DXGI_FORMAT_BC7_UNORM_SRGB:
602 case DXGI_FORMAT_BC7_UNORM:
629 m_requested.valid =
false;
633 m_requested.valid =
true;
634 m_requested.api =
api;
648 if (!inst->m_settingsApplied)
649 inst->applySettings();
660 switch (m_rhiBackend) {
680 switch (m_rhiBackend) {
711 return &vknat->gfxQueue;
714 return &maybeVkCbNat->commandBuffer;
718 return &vknat->physDev;
721 return &maybeVkRpNat->renderPass;
725 return &vknat->gfxQueueFamilyIdx;
727 return &vknat->gfxQueueIdx;
740 return glnat->context;
755 return d3dnat->context;
763 const QRhiD3D12NativeHandles *d3dnat =
static_cast<const QRhiD3D12NativeHandles *
>(nat);
768 return d3dnat->commandQueue;
787 return mtlnat->cmdQueue;
790 return maybeMtlCbNat->commandBuffer;
795 return maybeMtlCbNat->encoder;
831 switch (m_rhiBackend) {
837 return qsgrhi_vk_rifResource(
res, nat,
838 cb ?
cb->nativeHandles() :
nullptr,
844 return qsgrhi_gl_rifResource(
res, nat);
848 return qsgrhi_d3d11_rifResource(
res, nat);
850 return qsgrhi_d3d12_rifResource(
res, nat);
856 return qsgrhi_mtl_rifResource(
res, nat,
cb ?
cb->nativeHandles() :
nullptr);
869 msaaSampleCount =
qMax(1, msaaSampleCount);
870 if (msaaSampleCount > 1) {
872 if (!supportedSampleCounts.contains(msaaSampleCount)) {
873 int reducedSampleCount = 1;
874 for (
int i = supportedSampleCounts.size() - 1;
i >= 0; --
i) {
875 if (supportedSampleCounts[
i] <= msaaSampleCount) {
876 reducedSampleCount = supportedSampleCounts[
i];
880 qWarning() <<
"Requested MSAA sample count" << msaaSampleCount
881 <<
"but supported sample counts are" << supportedSampleCounts
882 <<
", using sample count" << reducedSampleCount <<
"instead";
883 msaaSampleCount = reducedSampleCount;
886 return msaaSampleCount;
901 offscreenSurface = QRhiGles2InitParams::newFallbackSurface(
format);
906 return offscreenSurface;
924 qCDebug(QSG_LOG_INFO) <<
"Got Vulkan instance from QVulkanDefaultInstance, requested api version was" << vkinst->apiVersion();
926 qCDebug(QSG_LOG_INFO) <<
"No Vulkan instance from QVulkanDefaultInstance, expect problems";
927 window->setVulkanInstance(vkinst);
943 static bool checked =
false;
944 static QString currentCacheDir;
945 static bool cacheWritable =
false;
948 return cacheWritable ? currentCacheDir :
QString();
960 if (!cachePath.isEmpty()) {
961 currentCacheDir = cachePath +
subPath;
965 return cacheWritable ? currentCacheDir :
QString();
971 if (!cacheDir.isEmpty())
999 bool isAutomatic =
false;
1007 if (pipelineCacheLoad.isEmpty())
1012 qWarning(
"Could not create pipeline cache lock file '%s'",
1017 QFile f(pipelineCacheLoad);
1020 qWarning(
"Could not open pipeline cache source file '%s'",
1027 if (!
buf.isEmpty()) {
1028 qCDebug(QSG_LOG_INFO,
"Attempting to seed pipeline cache for QRhi %p from '%s'",
1037 qCDebug(QSG_LOG_INFO,
"Total time spent on pipeline creation during the lifetime of the QRhi %p was %lld ms",
1042 bool isAutomatic =
false;
1043 if (pipelineCacheSave.isEmpty() &&
config.isAutomaticPipelineCacheEnabled()) {
1048 if (pipelineCacheSave.isEmpty())
1055 if (
buf.isEmpty()) {
1070 qWarning(
"Could not create pipeline cache lock file '%s'",
1075#if QT_CONFIG(temporaryfile)
1076 QSaveFile
f(pipelineCacheSave);
1078 QFile f(pipelineCacheSave);
1082 const QString msg =
f.errorString();
1083 qWarning(
"Could not open pipeline cache output file '%s': %s",
1089 qCDebug(QSG_LOG_INFO,
"Writing pipeline cache contents (%d bytes) for QRhi %p to '%s'",
1092 if (
f.write(
buf) !=
buf.size()
1099 const QString msg =
f.errorString();
1109 QRhi *rhi =
nullptr;
1112 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::Rhi) {
1113 rhi = customDevD->u.rhi;
1115 preparePipelineCache(rhi,
window);
1116 return { rhi,
false };
1130 "Creating QRhi with backend %s for window %p (wflags 0x%X)\n"
1131 " Graphics API debug/validation layers: %d\n"
1132 " Debug markers: %d\n"
1134 " Prefer software device: %d%s\n"
1135 " Shader/pipeline cache collection: %d",
1137 debugMarkers, timestamps, preferSoftware, forcePreferSwRenderer ?
" [FORCED]" :
"", pipelineCacheSave);
1147 if (pipelineCacheSave)
1155#if QT_CONFIG(opengl)
1159 rhiParams.format =
format;
1160 rhiParams.fallbackSurface = offscreenSurface;
1161 rhiParams.window =
window;
1162 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::OpenGLContext) {
1164 importDev.context = customDevD->u.context;
1165 qCDebug(QSG_LOG_INFO,
"Using existing QOpenGLContext %p", importDev.context);
1174 qWarning(
"OpenGL was requested for Qt Quick, but this build of Qt has no OpenGL support.");
1176#if QT_CONFIG(vulkan)
1179 QVulkanDefaultInstance::setFlag(QVulkanDefaultInstance::EnableValidation,
true);
1182 rhiParams.inst =
window->vulkanInstance();
1183 if (!rhiParams.inst)
1184 qWarning(
"No QVulkanInstance set for QQuickWindow, this is wrong.");
1186 rhiParams.window =
window;
1188 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::DeviceObjects) {
1190 importDev.physDev =
reinterpret_cast<VkPhysicalDevice
>(customDevD->u.deviceObjects.physicalDevice);
1191 importDev.dev =
reinterpret_cast<VkDevice
>(customDevD->u.deviceObjects.device);
1192 importDev.gfxQueueFamilyIdx = customDevD->u.deviceObjects.queueFamilyIndex;
1193 importDev.gfxQueueIdx = customDevD->u.deviceObjects.queueIndex;
1194 qCDebug(QSG_LOG_INFO,
"Using existing native Vulkan physical device %p device %p graphics queue family index %d",
1195 importDev.physDev, importDev.dev, importDev.gfxQueueFamilyIdx);
1197 }
else if (customDevD->type == QQuickGraphicsDevicePrivate::Type::PhysicalDevice) {
1199 importDev.physDev =
reinterpret_cast<VkPhysicalDevice
>(customDevD->u.physicalDevice.physicalDevice);
1200 qCDebug(QSG_LOG_INFO,
"Using existing native Vulkan physical device %p", importDev.physDev);
1208 qWarning(
"Vulkan was requested for Qt Quick, but this build of Qt has no Vulkan support.");
1213 rhiParams.enableDebugLayer = debugLayer;
1214 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::DeviceAndContext) {
1216 importDev.dev = customDevD->u.deviceAndContext.device;
1217 importDev.context = customDevD->u.deviceAndContext.context;
1218 qCDebug(QSG_LOG_INFO,
"Using existing native D3D11 device %p and context %p",
1219 importDev.dev, importDev.context);
1221 }
else if (customDevD->type == QQuickGraphicsDevicePrivate::Type::Adapter) {
1223 importDev.adapterLuidLow = customDevD->u.adapter.luidLow;
1224 importDev.adapterLuidHigh = customDevD->u.adapter.luidHigh;
1225 importDev.featureLevel = customDevD->u.adapter.featureLevel;
1226 qCDebug(QSG_LOG_INFO,
"Using D3D11 adapter LUID %u, %d and feature level %d",
1227 importDev.adapterLuidLow, importDev.adapterLuidHigh, importDev.featureLevel);
1232 qCDebug(QSG_LOG_INFO,
"Failed to create a D3D device with default settings; "
1233 "attempting to get a software rasterizer backed device instead");
1239 QRhiD3D12InitParams rhiParams;
1240 rhiParams.enableDebugLayer = debugLayer;
1241 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::DeviceAndContext) {
1242 QRhiD3D12NativeHandles importDev;
1243 importDev.dev = customDevD->u.deviceAndContext.device;
1244 qCDebug(QSG_LOG_INFO,
"Using existing native D3D12 device %p", importDev.dev);
1246 }
else if (customDevD->type == QQuickGraphicsDevicePrivate::Type::Adapter) {
1247 QRhiD3D12NativeHandles importDev;
1248 importDev.adapterLuidLow = customDevD->u.adapter.luidLow;
1249 importDev.adapterLuidHigh = customDevD->u.adapter.luidHigh;
1250 importDev.minimumFeatureLevel = customDevD->u.adapter.featureLevel;
1251 qCDebug(QSG_LOG_INFO,
"Using D3D12 adapter LUID %u, %d and minimum feature level %d",
1252 importDev.adapterLuidLow, importDev.adapterLuidHigh, importDev.minimumFeatureLevel);
1257 qCDebug(QSG_LOG_INFO,
"Failed to create a D3D device with default settings; "
1258 "attempting to get a software rasterizer backed device instead");
1268 if (customDevD->type == QQuickGraphicsDevicePrivate::Type::DeviceAndCommandQueue) {
1270 importDev.dev = (MTLDevice *) customDevD->u.deviceAndCommandQueue.device;
1271 importDev.cmdQueue = (MTLCommandQueue *) customDevD->u.deviceAndCommandQueue.cmdQueue;
1272 qCDebug(QSG_LOG_INFO,
"Using existing native Metal device %p and command queue %p",
1273 importDev.dev, importDev.cmdQueue);
1282 qCDebug(QSG_LOG_INFO,
"Created QRhi %p for window %p", rhi,
window);
1283 preparePipelineCache(rhi,
window);
1285 qWarning(
"Failed to create RHI (backend %d)", backend);
1288 return { rhi,
true };
1297 finalizePipelineCache(rhi,
config);
1311 cb->resourceUpdate(resourceUpdates);
1317#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
1331 return img.mirrored();
1350 if (!rhiResult.rhi) {
1351 qWarning(
"Failed to initialize QRhi for offscreen readback");
1354 std::unique_ptr<QRhi> rhiOwner(rhiResult.rhi);
1355 QRhi *rhi = rhiResult.own ? rhiOwner.get() : rhiOwner.release();
1361 qWarning(
"Failed to build texture for offscreen readback");
1365 if (!depthStencil->create()) {
1366 qWarning(
"Failed to create depth/stencil buffer for offscreen readback");
1370 rtDesc.setDepthStencilBuffer(depthStencil.data());
1372 QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
1373 rt->setRenderPassDescriptor(rpDesc.data());
1374 if (!rt->create()) {
1375 qWarning(
"Failed to build render target for offscreen readback");
1384 params.initialSurfacePixelSize = pixelSize;
1394 qWarning(
"Failed to start recording the frame for offscreen readback");
1407 image.setDevicePixelRatio(
window->devicePixelRatio());
1426 QScopedPointer<QQuickWindow> offscreenWindow;
1438 offscreenWindow->setFormat(surfaceFormat);
1442 RhiCreateResult rhiResult =
createRhi(offscreenWindow.data() ? offscreenWindow.data() :
window, offscreenSurface.
data());
1443 if (!rhiResult.rhi) {
1444 qWarning(
"Failed to initialize QRhi for offscreen readback");
1447 QScopedPointer<QRhi> rhiOwner(rhiResult.rhi);
1448 QRhi *rhi = rhiResult.own ? rhiOwner.data() : rhiOwner.take();
1454 qWarning(
"Failed to build texture for offscreen readback");
1458 if (!depthStencil->create()) {
1459 qWarning(
"Failed to create depth/stencil buffer for offscreen readback");
1463 rtDesc.setDepthStencilBuffer(depthStencil.data());
1465 QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
1466 rt->setRenderPassDescriptor(rpDesc.data());
1467 if (!rt->create()) {
1468 qWarning(
"Failed to build render target for offscreen readback");
1479 params.initialSurfacePixelSize = pixelSize;
1491 qWarning(
"Failed to start recording the frame for offscreen readback");
1504 image.setDevicePixelRatio(
window->devicePixelRatio());
1516 window->setRenderTarget(currentRenderTarget);
1517 wd->
rhi = currentRhi;
1533 if (hdrRequest.isEmpty())
1534 hdrRequest =
window->property(
"_qt_sg_hdr_format").toByteArray();
1536 if (!hdrRequest.isEmpty()) {
1537 hdrRequest = hdrRequest.toLower();
1546 const char *fmtStr =
"unknown";
1547 switch (swapChainFormat) {
1558 fmtStr =
"Extended Linear Display P3";
1564 if (!scWithWindowSet->isFormatSupported(swapChainFormat)) {
1566 qCDebug(QSG_LOG_INFO,
"Requested a %s swapchain but it is reported to be unsupported with the current display(s). "
1567 "In multi-screen configurations make sure the window is located on a HDR-enabled screen. "
1568 "Request ignored, using SDR swapchain.", fmtStr);
1573 scWithWindowSet->setFormat(swapChainFormat);
1576 qCDebug(QSG_LOG_INFO,
"Creating %s swapchain", fmtStr);
1577 qCDebug(QSG_LOG_INFO) <<
"HDR output info:" << scWithWindowSet->hdrInfo();
1583 switch (m_rhiBackend) {
1584#if QT_CONFIG(vulkan)
1586 return toRhiTextureFormatFromVulkan(nativeFormat,
flags);
1588#if QT_CONFIG(opengl)
1591 return toRhiTextureFormatFromGL(nativeFormat,
flags);
1596 return toRhiTextureFormatFromDXGI(nativeFormat,
flags);
1600 return toRhiTextureFormatFromMetal(nativeFormat,
flags);
bool remove(const QString &fileName)
Removes the file, fileName.
static QDir root()
Returns the root directory.
bool isWritable() const
Returns true if the user can write to the file system entry this QFileInfo refers to; otherwise retur...
Format
The following image formats are available in Qt.
@ Format_RGBA8888_Premultiplied
@ Format_ARGB32_Premultiplied
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
QString pipelineCacheLoadFile() const
QString pipelineCacheSaveFile() const
bool isDebugLayerEnabled() const
bool isAutomaticPipelineCacheEnabled() const
bool isDebugMarkersEnabled() const
bool prefersSoftwareDevice() const
QByteArrayList deviceExtensions() const
bool timestampsEnabled() const
static QQuickGraphicsDevicePrivate * get(QQuickGraphicsDevice *p)
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a ...
static QQuickRenderTarget fromRhiRenderTarget(QRhiRenderTarget *renderTarget)
QQuickGraphicsConfiguration graphicsConfig
static QQuickWindowPrivate * get(QQuickWindow *c)
QSGRenderContext * context
QQuickRenderControl * renderControl
void cleanupNodesOnShutdown()
void setCustomCommandBuffer(QRhiCommandBuffer *cb)
QQuickGraphicsDevice customDeviceObjects
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\variable QRhiD3D11InitParams::enableDebugLayer
\variable QRhiGles2InitParams::format
virtual const QRhiNativeHandles * nativeHandles()
void readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
Enqueues a texture-to-host copy operation as described by rb.
Format
Describes the swapchain format.
@ HDRExtendedDisplayP3Linear
Format
Specifies the texture format.
\variable QRhiVulkanNativeHandles::physDev
\variable QRhiVulkanInitParams::inst
\variable QRhiVulkanCommandBufferNativeHandles::commandBuffer
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
FrameOpResult endOffscreenFrame(EndFrameFlags flags={})
Ends, submits, and waits for the offscreen frame.
QRhiStats statistics() const
Gathers and returns statistics about the timings and allocations of graphics resources.
bool isYUpInFramebuffer() const
QList< int > supportedSampleCounts() const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
QRhi::FrameOpResult finish()
Waits for any work on the graphics queue (where applicable) to complete, then executes all deferred o...
FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, BeginFrameFlags flags={})
Starts a new offscreen frame.
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
bool isRecordingFrame() const
const char * backendName() const
static bool probe(Implementation impl, QRhiInitParams *params)
static QRhi * create(Implementation impl, QRhiInitParams *params, Flags flags={}, QRhiNativeHandles *importDevice=nullptr)
QByteArray pipelineCacheData()
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
void setPipelineCacheData(const QByteArray &data)
Loads data into the pipeline cache, when applicable.
const QRhiNativeHandles * nativeHandles()
QRhiResourceUpdateBatch * nextResourceUpdateBatch()
bool isDeviceLost() const
@ EnablePipelineCacheDataSave
@ SuppressSmokeTestWarnings
QRhiRenderPassDescriptor * currentFrameRenderPass() const
QRhi * rhi() const override
QRhiCommandBuffer * currentFrameCommandBuffer() const
virtual void initialize(const InitParams *params)
virtual void invalidate()
Resource
\value DeviceResource The resource is a pointer to the graphics device, when applicable.
@ RhiRedirectCommandBuffer
@ GraphicsQueueIndexResource
@ RhiRedirectRenderTarget
@ GraphicsQueueFamilyIndexResource
static bool isApiRhiBased(GraphicsApi api)
GraphicsApi
\value Unknown An unknown graphics API is in use \value Software The Qt Quick 2D Renderer is in use \...
QRhiTexture::Format toRhiTextureFormat(uint nativeFormat, QRhiTexture::Flags *flags) const
QOffscreenSurface * maybeCreateOffscreenSurface(QWindow *window)
void applySwapChainFormat(QRhiSwapChain *scWithWindowSet, QQuickWindow *window)
static QSGRhiSupport * instance_internal()
static void checkEnvQSgInfo()
const void * rifResource(QSGRendererInterface::Resource res, const QSGDefaultRenderContext *rc, const QQuickWindow *w)
static int chooseSampleCountForWindowWithRhi(QWindow *window, QRhi *rhi)
bool attemptReinitWithSwRastUponFail() const
QSGRendererInterface::GraphicsApi graphicsApi() const
QSGRendererInterface::GraphicsApi api
void prepareWindowForRhi(QQuickWindow *window)
RhiCreateResult createRhi(QQuickWindow *window, QSurface *offscreenSurface, bool forcePreferSwRenderer=false)
static int chooseSampleCount(int samples, QRhi *rhi)
static QImage grabAndBlockInCurrentFrame(QRhi *rhi, QRhiCommandBuffer *cb, QRhiTexture *src=nullptr)
void configure(QSGRendererInterface::GraphicsApi api)
QRhi::Implementation rhiBackend() const
QImage grabOffscreen(QQuickWindow *window)
void destroyRhi(QRhi *rhi, const QQuickGraphicsConfiguration &config)
QString rhiBackendName() const
static QSGRhiSupport * instance()
QSurface::SurfaceType windowSurfaceType() const
static QString writableLocation(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
SurfaceType
The SurfaceType enum describes what type of surface this is.
static QString buildAbi()
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
QRhiTexture::Format toRhiTextureFormatFromMetal(uint format, QRhiTexture::Flags *flags)
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
static const QPainterPath::ElementType * subPath(const QPainterPath::ElementType *t, const QPainterPath::ElementType *end, const qreal *points, bool *closed)
#define qCDebug(category,...)
constexpr const T & qMax(const T &a, const T &b)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum format
#define GL_DEPTH_COMPONENT32F
#define GL_DEPTH24_STENCIL8
#define GL_DEPTH_COMPONENT16
#define GL_DEPTH_COMPONENT24
#define Q_ASSERT_X(cond, x, msg)
static QString pipelineCacheLockFileName(const QString &name)
static bool isAutomaticPipelineCacheLoadSkippedForWindow(Qt::WindowFlags wflags)
static QString automaticPipelineCacheDir()
static bool ensureWritableDir(const QString &name)
static QString automaticPipelineCacheFileName(QRhi *rhi)
static bool isAutomaticPipelineCacheSaveSkippedForWindow(Qt::WindowFlags wflags)
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QT_CONFIG(feature)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QNetworkRequestFactory api
[0]
\inmodule QtCore \reentrant
\variable QRhiReadbackResult::completed
qint64 totalPipelineCreationTime