Working on the LOD system

This commit is contained in:
Sam Gateau 2018-08-23 11:39:47 -07:00
parent 04d72ea39d
commit 473f8d0ca5
9 changed files with 198 additions and 24 deletions

View file

@ -264,20 +264,27 @@ Item {
StatText {
text: "GPU: " + root.gpuFrameTime.toFixed(1) + " ms"
}
StatText {
text: "Drawcalls: " + root.drawcalls
}
StatText {
text: "Triangles: " + root.triangles +
" / Material Switches: " + root.materialSwitches
}
StatText {
visible: root.expanded;
text: "GPU Free Memory: " + root.gpuFreeMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GPU Textures: ";
}
StatText {
visible: root.expanded;
text: " Count: " + root.gpuTextures;
}
StatText {
visible: root.expanded;
text: " Pressure State: " + root.gpuTextureMemoryPressureState;
}
StatText {
@ -287,27 +294,35 @@ Item {
text: " " + root.gpuTextureResourceMemory + " / " + root.gpuTextureResourcePopulatedMemory + " / " + root.texturePendingTransfers + " MB";
}
StatText {
visible: root.expanded;
text: " Resident Memory: " + root.gpuTextureResidentMemory + " MB";
}
StatText {
visible: root.expanded;
text: " Framebuffer Memory: " + root.gpuTextureFramebufferMemory + " MB";
}
StatText {
visible: root.expanded;
text: " External Memory: " + root.gpuTextureExternalMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GPU Buffers: "
}
StatText {
visible: root.expanded;
text: " Count: " + root.gpuBuffers;
}
StatText {
visible: root.expanded;
text: " Memory: " + root.gpuBufferMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GL Swapchain Memory: " + root.glContextSwapchainMemory + " MB";
}
StatText {
visible: root.expanded;
text: "QML Texture Memory: " + root.qmlTextureMemory + " MB";
}
StatText {

View file

@ -285,52 +285,69 @@ Item {
StatText {
text: "GPU frame size: " + root.gpuFrameSize.x + " x " + root.gpuFrameSize.y
}
StatText {
text: "Drawcalls: " + root.drawcalls
}
StatText {
text: "Triangles: " + root.triangles +
" / Material Switches: " + root.materialSwitches
}
StatText {
visible: root.expanded;
text: "GPU Free Memory: " + root.gpuFreeMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GPU Textures: ";
}
StatText {
visible: root.expanded;
text: " Count: " + root.gpuTextures;
}
StatText {
visible: root.expanded;
text: " Pressure State: " + root.gpuTextureMemoryPressureState;
}
StatText {
visible: root.expanded;
property bool showIdeal: (root.gpuTextureResourceIdealMemory != root.gpuTextureResourceMemory);
text: " Resource Allocated " + (showIdeal ? "(Ideal)" : "") + " / Populated / Pending: ";
}
StatText {
visible: root.expanded;
property bool showIdeal: (root.gpuTextureResourceIdealMemory != root.gpuTextureResourceMemory);
text: " " + root.gpuTextureResourceMemory + (showIdeal ? ("(" + root.gpuTextureResourceIdealMemory + ")") : "") + " / " + root.gpuTextureResourcePopulatedMemory + " / " + root.texturePendingTransfers + " MB";
}
StatText {
visible: root.expanded;
text: " Resident Memory: " + root.gpuTextureResidentMemory + " MB";
}
StatText {
visible: root.expanded;
text: " Framebuffer Memory: " + root.gpuTextureFramebufferMemory + " MB";
}
StatText {
visible: root.expanded;
text: " External Memory: " + root.gpuTextureExternalMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GPU Buffers: "
}
StatText {
visible: root.expanded;
text: " Count: " + root.gpuBuffers;
}
StatText {
visible: root.expanded;
text: " Memory: " + root.gpuBufferMemory + " MB";
}
StatText {
visible: root.expanded;
text: "GL Swapchain Memory: " + root.glContextSwapchainMemory + " MB";
}
StatText {
visible: root.expanded;
text: "QML Texture Memory: " + root.qmlTextureMemory + " MB";
}
StatText {

View file

@ -87,6 +87,7 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
_octreeSizeScale = ADJUST_LOD_MIN_SIZE_SCALE;
}
emit LODDecreased();
emit LODChanged();
// Assuming the LOD adjustment will work: we optimistically reset _avgRenderTime
// to provide an FPS just above the decrease threshold. It will drift close to its
// true value after a few LOD_ADJUST_TIMESCALEs and we'll adjust again as necessary.
@ -108,6 +109,8 @@ void LODManager::autoAdjustLOD(float realTimeDelta) {
_octreeSizeScale = ADJUST_LOD_MAX_SIZE_SCALE;
}
emit LODIncreased();
emit LODChanged();
// Assuming the LOD adjustment will work: we optimistically reset _avgRenderTime
// to provide an FPS just below the increase threshold. It will drift close to its
// true value after a few LOD_ADJUST_TIMESCALEs and we'll adjust again as necessary.
@ -145,6 +148,10 @@ float LODManager::getLODLevel() const {
return simpleLOD;
}
void LODManager::setLODLevel(float level) {
}
const float MIN_DECREASE_FPS = 0.5f;
void LODManager::setDesktopLODDecreaseFPS(float fps) {

View file

@ -30,7 +30,9 @@ const float INCREASE_LOD_GAP_FPS = 10.0f; // fps
// The default value DEFAULT_OCTREE_SIZE_SCALE means you can be 400 meters away from a 1 meter object in order to see it (which is ~20:20 vision).
const float ADJUST_LOD_MAX_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE;
// This controls how low the auto-adjust LOD will go. We want a minimum vision of ~20:500 or 0.04 of default
const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.04f;
// const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.04f;
// const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.02f;
const float ADJUST_LOD_MIN_SIZE_SCALE = DEFAULT_OCTREE_SIZE_SCALE * 0.01f;
class AABox;
@ -60,9 +62,10 @@ class LODManager : public QObject, public Dependency {
Q_PROPERTY(float gpuTime READ getGPUTime)
Q_PROPERTY(float avgRenderTime READ getAverageRenderTime)
Q_PROPERTY(float fps READ getMaxTheoreticalFPS)
Q_PROPERTY(float lodLevel READ getLODLevel)
Q_PROPERTY(float lodLevel READ getLODLevel WRITE setLODLevel NOTIFY LODChanged)
Q_PROPERTY(float lodDecreaseFPS READ getLODDecreaseFPS)
Q_PROPERTY(float lodIncreaseFPS READ getLODIncreaseFPS)
Q_PROPERTY(bool automaticLODAdjust READ getAutomaticLODAdjust WRITE setAutomaticLODAdjust)
public:
@ -174,6 +177,7 @@ public:
float getAverageRenderTime() const { return _avgRenderTime; };
float getMaxTheoreticalFPS() const { return (float)MSECS_PER_SECOND / _avgRenderTime; };
float getLODLevel() const;
void setLODLevel(float level);
signals:
@ -189,6 +193,8 @@ signals:
*/
void LODDecreased();
void LODChanged();
private:
LODManager();

View file

@ -376,6 +376,12 @@ void Stats::updateStats(bool force) {
STAT_UPDATE(rectifiedTextureCount, (int)RECTIFIED_TEXTURE_COUNT.load());
STAT_UPDATE(decimatedTextureCount, (int)DECIMATED_TEXTURE_COUNT.load());
gpu::ContextStats gpuFrameStats;
gpuContext->getFrameStats(gpuFrameStats);
STAT_UPDATE(drawcalls, gpuFrameStats._DSNumDrawcalls);
// Incoming packets
QLocale locale(QLocale::English);
auto voxelPacketsToProcess = qApp->getOctreePacketProcessor().packetsToProcessCount();

View file

@ -239,7 +239,8 @@ class Stats : public QQuickItem {
STATS_PROPERTY(int, processing, 0)
STATS_PROPERTY(int, processingPending, 0)
STATS_PROPERTY(int, triangles, 0)
STATS_PROPERTY(int, quads, 0)
STATS_PROPERTY(int, drawcalls, 0)
// STATS_PROPERTY(int, quads, 0)
STATS_PROPERTY(int, materialSwitches, 0)
STATS_PROPERTY(int, itemConsidered, 0)
STATS_PROPERTY(int, itemOutOfView, 0)
@ -708,12 +709,20 @@ signals:
*/
void trianglesChanged();
/**jsdoc
* Triggered when the value of the <code>drawcalls</code> property changes.
* This
* @function Stats.drawcallsChanged
* @returns {Signal}
*/
void drawcallsChanged();
/**jsdoc
* Triggered when the value of the <code>quads</code> property changes.
* @function Stats.quadsChanged
* @returns {Signal}
*/
void quadsChanged();
// void quadsChanged();
/**jsdoc
* Triggered when the value of the <code>materialSwitches</code> property changes.

View file

@ -56,13 +56,13 @@ Item {
anchors.verticalCenter: root.verticalCenter
}
Binding {
/* Binding {
id: bindingControl
target: root.config
property: root.property
value: sliderControl.value
when: false
}
}*/
HifiControls.Slider {
id: sliderControl
@ -73,7 +73,7 @@ Item {
anchors.top: root.top
anchors.topMargin: 0
onValueChanged: { root.valueChanged(value) }
// onValueChanged: { root.valueChanged(value) }
}
HifiControls.Label {

View file

@ -16,15 +16,9 @@
var ICON_URL = Script.resolvePath("../../../system/assets/images/lod-i.svg");
var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/lod-a.svg");
var onScreen = false;
var onTablet = false; // set this to true to use the tablet, false use a floating window
function onClicked() {
if (onScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
}
var onAppScreen = false;
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = tablet.addButton({
@ -35,6 +29,51 @@
var hasEventBridge = false;
var onScreen = false;
var window;
function onClicked() {
if (onTablet) {
if (onAppScreen) {
tablet.gotoHomeScreen();
} else {
tablet.loadQMLSource(QMLAPP_URL);
}
} else {
if (onScreen) {
killWindow()
} else {
createWindow()
}
}
}
function createWindow() {
var qml = Script.resolvePath(QMLAPP_URL);
window = Desktop.createWindow(Script.resolvePath(QMLAPP_URL), {
title: TABLET_BUTTON_NAME,
flags: Desktop.ALWAYS_ON_TOP,
presentationMode: Desktop.PresentationMode.NATIVE,
size: {x: 400, y: 600}
});
// window.setPosition(200, 50);
window.closed.connect(killWindow);
window.fromQml.connect(fromQml);
onScreen = true
button.editProperties({isActive: true});
}
function killWindow() {
if (window !== undefined) {
window.closed.disconnect(killWindow);
window.fromQml.disconnect(fromQml);
window.close()
window = undefined
}
onScreen = false
button.editProperties({isActive: false})
}
function wireEventBridge(on) {
if (!tablet) {
print("Warning in wireEventBridge(): 'tablet' undefined!");
@ -54,23 +93,42 @@
}
function onScreenChanged(type, url) {
onScreen = (url === QMLAPP_URL);
button.editProperties({isActive: onScreen});
wireEventBridge(onScreen);
}
function fromQml(message) {
if (onTablet) {
if (url === QMLAPP_URL) {
onAppScreen = true;
} else {
onAppScreen = false;
}
button.editProperties({isActive: onAppScreen});
wireEventBridge(onAppScreen);
}
}
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged);
Script.scriptEnding.connect(function () {
if (onScreen) {
killWindow()
if (onAppScreen) {
tablet.gotoHomeScreen();
}
button.clicked.disconnect(onClicked);
tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
});
function fromQml(message) {
}
function sendToQml(message) {
if (onTablet) {
tablet.sendToQml(message);
} else {
if (window) {
window.sendToQml(message);
}
}
}
}());

View file

@ -10,20 +10,73 @@
//
import QtQuick 2.5
import QtQuick.Controls 1.4
import "qrc:///qml/styles-uit"
import "qrc:///qml/controls-uit" as HifiControls
import "../lib/plotperf"
import "configSlider"
Item {
id: lodIU
anchors.fill:parent
Component.onCompleted: {
Render.getConfig("RenderMainView.DrawSceneOctree").showVisibleCells = false
Render.getConfig("RenderMainView.DrawSceneOctree").showEmptyCells = false
}
Component.onDestruction: {
Render.getConfig("RenderMainView.DrawSceneOctree").enabled = false
}
Column {
id: topHeader
spacing: 8
anchors.right: parent.right
anchors.left: parent.left
HifiControls.CheckBox {
boxSize: 20
text: "Show LOD Reticule"
checked: Render.getConfig("RenderMainView.DrawSceneOctree").enabled
onCheckedChanged: { Render.getConfig("RenderMainView.DrawSceneOctree").enabled = checked }
}
HifiControls.CheckBox {
boxSize: 20
text: "Manual LOD"
checked: LODManager.getAutomaticLODAdjust()
onCheckedChanged: { LODManager.setAutomaticLODAdjust(checked) }
}
ConfigSlider {
showLabel: true
config: LODManager
property: "lodLevel"
max: 13
min: 0
integral: false
anchors.left: parent.left
anchors.right: parent.right
}
}
Column {
id: stats
spacing: 8
anchors.fill:parent
anchors.right: parent.right
anchors.left: parent.left
anchors.top: topHeader.bottom
anchors.bottom: parent.bottom
function evalEvenHeight() {
// Why do we have to do that manually ? cannot seem to find a qml / anchor / layout mode that does that ?
return (height - spacing * (children.length - 1)) / children.length
return (height - topLine.height - bottomLine.height - spacing * (children.length - 3)) / (children.length - 2)
}
Separator {
id: topLine
}
PlotPerf {
@ -87,6 +140,9 @@ Item {
color: "#9999FF"
}
]
}
Separator {
id: bottomLine
}
}
}