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

Per tile stats #5188

merged 20 commits into from
May 3, 2017

Conversation

rahwang
Copy link
Contributor

@rahwang rahwang commented Apr 7, 2017

For #5156. Not ready yet! Is this on the right track, @lilleyse ? Seems wrong to just be using the tileset._statistics for draw command, texture memory and vertex memory numbers, but I'm not sure how to compute these per tile.

@lilleyse
Copy link
Contributor

lilleyse commented Apr 7, 2017

Yes this is on the right track. I didn't look too deeply at the code yet, but just a few things:

  • You can access the memory stats from the tile's content
  • Number of draw commands is tougher and not as easily accessible per-tile. PointCloud3DTileContent is always 1, Batched and Instanced can probably be determined in their update functions by looking at the number of commands before and after. Either way, add a commandsLength getter to each Content. I haven't fully thought this case through...
  • Now that triangles length is reported, also add that to tile info (add points length as well)
  • Use the new depth-test off feature so labels aren't clipped Billboard depth fail #5166
  • Use a smaller font, or adjust based on the number of properties showing
  • Maybe this is already on your radar, but the ability to only show the label for the tile that is hovered over, similar to the Picking Sandcastle. A checkbox in the tile info tab can control which mode is being used.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 20, 2017

Hey @lilleyse , I redid my changes to reflect Hannah's recent refactoring of the inspector and addressed all the things you mentioned above (except the picking, which I'm working on). How should the tile info stats changes I've made so far be tested? Just follow the template of the debugShowGeometricError tests in the Cesium3DTilesetSpec?

@lilleyse
Copy link
Contributor

Those tests can be renamed to show tile info labels with _____. In at least one of them all the debug options should be set to true.

Then a separate test can check how the labels change when new debug settings are toggled. Setting viewRootOnly at the beginning will keep the code more concise for that test.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 26, 2017

Ah, as per discussion with @lilleyse , going to refactor the debug label assembly to happen in the inspector view model instead of in the tileset.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 27, 2017

Ah, sorry about that @lilleyse -- I still had the original labels drawing for debugging purposes. Here is my properly broken code. XD

@lilleyse
Copy link
Contributor

lilleyse commented Apr 27, 2017

The problem is that the update is pushing commands after the render loop, and so they just get ignored. The same would happen with preRender. Maybe this means storing the label collection in the view model is bad design.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 27, 2017

Ah, thanks for explaining, @lilleyse . So shall I just revert to the previous version?

@lilleyse
Copy link
Contributor

Yeah, that's best for now.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 27, 2017

Ready for another look @lilleyse

@lilleyse
Copy link
Contributor

Just to summarize the PR breakdown...

This one should be ready soon. Then open a 2nd PR to fix picking for tilesets that don't use a batch table. And then a 3rd PR to add this feature:

the ability to only show the label for the tile that is hovered over, similar to the Picking Sandcastle. A checkbox in the tile info tab can control which mode is being used.

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

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

Looks great! Some of these new options will be super helpful.

applyDebugSettings(this, tileset, frameState);
this._content.update(tileset, frameState);
this._transformDirty = false;
this._content.commandsLength = frameState.commandList.length - initCommandLength;
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be simpler if Cesium3DTile holds onto this._commandsLength instead of the contents.

*/
this.debugShowNumberOfPoints = defaultValue(options.debugShowNumberOfPoints, false);


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.

text: tile.geometricError.toString(),
position: position

var labelString = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Style: Use single quotes instead double quotes throughout.

position: position

var labelString = "";
var attribCounter = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Style: avoid abbreviations.

var attribCounter = 0;

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

Choose a reason for hiding this comment

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

toString() for these isn't needed.

*/
this.tileInfoVisible = false;


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.

* @type {Boolean}
* @default false
*/
this.textureMemory = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Place the showGeometricError stuff closer to these.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it would be better to arrange these in the order they are shown in the UI.

get : function() {
return numberOfTriangles();
},
set : function(val) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Change all val to value.

expect(tileset._tileInfoLabels.length).toEqual(5);

