6#include <QtQuick/private/qquickitem_p.h>
7#include <QtQuick/private/qquickwindow_p.h>
8#include <QtQuick/private/qsgrhisupport_p.h>
31 pixelSize(
other.pixelSize),
32 devicePixelRatio(
other.devicePixelRatio),
33 sampleCount(
other.sampleCount),
35 customDepthTexture(
other.customDepthTexture),
36 mirrorVertically(
other.mirrorVertically),
37 multisampleResolve(
other.multisampleResolve)
53void QQuickRenderTarget::detach()
91 return d->
type == QQuickRenderTargetPrivate::Type::Null;
274#if QT_CONFIG(opengl) || defined(Q_QDOC)
276 const QSize &pixelSize,
int sampleCount)
282 qWarning(
"QQuickRenderTarget: textureId is invalid");
287 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
291 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
292 d->pixelSize = pixelSize;
293 d->sampleCount =
qMax(1, sampleCount);
295 QRhiTexture::Flags formatFlags;
332 return fromOpenGLTexture(textureId, 0, pixelSize, sampleCount);
392 qWarning(
"QQuickRenderTarget: textureId is invalid");
397 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
401 QRhiTexture::Flags formatFlags;
404 d->pixelSize = pixelSize;
405 d->sampleCount =
qMax(1, sampleCount);
408 if (arraySize <= 1) {
409 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
412 d->type = QQuickRenderTargetPrivate::Type::NativeTextureArray;
413 d->u.nativeTextureArray = {
textureId, 0, arraySize,
uint(rhiFormat),
uint(formatFlags),
uint(rhiFormat),
uint(formatFlags) };
450 if (!renderbufferId) {
451 qWarning(
"QQuickRenderTarget: renderbufferId is invalid");
456 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
460 d->type = QQuickRenderTargetPrivate::Type::NativeRenderbuffer;
461 d->pixelSize = pixelSize;
462 d->sampleCount =
qMax(1, sampleCount);
463 d->u.nativeRenderbufferObject = renderbufferId;
496#if defined(Q_OS_WIN) || defined(Q_QDOC)
498 const QSize &pixelSize,
int sampleCount)
504 qWarning(
"QQuickRenderTarget: texture is null");
509 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
513 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
514 d->pixelSize = pixelSize;
515 d->sampleCount =
qMax(1, sampleCount);
517 QRhiTexture::Flags formatFlags;
551 return fromD3D11Texture(
texture, 0 , pixelSize, sampleCount);
630 const QSize &pixelSize,
637 qWarning(
"QQuickRenderTarget: texture is null");
642 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
646 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
647 d->pixelSize = pixelSize;
648 d->sampleCount =
qMax(1, sampleCount);
650 QRhiTexture::Flags formatFlags;
716 const QSize &pixelSize,
725 qWarning(
"QQuickRenderTarget: texture is null");
730 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
734 QRhiTexture::Flags formatFlags;
736 QRhiTexture::Flags viewFormatFlags;
737 QRhiTexture::Format rhiViewFormat = QSGRhiSupport::toRhiTextureFormatFromDXGI(viewFormat, &viewFormatFlags);
739 d->pixelSize = pixelSize;
740 d->sampleCount =
qMax(1, sampleCount);
743 if (arraySize <= 1) {
744 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
747 d->type = QQuickRenderTargetPrivate::Type::NativeTextureArray;
748 d->u.nativeTextureArray = {
quint64(
texture), resourceState, arraySize,
uint(rhiFormat),
uint(formatFlags),
uint(rhiViewFormat),
uint(viewFormatFlags) };
783#if QT_CONFIG(metal) || defined(Q_QDOC)
785 const QSize &pixelSize,
int sampleCount)
791 qWarning(
"QQuickRenderTarget: texture is null");
796 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
800 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
801 d->pixelSize = pixelSize;
802 d->sampleCount =
qMax(1, sampleCount);
804 QRhiTexture::Flags formatFlags;
838 return fromMetalTexture(
texture, 0 , pixelSize, sampleCount);
899 qWarning(
"QQuickRenderTarget: texture is null");
904 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
908 QRhiTexture::Flags formatFlags;
910 QRhiTexture::Flags viewFormatFlags;
911 QRhiTexture::Format rhiViewFormat = QSGRhiSupport::toRhiTextureFormatFromMetal(viewFormat, &viewFormatFlags);
913 d->pixelSize = pixelSize;
914 d->sampleCount =
qMax(1, sampleCount);
917 if (arraySize <= 1) {
918 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
921 d->type = QQuickRenderTargetPrivate::Type::NativeTextureArray;
958#if QT_CONFIG(vulkan) || defined(Q_QDOC)
964 if (
image == VK_NULL_HANDLE) {
965 qWarning(
"QQuickRenderTarget: image is invalid");
970 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
974 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
975 d->pixelSize = pixelSize;
976 d->sampleCount =
qMax(1, sampleCount);
978 QRhiTexture::Flags formatFlags;
1012 return fromVulkanImage(
image,
layout, VK_FORMAT_UNDEFINED, pixelSize, sampleCount);
1073 if (
image == VK_NULL_HANDLE) {
1074 qWarning(
"QQuickRenderTarget: image is invalid");
1079 qWarning(
"QQuickRenderTarget: Cannot create with empty size");
1083 QRhiTexture::Flags formatFlags;
1085 QRhiTexture::Flags viewFormatFlags;
1086 QRhiTexture::Format rhiViewFormat = QSGRhiSupport::toRhiTextureFormatFromVulkan(viewFormat, &viewFormatFlags);
1088 d->pixelSize = pixelSize;
1089 d->sampleCount =
qMax(1, sampleCount);
1092 if (arraySize <= 1) {
1093 d->type = QQuickRenderTargetPrivate::Type::NativeTexture;
1096 d->type = QQuickRenderTargetPrivate::Type::NativeTextureArray;
1126 if (!renderTarget) {
1127 qWarning(
"QQuickRenderTarget: Needs a valid QRhiRenderTarget");
1131 d->type = QQuickRenderTargetPrivate::Type::RhiRenderTarget;
1134 d->u.rhiRt = renderTarget;
1158 d->type = QQuickRenderTargetPrivate::Type::PaintDevice;
1182 if (
d->type !=
other.d->type
1183 ||
d->pixelSize !=
other.d->pixelSize
1184 ||
d->devicePixelRatio !=
other.d->devicePixelRatio
1185 ||
d->sampleCount !=
other.d->sampleCount
1186 ||
d->mirrorVertically !=
other.d->mirrorVertically
1187 ||
d->multisampleResolve !=
other.d->multisampleResolve)
1193 case QQuickRenderTargetPrivate::Type::Null:
1195 case QQuickRenderTargetPrivate::Type::NativeTexture:
1196 if (
d->u.nativeTexture.object !=
other.d->u.nativeTexture.object
1197 ||
d->u.nativeTexture.layoutOrState !=
other.d->u.nativeTexture.layoutOrState
1198 ||
d->u.nativeTexture.rhiFormat !=
other.d->u.nativeTexture.rhiFormat
1199 ||
d->u.nativeTexture.rhiFormatFlags !=
other.d->u.nativeTexture.rhiFormatFlags
1200 ||
d->u.nativeTexture.rhiViewFormat !=
other.d->u.nativeTexture.rhiViewFormat
1201 ||
d->u.nativeTexture.rhiViewFormatFlags !=
other.d->u.nativeTexture.rhiViewFormatFlags)
1204 case QQuickRenderTargetPrivate::Type::NativeTextureArray:
1205 if (
d->u.nativeTextureArray.object !=
other.d->u.nativeTextureArray.object
1206 ||
d->u.nativeTextureArray.layoutOrState !=
other.d->u.nativeTextureArray.layoutOrState
1207 ||
d->u.nativeTextureArray.arraySize !=
other.d->u.nativeTextureArray.arraySize
1208 ||
d->u.nativeTextureArray.rhiFormat !=
other.d->u.nativeTextureArray.rhiFormat
1209 ||
d->u.nativeTextureArray.rhiFormatFlags !=
other.d->u.nativeTextureArray.rhiFormatFlags
1210 ||
d->u.nativeTextureArray.rhiViewFormat !=
other.d->u.nativeTextureArray.rhiViewFormat
1211 ||
d->u.nativeTextureArray.rhiViewFormatFlags !=
other.d->u.nativeTextureArray.rhiViewFormatFlags)
1214 case QQuickRenderTargetPrivate::Type::NativeRenderbuffer:
1215 if (
d->u.nativeRenderbufferObject !=
other.d->u.nativeRenderbufferObject)
1218 case QQuickRenderTargetPrivate::Type::RhiRenderTarget:
1219 if (
d->u.rhiRt !=
other.d->u.rhiRt)
1222 case QQuickRenderTargetPrivate::Type::PaintDevice:
1223 if (
d->u.paintDevice !=
other.d->u.paintDevice)
1234 const QSize &pixelSize,
1241 std::unique_ptr<QRhiRenderBuffer> depthStencil;
1242 if (
dst->implicitBuffers.depthStencil) {
1243 if (
dst->implicitBuffers.depthStencil->pixelSize() == pixelSize
1244 &&
dst->implicitBuffers.depthStencil->sampleCount() == sampleCount)
1246 depthStencil.reset(
dst->implicitBuffers.depthStencil);
1247 dst->implicitBuffers.depthStencil =
nullptr;
1250 dst->implicitBuffers.reset(rhi);
1252 if (!depthStencil) {
1254 depthStencil->setName(
QByteArrayLiteral(
"Depth-stencil buffer for QQuickRenderTarget"));
1255 if (!depthStencil->create()) {
1256 qWarning(
"Failed to build depth-stencil buffer for QQuickRenderTarget");
1263 rtDesc.setDepthStencilBuffer(depthStencil.get());
1266 std::unique_ptr<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor());
1267 rt->setRenderPassDescriptor(rp.get());
1269 if (!rt->create()) {
1270 qWarning(
"Failed to build renderbuffer-based render target for QQuickRenderTarget");
1274 dst->rt.renderTarget = rt.release();
1275 dst->rt.owns =
true;
1276 dst->res.rpDesc = rp.release();
1277 dst->implicitBuffers.depthStencil = depthStencil.release();
1283 const QSize &pixelSize,
1285 bool multisampleResolve,
1294 if (sampleCount <= 1)
1295 multisampleResolve =
false;
1297 std::unique_ptr<QRhiRenderBuffer> depthStencil;
1298 if (
dst->implicitBuffers.depthStencil) {
1299 if (
dst->implicitBuffers.depthStencil->pixelSize() == pixelSize
1300 &&
dst->implicitBuffers.depthStencil->sampleCount() == sampleCount)
1302 depthStencil.reset(
dst->implicitBuffers.depthStencil);
1303 dst->implicitBuffers.depthStencil =
nullptr;
1307 std::unique_ptr<QRhiTexture> colorBuffer;
1308 QRhiTexture::Flags multisampleTextureFlags;
1310 if (multisampleResolve) {
1315 if (
dst->implicitBuffers.multisampleTexture) {
1316 if (
dst->implicitBuffers.multisampleTexture->pixelSize() == pixelSize
1317 &&
dst->implicitBuffers.multisampleTexture->format() == multisampleTextureFormat
1318 &&
dst->implicitBuffers.multisampleTexture->sampleCount() == sampleCount
1319 &&
dst->implicitBuffers.multisampleTexture->flags().testFlags(multisampleTextureFlags))
1321 colorBuffer.reset(
dst->implicitBuffers.multisampleTexture);
1322 dst->implicitBuffers.multisampleTexture =
nullptr;
1327 dst->implicitBuffers.reset(rhi);
1329 if (!depthStencil) {
1331 depthStencil->setName(
QByteArrayLiteral(
"Depth-stencil buffer for QQuickRenderTarget"));
1332 if (!depthStencil->create()) {
1333 qWarning(
"Failed to build depth-stencil buffer for QQuickRenderTarget");
1338 if (multisampleResolve && !colorBuffer) {
1339 colorBuffer.reset(rhi->
newTexture(multisampleTextureFormat, pixelSize, sampleCount, multisampleTextureFlags));
1340 colorBuffer->setName(
QByteArrayLiteral(
"Multisample color buffer for QQuickRenderTarget"));
1341 colorBuffer->setWriteViewFormat(
texture->writeViewFormat());
1342 if (!colorBuffer->create()) {
1343 qWarning(
"Failed to build multisample color buffer for QQuickRenderTarget");
1349 if (multisampleResolve) {
1350 colorAttachment.
setTexture(colorBuffer.get());
1351 colorAttachment.setResolveTexture(
texture);
1353 colorAttachment.setTexture(
texture);
1356 rtDesc.setDepthStencilBuffer(depthStencil.get());
1359 std::unique_ptr<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor());
1360 rt->setRenderPassDescriptor(rp.get());
1362 if (!rt->create()) {
1363 qWarning(
"Failed to build texture render target for QQuickRenderTarget");
1367 dst->rt.renderTarget = rt.release();
1368 dst->rt.owns =
true;
1369 dst->res.rpDesc = rp.release();
1370 dst->implicitBuffers.depthStencil = depthStencil.release();
1371 if (multisampleResolve)
1372 dst->implicitBuffers.multisampleTexture = colorBuffer.release();
1379 const QSize &pixelSize,
1381 bool multisampleResolve,
1395 if (sampleCount <= 1)
1396 multisampleResolve =
false;
1398 std::unique_ptr<QRhiTexture> depthStencil;
1399 if (
dst->implicitBuffers.depthStencilTexture) {
1400 if (
dst->implicitBuffers.depthStencilTexture->pixelSize() == pixelSize
1401 &&
dst->implicitBuffers.depthStencilTexture->sampleCount() == sampleCount)
1403 depthStencil.reset(
dst->implicitBuffers.depthStencilTexture);
1404 dst->implicitBuffers.depthStencilTexture =
nullptr;
1408 std::unique_ptr<QRhiTexture> colorBuffer;
1409 QRhiTexture::Flags multisampleTextureFlags;
1411 if (multisampleResolve) {
1416 if (
dst->implicitBuffers.multisampleTexture) {
1417 if (
dst->implicitBuffers.multisampleTexture->pixelSize() == pixelSize
1418 &&
dst->implicitBuffers.multisampleTexture->format() == multisampleTextureFormat
1419 &&
dst->implicitBuffers.multisampleTexture->sampleCount() == sampleCount
1420 &&
dst->implicitBuffers.multisampleTexture->flags().testFlags(multisampleTextureFlags))
1422 colorBuffer.reset(
dst->implicitBuffers.multisampleTexture);
1423 dst->implicitBuffers.multisampleTexture =
nullptr;
1428 dst->implicitBuffers.reset(rhi);
1430 bool needsDepthStencilBuffer =
true;
1431 if (sampleCount <= 1) {
1432 depthStencil.reset();
1433 needsDepthStencilBuffer =
false;
1435 if (depthTexture->
pixelSize() != pixelSize) {
1436 qWarning(
"Custom depth texture size (%dx%d) does not match the QQuickRenderTarget (%dx%d)",
1444 qWarning(
"Custom depth texture cannot be multisample");
1447 if (needsDepthStencilBuffer && !depthStencil) {
1449 depthStencil->setName(
QByteArrayLiteral(
"Depth-stencil texture for QQuickRenderTarget"));
1450 if (!depthStencil->create()) {
1451 qWarning(
"Failed to build depth-stencil buffer for QQuickRenderTarget");
1456 if (multisampleResolve && !colorBuffer) {
1457 colorBuffer.reset(rhi->
newTexture(multisampleTextureFormat, pixelSize, sampleCount, multisampleTextureFlags));
1458 colorBuffer->setName(
QByteArrayLiteral(
"Multisample color buffer for QQuickRenderTarget"));
1459 colorBuffer->setWriteViewFormat(
texture->writeViewFormat());
1460 if (!colorBuffer->create()) {
1461 qWarning(
"Failed to build multisample color buffer for QQuickRenderTarget");
1467 if (multisampleResolve) {
1468 colorAttachment.
setTexture(colorBuffer.get());
1469 colorAttachment.setResolveTexture(
texture);
1471 colorAttachment.setTexture(
texture);
1475 if (sampleCount > 1) {
1476 rtDesc.setDepthTexture(depthStencil.get());
1478 rtDesc.setDepthResolveTexture(depthTexture);
1480 qWarning(
"Depth-stencil resolve is not supported by the underlying 3D API, depth contents will not be resolved");
1482 rtDesc.setDepthTexture(depthTexture);
1487 std::unique_ptr<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor());
1488 rt->setRenderPassDescriptor(rp.get());
1490 if (!rt->create()) {
1491 qWarning(
"Failed to build texture render target for QQuickRenderTarget");
1495 dst->rt.renderTarget = rt.release();
1496 dst->rt.owns =
true;
1497 dst->res.rpDesc = rp.release();
1499 dst->implicitBuffers.depthStencilTexture = depthStencil.release();
1500 if (multisampleResolve)
1501 dst->implicitBuffers.multisampleTexture = colorBuffer.release();
1508 const QSize &pixelSize,
1511 bool multisampleResolve,
1521 if (sampleCount <= 1)
1522 multisampleResolve =
false;
1524 std::unique_ptr<QRhiTexture> depthStencil;
1525 if (
dst->implicitBuffers.depthStencilTexture) {
1526 if (
dst->implicitBuffers.depthStencilTexture->pixelSize() == pixelSize
1527 &&
dst->implicitBuffers.depthStencilTexture->sampleCount() == sampleCount
1528 &&
dst->implicitBuffers.depthStencilTexture->arraySize() == arraySize)
1530 depthStencil.reset(
dst->implicitBuffers.depthStencilTexture);
1531 dst->implicitBuffers.depthStencilTexture =
nullptr;
1535 std::unique_ptr<QRhiTexture> colorBuffer;
1536 QRhiTexture::Flags multisampleTextureFlags;
1538 if (multisampleResolve) {
1543 if (
dst->implicitBuffers.multisampleTexture) {
1544 if (
dst->implicitBuffers.multisampleTexture->pixelSize() == pixelSize
1545 &&
dst->implicitBuffers.multisampleTexture->format() == multisampleTextureFormat
1546 &&
dst->implicitBuffers.multisampleTexture->sampleCount() == sampleCount
1547 &&
dst->implicitBuffers.multisampleTexture->arraySize() == arraySize
1548 &&
dst->implicitBuffers.multisampleTexture->flags().testFlags(multisampleTextureFlags))
1550 colorBuffer.reset(
dst->implicitBuffers.multisampleTexture);
1551 dst->implicitBuffers.multisampleTexture =
nullptr;
1556 dst->implicitBuffers.reset(rhi);
1558 bool needsDepthStencilBuffer =
true;
1559 if (maybeCustomDepthTexture) {
1560 if (sampleCount <= 1) {
1561 depthStencil.reset();
1562 needsDepthStencilBuffer =
false;
1564 if (maybeCustomDepthTexture->arraySize() != arraySize) {
1565 qWarning(
"Custom depth texture array size (%d) does not match QQuickRenderTarget (%d)",
1566 maybeCustomDepthTexture->arraySize(), arraySize);
1569 if (maybeCustomDepthTexture->pixelSize() != pixelSize) {
1570 qWarning(
"Custom depth texture size (%dx%d) does not match the QQuickRenderTarget (%dx%d)",
1571 maybeCustomDepthTexture->pixelSize().width(),
1572 maybeCustomDepthTexture->pixelSize().height(),
1577 if (maybeCustomDepthTexture->sampleCount() > 1) {
1578 qWarning(
"Custom depth texture cannot be multisample");
1582 if (needsDepthStencilBuffer && !depthStencil) {
1584 depthStencil->setName(
QByteArrayLiteral(
"Depth-stencil buffer (multiview) for QQuickRenderTarget"));
1585 if (!depthStencil->create()) {
1586 qWarning(
"Failed to build depth-stencil texture array for QQuickRenderTarget");
1591 if (multisampleResolve && !colorBuffer) {
1592 colorBuffer.reset(rhi->
newTextureArray(multisampleTextureFormat, arraySize, pixelSize, sampleCount, multisampleTextureFlags));
1593 colorBuffer->setName(
QByteArrayLiteral(
"Multisample color buffer (multiview) for QQuickRenderTarget"));
1594 colorBuffer->setWriteViewFormat(
texture->writeViewFormat());
1595 if (!colorBuffer->create()) {
1596 qWarning(
"Failed to build multisample texture array for QQuickRenderTarget");
1603 if (multisampleResolve) {
1604 colorAttachment.setTexture(colorBuffer.get());
1605 colorAttachment.setResolveTexture(
texture);
1607 colorAttachment.setTexture(
texture);
1611 if (sampleCount > 1) {
1612 rtDesc.setDepthTexture(depthStencil.get());
1613 if (maybeCustomDepthTexture) {
1615 rtDesc.setDepthResolveTexture(maybeCustomDepthTexture);
1617 qWarning(
"Depth-stencil resolve is not supported by the underlying 3D API, depth contents will not be resolved");
1621 rtDesc.setDepthTexture(depthStencil.get());
1622 else if (maybeCustomDepthTexture)
1623 rtDesc.setDepthTexture(maybeCustomDepthTexture);
1626 QRhiTextureRenderTarget::Flags rtFlags;
1627 if (!maybeCustomDepthTexture)
1632 std::unique_ptr<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor());
1633 rt->setRenderPassDescriptor(rp.get());
1635 if (!rt->create()) {
1636 qWarning(
"Failed to build multiview texture render target for QQuickRenderTarget");
1640 dst->rt.renderTarget = rt.release();
1641 dst->rt.owns =
true;
1642 dst->res.rpDesc = rp.release();
1644 dst->implicitBuffers.depthStencilTexture = depthStencil.release();
1645 if (multisampleResolve)
1646 dst->implicitBuffers.multisampleTexture = colorBuffer.release();
1648 dst->rt.multiViewCount = arraySize;
1661 dst->implicitBuffers.reset(rhi);
1664 case Type::NativeTexture:
1673 const bool viewIsSrgb = QRhiTexture::Flags(
u.nativeTexture.rhiViewFormatFlags).testFlag(
QRhiTexture::sRGB);
1674 if (viewFormat !=
format || viewIsSrgb != textureIsSrgb)
1675 texture->setWriteViewFormat({ viewFormat, viewIsSrgb });
1676 if (!
texture->createFrom({ u.nativeTexture.object, u.nativeTexture.layoutOrState })) {
1677 qWarning(
"Failed to build wrapper texture for QQuickRenderTarget");
1691 case Type::NativeTextureArray:
1698 const int arraySize =
u.nativeTextureArray.arraySize;
1701 const bool viewIsSrgb = QRhiTexture::Flags(
u.nativeTextureArray.rhiViewFormatFlags).testFlag(
QRhiTexture::sRGB);
1702 if (viewFormat !=
format || viewIsSrgb != textureIsSrgb)
1703 texture->setWriteViewFormat({ viewFormat, viewIsSrgb });
1704 if (!
texture->createFrom({ u.nativeTextureArray.object, u.nativeTextureArray.layoutOrState })) {
1705 qWarning(
"Failed to build wrapper texture array for QQuickRenderTarget");
1714 case Type::NativeRenderbuffer:
1717 if (!
renderbuffer->createFrom({ u.nativeRenderbufferObject })) {
1718 qWarning(
"Failed to build wrapper renderbuffer for QQuickRenderTarget");
1722 qWarning(
"Custom depth texture is not supported with renderbuffers in QQuickRenderTarget");
1729 case Type::RhiRenderTarget:
1730 dst->implicitBuffers.reset(rhi);
1731 dst->rt.renderTarget =
u.rhiRt;
1732 dst->rt.owns =
false;
1737 for (
auto it = desc.cbeginColorAttachments(),
end = desc.cendColorAttachments();
it !=
end; ++
it) {
1738 if (
it->multiViewCount() <= 1)
1740 if (
first ||
dst->rt.multiViewCount ==
it->multiViewCount()) {
1743 if (
it->texture()->arraySize() >=
it->layer() +
it->multiViewCount()) {
1744 dst->rt.multiViewCount =
it->multiViewCount();
1746 qWarning(
"Invalid QQuickRenderTarget; needs at least %d elements in texture array, got %d",
1747 it->layer() +
it->multiViewCount(),
1748 it->texture()->arraySize());
1752 qWarning(
"Invalid QQuickRenderTarget; multiview requires a texture array");
1756 qWarning(
"Inconsistent multiViewCount in QQuickRenderTarget (was %d, now found an attachment with %d)",
1757 dst->rt.multiViewCount,
it->multiViewCount());
1763 qWarning(
"Custom depth texture is not supported with QRhiRenderTarget in QQuickRenderTarget");
1766 case Type::PaintDevice:
1767 dst->implicitBuffers.reset(rhi);
1768 dst->sw.paintDevice =
u.paintDevice;
1769 dst->sw.owns =
false;
1773 Q_UNREACHABLE_RETURN(
false);
IOBluetoothDevice * device
static QQuickRenderTargetPrivate * get(QQuickRenderTarget *rt)
union QQuickRenderTargetPrivate::@695 u
QQuickRenderTargetPrivate()
QRhiTexture * customDepthTexture
bool resolve(QRhi *rhi, QQuickWindowRenderTarget *dst)
The QQuickRenderTarget class provides an opaque container for native graphics resources specifying a ...
static QQuickRenderTarget fromPaintDevice(QPaintDevice *device)
void setMirrorVertically(bool enable)
Sets the size of the render target contents should be mirrored vertically to enable when drawing.
void setDepthTexture(QRhiTexture *texture)
Requests using the given texture as the depth or depth-stencil buffer.
~QQuickRenderTarget()
Destructor.
QQuickRenderTarget & operator=(const QQuickRenderTarget &other)
qreal devicePixelRatio() const
QRhiTexture * depthTexture() const
void setDevicePixelRatio(qreal ratio)
Sets the device pixel ratio for this render target to ratio.
bool mirrorVertically() const
QQuickRenderTarget()
Constructs a default QQuickRenderTarget that does not reference any native objects.
static QQuickRenderTarget fromRhiRenderTarget(QRhiRenderTarget *renderTarget)
void setTexture(QRhiTexture *tex)
Sets the texture tex.
void setMultiViewCount(int count)
Sets the view count.
virtual QSize pixelSize() const =0
virtual int sampleCount() const =0
@ DoNotStoreDepthStencilContents
Format
Specifies the texture format.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
QRhiTexture * newTextureArray(QRhiTexture::Format format, int arraySize, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
bool isFeatureSupported(QRhi::Feature feature) const
QRhiRenderBuffer * newRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount=1, QRhiRenderBuffer::Flags flags={}, QRhiTexture::Format backingFormatHint=QRhiTexture::UnknownFormat)
QRhiTextureRenderTarget * newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags={})
QRhiTexture * newTexture(QRhiTexture::Format format, const QSize &pixelSize, int sampleCount=1, QRhiTexture::Flags flags={})
static int chooseSampleCount(int samples, QRhi *rhi)
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QT_WARNING_POP void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
#define QByteArrayLiteral(str)
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum format
static bool createRhiRenderTargetWithRenderBuffer(QRhiRenderBuffer *renderBuffer, const QSize &pixelSize, int sampleCount, QRhi *rhi, QQuickWindowRenderTarget *dst)
static bool createRhiRenderTargetWithDepthTexture(QRhiTexture *texture, QRhiTexture *depthTexture, const QSize &pixelSize, int sampleCount, bool multisampleResolve, QRhi *rhi, QQuickWindowRenderTarget *dst)
static bool createRhiRenderTargetMultiView(QRhiTexture *texture, QRhiTexture *maybeCustomDepthTexture, const QSize &pixelSize, int arraySize, int sampleCount, bool multisampleResolve, QRhi *rhi, QQuickWindowRenderTarget *dst)
static bool createRhiRenderTarget(QRhiTexture *texture, const QSize &pixelSize, int sampleCount, bool multisampleResolve, QRhi *rhi, QQuickWindowRenderTarget *dst)
unsigned long long quint64