5#include <QtCore/qurl.h>
6#include "Metal/Metal.h"
8#include <QtGui/rhi/qrhi.h>
9#include <QtGui/rhi/qrhi_platform.h>
15#if __has_feature(objc_arc)
16#error ARC not supported
19uint QGraphicsFrameCaptureMetal::frameNumber = 0;
25 m_captureDescriptor = [MTLCaptureDescriptor
new];
30#if defined(Q_OS_MACOS) && QT_CONFIG(process)
32 m_process->terminate();
50 if (mtlnh->cmdQueue) {
51 m_captureDescriptor.captureObject = mtlnh->cmdQueue;
52 }
else if (mtlnh->dev) {
53 m_captureDescriptor.captureObject = mtlnh->dev;
55 qCWarning(lcGraphicsFrameCapture) <<
"No valid Metal Device or Metal Command Queue found";
56 m_initialized =
false;
62 qCWarning(lcGraphicsFrameCapture) <<
"Invalid handles were provided. MTLCaptureManager works only with Metal API";
63 m_initialized =
false;
69 if (!m_captureManager) {
70 m_captureManager = MTLCaptureManager.sharedCaptureManager;
71 bool supportDocs = [m_captureManager supportsDestination:MTLCaptureDestinationGPUTraceDocument];
73 m_captureDescriptor.destination = MTLCaptureDestinationGPUTraceDocument;
82 qCWarning(lcGraphicsFrameCapture) <<
"Capturing on Metal was not initialized. Starting capturing can not be done.";
87 qCWarning(lcGraphicsFrameCapture) <<
"A frame capture is already in progress,"
88 "will not initiate another one until QGraphicsFrameCapture::endCaptureFrame is called.";
92 updateCaptureFileName();
94 if (![m_captureManager startCaptureWithDescriptor:m_captureDescriptor
error:&
error]) {
95 QString errorMsg = QString::fromNSString(
error.localizedDescription);
103 qCWarning(lcGraphicsFrameCapture) <<
"Capturing on Metal was not initialized. End capturing can not be done.";
108 qCWarning(lcGraphicsFrameCapture) <<
"A call to QGraphicsFrameCapture::endCaptureFrame can not be done"
109 " without a call to QGraphicsFrameCapture::startCaptureFrame";
113 [m_captureManager stopCapture];
120 return m_initialized;
126 qCWarning(lcGraphicsFrameCapture) <<
"Capturing on Metal was not initialized. Can not query if capturing is in progress or not.";
135#if defined(Q_OS_MACOS)
136#if !QT_CONFIG(process)
137 qFatal(
"QGraphicsFrameCapture requires QProcess on macOS");
140 qCWarning(lcGraphicsFrameCapture) <<
"Capturing on Metal was not initialized. Can not open XCode with a valid capture.";
145 m_process =
new QProcess();
149 m_process->setArguments(
args);
158void QGraphicsFrameCaptureMetal::updateCaptureFileName()
163 if ([NSFileManager.defaultManager fileExistsAtPath:m_traceURL.
path])
164 [NSFileManager.defaultManager removeItemAtURL:m_traceURL
error:nil];
166 m_captureDescriptor.outputURL = m_traceURL;
QStringList m_capturedFilesNames
void append(parameter_type t)
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Implementation backend() const
Implementation
Describes which graphics API-specific backend gets used by a QRhi instance.
const QRhiNativeHandles * nativeHandles()
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
DBusConnection const char DBusError * error
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
GLsizei const GLchar *const * path
static QString toLocalFile(const QString &url)
#define qPrintable(string)
#define QStringLiteral(str)
bool qputenv(const char *varName, QByteArrayView raw)
\variable QRhiReadbackResult::completed