var root = tileset._root;
expect(tileset._tileInfoLabels._labels[0].text).toEqual('Geometric error: ' + root.geometricError.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove uses of toString() throughout this file.

'Points: ' + content.pointsLength.toString() + '\n' +
'Triangles: ' + content.trianglesLength.toString() + '\n' +
'Texture Memory: ' + content.textureMemorySizeInBytes.toString() + '\n' +
'Vertex Memory: ' + content.vertexMemorySizeInBytes.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

To avoid the large indentation, create a var for the string.

@lilleyse
Copy link
Contributor

Fixes #5029 too
I forgot that issue existed...

@rahwang can you also add Number of features to this PR?

@rahwang
Copy link
Contributor Author

rahwang commented Apr 28, 2017

Sure! I'll do that now.

@rahwang
Copy link
Contributor Author

rahwang commented Apr 28, 2017

Ok @lilleyse, I added feature counts and updated according to your review. Ready for another look.

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.

// 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();

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.

@@ -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.

this.freezeFrame = false;
this.textureMemory = false;

var vertexMemory = knockout.observable();
Copy link
Contributor

Choose a reason for hiding this comment

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

I missed this from before. Can you rename all the new properties to showTextureMemory to follow the showGeometricError convention?

Copy link
Contributor Author

@rahwang rahwang Apr 28, 2017

Choose a reason for hiding this comment

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

You didn't miss it! I accidentally reverted it along with the labels-to-view-model commits. XD

@@ -681,7 +817,13 @@ define([
'showContentBoundingVolumes',
'showRequestVolumes',
'showGeometricError',
Copy link
Contributor

Choose a reason for hiding this comment

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

Move showGeometricError below near the others.

'vertexMemory',
'numberOfPoints',
'numberOfTriangles',
'numberOfCommands'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing numberOfFeatures.

@@ -681,7 +817,13 @@ define([
'showContentBoundingVolumes',
'showRequestVolumes',
'showGeometricError',
'freezeFrame'];
'freezeFrame',
'onlyPickedTileInfo',
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove

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?

@rahwang
Copy link
Contributor Author

rahwang commented Apr 28, 2017

Thanks for the review @lilleyse ! Comments addressed.

@@ -2221,7 +2221,7 @@ define([
Cesium3DTileset.prototype.destroy = function() {
// Destroy debug labels
if (defined(this._tileInfoLabels)) {
this._tileInfoLabels.destroy();
this._tileInfoLabels = 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.

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

@@ -196,17 +196,27 @@ define([
errorBox.setAttribute('data-bind', 'text: editorError');
stylePanelContents.appendChild(errorBox);

tileInfoPanelContents.appendChild(makeCheckbox('showGeometricError', 'Geometric Error'));
tileInfoPanelContents.appendChild(makeCheckbox('showNumberOfCommands', 'Number of Commands'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to Number Of Commands

'dynamicScreenSpaceErrorDensity', 'dynamicScreenSpaceErrorDensitySliderValue', 'dynamicScreenSpaceErrorFactor', 'pickActive'];
'showContentBoundingVolumes', 'showRequestVolumes', 'freezeFrame', 'maximumScreenSpaceError', 'dynamicScreenSpaceErrorDensity',
'dynamicScreenSpaceErrorDensitySliderValue', 'dynamicScreenSpaceErrorFactor', 'pickActive', 'showGeometricError',
'showTextureMemory', 'showVertexMemory', 'showNumberOfCommands', 'showNumberOfPoints', 'showNumberOfTriangles', 'showNumberOfFeatures'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Also reorder them here to match.

* @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?

@lilleyse
Copy link
Contributor

lilleyse commented May 1, 2017

Ok I think these are the last points, almost ready!

@rahwang
Copy link
Contributor Author

rahwang commented May 1, 2017

Done, @lilleyse!

@@ -121,7 +121,13 @@ define([
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
* @param {Boolean} [options.debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
* @param {Boolean} [options.debugShowViewerRequestVolume=false] For debugging only. When true, renders the viewer request volume for each tile.
* @param {Boolean} [options.debugShowGeometricError=false] For debugging only. When true, draws labels to indicate the geometric error of each tile
* @param {Boolean} [options.debugShowGeometricError=false] For debugging only. When true, draws labels to indicate the geometric error of each tile.
Copy link
Contributor

Choose a reason for hiding this comment

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

These are probably too fine-grained. Consider:

  • Combine debugShowNumberOfCommands, debugShowNumberOfPoints, debugShowNumberOfTriangles, and debugShowNumberOfFeatures into debugShowRenderingStatistics
  • Combine debugShowTextureMemoryUsage and debugShowVertexMemoryUsage into debugShowMemoryUsage

This will be a lot less code and is inline with how I expect folks will want to use these hopefully without cluttering the display.

If clutter is a problem, try a smaller font that is still readable or a slightly less coarse-grained separation for the rendering stats.

/**
* 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"

@lilleyse
Copy link
Contributor

lilleyse commented May 2, 2017

If going with the combined approach, it would make sense to hide number of triangles and number of points when those values are 0.

@rahwang
Copy link
Contributor Author

rahwang commented May 2, 2017

Thanks for the suggestions, @pjcozzi and @lilleyse. Fixed!

}

labelString += '\nFeatures: ' + tile.content.featuresLength;
attributes += 4;
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 be ++ now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops! Fixed @lilleyse

@lilleyse lilleyse merged commit fca40cb into CesiumGS:3d-tiles May 3, 2017
@lilleyse
Copy link
Contributor

lilleyse commented May 3, 2017

Nice work @rahwang.

@@ -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

@@ -1838,10 +1862,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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants