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

Fix mac build

parent 23b669b6
...@@ -391,14 +391,20 @@ void Window::render() ...@@ -391,14 +391,20 @@ void Window::render()
m_r->endFrame(m_sc); m_r->endFrame(m_sc);
// There should be no need to rely on requestUpdate(). // There should be no need to rely on requestUpdate(). Outside Apple that's
// Outside Apple that's a 5 ms timer, otherwise backed by CVDisplayLink but // a 5 ms timer, otherwise backed by CVDisplayLink but for Metal we do not
// for Metal we do not need that either. // need that either, on macOS at least. For iOS/tvOS however, or when using
bool sillyPlatform = false; // OpenGL on Apple, continue to use requestUpdate.
bool useRequestUpdate = false;
#ifdef Q_OS_DARWIN #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 #endif
if (sillyPlatform) if (useRequestUpdate)
requestUpdate(); requestUpdate();
else else
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
......
...@@ -567,9 +567,11 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain) ...@@ -567,9 +567,11 @@ QRhi::FrameOpResult QRhiD3D11::beginFrame(QRhiSwapChain *swapChain)
ok &= context->GetData(tsStart, &timestamps[0], sizeof(quint64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK; ok &= context->GetData(tsStart, &timestamps[0], sizeof(quint64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK;
if (ok) { if (ok) {
if (!dj.Disjoint && dj.Frequency) { if (!dj.Disjoint && dj.Frequency) {
// The timestamps seem to include vsync time with Present(1) on // The timestamps seem to include vsync time with Present(1),
// AMD and Intel, but not with NVIDIA. The latter is what we // except when running on a non-primary gpu. This is not ideal,
// would need but not much we can do about it. // 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; 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 // finally got a value, just report it, the profiler cares about min/max/avg anyway
......
...@@ -2557,8 +2557,12 @@ bool QMetalSwapChain::buildOrResize() ...@@ -2557,8 +2557,12 @@ bool QMetalSwapChain::buildOrResize()
if (m_flags.testFlag(UsedAsTransferSource)) if (m_flags.testFlag(UsedAsTransferSource))
d->layer.framebufferOnly = NO; d->layer.framebufferOnly = NO;
if (m_flags.testFlag(NoVSync)) #ifdef Q_OS_MAC
d->layer.displaySyncEnabled = NO; if (m_flags.testFlag(NoVSync)) {
if (@available(macOS 10.13, *))
d->layer.displaySyncEnabled = NO;
}
#endif
m_currentPixelSize = surfacePixelSize(); m_currentPixelSize = surfacePixelSize();
pixelSize = m_currentPixelSize; 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