Convert d3d12 backend into a plugin

Change-Id: I4300ba81800e44c0b5e2a86e72b1cf96434c323d
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
This commit is contained in:
Laszlo Agocs 2016-04-12 13:41:35 +02:00
parent b943809c41
commit 8c68adb073
44 changed files with 35 additions and 19 deletions

View File

@ -1,3 +1,4 @@
TEMPLATE = subdirs
!contains(QT_CONFIG, no-qml-debug):SUBDIRS += qmltooling
SUBDIRS += scenegraph

View File

@ -0,0 +1,3 @@
{
"Keys": ["d3d12"]
}

View File

@ -1,3 +1,14 @@
TARGET = qsgd3d12backend
QT += core-private gui-private qml-private quick-private
PLUGIN_TYPE = scenegraph
PLUGIN_CLASS_NAME = QSGD3D12Adaptation
load(qt_plugin)
QMAKE_TARGET_PRODUCT = "Qt Quick D3D12 Renderer (Qt $$QT_VERSION)"
QMAKE_TARGET_DESCRIPTION = "Quick D3D12 Renderer for Qt."
SOURCES += \
$$PWD/qsgd3d12adaptation.cpp \
$$PWD/qsgd3d12renderloop.cpp \
@ -35,6 +46,6 @@ HEADERS += \
LIBS += -ldxgi -ld3d12
DEFINES += QSG_D3D12
include($$PWD/shaders/shaders.pri)
OTHER_FILES += $$PWD/d3d12.json

View File

@ -61,6 +61,9 @@ class QSGRenderLoop;
class QSGD3D12Adaptation : public QSGContextPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QSGContextFactoryInterface" FILE "d3d12.json")
public:
QSGD3D12Adaptation(QObject *parent = 0);

View File

@ -40,6 +40,8 @@
#include "qsgd3d12builtinmaterials_p.h"
#include "qsgd3d12rendercontext_p.h"
#include <QQuickWindow>
#include <QtCore/qmath.h>
#include <QtGui/private/qfixed_p.h>
#include "vs_vertexcolor.hlslh"
#include "ps_vertexcolor.hlslh"

View File

@ -53,6 +53,7 @@
#include <private/qsgrenderer_p.h>
#include <QtGui/private/qdatabuffer_p.h>
#include <QtCore/qbitarray.h>
#include "qsgd3d12engine_p.h"
#include "qsgd3d12material_p.h"

View File

@ -49,6 +49,8 @@
#include <private/qqmldebugserviceinterfaces_p.h>
#include <private/qqmldebugconnector_p.h>
#include <QElapsedTimer>
#include <QQueue>
#include <QGuiApplication>
QT_BEGIN_NAMESPACE
@ -517,8 +519,7 @@ void QSGD3D12RenderThread::sync(bool inExpose)
void QSGD3D12RenderThread::syncAndRender()
{
bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled();
if (profileFrames) {
if (Q_UNLIKELY(debug_time())) {
sinceLastTime = threadTimer.nsecsElapsed();
threadTimer.start();
}
@ -542,7 +543,7 @@ void QSGD3D12RenderThread::syncAndRender()
sync(exposeRequested);
#ifndef QSG_NO_RENDER_TIMING
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
syncTime = threadTimer.nsecsElapsed();
#endif
Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
@ -578,7 +579,7 @@ void QSGD3D12RenderThread::syncAndRender()
if (canRender) {
wd->renderSceneGraph(engine->windowSize());
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
renderTime = threadTimer.nsecsElapsed();
Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphRenderLoopFrame);
@ -1035,15 +1036,14 @@ void QSGD3D12RenderLoop::polishAndSync(WindowData *w, bool inExpose)
qint64 polishTime = 0;
qint64 waitTime = 0;
qint64 syncTime = 0;
bool profileFrames = QSG_LOG_TIME_RENDERLOOP().isDebugEnabled();
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
timer.start();
Q_QUICK_SG_PROFILE_START(QQuickProfiler::SceneGraphPolishAndSync);
QQuickWindowPrivate *wd = QQuickWindowPrivate::get(window);
wd->polishItems();
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
polishTime = timer.nsecsElapsed();
Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
@ -1060,7 +1060,7 @@ void QSGD3D12RenderLoop::polishAndSync(WindowData *w, bool inExpose)
if (Q_UNLIKELY(debug_loop()))
qDebug("polishAndSync - wait for sync");
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
waitTime = timer.nsecsElapsed();
Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);
w->thread->waitCondition.wait(&w->thread->mutex);
@ -1069,7 +1069,7 @@ void QSGD3D12RenderLoop::polishAndSync(WindowData *w, bool inExpose)
if (Q_UNLIKELY(debug_loop()))
qDebug("polishAndSync - unlock after sync");
if (profileFrames)
if (Q_UNLIKELY(debug_time()))
syncTime = timer.nsecsElapsed();
Q_QUICK_SG_PROFILE_RECORD(QQuickProfiler::SceneGraphPolishAndSync);

View File

@ -0,0 +1,2 @@
TEMPLATE = subdirs
config_d3d12: SUBDIRS += d3d12

View File

@ -1,2 +1 @@
include(software/software.pri)
config_d3d12: include(d3d12/d3d12.pri)

View File

@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
class QSGMaterial;
class QSGBasicGlyphNode: public QSGGlyphNode
class Q_QUICK_PRIVATE_EXPORT QSGBasicGlyphNode: public QSGGlyphNode
{
public:
QSGBasicGlyphNode();

View File

@ -45,9 +45,6 @@
// Built-in adaptations
#include <QtQuick/private/qsgsoftwareadaptation_p.h>
#ifdef QSG_D3D12
#include <QtQuick/private/qsgd3d12adaptation_p.h>
#endif
#ifndef QT_NO_OPENGL
#include <QtQuick/private/qsgdefaultcontext_p.h>
#endif
@ -89,9 +86,6 @@ QSGAdaptionBackendData::QSGAdaptionBackendData()
{
// Fill in the table with the built-in adaptations.
builtIns.append(new QSGSoftwareAdaptation);
#ifdef QSG_D3D12
builtIns.append(new QSGD3D12Adaptation);
#endif
}
Q_GLOBAL_STATIC(QSGAdaptionBackendData, qsg_adaptation_data)