diff options
author | Liang Qi <liang.qi@qt.io> | 2016-12-14 19:01:23 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-12-14 19:01:23 +0100 |
commit | 0e80d28aa5892d6bbb4d0017b1bc9a33489f4176 (patch) | |
tree | 0db2e10c8776d172bccaeaa7ee1fab3934b93073 /src/plugins/scenegraph | |
parent | ed32558d6280cae40578f735fd326327d571d993 (diff) | |
parent | 16c81bb0d493af00bc376784bcb7e03a4a037b04 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
src/qml/qml/qqmlimport.cpp
src/quick/items/context2d/qquickcontext2dtexture_p.h
tools/qmleasing/splineeditor.h
Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
Diffstat (limited to 'src/plugins/scenegraph')
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp | 72 | ||||
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp | 12 | ||||
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp | 24 |
3 files changed, 73 insertions, 35 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp index caf64ebb8b..908f1221ab 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp @@ -61,6 +61,8 @@ #include <windows.ui.xaml.media.dxinterop.h> #endif +#include <comdef.h> + QT_BEGIN_NAMESPACE // NOTE: Avoid categorized logging. It is slow. @@ -98,6 +100,19 @@ static const int BUCKETS_PER_HEAP = 8; // must match freeMap static const int DESCRIPTORS_PER_BUCKET = 32; // the bit map (freeMap) is quint32 static const int MAX_DESCRIPTORS_PER_HEAP = BUCKETS_PER_HEAP * DESCRIPTORS_PER_BUCKET; +static QString comErrorMessage(HRESULT hr) +{ +#ifndef Q_OS_WINRT + const _com_error comError(hr); +#else + const _com_error comError(hr, nullptr); +#endif + QString result = QLatin1String("Error 0x") + QString::number(ulong(hr), 16); + if (const wchar_t *msg = comError.ErrorMessage()) + result += QLatin1String(": ") + QString::fromWCharArray(msg); + return result; +} + D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DESCRIPTOR_HEAP_TYPE type) { D3D12_CPU_DESCRIPTOR_HANDLE h = {}; @@ -128,7 +143,8 @@ D3D12_CPU_DESCRIPTOR_HANDLE QSGD3D12CPUDescriptorHeapManager::allocate(D3D12_DES HRESULT hr = m_device->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&heap.heap)); if (FAILED(hr)) { - qWarning("Failed to create heap with type 0x%x: %x", type, hr); + qWarning("Failed to create heap with type 0x%x: %s", + type, qPrintable(comErrorMessage(hr))); return h; } @@ -211,7 +227,8 @@ static void getHardwareAdapter(IDXGIFactory1 *factory, IDXGIAdapter1 **outAdapte *outAdapter = adapter.Detach(); return; } else { - qWarning("Failed to create device for requested adapter '%s': 0x%x", qPrintable(name), hr); + qWarning("Failed to create device for requested adapter '%s': %s", + qPrintable(name), qPrintable(comErrorMessage(hr))); } } } @@ -270,7 +287,7 @@ void QSGD3D12DeviceManager::ensureCreated() HRESULT hr = CreateDXGIFactory2(0, IID_PPV_ARGS(&m_factory)); if (FAILED(hr)) { - qWarning("Failed to create DXGI: 0x%x", hr); + qWarning("Failed to create DXGI: %s", qPrintable(comErrorMessage(hr))); return; } @@ -283,7 +300,7 @@ void QSGD3D12DeviceManager::ensureCreated() if (SUCCEEDED(hr)) warp = false; else - qWarning("Failed to create device: 0x%x", hr); + qWarning("Failed to create device: %s", qPrintable(comErrorMessage(hr))); } if (warp) { @@ -291,7 +308,7 @@ void QSGD3D12DeviceManager::ensureCreated() m_factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter)); HRESULT hr = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)); if (FAILED(hr)) { - qWarning("Failed to create WARP device: 0x%x", hr); + qWarning("Failed to create WARP device: %s", qPrintable(comErrorMessage(hr))); return; } } @@ -798,15 +815,18 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int if (SUCCEEDED(hr)) { hr = dcompDevice->CreateVisual(&dcompVisual); if (FAILED(hr)) { - qWarning("Failed to create DirectComposition visual: 0x%x", hr); + qWarning("Failed to create DirectComposition visual: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("Failed to create DirectComposition target: 0x%x", hr); + qWarning("Failed to create DirectComposition target: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("Failed to create DirectComposition device: 0x%x", hr); + qWarning("Failed to create DirectComposition device: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } @@ -833,11 +853,13 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int if (SUCCEEDED(hr)) { hr = dcompTarget->SetRoot(dcompVisual.Get()); if (FAILED(hr)) { - qWarning("SetRoot failed for DirectComposition target: 0x%x", hr); + qWarning("SetRoot failed for DirectComposition target: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { - qWarning("SetContent failed for DirectComposition visual: 0x%x", hr); + qWarning("SetContent failed for DirectComposition visual: %s", + qPrintable(comErrorMessage(hr))); windowAlpha = false; } } else { @@ -867,11 +889,12 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int ComPtr<IDXGISwapChain> baseSwapChain; HRESULT hr = dev->dxgi()->CreateSwapChain(commandQueue.Get(), &swapChainDesc, &baseSwapChain); if (FAILED(hr)) { - qWarning("Failed to create swap chain: 0x%x", hr); + qWarning("Failed to create swap chain: %s", qPrintable(comErrorMessage(hr))); return; } - if (FAILED(baseSwapChain.As(&swapChain))) { - qWarning("Failed to cast swap chain"); + hr = baseSwapChain.As(&swapChain); + if (FAILED(hr)) { + qWarning("Failed to cast swap chain: %s", qPrintable(comErrorMessage(hr))); return; } } @@ -1165,7 +1188,7 @@ void QSGD3D12EnginePrivate::setWindowSize(const QSize &size, float dpr) deviceManager()->deviceLossDetected(); return; } else if (FAILED(hr)) { - qWarning("Failed to resize buffers: 0x%x", hr); + qWarning("Failed to resize buffers: %s", qPrintable(comErrorMessage(hr))); return; } @@ -1188,7 +1211,7 @@ QSGD3D12CPUWaitableFence *QSGD3D12EnginePrivate::createCPUWaitableFence() const QSGD3D12CPUWaitableFence *f = new QSGD3D12CPUWaitableFence; HRESULT hr = device->CreateFence(f->value, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&f->fence)); if (FAILED(hr)) { - qWarning("Failed to create fence: 0x%x", hr); + qWarning("Failed to create fence: %s", qPrintable(comErrorMessage(hr))); return f; } f->event = CreateEvent(nullptr, FALSE, FALSE, nullptr); @@ -1202,7 +1225,7 @@ void QSGD3D12EnginePrivate::waitForGPU(QSGD3D12CPUWaitableFence *f) const if (f->fence->GetCompletedValue() < newValue) { HRESULT hr = f->fence->SetEventOnCompletion(newValue, f->event); if (FAILED(hr)) { - qWarning("SetEventOnCompletion failed: 0x%x", hr); + qWarning("SetEventOnCompletion failed: %s", qPrintable(comErrorMessage(hr))); return; } WaitForSingleObject(f->event, INFINITE); @@ -1283,7 +1306,7 @@ ID3D12Resource *QSGD3D12EnginePrivate::createBuffer(int size) HRESULT hr = device->CreateCommittedResource(&uploadHeapProp, D3D12_HEAP_FLAG_NONE, &bufDesc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&buf)); if (FAILED(hr)) - qWarning("Failed to create buffer resource: 0x%x", hr); + qWarning("Failed to create buffer resource: %s", qPrintable(comErrorMessage(hr))); return buf; } @@ -1640,7 +1663,7 @@ void QSGD3D12EnginePrivate::endDrawCalls(bool lastInFrame) // Go! HRESULT hr = frameCommandList->Close(); if (FAILED(hr)) { - qWarning("Failed to close command list: 0x%x", hr); + qWarning("Failed to close command list: %s", qPrintable(comErrorMessage(hr))); if (hr == E_INVALIDARG) qWarning("Invalid arguments. Some of the commands in the list is invalid in some way."); } @@ -1874,7 +1897,8 @@ void QSGD3D12EnginePrivate::finalizePipeline(const QSGD3D12PipelineState &pipeli HRESULT hr = device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&cachedPso->pso)); if (FAILED(hr)) { - qWarning("Failed to create graphics pipeline state"); + qWarning("Failed to create graphics pipeline state: %s", + qPrintable(comErrorMessage(hr))); return; } @@ -2179,7 +2203,7 @@ void QSGD3D12EnginePrivate::present() deviceManager()->deviceLossDetected(); return; } else if (FAILED(hr)) { - qWarning("Present failed: 0x%x", hr); + qWarning("Present failed: %s", qPrintable(comErrorMessage(hr))); return; } @@ -2433,7 +2457,7 @@ void QSGD3D12EnginePrivate::createTexture(uint id, const QSize &size, QImage::Fo HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture)); if (FAILED(hr)) { - qWarning("Failed to create texture resource: 0x%x", hr); + qWarning("Failed to create texture resource: %s", qPrintable(comErrorMessage(hr))); return; } @@ -2498,7 +2522,8 @@ void QSGD3D12EnginePrivate::queueTextureResize(uint id, const QSize &size) HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&t.texture)); if (FAILED(hr)) { - qWarning("Failed to create resized texture resource: 0x%x", hr); + qWarning("Failed to create resized texture resource: %s", + qPrintable(comErrorMessage(hr))); return; } @@ -2954,7 +2979,8 @@ void QSGD3D12EnginePrivate::createRenderTarget(uint id, const QSize &size, const HRESULT hr = device->CreateCommittedResource(&defaultHeapProp, D3D12_HEAP_FLAG_NONE, &textureDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&rt.colorResolve)); if (FAILED(hr)) { - qWarning("Failed to create resolve buffer: 0x%x", hr); + qWarning("Failed to create resolve buffer: %s", + qPrintable(comErrorMessage(hr))); return; } diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp index c53a1fa6c1..60b76deb2e 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12renderloop.cpp @@ -421,7 +421,8 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) polishTime = renderTimer.nsecsElapsed(); Q_QUICK_SG_PROFILE_SWITCH(QQuickProfiler::SceneGraphPolishFrame, - QQuickProfiler::SceneGraphRenderLoopFrame); + QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphPolishPolish); emit window->afterAnimating(); @@ -463,13 +464,15 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window) if (profileFrames) syncTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); wd->renderSceneGraph(window->size()); if (profileFrames) renderTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); if (!data.grabOnly) { // The engine is able to have multiple frames in flight. This in effect is @@ -496,7 +499,8 @@ void QSGD3D12RenderLoop::renderWindow(QQuickWindow *window) qint64 swapTime = 0; if (profileFrames) swapTime = renderTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); if (Q_UNLIKELY(debug_time())) { static QTime lastFrameTime = QTime::currentTime(); diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp index a803f67380..317471eeec 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12threadedrenderloop.cpp @@ -597,7 +597,8 @@ void QSGD3D12RenderThread::syncAndRender() if (Q_UNLIKELY(debug_time())) syncTime = threadTimer.nsecsElapsed(); #endif - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync); if (!syncResultedInChanges && !repaintRequested) { if (Q_UNLIKELY(debug_loop())) @@ -632,7 +633,8 @@ void QSGD3D12RenderThread::syncAndRender() wd->renderSceneGraph(engine->windowSize()); if (Q_UNLIKELY(debug_time())) renderTime = threadTimer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopRender); // The engine is able to have multiple frames in flight. This in effect is // similar to BufferQueueingOpenGL. Provide an env var to force the @@ -649,7 +651,8 @@ void QSGD3D12RenderThread::syncAndRender() // blockOnEachFrame is not used, but emit it for compatibility. wd->fireFrameSwapped(); } else { - Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, 1); + Q_QUICK_SG_PROFILE_SKIP(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSync, 1); if (Q_UNLIKELY(debug_loop())) qDebug("RT - window not ready, skipping render"); } @@ -671,7 +674,8 @@ void QSGD3D12RenderThread::syncAndRender() int((renderTime - syncTime) / 1000000), int(threadTimer.elapsed() - renderTime / 1000000)); - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphRenderLoopFrame, + QQuickProfiler::SceneGraphRenderLoopSwap); static int devLossTest = qEnvironmentVariableIntValue("QT_D3D_TEST_DEVICE_LOSS"); if (devLossTest > 0) { @@ -1127,7 +1131,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose) if (Q_UNLIKELY(debug_time())) polishTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncPolish); w->updateDuringSync = false; @@ -1144,7 +1149,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose) qDebug("polishAndSync - wait for sync"); if (Q_UNLIKELY(debug_time())) waitTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncWait); w->thread->waitCondition.wait(&w->thread->mutex); lockedForSync = false; w->thread->mutex.unlock(); @@ -1153,7 +1159,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose) if (Q_UNLIKELY(debug_time())) syncTime = timer.nsecsElapsed(); - Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncSync); if (!animationTimer && anim->isRunning()) { if (Q_UNLIKELY(debug_loop())) @@ -1175,7 +1182,8 @@ void QSGD3D12ThreadedRenderLoop::polishAndSync(WindowData *w, bool inExpose) << ", animations=" << (timer.nsecsElapsed() - syncTime) / 1000000 << " - (on gui thread) " << window; - Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync); + Q_QUICK_SG_PROFILE_END(QQuickProfiler::SceneGraphPolishAndSync, + QQuickProfiler::SceneGraphPolishAndSyncAnimations); } #include "qsgd3d12threadedrenderloop.moc" |