mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 11:43:16 +02:00
Merge pull request #12780 from samcake/workload
Workload : adding helper feature on the task and job config to inspect them and start proper ui lib around it
This commit is contained in:
commit
8c065506e4
11 changed files with 216 additions and 22 deletions
|
@ -265,6 +265,9 @@ public:
|
|||
render::EnginePointer getRenderEngine() override { return _renderEngine; }
|
||||
gpu::ContextPointer getGPUContext() const { return _gpuContext; }
|
||||
|
||||
|
||||
const GameWorkload& getGameWorkload() const { return _gameWorkload; }
|
||||
|
||||
virtual void pushPostUpdateLambda(void* key, std::function<void()> func) override;
|
||||
|
||||
void updateMyAvatarLookAtPosition();
|
||||
|
|
|
@ -256,6 +256,7 @@ void Web3DOverlay::setupQmlSurface() {
|
|||
_webSurface->getSurfaceContext()->setContextProperty("MenuInterface", MenuScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Settings", SettingsScriptingInterface::getInstance());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Render", AbstractViewStateInterface::instance()->getRenderEngine()->getConfiguration().get());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Workload", qApp->getGameWorkload()._engine->getConfiguration().get());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this);
|
||||
|
|
|
@ -19,6 +19,7 @@ GameWorkloadContext::~GameWorkloadContext() {
|
|||
|
||||
|
||||
GameWorkload::GameWorkload() {
|
||||
|
||||
}
|
||||
|
||||
GameWorkload::~GameWorkload() {
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
JobConfig() = default;
|
||||
JobConfig(bool enabled) : alwaysEnabled{ false }, enabled{ enabled } {}
|
||||
|
||||
bool isEnabled() const { return alwaysEnabled || enabled; }
|
||||
bool isEnabled() { return alwaysEnabled || enabled; }
|
||||
void setEnabled(bool enable) { enabled = alwaysEnabled || enable; emit dirtyEnabled(); }
|
||||
|
||||
bool alwaysEnabled{ true };
|
||||
|
@ -108,11 +108,18 @@ public:
|
|||
Q_INVOKABLE QString toJSON() { return QJsonDocument(toJsonValue(*this).toObject()).toJson(QJsonDocument::Compact); }
|
||||
Q_INVOKABLE void load(const QVariantMap& map) { qObjectFromJsonValue(QJsonObject::fromVariantMap(map), *this); emit loaded(); }
|
||||
|
||||
Q_INVOKABLE QObject* getConfig(const QString& name) { return nullptr; }
|
||||
|
||||
// Running Time measurement
|
||||
// The new stats signal is emitted once per run time of a job when stats (cpu runtime) are updated
|
||||
void setCPURunTime(double mstime) { _msCPURunTime = mstime; emit newStats(); }
|
||||
double getCPURunTime() const { return _msCPURunTime; }
|
||||
|
||||
Q_INVOKABLE virtual bool isTask() const { return false; }
|
||||
Q_INVOKABLE virtual QObjectList getSubConfigs() const { return QObjectList(); }
|
||||
Q_INVOKABLE virtual int getNumSubs() const { return 0; }
|
||||
Q_INVOKABLE virtual QObject* getSubConfig(int i) const { return nullptr; }
|
||||
|
||||
public slots:
|
||||
void load(const QJsonObject& val) { qObjectFromJsonValue(val, *this); emit loaded(); }
|
||||
|
||||
|
@ -122,6 +129,8 @@ signals:
|
|||
void dirtyEnabled();
|
||||
};
|
||||
|
||||
using QConfigPointer = std::shared_ptr<JobConfig>;
|
||||
|
||||
class TConfigProxy {
|
||||
public:
|
||||
using Config = JobConfig;
|
||||
|
@ -130,11 +139,9 @@ public:
|
|||
class TaskConfig : public JobConfig {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using QConfigPointer = std::shared_ptr<QObject>;
|
||||
|
||||
using Persistent = PersistentConfig<TaskConfig>;
|
||||
|
||||
TaskConfig() = default ;
|
||||
TaskConfig() = default;
|
||||
TaskConfig(bool enabled) : JobConfig(enabled) {}
|
||||
|
||||
|
||||
|
@ -156,7 +163,8 @@ public:
|
|||
|
||||
if (tokens.empty()) {
|
||||
tokens.push_back(QString());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
while (tokens.size() > 1) {
|
||||
auto name = tokens.front();
|
||||
tokens.pop_front();
|
||||
|
@ -170,6 +178,22 @@ public:
|
|||
return root->findChild<typename T::Config*>(tokens.front());
|
||||
}
|
||||
|
||||
Q_INVOKABLE bool isTask() const override { return true; }
|
||||
Q_INVOKABLE QObjectList getSubConfigs() const override {
|
||||
auto list = findChildren<JobConfig*>(QRegExp(".*"), Qt::FindDirectChildrenOnly);
|
||||
QObjectList returned;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
returned.push_back(list[i]);
|
||||
}
|
||||
return returned;
|
||||
}
|
||||
|
||||
Q_INVOKABLE int getNumSubs() const override { return getSubConfigs().size(); }
|
||||
Q_INVOKABLE QObject* getSubConfig(int i) const override {
|
||||
auto subs = getSubConfigs();
|
||||
return ((i < 0 || i >= subs.size()) ? nullptr : subs[i] );
|
||||
}
|
||||
|
||||
void connectChildConfig(QConfigPointer childConfig, const std::string& name);
|
||||
void transferChildrenConfigs(QConfigPointer source);
|
||||
|
||||
|
@ -179,8 +203,6 @@ public slots:
|
|||
void refresh();
|
||||
};
|
||||
|
||||
using QConfigPointer = std::shared_ptr<QObject>;
|
||||
|
||||
}
|
||||
|
||||
#endif // hifi_task_Config_h
|
||||
|
|
73
scripts/developer/utilities/lib/jet/jet.js
Normal file
73
scripts/developer/utilities/lib/jet/jet.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Job Engine & Task...
|
||||
// jet.js
|
||||
//
|
||||
// Created by Sam Gateau, 2018/03/28
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
"use strict";
|
||||
|
||||
// traverse task tree
|
||||
function task_traverse(root, functor, depth) {
|
||||
// if (root.isTask()) {
|
||||
depth++;
|
||||
for (var i = 0; i <root.getNumSubs(); i++) {
|
||||
var sub = root.getSubConfig(i);
|
||||
if (functor(sub, depth, i)) {
|
||||
task_traverse(sub, functor, depth)
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
function task_traverseTree(root, functor) {
|
||||
if (functor(root, 0, 0)) {
|
||||
task_traverse(root, functor, 0)
|
||||
}
|
||||
}
|
||||
|
||||
// Access job properties
|
||||
// return all the properties of a job
|
||||
function job_propKeys(job) {
|
||||
var keys = Object.keys(job)
|
||||
var propKeys = [];
|
||||
for (var k=0; k < keys.length;k++) {
|
||||
// Filter for relevant property
|
||||
var key = keys[k]
|
||||
if ((typeof job[key]) !== "function") {
|
||||
if ((key !== "objectName") && (key !== "cpuRunTime") && (key !== "enabled")) {
|
||||
propKeys.push(keys[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return propKeys;
|
||||
}
|
||||
|
||||
// Use this function to create a functor that will print the content of the Job visited calling the specified 'printout' function
|
||||
function job_print_functor(printout, maxDepth) {
|
||||
if (maxDepth === undefined) maxDepth = 100
|
||||
return function (job, depth, index) {
|
||||
var tab = " "
|
||||
var depthTab = "";
|
||||
for (var d = 0; d < depth; d++) { depthTab += tab }
|
||||
printout(depthTab + index + " " + job.objectName + " " + (job.enabled ? "on" : "off"))
|
||||
var keys = job_propKeys(job);
|
||||
for (var p=0; p < keys.length;p++) {
|
||||
var prop = job[keys[p]]
|
||||
printout(depthTab + tab + tab + typeof prop + " " + keys[p] + " " + prop);
|
||||
}
|
||||
|
||||
return true
|
||||
// return depth < maxDepth;
|
||||
}
|
||||
}
|
||||
|
||||
// Expose functions for regular js including this files through the 'Jet' object
|
||||
/*Jet = {}
|
||||
Jet.task_traverse = task_traverse
|
||||
Jet.task_traverseTree = task_traverseTree
|
||||
Jet.job_propKeys = job_propKeys
|
||||
Jet.job_print_functor = job_print_functor
|
||||
*/
|
48
scripts/developer/utilities/lib/jet/qml/TaskList.qml
Normal file
48
scripts/developer/utilities/lib/jet/qml/TaskList.qml
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// jet/TaskList.qml
|
||||
//
|
||||
// Created by Sam Gateau, 2018/03/28
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
|
||||
import "../jet.js" as Jet
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
// width: parent ? parent.width : 200
|
||||
// height: parent ? parent.height : 400
|
||||
property var rootConfig : Workload
|
||||
|
||||
Original.TextArea {
|
||||
id: textArea
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
text: ""
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var message = ""
|
||||
var functor = Jet.job_print_functor(function (line) { message += line + "\n"; });
|
||||
Jet.task_traverseTree(rootConfig, functor);
|
||||
textArea.append(message);
|
||||
}
|
||||
function fromScript(mope) {
|
||||
var message ='Received \n';
|
||||
message += mope;
|
||||
textArea.append(message);
|
||||
}
|
||||
|
||||
function clearWindow() {
|
||||
textArea.remove(0,textArea.length);
|
||||
}
|
||||
}
|
1
scripts/developer/utilities/lib/jet/qml/qmldir
Normal file
1
scripts/developer/utilities/lib/jet/qml/qmldir
Normal file
|
@ -0,0 +1 @@
|
|||
TaskList 1.0 TaskList.qml
|
|
@ -14,6 +14,7 @@ import QtQuick.Layouts 1.3
|
|||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
import "configSlider"
|
||||
import "../lib/jet/qml" as Jet
|
||||
|
||||
Rectangle {
|
||||
HifiConstants { id: hifi;}
|
||||
|
@ -274,6 +275,15 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
Separator {}
|
||||
|
||||
Jet.TaskList {
|
||||
rootConfig: Render
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
height: 200
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
|
23
scripts/developer/utilities/workload/inspectEngine.js
Normal file
23
scripts/developer/utilities/workload/inspectEngine.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var qml = Script.resolvePath('./workloadInspector.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Inspect Engine',
|
||||
source: qml,
|
||||
width: 400,
|
||||
height: 600
|
||||
});
|
||||
|
||||
window.closed.connect(function () { Script.stop(); });
|
||||
Script.scriptEnding.connect(function () {
|
||||
/* var geometry = JSON.stringify({
|
||||
x: window.position.x,
|
||||
y: window.position.y,
|
||||
width: window.size.x,
|
||||
height: window.size.y
|
||||
})
|
||||
|
||||
Settings.setValue(HMD_DEBUG_WINDOW_GEOMETRY_KEY, geometry);*/
|
||||
window.close();
|
||||
})
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
(function() {
|
||||
var TABLET_BUTTON_NAME = "Workload";
|
||||
var QMLAPP_URL = Script.resolvePath("./workload.qml");
|
||||
var QMLAPP_URL = Script.resolvePath("./workloadInspector.qml");
|
||||
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
|
||||
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// workload.qml
|
||||
// _workload.qml
|
||||
//
|
||||
// Created by Sam Gateau on 3/1/2018
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
|
@ -13,17 +13,20 @@ import QtQuick.Layouts 1.3
|
|||
|
||||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
import "../render/configSlider"
|
||||
import "../render/configSlider"
|
||||
import "../lib/jet/qml" as Jet
|
||||
|
||||
|
||||
Rectangle {
|
||||
HifiConstants { id: hifi;}
|
||||
id: workload;
|
||||
id: _workload;
|
||||
|
||||
width: parent ? parent.width : 400
|
||||
height: parent ? parent.height : 600
|
||||
anchors.margins: hifi.dimensions.contentMargin.x
|
||||
|
||||
color: hifi.colors.baseGray;
|
||||
property var setupViews: Workload.getConfig("setupViews")
|
||||
property var spaceToRender: Workload.getConfig("SpaceToRender")
|
||||
|
||||
|
||||
Column {
|
||||
spacing: 5
|
||||
anchors.left: parent.left
|
||||
|
@ -34,11 +37,12 @@ Rectangle {
|
|||
HifiControls.Label {
|
||||
text: "Workload"
|
||||
}
|
||||
|
||||
HifiControls.CheckBox {
|
||||
boxSize: 20
|
||||
text: "Freeze Views"
|
||||
checked: workload.setupViews["freezeViews"]
|
||||
onCheckedChanged: { workload.spaceToRender["freezeViews"] = checked, workload.setupViews["freezeViews"] = checked; }
|
||||
checked: Workload.getConfig("setupViews")["freezeViews"]
|
||||
onCheckedChanged: { Workload.getConfig("SpaceToRender")["freezeViews"] = checked, Workload.getConfig("setupViews")["freezeViews"] = checked; }
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
@ -59,7 +63,7 @@ Rectangle {
|
|||
]
|
||||
ConfigSlider {
|
||||
label: qsTr(modelData.split(":")[0])
|
||||
config: workload.setupViews
|
||||
config: Workload.getConfig("setupViews")
|
||||
property: modelData.split(":")[1]
|
||||
max: modelData.split(":")[2]
|
||||
min: modelData.split(":")[3]
|
||||
|
@ -86,7 +90,7 @@ Rectangle {
|
|||
]
|
||||
ConfigSlider {
|
||||
showLabel: false
|
||||
config: workload.setupViews
|
||||
config: Workload.getConfig("setupViews")
|
||||
property: modelData.split(":")[0]
|
||||
max: modelData.split(":")[1]
|
||||
min: modelData.split(":")[2]
|
||||
|
@ -106,15 +110,23 @@ Rectangle {
|
|||
HifiControls.CheckBox {
|
||||
boxSize: 20
|
||||
text: "Show Proxies"
|
||||
checked: workload.spaceToRender["showProxies"]
|
||||
onCheckedChanged: { workload.spaceToRender["showProxies"] = checked }
|
||||
checked: Workload.getConfig("SpaceToRender")["showProxies"]
|
||||
onCheckedChanged: { Workload.getConfig("SpaceToRender")["showProxies"] = checked }
|
||||
}
|
||||
HifiControls.CheckBox {
|
||||
boxSize: 20
|
||||
text: "Show Views"
|
||||
checked: workload.spaceToRender["showViews"]
|
||||
onCheckedChanged: { workload.spaceToRender["showViews"] = checked }
|
||||
checked: Workload.getConfig("SpaceToRender")["showViews"]
|
||||
onCheckedChanged: { Workload.getConfig("SpaceToRender")["showViews"] = checked }
|
||||
}
|
||||
Separator {}
|
||||
|
||||
Jet.TaskList {
|
||||
rootConfig: Workload
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
height: 300
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue