diff --git a/libraries/networking/src/ResourceCache.cpp b/libraries/networking/src/ResourceCache.cpp index 88e6b14ec7..36daf7709c 100644 --- a/libraries/networking/src/ResourceCache.cpp +++ b/libraries/networking/src/ResourceCache.cpp @@ -148,6 +148,8 @@ void ResourceCacheSharedItems::clear() { ScriptableResourceCache::ScriptableResourceCache(QSharedPointer resourceCache) { _resourceCache = resourceCache; + connect(&(*_resourceCache), &ResourceCache::dirty, + this, &ScriptableResourceCache::dirty, Qt::DirectConnection); } QVariantList ScriptableResourceCache::getResourceList() { diff --git a/libraries/networking/src/ResourceCache.h b/libraries/networking/src/ResourceCache.h index e1f3098658..8026acb265 100644 --- a/libraries/networking/src/ResourceCache.h +++ b/libraries/networking/src/ResourceCache.h @@ -200,12 +200,15 @@ class ResourceCache : public QObject { Q_PROPERTY(size_t sizeTotal READ getSizeTotalResources NOTIFY dirty) Q_PROPERTY(size_t sizeCached READ getSizeCachedResources NOTIFY dirty) + Q_PROPERTY(size_t numLoading READ getNumLoadingResources NOTIFY dirty) + public: size_t getNumTotalResources() const { return _numTotalResources; } size_t getSizeTotalResources() const { return _totalResourcesSize; } size_t getNumCachedResources() const { return _numUnusedResources; } size_t getSizeCachedResources() const { return _unusedResourcesSize; } + size_t getSizeCachedResources() const { return _unusedResourcesSize; } Q_INVOKABLE QVariantList getResourceList(); diff --git a/libraries/render/src/render/EngineStats.cpp b/libraries/render/src/render/EngineStats.cpp index ae1467ac0f..9f45f7e559 100644 --- a/libraries/render/src/render/EngineStats.cpp +++ b/libraries/render/src/render/EngineStats.cpp @@ -63,4 +63,5 @@ void EngineStats::run(const RenderContextPointer& renderContext) { config->frameSetPipelineCount = _gpuStats._PSNumSetPipelines; config->frameSetInputFormatCount = _gpuStats._ISNumFormatChanges; + config->emitDirty(); } diff --git a/libraries/render/src/render/EngineStats.h b/libraries/render/src/render/EngineStats.h index 3ccbd40715..9150e78f82 100644 --- a/libraries/render/src/render/EngineStats.h +++ b/libraries/render/src/render/EngineStats.h @@ -24,42 +24,42 @@ namespace render { class EngineStatsConfig : public Job::Config{ Q_OBJECT - Q_PROPERTY(quint32 bufferCPUCount MEMBER bufferCPUCount NOTIFY dirty) - Q_PROPERTY(quint32 bufferGPUCount MEMBER bufferGPUCount NOTIFY dirty) - Q_PROPERTY(qint64 bufferCPUMemSize MEMBER bufferCPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 bufferGPUMemSize MEMBER bufferGPUMemSize NOTIFY dirty) + Q_PROPERTY(quint32 bufferCPUCount MEMBER bufferCPUCount NOTIFY newStats) + Q_PROPERTY(quint32 bufferGPUCount MEMBER bufferGPUCount NOTIFY newStats) + Q_PROPERTY(qint64 bufferCPUMemSize MEMBER bufferCPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 bufferGPUMemSize MEMBER bufferGPUMemSize NOTIFY newStats) - Q_PROPERTY(quint32 textureCPUCount MEMBER textureCPUCount NOTIFY dirty) - Q_PROPERTY(quint32 textureGPUCount MEMBER textureGPUCount NOTIFY dirty) - Q_PROPERTY(quint32 textureResidentGPUCount MEMBER textureResidentGPUCount NOTIFY dirty) - Q_PROPERTY(quint32 textureFramebufferGPUCount MEMBER textureFramebufferGPUCount NOTIFY dirty) - Q_PROPERTY(quint32 textureResourceGPUCount MEMBER textureResourceGPUCount NOTIFY dirty) - Q_PROPERTY(quint32 textureExternalGPUCount MEMBER textureExternalGPUCount NOTIFY dirty) + Q_PROPERTY(quint32 textureCPUCount MEMBER textureCPUCount NOTIFY newStats) + Q_PROPERTY(quint32 textureGPUCount MEMBER textureGPUCount NOTIFY newStats) + Q_PROPERTY(quint32 textureResidentGPUCount MEMBER textureResidentGPUCount NOTIFY newStats) + Q_PROPERTY(quint32 textureFramebufferGPUCount MEMBER textureFramebufferGPUCount NOTIFY newStats) + Q_PROPERTY(quint32 textureResourceGPUCount MEMBER textureResourceGPUCount NOTIFY newStats) + Q_PROPERTY(quint32 textureExternalGPUCount MEMBER textureExternalGPUCount NOTIFY newStats) - Q_PROPERTY(qint64 textureCPUMemSize MEMBER textureCPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 textureGPUMemSize MEMBER textureGPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 textureResidentGPUMemSize MEMBER textureResidentGPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 textureFramebufferGPUMemSize MEMBER textureFramebufferGPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 textureResourceGPUMemSize MEMBER textureResourceGPUMemSize NOTIFY dirty) - Q_PROPERTY(qint64 textureExternalGPUMemSize MEMBER textureExternalGPUMemSize NOTIFY dirty) + Q_PROPERTY(qint64 textureCPUMemSize MEMBER textureCPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 textureGPUMemSize MEMBER textureGPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 textureResidentGPUMemSize MEMBER textureResidentGPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 textureFramebufferGPUMemSize MEMBER textureFramebufferGPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 textureResourceGPUMemSize MEMBER textureResourceGPUMemSize NOTIFY newStats) + Q_PROPERTY(qint64 textureExternalGPUMemSize MEMBER textureExternalGPUMemSize NOTIFY newStats) - Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY dirty) - Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY dirty) - Q_PROPERTY(qint64 textureResourcePopulatedGPUMemSize MEMBER textureResourcePopulatedGPUMemSize NOTIFY dirty) + Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY newStats) + Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY newStats) + Q_PROPERTY(qint64 textureResourcePopulatedGPUMemSize MEMBER textureResourcePopulatedGPUMemSize NOTIFY newStats) - Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty) - Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty) - Q_PROPERTY(quint32 frameDrawcallRate MEMBER frameDrawcallRate NOTIFY dirty) + Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY newStats) + Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY newStats) + Q_PROPERTY(quint32 frameDrawcallRate MEMBER frameDrawcallRate NOTIFY newStats) - Q_PROPERTY(quint32 frameTriangleCount MEMBER frameTriangleCount NOTIFY dirty) - Q_PROPERTY(quint32 frameTriangleRate MEMBER frameTriangleRate NOTIFY dirty) + Q_PROPERTY(quint32 frameTriangleCount MEMBER frameTriangleCount NOTIFY newStats) + Q_PROPERTY(quint32 frameTriangleRate MEMBER frameTriangleRate NOTIFY newStats) - Q_PROPERTY(quint32 frameTextureCount MEMBER frameTextureCount NOTIFY dirty) - Q_PROPERTY(quint32 frameTextureRate MEMBER frameTextureRate NOTIFY dirty) - Q_PROPERTY(quint64 frameTextureMemoryUsage MEMBER frameTextureMemoryUsage NOTIFY dirty) + Q_PROPERTY(quint32 frameTextureCount MEMBER frameTextureCount NOTIFY newStats) + Q_PROPERTY(quint32 frameTextureRate MEMBER frameTextureRate NOTIFY newStats) + Q_PROPERTY(quint64 frameTextureMemoryUsage MEMBER frameTextureMemoryUsage NOTIFY newStats) - Q_PROPERTY(quint32 frameSetPipelineCount MEMBER frameSetPipelineCount NOTIFY dirty) - Q_PROPERTY(quint32 frameSetInputFormatCount MEMBER frameSetInputFormatCount NOTIFY dirty) + Q_PROPERTY(quint32 frameSetPipelineCount MEMBER frameSetPipelineCount NOTIFY newStats) + Q_PROPERTY(quint32 frameSetInputFormatCount MEMBER frameSetInputFormatCount NOTIFY newStats) public: @@ -104,10 +104,8 @@ namespace render { - void emitDirty() { emit dirty(); } + void emitDirty() { emit newStats(); } - signals: - void dirty(); }; class EngineStats { diff --git a/scripts/developer/utilities/cache/cash.js b/scripts/developer/utilities/cache/cash.js index 078cd84218..b575b481c7 100644 --- a/scripts/developer/utilities/cache/cash.js +++ b/scripts/developer/utilities/cache/cash.js @@ -49,7 +49,7 @@ function openView() { pages.clear(); } - pages.addPage('Cash', 'Cash', "../cash.qml", 300, 420, openCashWindow, closeCashWindow); + pages.addPage('Cash', 'Cash', "../cash.qml", 300, 500, openCashWindow, closeCashWindow); pages.addPage('openModelCacheInspector', 'Model Cache Inspector', "./ModelCacheInspector.qml", 300, 500); pages.addPage('openMaterialCacheInspector', 'Material Cache Inspector', "./MaterialCacheInspector.qml", 300, 500); pages.addPage('openTextureCacheInspector', 'Texture Cache Inspector', "./TextureCacheInspector.qml", 300, 500); diff --git a/scripts/developer/utilities/cache/cash.qml b/scripts/developer/utilities/cache/cash.qml index a6551f117e..572fd481cb 100644 --- a/scripts/developer/utilities/cache/cash.qml +++ b/scripts/developer/utilities/cache/cash.qml @@ -15,6 +15,7 @@ import controlsUit 1.0 as HifiControls import "../lib/prop" as Prop import "cash" +import "../lib/plotperf" Rectangle { anchors.fill: parent @@ -32,6 +33,58 @@ Rectangle { Column { id: column width: parent.width + + Prop.PropFolderPanel { + label: "Stats" + isUnfold: true + panelFrameData: Component { Column { + PlotPerf { + title: "Resources" + height: 200 + valueScale: 1 + valueUnit: "" + plots: [ + { + object: TextureCache, + prop: "numTotal", + label: "Textures", + color: "#1AC567" + }, + { + object: TextureCache, + prop: "numCached", + label: "Textures Cached", + color: "#FEC567" + }, + { + object: ModelCache, + prop: "numTotal", + label: "Models", + color: "#FED959" + }, + { + object: ModelCache, + prop: "numCached", + label: "Models Cached", + color: "#FEFE59" + }, + { + object: MaterialCache, + prop: "numTotal", + label: "Materials", + color: "#00B4EF" + }, + { + object: MaterialCache, + prop: "numCached", + label: "Materials Cached", + color: "#FFB4EF" + } + ] + } + }} + } + Prop.PropFolderPanel { label: "Cache Inspectors" isUnfold: true diff --git a/scripts/developer/utilities/cache/cash/AnimationCacheInspector.qml b/scripts/developer/utilities/cache/cash/AnimationCacheInspector.qml index 1a9fc822fa..4ded44c2b1 100644 --- a/scripts/developer/utilities/cache/cash/AnimationCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/AnimationCacheInspector.qml @@ -17,4 +17,5 @@ ResourceCacheInspector { id: root; anchors.fill: parent.fill cache: AnimationCache + cacheResourceName: "Animation" } diff --git a/scripts/developer/utilities/cache/cash/MaterialCacheInspector.qml b/scripts/developer/utilities/cache/cash/MaterialCacheInspector.qml index fcdd0cbed0..160c47c946 100644 --- a/scripts/developer/utilities/cache/cash/MaterialCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/MaterialCacheInspector.qml @@ -17,4 +17,5 @@ ResourceCacheInspector { id: root; anchors.fill: parent.fill cache: MaterialCache + cacheResourceName: "Material" } diff --git a/scripts/developer/utilities/cache/cash/ModelCacheInspector.qml b/scripts/developer/utilities/cache/cash/ModelCacheInspector.qml index 10615b2632..017942dfc9 100644 --- a/scripts/developer/utilities/cache/cash/ModelCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/ModelCacheInspector.qml @@ -17,4 +17,5 @@ ResourceCacheInspector { id: root; anchors.fill: parent.fill cache: ModelCache + cacheResourceName: "Model" } diff --git a/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml b/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml index a6b4c1df5d..a8eeee2d27 100644 --- a/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/ResourceCacheInspector.qml @@ -17,41 +17,104 @@ Item { id: root; anchors.fill: parent.fill property var cache: {} + property string cacheResourceName: "" function fromScript(message) { switch (message.method) { - case "setJSON": - // jsonText.items = message.params.items; - break; - case "setItemList": - //console.log(message.params.items) - resouceItemsModel.resetItemList(message.params.items) - break; case "resetItemList": - resetItemList() + resetItemListFromCache() break; } } Component.onCompleted: { - // if (cache !== undefined) { - resetItemList(); - // } + resetItemListFromCache(); } - function resetItemList() { - var theList = cache.getResourceList(); - resouceItemsModel.resetItemList(theList) + function fetchItemsList() { + var theList; + if (cache !== undefined) { + theList = cache.getResourceList(); + } else { + theList = [{"name": "ResourceCacheInspector.cache is undefined"}]; + } + return theList; } + function resetItemListFromCache() { + resourceItemsModel.resetItemList(fetchItemsList()) + } + function updateItemListFromCache() { + resourceItemsModel.updateItemList(fetchItemsList()) + } + + Column { + id: header + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + + /*Prop.PropButton { + anchors.left: parent.left + id: refresh + text: "Refresh" + onClicked: { + resetItemListFromCache() + } + }*/ + Item { + anchors.left: parent.left + anchors.right: parent.right + + Prop.PropScalar { + id: totalCount + anchors.left: parent.left + anchors.right: parent.horizontalCenter + label: "Count" + object: root.cache + property: "numTotal" + integral: true + readOnly: true + onSourceValueVarChanged: { console.log( root.cacheResourceName + " NumResource Value Changed!!!!") ;updateItemListFromCache() } + } + Prop.PropScalar { + id: cachedCount + anchors.left: parent.horizontalCenter + anchors.right: parent.right + label: "Cached" + object: root.cache + property: "numCached" + integral: true + readOnly: true + onSourceValueVarChanged: { console.log( root.cacheResourceName + " NumResource Value Changed!!!!") ;updateItemListFromCache() } + } + height: totalCount.height + } + } + + ListModel { - id: resouceItemsModel + id: resourceItemsModel + function packItemEntry(item) { + var some_uri = Qt.resolvedUrl(item) + + return { "name": item, "url": some_uri} + } + function resetItemList(itemList) { - resouceItemsModel.clear() + resourceItemsModel.clear() for (var i in itemList) { - //resouceItemsModel.append({ "name": itemList[i]}) - resouceItemsModel.append({ "name": itemList[i].toString()}) + resourceItemsModel.append(packItemEntry(itemList[i])) + } + } + + function updateItemList(itemList) { + resourceItemsModel.clear() + for (var i in itemList) { + resourceItemsModel.append(packItemEntry(itemList[i])) } } } @@ -60,53 +123,22 @@ Item { id: resouceItemDelegate Row { id: itemRow - Prop.PropLabel { - text: model.name + Prop.PropText { + text: model.index + width: 30 } + Prop.PropSplitter { + size:8 + } + Prop.PropLabel { + text: JSON.stringify(model.url) + } + /* Prop.PropLabel { + text: model.url + }*/ } } - - Item { - id: header - - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - - - Prop.PropButton { - - anchors.left: parent.left - id: refresh - text: "Refresh" - onClicked: { - resetItemList() - } - } - - Prop.PropScalar { - id: totalCount - anchors.right: parent.right - label: "Count" - sourceValueVar: resouceItemsModel.count - integral: true - readOnly: true - } - - Prop.PropScalar { - id: totalCount - anchors.right: parent.right - label: "Count" - sourceValueVar: resouceItemsModel.count - integral: true - readOnly: true - } - - height: refresh.height - } - - ScrollView { anchors.top: header.bottom anchors.bottom: parent.bottom @@ -115,7 +147,7 @@ Item { clip: true ListView { id: listView - model: resouceItemsModel + model: resourceItemsModel delegate: resouceItemDelegate } } diff --git a/scripts/developer/utilities/cache/cash/SoundCacheInspector.qml b/scripts/developer/utilities/cache/cash/SoundCacheInspector.qml index 2aef4efefd..26b043469e 100644 --- a/scripts/developer/utilities/cache/cash/SoundCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/SoundCacheInspector.qml @@ -17,4 +17,5 @@ ResourceCacheInspector { id: root; anchors.fill: parent.fill cache: SoundCache + cacheResourceName: "Sound" } diff --git a/scripts/developer/utilities/cache/cash/TextureCacheInspector.qml b/scripts/developer/utilities/cache/cash/TextureCacheInspector.qml index a136ce6c47..9bfd663a4e 100644 --- a/scripts/developer/utilities/cache/cash/TextureCacheInspector.qml +++ b/scripts/developer/utilities/cache/cash/TextureCacheInspector.qml @@ -17,4 +17,5 @@ ResourceCacheInspector { id: root; anchors.fill: parent.fill cache: TextureCache + cacheResourceName: "Texture" } diff --git a/scripts/developer/utilities/lib/prop/PropItem.qml b/scripts/developer/utilities/lib/prop/PropItem.qml index 6d2f4c11ad..fe2364b59a 100644 --- a/scripts/developer/utilities/lib/prop/PropItem.qml +++ b/scripts/developer/utilities/lib/prop/PropItem.qml @@ -24,11 +24,11 @@ Item { // By default, these just go get or set the value from the object[property] // function defaultGet() { var v = root.object[root.property]; return v; } + // function defaultGet() { return root.object[root.property]; } function defaultSet(value) { root.object[root.property] = value; } - // function defaultSetReadOnly(value) { log ( "read only " + property + ", NOT setting to " + value); } - // function defaultSetReadOnly(value) {} - // property var valueVarSetter: (root.readOnly ? defaultSetReadOnly : defaultSet) - property var valueVarSetter: defaultSet + function defaultSetReadOnly(value) {} + + property var valueVarSetter: (readOnly ? defaultSetReadOnly : defaultSet) property var valueVarGetter: defaultGet // PropItem is stretching horizontally accross its parent diff --git a/scripts/developer/utilities/lib/prop/PropScalar.qml b/scripts/developer/utilities/lib/prop/PropScalar.qml index ce89342997..3776f5c4bc 100644 --- a/scripts/developer/utilities/lib/prop/PropScalar.qml +++ b/scripts/developer/utilities/lib/prop/PropScalar.qml @@ -32,9 +32,7 @@ PropItem { property var sourceValueVar: root.valueVarGetter() function applyValueVarFromWidgets(value) { - if (!root.readOnly) { - root.valueVarSetter(value) - } + root.valueVarSetter(value) } PropLabel { @@ -58,6 +56,7 @@ PropItem { MouseArea{ id: mousearea + enabled: !root.readOnly anchors.fill: parent onDoubleClicked: { sliderControl.visible = !sliderControl.visible } }