mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-28 22:29:54 +02:00
Merge pull request #8881 from jherico/offscreen_texture_memory_stats
Report offscreen texture memory usage in stats
This commit is contained in:
commit
ee1f3ac38c
6 changed files with 26 additions and 1 deletions
|
@ -256,6 +256,11 @@ Item {
|
||||||
font.pixelSize: root.fontSize
|
font.pixelSize: root.fontSize
|
||||||
text: "GPU Buffers: " + root.gpuBuffers;
|
text: "GPU Buffers: " + root.gpuBuffers;
|
||||||
}
|
}
|
||||||
|
Text {
|
||||||
|
color: root.fontColor;
|
||||||
|
font.pixelSize: root.fontSize
|
||||||
|
text: "QML Texture Memory: " + root.qmlTextureMemory + " MB";
|
||||||
|
}
|
||||||
Text {
|
Text {
|
||||||
color: root.fontColor;
|
color: root.fontColor;
|
||||||
font.pixelSize: root.fontSize
|
font.pixelSize: root.fontSize
|
||||||
|
|
|
@ -287,6 +287,7 @@ void Stats::updateStats(bool force) {
|
||||||
|
|
||||||
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
||||||
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());
|
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());
|
||||||
|
STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory()));
|
||||||
|
|
||||||
// Incoming packets
|
// Incoming packets
|
||||||
QLocale locale(QLocale::English);
|
QLocale locale(QLocale::English);
|
||||||
|
|
|
@ -89,6 +89,7 @@ class Stats : public QQuickItem {
|
||||||
STATS_PROPERTY(int, localLeaves, 0)
|
STATS_PROPERTY(int, localLeaves, 0)
|
||||||
STATS_PROPERTY(int, gpuBuffers, 0)
|
STATS_PROPERTY(int, gpuBuffers, 0)
|
||||||
STATS_PROPERTY(int, gpuTextures, 0)
|
STATS_PROPERTY(int, gpuTextures, 0)
|
||||||
|
STATS_PROPERTY(int, qmlTextureMemory, 0)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Stats* getInstance();
|
static Stats* getInstance();
|
||||||
|
@ -176,6 +177,7 @@ signals:
|
||||||
void timingStatsChanged();
|
void timingStatsChanged();
|
||||||
void gpuBuffersChanged();
|
void gpuBuffersChanged();
|
||||||
void gpuTexturesChanged();
|
void gpuTexturesChanged();
|
||||||
|
void qmlTextureMemoryChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _recentMaxPackets{ 0 } ; // recent max incoming voxel packets to process
|
int _recentMaxPackets{ 0 } ; // recent max incoming voxel packets to process
|
||||||
|
|
|
@ -108,14 +108,23 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t getUsedTextureMemory() { return _totalTextureUsage; }
|
||||||
private:
|
private:
|
||||||
static void waitOnFence(GLsync fence) {
|
static void waitOnFence(GLsync fence) {
|
||||||
glWaitSync(fence, 0, GL_TIMEOUT_IGNORED);
|
glWaitSync(fence, 0, GL_TIMEOUT_IGNORED);
|
||||||
glDeleteSync(fence);
|
glDeleteSync(fence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t getMemoryForSize(const uvec2& size) {
|
||||||
|
// Base size + mips
|
||||||
|
return static_cast<size_t>(((size.x * size.y) << 2) * 1.33f);
|
||||||
|
}
|
||||||
|
|
||||||
void destroyTexture(GLuint texture) {
|
void destroyTexture(GLuint texture) {
|
||||||
--_allTextureCount;
|
--_allTextureCount;
|
||||||
|
auto size = _textureSizes[texture];
|
||||||
|
assert(getMemoryForSize(size) < _totalTextureUsage);
|
||||||
|
_totalTextureUsage -= getMemoryForSize(size);
|
||||||
_textureSizes.erase(texture);
|
_textureSizes.erase(texture);
|
||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, &texture);
|
||||||
}
|
}
|
||||||
|
@ -131,6 +140,7 @@ private:
|
||||||
glGenTextures(1, &newTexture);
|
glGenTextures(1, &newTexture);
|
||||||
++_allTextureCount;
|
++_allTextureCount;
|
||||||
_textureSizes[newTexture] = size;
|
_textureSizes[newTexture] = size;
|
||||||
|
_totalTextureUsage += getMemoryForSize(size);
|
||||||
glBindTexture(GL_TEXTURE_2D, newTexture);
|
glBindTexture(GL_TEXTURE_2D, newTexture);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
@ -177,6 +187,7 @@ private:
|
||||||
Mutex _mutex;
|
Mutex _mutex;
|
||||||
std::list<OffscreenQmlSurface::TextureAndFence> _returnedTextures;
|
std::list<OffscreenQmlSurface::TextureAndFence> _returnedTextures;
|
||||||
uint64_t _lastReport { 0 };
|
uint64_t _lastReport { 0 };
|
||||||
|
size_t _totalTextureUsage { 0 };
|
||||||
} offscreenTextures;
|
} offscreenTextures;
|
||||||
|
|
||||||
class UrlHandler : public QObject {
|
class UrlHandler : public QObject {
|
||||||
|
@ -217,6 +228,10 @@ private:
|
||||||
friend class OffscreenQmlSurface;
|
friend class OffscreenQmlSurface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
size_t OffscreenQmlSurface::getUsedTextureMemory() {
|
||||||
|
return offscreenTextures.getUsedTextureMemory();
|
||||||
|
}
|
||||||
|
|
||||||
class QmlNetworkAccessManager : public NetworkAccessManager {
|
class QmlNetworkAccessManager : public NetworkAccessManager {
|
||||||
public:
|
public:
|
||||||
friend class QmlNetworkAccessManagerFactory;
|
friend class QmlNetworkAccessManagerFactory;
|
||||||
|
|
|
@ -89,6 +89,7 @@ public:
|
||||||
bool fetchTexture(TextureAndFence& textureAndFence);
|
bool fetchTexture(TextureAndFence& textureAndFence);
|
||||||
|
|
||||||
static std::function<void(uint32_t, void*)> getDiscardLambda();
|
static std::function<void(uint32_t, void*)> getDiscardLambda();
|
||||||
|
static size_t getUsedTextureMemory();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void focusObjectChanged(QObject* newFocus);
|
void focusObjectChanged(QObject* newFocus);
|
||||||
|
|
|
@ -74,7 +74,8 @@ ENTITY_SPAWNER = function (properties) {
|
||||||
for (; n > 0; --n) {
|
for (; n > 0; --n) {
|
||||||
entities.push(makeEntity({
|
entities.push(makeEntity({
|
||||||
type: "Web",
|
type: "Web",
|
||||||
sourceUrl: "https://www.reddit.com/r/random/",
|
//sourceUrl: "https://www.reddit.com/r/random/",
|
||||||
|
sourceUrl: "https://en.wikipedia.org/wiki/Special:Random",
|
||||||
name: TEST_ENTITY_NAME,
|
name: TEST_ENTITY_NAME,
|
||||||
position: randomPositionXZ(center, RADIUS),
|
position: randomPositionXZ(center, RADIUS),
|
||||||
rotation: MyAvatar.orientation,
|
rotation: MyAvatar.orientation,
|
||||||
|
|
Loading…
Reference in a new issue