Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per tile stats #5188

Merged
merged 20 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ define([
}
this._viewerRequestVolume = viewerRequestVolume;

this._commandsLength = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a readonly property getter.

Up to you, but this and the other "length" properties for rendering debugging output could be prefixed like _debugCommandsLength


/**
* The error, in meters, introduced if this tile is rendered and its children are not.
* This is used to compute Screen-Space Error (SSE), i.e., the error measured in pixels.
Expand Down Expand Up @@ -851,9 +853,11 @@ define([
* @private
*/
Cesium3DTile.prototype.update = function(tileset, frameState) {
var initCommandLength = frameState.commandList.length;
applyDebugSettings(this, tileset, frameState);
this._content.update(tileset, frameState);
this._transformDirty = false;
this._commandsLength = frameState.commandList.length - initCommandLength;
};

var scratchCommandList = [];
Expand Down
133 changes: 121 additions & 12 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,73 @@ define([
* @default false
*/
this.debugShowGeometricError = defaultValue(options.debugShowGeometricError, false);
this._geometricErrorLabels = undefined;
this._tileInfoLabels = undefined;

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the number of commands used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"commands used" -> "commands executed for this tile"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"each tile"

* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowNumberOfCommands = defaultValue(options.debugShowNumberOfCommands, false);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the number of points in each tile.
* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowNumberOfPoints = defaultValue(options.debugShowNumberOfPoints, false);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the number of triangles in each tile.
* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowNumberOfTriangles = defaultValue(options.debugShowNumberOfTriangles, false);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the number of features in each tile.
* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowNumberOfFeatures = defaultValue(options.debugShowNumberOfFeatures, false);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the texture memory usage.
* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowTextureMemoryUsage = defaultValue(options.debugShowTextureMemoryUsage, false);

/**
* This property is for debugging only; it is not optimized for production use.
* <p>
* When true, draws labels to indicate the vertex memory usage.
* </p>
*
* @type {Boolean}
* @default false
*/
this.debugShowVertexMemoryUsage = defaultValue(options.debugShowVertexMemoryUsage, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add these debugShow options to the doc in the constructor?


/**
* The event fired to indicate progress of loading new tiles. This event is fired when a new tile
Expand Down Expand Up @@ -1838,10 +1904,10 @@ define([

var scratchCartesian2 = new Cartesian3();

function updateGeometricErrorLabels(tileset, frameState) {
function updateTileInfoLabels(tileset, frameState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TileInfo is very generic; we try to avoid names like "info." Perhaps updateTileDebugLabels.

Same for the _tileInfoLabels naming.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tileInfoVisible, etc.

var selectedTiles = tileset._selectedTiles;
var length = selectedTiles.length;
tileset._geometricErrorLabels.removeAll();
tileset._tileInfoLabels.removeAll();
for (var i = 0; i < length; ++i) {
var tile = selectedTiles[i];
var boundingVolume = tile._boundingVolume.boundingVolume;
Expand All @@ -1858,12 +1924,48 @@ define([
normal = Cartesian3.multiplyByScalar(normal, 0.75 * radius, scratchCartesian2);
position = Cartesian3.add(normal, boundingVolume.center, scratchCartesian2);
}
tileset._geometricErrorLabels.add({
text: tile.geometricError.toString(),
position: position

var labelString = '';
var attributes = 0;

if (tileset.debugShowGeometricError) {
labelString += "\nGeometric error: " + tile.geometricError;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use single-quotes for these.

attributes++;
}
if (tileset.debugShowNumberOfCommands) {
labelString += "\nCommands: " + tile._commandsLength;
attributes++;
}
if (tileset.debugShowNumberOfPoints) {
labelString += "\nPoints: " + tile.content.pointsLength;
attributes++;
}
if (tileset.debugShowNumberOfTriangles) {
labelString += "\nTriangles: " + tile.content.trianglesLength;
attributes++;
}
if (tileset.debugShowNumberOfFeatures) {
labelString += "\nFeatures: " + tile.content.featuresLength;
attributes++;
}
if (tileset.debugShowTextureMemoryUsage) {
labelString += "\nTexture Memory: " + tile.content.textureMemorySizeInBytes;
attributes++;
}
if (tileset.debugShowVertexMemoryUsage) {
labelString += "\nVertex Memory: " + tile.content.vertexMemorySizeInBytes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late suggestion, but can this and texture memory usage show it in megabytes like in the stats panel in the inspector?

attributes++;
}

tileset._tileInfoLabels.add({
text : labelString.substring(1),
position : position,
font : (19-attributes) + 'px sans-serif',
showBackground : true,
disableDepthTestDistance : Number.POSITIVE_INFINITY
});
}
tileset._geometricErrorLabels.update(frameState);
tileset._tileInfoLabels.update(frameState);
}

var stencilClearCommand = new ClearCommand({
Expand Down Expand Up @@ -1948,13 +2050,15 @@ define([
// Number of commands added by each update above
tileset._statistics.numberOfCommands = (commandList.length - numberOfInitialCommands);

if (tileset.debugShowGeometricError) {
if (!defined(tileset._geometricErrorLabels)) {
tileset._geometricErrorLabels = new LabelCollection();
if (tileset.debugShowGeometricError || tileset.debugShowNumberOfCommands || tileset.debugShowTextureMemoryUsage ||
tileset.debugShowVertexMemoryUsage || tileset.debugShowNumberOfPoints || tileset.debugShowNumberOfTriangles ||
tileset.debugShowNumberOfFeatures) {
if (!defined(tileset._tileInfoLabels)) {
tileset._tileInfoLabels = new LabelCollection();
}
updateGeometricErrorLabels(tileset, frameState);
updateTileInfoLabels(tileset, frameState);
} else {
tileset._geometricErrorLabels = tileset._geometricErrorLabels && tileset._geometricErrorLabels.destroy();
tileset._tileInfoLabels = tileset._tileInfoLabels && tileset._tileInfoLabels.destroy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also destroy the labels in destroy.

}
}

Expand Down Expand Up @@ -2115,6 +2219,11 @@ define([
* @see Cesium3DTileset#isDestroyed
*/
Cesium3DTileset.prototype.destroy = function() {
// Destroy debug labels
if (defined(this._tileInfoLabels)) {
this._tileInfoLabels.destroy();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The destroy convention usually looks like:

tileset._tileInfoLabels = tileset._tileInfoLabels && tileset._tileInfoLabels.destroy();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the if (defined(this._tileInfoLabels)) { wrapper, it is unnecessary now.


// Traverse the tree and destroy all tiles
if (defined(this._root)) {
var stack = scratchStack;
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Instanced3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ define([
this.featurePropertiesDirty = false;

this._features = undefined;

initialize(this, arrayBuffer, byteOffset);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

}

defineProperties(Instanced3DModel3DTileContent.prototype, {
Expand Down
5 changes: 0 additions & 5 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3356,11 +3356,6 @@ define([

function triangleCountFromPrimitiveIndices(primitive, indicesCount) {
switch (primitive.mode) {
case PrimitiveType.POINTS:
case PrimitiveType.LINES:
case PrimitiveType.LINE_LOOP:
case PrimitiveType.LINE_STRIP:
return 0;
case PrimitiveType.TRIANGLES:
return (indicesCount / 3);
case PrimitiveType.TRIANGLE_STRIP:
Expand Down
12 changes: 11 additions & 1 deletion Source/Widgets/Cesium3DTilesInspector/Cesium3DTilesInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ define([
var updatePanelContents = document.createElement('div');
var loggingPanelContents = document.createElement('div');
var stylePanelContents = document.createElement('div');
var tileInfoPanelContents = document.createElement('div');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also place this before stylePanel for consistency.


var properties = document.createElement('div');
properties.className = 'field-group';
Expand All @@ -152,7 +153,6 @@ define([
displayPanelContents.appendChild(makeCheckbox('showBoundingVolumes', 'Bounding Volumes'));
displayPanelContents.appendChild(makeCheckbox('showContentBoundingVolumes', 'Content Volumes'));
displayPanelContents.appendChild(makeCheckbox('showRequestVolumes', 'Request Volumes'));
displayPanelContents.appendChild(makeCheckbox('showGeometricError', 'Geometric Error'));

updatePanelContents.appendChild(makeCheckbox('freezeFrame', 'Freeze Frame'));
updatePanelContents.appendChild(makeCheckbox('dynamicScreenSpaceError', 'Dynamic Screen Space Error'));
Expand Down Expand Up @@ -196,17 +196,27 @@ define([
errorBox.setAttribute('data-bind', 'text: editorError');
stylePanelContents.appendChild(errorBox);

tileInfoPanelContents.appendChild(makeCheckbox('showGeometricError', 'Geometric Error'));
tileInfoPanelContents.appendChild(makeCheckbox('numberOfCommands', 'Number Of Commands'));
tileInfoPanelContents.appendChild(makeCheckbox('numberOfPoints', 'Number Of Points'));
tileInfoPanelContents.appendChild(makeCheckbox('numberOfTriangles', 'Number Of Triangles'));
tileInfoPanelContents.appendChild(makeCheckbox('numberOfFeatures', 'Number Of Features'));
tileInfoPanelContents.appendChild(makeCheckbox('textureMemory', 'Texture Memory Usage'));
tileInfoPanelContents.appendChild(makeCheckbox('vertexMemory', 'Vertex Memory Usage'));

var tilesetPanel = makeSection('Tileset', 'tilesetVisible', 'toggleTileset', tilesetPanelContents);
var displayPanel = makeSection('Display', 'displayVisible', 'toggleDisplay', displayPanelContents);
var updatePanel = makeSection('Update', 'updateVisible', 'toggleUpdate', updatePanelContents);
var loggingPanel = makeSection('Logging', 'loggingVisible', 'toggleLogging', loggingPanelContents);
var tileInfoPanel = makeSection('Tile Info', 'tileInfoVisible', 'toggleTileInfo', tileInfoPanelContents);
var stylePanel = makeSection('Style', 'styleVisible', 'toggleStyle', stylePanelContents);

// first add and bind all the toggleable panels
element.appendChild(tilesetPanel);
element.appendChild(displayPanel);
element.appendChild(updatePanel);
element.appendChild(loggingPanel);
element.appendChild(tileInfoPanel);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visually, I think the tile info panel belongs after the logging panel.

element.appendChild(stylePanel);

knockout.applyBindings(viewModel, element);
Expand Down
Loading