Commit 14f8e314 authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Fix mac build

parent 23b669b6
......@@ -391,14 +391,20 @@ void Window::render()
m_r->endFrame(m_sc);
// There should be no need to rely on requestUpdate().
// Outside Apple that's a 5 ms timer, otherwise backed by CVDisplayLink but
// for Metal we do not need that either.
bool sillyPlatform = false;
// There should be no need to rely on requestUpdate(). Outside Apple that's
// a 5 ms timer, otherwise backed by CVDisplayLink but for Metal we do not
// need that either, on macOS at least. For iOS/tvOS however, or when using
// OpenGL on Apple, continue to use requestUpdate.
bool useRequestUpdate = false;
#ifdef Q_OS_DARWIN
sillyPlatform = graphicsApi == OpenGL;
#if defined(Q_OS_IOS) || defined(Q_OS_TVOS)
useRequestUpdate = true;
#else
if (graphicsApi == OpenGL)
useRequestUpdate = true;
#endif
#endif
if (sillyPlatform)
if (useRequestUpdate)
requestUpdate();
else
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
......
......@@ -567,9 +567,11 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain)
ok &= context->GetData(tsStart, &timestamps[0], sizeof(quint64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK;
if (ok) {
if (!dj.Disjoint && dj.Frequency) {
// The timestamps seem to include vsync time with Present(1) on
// AMD and Intel, but not with NVIDIA. The latter is what we
// would need but not much we can do about it.
// The timestamps seem to include vsync time with Present(1),
// except when running on a non-primary gpu. This is not ideal,
// and differs from other backends (Vulkan), but not much we
// can do about it. (apart from telling people to set NoVSync
// to get more useful results)
const float elapsedMs = (timestamps[1] - timestamps[0]) / float(dj.Frequency) * 1000.0f;
// finally got a value, just report it, the profiler cares about min/max/avg anyway
......
......@@ -2557,8 +2557,12 @@ bool QMetalSwapChain::buildOrResize()
if (m_flags.testFlag(UsedAsTransferSource))
d->layer.framebufferOnly = NO;
if (m_flags.testFlag(NoVSync))
d->layer.displaySyncEnabled = NO;
#ifdef Q_OS_MAC
if (m_flags.testFlag(NoVSync)) {
if (@available(macOS 10.13, *))
d->layer.displaySyncEnabled = NO;
}
#endif
m_currentPixelSize = surfacePixelSize();
pixelSize = m_currentPixelSize;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment