Introducing a ui app for debugging the workload and fixing the vissible/invisisble behavior of the render item

This commit is contained in:
samcake 2018-03-01 13:40:58 -08:00
parent f9db9e999e
commit 3a9a93f502
5 changed files with 152 additions and 14 deletions

View file

@ -20,7 +20,7 @@
void GameSpaceToRender::configure(const Config& config) {
_showAllWorkspace = config.showAllWorkspace;
_showAllProxies = config.showAllProxies;
}
void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext, Outputs& outputs) {
@ -33,8 +33,9 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
return;
}
auto visible = _showAllWorkspace;
auto visible = _showAllProxies;
render::Transaction transaction;
auto scene = gameWorkloadContext->_scene;
// Nothing really needed, early exit
if (!visible) {
@ -42,6 +43,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
transaction.updateItem<GameWorkloadRenderItem>(_spaceRenderItemID, [](GameWorkloadRenderItem& item) {
item.setVisible(false);
});
scene->enqueueTransaction(transaction);
}
return;
}
@ -50,7 +52,6 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
space->copyProxyValues(proxies.data(), (uint32_t)proxies.size());
auto scene = gameWorkloadContext->_scene;
// Valid space, let's display its content
if (!render::Item::isValidID(_spaceRenderItemID)) {
@ -71,11 +72,7 @@ void GameSpaceToRender::run(const workload::WorkloadContextPointer& runContext,
namespace render {
template <> const ItemKey payloadGetKey(const GameWorkloadRenderItem::Pointer& payload) {
auto key = ItemKey::Builder::opaqueShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1);
if (!payload->isVisible()) {
key.withInvisible();
}
return key;
return payload->getKey();
}
template <> const Item::Bound payloadGetBound(const GameWorkloadRenderItem::Pointer& payload) {
if (payload) {
@ -97,6 +94,21 @@ namespace render {
}
GameWorkloadRenderItem::GameWorkloadRenderItem() : _key(render::ItemKey::Builder::opaqueShape().withTagBits(render::ItemKey::TAG_BITS_0 | render::ItemKey::TAG_BITS_1)) {
}
render::ItemKey GameWorkloadRenderItem::getKey() const {
return _key;
}
void GameWorkloadRenderItem::setVisible(bool isVisible) {
if (isVisible) {
_key = render::ItemKey::Builder(_key).withVisible();
} else {
_key = render::ItemKey::Builder(_key).withInvisible();
}
}
void GameWorkloadRenderItem::setAllProxies(const std::vector<workload::Space::Proxy>& proxies) {
_myOwnProxies = proxies;
static const uint32_t sizeOfProxy = sizeof(workload::Space::Proxy);

View file

@ -14,10 +14,10 @@
class GameSpaceToRenderConfig : public workload::Job::Config {
Q_OBJECT
Q_PROPERTY(bool showAllWorkspace MEMBER showAllWorkspace NOTIFY dirty)
Q_PROPERTY(bool showAllProxies MEMBER showAllProxies NOTIFY dirty)
public:
bool showAllWorkspace{ false };
bool showAllProxies{ false };
signals:
void dirty();
@ -37,7 +37,7 @@ public:
protected:
render::ItemID _spaceRenderItemID{ render::Item::INVALID_ITEM_ID };
bool _showAllWorkspace{ false };
bool _showAllProxies{ false };
};
@ -46,18 +46,19 @@ public:
using Payload = render::Payload<GameWorkloadRenderItem>;
using Pointer = Payload::DataPointer;
GameWorkloadRenderItem() {}
GameWorkloadRenderItem();
~GameWorkloadRenderItem() {}
void render(RenderArgs* args);
render::Item::Bound& editBound() { _needUpdate = true; return _bound; }
const render::Item::Bound& getBound() { return _bound; }
void setVisible(bool visible) { _isVisible = visible; }
bool isVisible() const { return _isVisible; }
void setVisible(bool visible);
void setAllProxies(const std::vector<workload::Space::Proxy>& proxies);
render::ItemKey getKey() const;
protected:
render::Item::Bound _bound;
@ -68,6 +69,7 @@ protected:
gpu::PipelinePointer _drawAllProxiesPipeline;
const gpu::PipelinePointer getPipeline();
render::ItemKey _key;
bool _needUpdate{ true };
bool _isVisible{ true };
};

View file

@ -122,6 +122,7 @@ public:
Builder& withDynamic() { _flags.set(DYNAMIC); return (*this); }
Builder& withDeformed() { _flags.set(DEFORMED); return (*this); }
Builder& withInvisible() { _flags.set(INVISIBLE); return (*this); }
Builder& withVisible() { _flags.reset(INVISIBLE); return (*this); }
Builder& withShadowCaster() { _flags.set(SHADOW_CASTER); return (*this); }
Builder& withLayered() { _flags.set(LAYERED); return (*this); }
Builder& withMetaCullGroup() { _flags.set(META_CULL_GROUP); return (*this); }

View file

@ -0,0 +1,83 @@
"use strict";
//
// Workload.js
// tablet-workload-engine app
//
// 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
//
(function() {
var TABLET_BUTTON_NAME = "Workload";
var QMLAPP_URL = Script.resolvePath("./workload.qml");
var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg");
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg");
var onAppScreen = false;
function onClicked() {
if (onAppScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
text: TABLET_BUTTON_NAME,
icon: ICON_URL,
activeIcon: ACTIVE_ICON_URL
});
var hasEventBridge = false;
function wireEventBridge(on) {
if (!tablet) {
print("Warning in wireEventBridge(): 'tablet' undefined!");
return;
}
if (on) {
if (!hasEventBridge) {
tablet.fromQml.connect(fromQml);
hasEventBridge = true;
}
} else {
if (hasEventBridge) {
tablet.fromQml.disconnect(fromQml);
hasEventBridge = false;
}
}
}
function onScreenChanged(type, url) {
if (url === QMLAPP_URL) {
onAppScreen = true;
} else {
onAppScreen = false;
}
button.editProperties({isActive: onAppScreen});
wireEventBridge(onAppScreen);
}
function fromQml(message) {
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
Script.scriptEnding.connect(function () {
if (onAppScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
});
}());

View file

@ -0,0 +1,40 @@
//
// workload.qml
//
// Created by Sam Gateau on 3/1/2018
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
import "qrc:///qml/styles-uit"
import "qrc:///qml/controls-uit" as HifiControls
import "../render/configSlider"
Rectangle {
HifiConstants { id: hifi;}
id: workload;
anchors.margins: hifi.dimensions.contentMargin.x
color: hifi.colors.baseGray;
property var spaceToRender: Workload.getConfig("SpaceToRender")
Column {
spacing: 5
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: hifi.dimensions.contentMargin.x
//padding: hifi.dimensions.contentMargin.x
HifiControls.CheckBox {
boxSize: 20
text: "Show All Proxies"
checked: workload.spaceToRender["showAllProxies"]
onCheckedChanged: { workload.spaceToRender["showAllProxies"] = checked }
}
}
}