Add more GPU stats, make stats easier to read

This commit is contained in:
Brad Davis 2016-10-22 14:38:46 -07:00
parent ee1f3ac38c
commit 62de2af944
11 changed files with 178 additions and 138 deletions

View file

@ -0,0 +1,9 @@
import QtQuick 2.3
import QtQuick.Controls 1.2
Text {
color: "white";
style: Text.Outline;
styleColor: "black";
font.pixelSize: 12;
}

View file

@ -1,6 +1,7 @@
import Hifi 1.0 as Hifi import Hifi 1.0 as Hifi
import QtQuick 2.3 import QtQuick 2.3
import QtQuick.Controls 1.2 import QtQuick.Controls 1.2
import '.'
Item { Item {
id: stats id: stats
@ -28,9 +29,7 @@ Item {
implicitWidth: row.width implicitWidth: row.width
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
readonly property int fontSize: 12 readonly property string bgColor: "#AA111111"
readonly property string fontColor: "white"
readonly property string bgColor: "#99333333"
Row { Row {
id: row id: row
@ -49,64 +48,40 @@ Item {
Column { Column {
id: generalCol id: generalCol
spacing: 4; x: 4; y: 4; spacing: 4; x: 4; y: 4;
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Servers: " + root.serverCount text: "Servers: " + root.serverCount
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Avatars: " + root.avatarCount text: "Avatars: " + root.avatarCount
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Frame Rate: " + root.framerate.toFixed(2); text: "Frame Rate: " + root.framerate.toFixed(2);
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Render Rate: " + root.renderrate.toFixed(2); text: "Render Rate: " + root.renderrate.toFixed(2);
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Present Rate: " + root.presentrate.toFixed(2); text: "Present Rate: " + root.presentrate.toFixed(2);
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Present New Rate: " + root.presentnewrate.toFixed(2); text: "Present New Rate: " + root.presentnewrate.toFixed(2);
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Present Drop Rate: " + root.presentdroprate.toFixed(2); text: "Present Drop Rate: " + root.presentdroprate.toFixed(2);
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Simrate: " + root.simrate text: "Simrate: " + root.simrate
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Avatar Simrate: " + root.avatarSimrate text: "Avatar Simrate: " + root.avatarSimrate
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Packets In/Out: " + root.packetInCount + "/" + root.packetOutCount text: "Packets In/Out: " + root.packetInCount + "/" + root.packetOutCount
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Mbps In/Out: " + root.mbpsIn.toFixed(2) + "/" + root.mbpsOut.toFixed(2) text: "Mbps In/Out: " + root.mbpsIn.toFixed(2) + "/" + root.mbpsOut.toFixed(2)
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "Asset Mbps In/Out: " + root.assetMbpsIn.toFixed(2) + "/" + root.assetMbpsOut.toFixed(2) text: "Asset Mbps In/Out: " + root.assetMbpsIn.toFixed(2) + "/" + root.assetMbpsOut.toFixed(2)
} }
@ -126,29 +101,19 @@ Item {
Column { Column {
id: pingCol id: pingCol
spacing: 4; x: 4; y: 4; spacing: 4; x: 4; y: 4;
Text { StatText {
color: root.fontColor
font.pixelSize: root.fontSize
text: "Audio ping: " + root.audioPing text: "Audio ping: " + root.audioPing
} }
Text { StatText {
color: root.fontColor
font.pixelSize: root.fontSize
text: "Avatar ping: " + root.avatarPing text: "Avatar ping: " + root.avatarPing
} }
Text { StatText {
color: root.fontColor
font.pixelSize: root.fontSize
text: "Entities avg ping: " + root.entitiesPing text: "Entities avg ping: " + root.entitiesPing
} }
Text { StatText {
color: root.fontColor
font.pixelSize: root.fontSize
text: "Asset ping: " + root.assetPing text: "Asset ping: " + root.assetPing
} }
Text { StatText {
color: root.fontColor
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Messages max ping: " + root.messagePing text: "Messages max ping: " + root.messagePing
} }
@ -167,46 +132,32 @@ Item {
Column { Column {
id: geoCol id: geoCol
spacing: 4; x: 4; y: 4; spacing: 4; x: 4; y: 4;
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Position: " + root.position.x.toFixed(1) + ", " + text: "Position: " + root.position.x.toFixed(1) + ", " +
root.position.y.toFixed(1) + ", " + root.position.z.toFixed(1) root.position.y.toFixed(1) + ", " + root.position.z.toFixed(1)
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Speed: " + root.speed.toFixed(1) text: "Speed: " + root.speed.toFixed(1)
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Yaw: " + root.yaw.toFixed(1) text: "Yaw: " + root.yaw.toFixed(1)
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Avatar Mixer In: " + root.avatarMixerInKbps + " kbps, " + text: "Avatar Mixer In: " + root.avatarMixerInKbps + " kbps, " +
root.avatarMixerInPps + "pps"; root.avatarMixerInPps + "pps";
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Avatar Mixer Out: " + root.avatarMixerOutKbps + " kbps, " + text: "Avatar Mixer Out: " + root.avatarMixerOutKbps + " kbps, " +
root.avatarMixerOutPps + "pps"; root.avatarMixerOutPps + "pps";
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Downloads: " + root.downloads + "/" + root.downloadLimit + text: "Downloads: " + root.downloads + "/" + root.downloadLimit +
", Pending: " + root.downloadsPending; ", Pending: " + root.downloadsPending;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded && root.downloadUrls.length > 0; visible: root.expanded && root.downloadUrls.length > 0;
text: "Download URLs:" text: "Download URLs:"
} }
@ -217,9 +168,7 @@ Item {
visible: root.expanded && root.downloadUrls.length > 0; visible: root.expanded && root.downloadUrls.length > 0;
model: root.downloadUrls model: root.downloadUrls
delegate: Text { delegate: StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: modelData.length > 30 text: modelData.length > 30
? modelData.substring(0, 5) + "..." + modelData.substring(modelData.length - 22) ? modelData.substring(0, 5) + "..." + modelData.substring(modelData.length - 22)
@ -240,99 +189,92 @@ Item {
Column { Column {
id: octreeCol id: octreeCol
spacing: 4; x: 4; y: 4; spacing: 4; x: 4; y: 4;
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Triangles: " + root.triangles + text: "Triangles: " + root.triangles +
" / Material Switches: " + root.materialSwitches " / Material Switches: " + root.materialSwitches
} }
Text { StatText {
color: root.fontColor; text: "GPU Textures: ";
font.pixelSize: root.fontSize
text: "GPU Textures: " + root.gpuTextures;
} }
Text { StatText {
color: root.fontColor; text: " Sparse Enabled: " + (0 == root.gpuSparseTextureEnabled ? "false" : "true");
font.pixelSize: root.fontSize
text: "GPU Buffers: " + root.gpuBuffers;
} }
Text { StatText {
color: root.fontColor; text: " Count: " + root.gpuTextures;
font.pixelSize: root.fontSize }
StatText {
text: " Sparse Count: " + root.gpuTexturesSparse;
visible: 0 != root.gpuSparseTextureEnabled;
}
StatText {
text: " Virtual Memory: " + root.gpuTextureVirtualMemory + " MB";
}
StatText {
text: " Commited Memory: " + root.gpuTextureMemory + " MB";
}
StatText {
text: " Sparse Memory: " + root.gpuTextureSparseMemory + " MB";
visible: 0 != root.gpuSparseTextureEnabled;
}
StatText {
text: "GPU Buffers: "
}
StatText {
text: " Count: " + root.gpuTextures;
}
StatText {
text: "QML Texture Memory: " + root.qmlTextureMemory + " MB"; text: "QML Texture Memory: " + root.qmlTextureMemory + " MB";
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Items rendered / considered: " + text: "Items rendered / considered: " +
root.itemRendered + " / " + root.itemConsidered; root.itemRendered + " / " + root.itemConsidered;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: " out of view: " + root.itemOutOfView + text: " out of view: " + root.itemOutOfView +
" too small: " + root.itemTooSmall; " too small: " + root.itemTooSmall;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: "Shadows rendered / considered: " + text: "Shadows rendered / considered: " +
root.shadowRendered + " / " + root.shadowConsidered; root.shadowRendered + " / " + root.shadowConsidered;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded; visible: root.expanded;
text: " out of view: " + root.shadowOutOfView + text: " out of view: " + root.shadowOutOfView +
" too small: " + root.shadowTooSmall; " too small: " + root.shadowTooSmall;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: !root.expanded visible: !root.expanded
text: "Octree Elements Server: " + root.serverElements + text: "Octree Elements Server: " + root.serverElements +
" Local: " + root.localElements; " Local: " + root.localElements;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "Octree Sending Mode: " + root.sendingMode; text: "Octree Sending Mode: " + root.sendingMode;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "Octree Packets to Process: " + root.packetStats; text: "Octree Packets to Process: " + root.packetStats;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "Octree Elements - "; text: "Octree Elements - ";
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "\tServer: " + root.serverElements + text: "\tServer: " + root.serverElements +
" Internal: " + root.serverInternal + " Internal: " + root.serverInternal +
" Leaves: " + root.serverLeaves; " Leaves: " + root.serverLeaves;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "\tLocal: " + root.localElements + text: "\tLocal: " + root.localElements +
" Internal: " + root.localInternal + " Internal: " + root.localInternal +
" Leaves: " + root.localLeaves; " Leaves: " + root.localLeaves;
} }
Text { StatText {
color: root.fontColor;
font.pixelSize: root.fontSize
visible: root.expanded visible: root.expanded
text: "LOD: " + root.lodStatus; text: "LOD: " + root.lodStatus;
} }
@ -346,12 +288,10 @@ Item {
width: perfText.width + 8 width: perfText.width + 8
height: perfText.height + 8 height: perfText.height + 8
color: root.bgColor; color: root.bgColor;
Text { StatText {
x: 4; y: 4 x: 4; y: 4
id: perfText id: perfText
color: root.fontColor
font.family: root.monospaceFont font.family: root.monospaceFont
font.pixelSize: 12
text: "------------------------------------------ Function " + text: "------------------------------------------ Function " +
"--------------------------------------- --msecs- -calls--\n" + "--------------------------------------- --msecs- -calls--\n" +
root.timingStats; root.timingStats;

View file

@ -287,7 +287,13 @@ 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(gpuTexturesSparse, (int)gpu::Context::getTextureGPUSparseCount());
STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory())); STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory()));
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUMemoryUsage()));
STAT_UPDATE(gpuTextureVirtualMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUVirtualMemoryUsage()));
STAT_UPDATE(gpuTextureSparseMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUSparseMemoryUsage()));
STAT_UPDATE(gpuSparseTextureEnabled, gpu::Texture::getEnableSparseTextures() ? 1 : 0);
// Incoming packets // Incoming packets
QLocale locale(QLocale::English); QLocale locale(QLocale::English);

View file

@ -89,7 +89,12 @@ 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, gpuTexturesSparse, 0)
STATS_PROPERTY(int, qmlTextureMemory, 0) STATS_PROPERTY(int, qmlTextureMemory, 0)
STATS_PROPERTY(int, gpuTextureMemory, 0)
STATS_PROPERTY(int, gpuTextureVirtualMemory, 0)
STATS_PROPERTY(int, gpuTextureSparseMemory, 0)
STATS_PROPERTY(int, gpuSparseTextureEnabled, 0)
public: public:
static Stats* getInstance(); static Stats* getInstance();
@ -175,9 +180,14 @@ signals:
void localInternalChanged(); void localInternalChanged();
void localLeavesChanged(); void localLeavesChanged();
void timingStatsChanged(); void timingStatsChanged();
void qmlTextureMemoryChanged();
void gpuBuffersChanged(); void gpuBuffersChanged();
void gpuTexturesChanged(); void gpuTexturesChanged();
void qmlTextureMemoryChanged(); void gpuTexturesSparseChanged();
void gpuTextureMemoryChanged();
void gpuTextureVirtualMemoryChanged();
void gpuTextureSparseMemoryChanged();
void gpuSparseTextureEnabledChanged();
private: private:
int _recentMaxPackets{ 0 } ; // recent max incoming voxel packets to process int _recentMaxPackets{ 0 } ; // recent max incoming voxel packets to process

View file

@ -205,6 +205,8 @@ GLTexture::~GLTexture() {
qWarning() << "No recycler available for texture " << _id << " possible leak"; qWarning() << "No recycler available for texture " << _id << " possible leak";
} }
} else if (_id) { } else if (_id) {
// WARNING! Sparse textures do not use this code path. See GL45BackendTexture for
// the GL45Texture destructor for doing any required work tracking GPU stats
backend->releaseTexture(_id, _size); backend->releaseTexture(_id, _size);
} }
} }
@ -275,7 +277,7 @@ void GLTexture::postTransfer() {
setSyncState(GLSyncState::Idle); setSyncState(GLSyncState::Idle);
++_transferCount; ++_transferCount;
// At this point the mip pixels have been loaded, we can notify the gpu texture to abandon it's memory // At this point the mip pixels have been loaded, we can notify the g pu texture to abandon it's memory
switch (_gpuObject.getType()) { switch (_gpuObject.getType()) {
case Texture::TEX_2D: case Texture::TEX_2D:
for (uint16_t i = 0; i < Sampler::MAX_MIP_LEVEL; ++i) { for (uint16_t i = 0; i < Sampler::MAX_MIP_LEVEL; ++i) {

View file

@ -30,7 +30,7 @@ public:
static std::shared_ptr<GLTextureTransferHelper> _textureTransferHelper; static std::shared_ptr<GLTextureTransferHelper> _textureTransferHelper;
template <typename GLTextureType> template <typename GLTextureType>
static GLTextureType* sync(GLBackend& backend, const TexturePointer& texturePointer, bool needTransfer) { static GLTexture* sync(GLBackend& backend, const TexturePointer& texturePointer, bool needTransfer) {
const Texture& texture = *texturePointer; const Texture& texture = *texturePointer;
// Special case external textures // Special case external textures
@ -74,7 +74,7 @@ public:
} }
// If the object hasn't been created, or the object definition is out of date, drop and re-create // If the object hasn't been created, or the object definition is out of date, drop and re-create
GLTextureType* object = Backend::getGPUObject<GLTextureType>(texture); GLTexture* object = Backend::getGPUObject<GLTextureType>(texture);
// Create the texture if need be (force re-creation if the storage stamp changes // Create the texture if need be (force re-creation if the storage stamp changes
// for easier use of immutable storage) // for easier use of immutable storage)
@ -84,6 +84,7 @@ public:
if (!object->_transferrable) { if (!object->_transferrable) {
object->createTexture(); object->createTexture();
object->_contentStamp = texture.getDataStamp(); object->_contentStamp = texture.getDataStamp();
object->updateSize();
object->postTransfer(); object->postTransfer();
} }
} }
@ -119,7 +120,7 @@ public:
if (!texture) { if (!texture) {
return 0; return 0;
} }
GLTextureType* object { nullptr }; GLTexture* object { nullptr };
if (shouldSync) { if (shouldSync) {
object = sync<GLTextureType>(backend, texture, shouldSync); object = sync<GLTextureType>(backend, texture, shouldSync);
} else { } else {

View file

@ -252,6 +252,9 @@ GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture&
if (_transferrable && Texture::getEnableSparseTextures()) { if (_transferrable && Texture::getEnableSparseTextures()) {
_sparseInfo.maybeMakeSparse(); _sparseInfo.maybeMakeSparse();
if (_sparseInfo.sparse) {
Backend::incrementTextureGPUSparseCount();
}
} }
} }
@ -261,6 +264,7 @@ GL45Texture::~GL45Texture() {
qCDebug(gpugl45logging) << "Destroying texture " << _id << " from source " << _source.c_str(); qCDebug(gpugl45logging) << "Destroying texture " << _id << " from source " << _source.c_str();
} }
if (_sparseInfo.sparse) { if (_sparseInfo.sparse) {
Backend::decrementTextureGPUSparseCount();
// Remove this texture from the candidate list of derezzable textures // Remove this texture from the candidate list of derezzable textures
{ {
auto mipLevels = usedMipLevels(); auto mipLevels = usedMipLevels();
@ -300,6 +304,7 @@ GL45Texture::~GL45Texture() {
} }
auto size = _size; auto size = _size;
const_cast<GLuint&>(_size) = 0;
_textureTransferHelper->queueExecution([id, size, destructionFunctions] { _textureTransferHelper->queueExecution([id, size, destructionFunctions] {
for (auto function : destructionFunctions) { for (auto function : destructionFunctions) {
function(); function();
@ -307,6 +312,7 @@ GL45Texture::~GL45Texture() {
glDeleteTextures(1, &id); glDeleteTextures(1, &id);
Backend::decrementTextureGPUCount(); Backend::decrementTextureGPUCount();
Backend::updateTextureGPUMemoryUsage(size, 0); Backend::updateTextureGPUMemoryUsage(size, 0);
Backend::updateTextureGPUSparseMemoryUsage(size, 0);
}); });
} }
} }
@ -338,7 +344,9 @@ void GL45Texture::updateSize() const {
qFatal("Compressed textures not yet supported"); qFatal("Compressed textures not yet supported");
} }
if (_transferrable) { if (_transferrable && _sparseInfo.sparse) {
auto size = _allocatedPages * _sparseInfo.pageBytes;
Backend::updateTextureGPUSparseMemoryUsage(_size, size);
setSize(_allocatedPages * _sparseInfo.pageBytes); setSize(_allocatedPages * _sparseInfo.pageBytes);
} else { } else {
setSize(_virtualSize); setSize(_virtualSize);

View file

@ -167,9 +167,11 @@ std::atomic<uint32_t> Context::_bufferGPUCount { 0 };
std::atomic<Buffer::Size> Context::_bufferGPUMemoryUsage { 0 }; std::atomic<Buffer::Size> Context::_bufferGPUMemoryUsage { 0 };
std::atomic<uint32_t> Context::_textureGPUCount{ 0 }; std::atomic<uint32_t> Context::_textureGPUCount{ 0 };
std::atomic<Texture::Size> Context::_textureGPUMemoryUsage{ 0 }; std::atomic<uint32_t> Context::_textureGPUSparseCount { 0 };
std::atomic<Texture::Size> Context::_textureGPUMemoryUsage { 0 };
std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage{ 0 }; std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage{ 0 };
std::atomic<uint32_t> Context::_textureGPUTransferCount{ 0 }; std::atomic<Texture::Size> Context::_textureGPUSparseMemoryUsage { 0 };
std::atomic<uint32_t> Context::_textureGPUTransferCount { 0 };
void Context::incrementBufferGPUCount() { void Context::incrementBufferGPUCount() {
static std::atomic<uint32_t> max { 0 }; static std::atomic<uint32_t> max { 0 };
@ -217,6 +219,18 @@ void Context::decrementTextureGPUCount() {
--_textureGPUCount; --_textureGPUCount;
} }
void Context::incrementTextureGPUSparseCount() {
static std::atomic<uint32_t> max { 0 };
auto total = ++_textureGPUSparseCount;
if (total > max.load()) {
max = total;
qCDebug(gpulogging) << "New max GPU textures " << total;
}
}
void Context::decrementTextureGPUSparseCount() {
--_textureGPUSparseCount;
}
void Context::updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) { void Context::updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
if (prevObjectSize == newObjectSize) { if (prevObjectSize == newObjectSize) {
return; return;
@ -239,6 +253,17 @@ void Context::updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newOb
} }
} }
void Context::updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize) {
if (prevObjectSize == newObjectSize) {
return;
}
if (newObjectSize > prevObjectSize) {
_textureGPUSparseMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
} else {
_textureGPUSparseMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
}
}
void Context::incrementTextureGPUTransferCount() { void Context::incrementTextureGPUTransferCount() {
static std::atomic<uint32_t> max { 0 }; static std::atomic<uint32_t> max { 0 };
auto total = ++_textureGPUTransferCount; auto total = ++_textureGPUTransferCount;
@ -263,6 +288,10 @@ uint32_t Context::getTextureGPUCount() {
return _textureGPUCount.load(); return _textureGPUCount.load();
} }
uint32_t Context::getTextureGPUSparseCount() {
return _textureGPUSparseCount.load();
}
Context::Size Context::getTextureGPUMemoryUsage() { Context::Size Context::getTextureGPUMemoryUsage() {
return _textureGPUMemoryUsage.load(); return _textureGPUMemoryUsage.load();
} }
@ -271,6 +300,10 @@ Context::Size Context::getTextureGPUVirtualMemoryUsage() {
return _textureGPUVirtualMemoryUsage.load(); return _textureGPUVirtualMemoryUsage.load();
} }
Context::Size Context::getTextureGPUSparseMemoryUsage() {
return _textureGPUSparseMemoryUsage.load();
}
uint32_t Context::getTextureGPUTransferCount() { uint32_t Context::getTextureGPUTransferCount() {
return _textureGPUTransferCount.load(); return _textureGPUTransferCount.load();
} }
@ -280,7 +313,10 @@ void Backend::decrementBufferGPUCount() { Context::decrementBufferGPUCount(); }
void Backend::updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateBufferGPUMemoryUsage(prevObjectSize, newObjectSize); } void Backend::updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateBufferGPUMemoryUsage(prevObjectSize, newObjectSize); }
void Backend::incrementTextureGPUCount() { Context::incrementTextureGPUCount(); } void Backend::incrementTextureGPUCount() { Context::incrementTextureGPUCount(); }
void Backend::decrementTextureGPUCount() { Context::decrementTextureGPUCount(); } void Backend::decrementTextureGPUCount() { Context::decrementTextureGPUCount(); }
void Backend::incrementTextureGPUSparseCount() { Context::incrementTextureGPUSparseCount(); }
void Backend::decrementTextureGPUSparseCount() { Context::decrementTextureGPUSparseCount(); }
void Backend::updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUMemoryUsage(prevObjectSize, newObjectSize); } void Backend::updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUMemoryUsage(prevObjectSize, newObjectSize); }
void Backend::updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUVirtualMemoryUsage(prevObjectSize, newObjectSize); } void Backend::updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUVirtualMemoryUsage(prevObjectSize, newObjectSize); }
void Backend::updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUSparseMemoryUsage(prevObjectSize, newObjectSize); }
void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); } void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); }
void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); } void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); }

View file

@ -94,7 +94,10 @@ public:
static void updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize); static void updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
static void incrementTextureGPUCount(); static void incrementTextureGPUCount();
static void decrementTextureGPUCount(); static void decrementTextureGPUCount();
static void incrementTextureGPUSparseCount();
static void decrementTextureGPUSparseCount();
static void updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize); static void updateTextureGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
static void updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
static void updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize); static void updateTextureGPUVirtualMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
static void incrementTextureGPUTransferCount(); static void incrementTextureGPUTransferCount();
static void decrementTextureGPUTransferCount(); static void decrementTextureGPUTransferCount();
@ -201,8 +204,10 @@ public:
static Size getBufferGPUMemoryUsage(); static Size getBufferGPUMemoryUsage();
static uint32_t getTextureGPUCount(); static uint32_t getTextureGPUCount();
static uint32_t getTextureGPUSparseCount();
static Size getTextureGPUMemoryUsage(); static Size getTextureGPUMemoryUsage();
static Size getTextureGPUVirtualMemoryUsage(); static Size getTextureGPUVirtualMemoryUsage();
static Size getTextureGPUSparseMemoryUsage();
static uint32_t getTextureGPUTransferCount(); static uint32_t getTextureGPUTransferCount();
protected: protected:
@ -235,7 +240,10 @@ protected:
static void incrementTextureGPUCount(); static void incrementTextureGPUCount();
static void decrementTextureGPUCount(); static void decrementTextureGPUCount();
static void incrementTextureGPUSparseCount();
static void decrementTextureGPUSparseCount();
static void updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize); static void updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
static void updateTextureGPUSparseMemoryUsage(Size prevObjectSize, Size newObjectSize);
static void updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize); static void updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize);
static void incrementTextureGPUTransferCount(); static void incrementTextureGPUTransferCount();
static void decrementTextureGPUTransferCount(); static void decrementTextureGPUTransferCount();
@ -247,7 +255,9 @@ protected:
static std::atomic<Size> _bufferGPUMemoryUsage; static std::atomic<Size> _bufferGPUMemoryUsage;
static std::atomic<uint32_t> _textureGPUCount; static std::atomic<uint32_t> _textureGPUCount;
static std::atomic<uint32_t> _textureGPUSparseCount;
static std::atomic<Size> _textureGPUMemoryUsage; static std::atomic<Size> _textureGPUMemoryUsage;
static std::atomic<Size> _textureGPUSparseMemoryUsage;
static std::atomic<Size> _textureGPUVirtualMemoryUsage; static std::atomic<Size> _textureGPUVirtualMemoryUsage;
static std::atomic<uint32_t> _textureGPUTransferCount; static std::atomic<uint32_t> _textureGPUTransferCount;

View file

@ -70,6 +70,14 @@ void Texture::updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSiz
} }
} }
bool Texture::getEnableSparseTextures() {
return _enableSparseTextures.load();
}
bool Texture::getEnableIncrementalTextureTransfers() {
return _enableIncrementalTextureTransfers.load();
}
uint32_t Texture::getTextureCPUCount() { uint32_t Texture::getTextureCPUCount() {
return _textureCPUCount.load(); return _textureCPUCount.load();
} }
@ -82,6 +90,10 @@ uint32_t Texture::getTextureGPUCount() {
return Context::getTextureGPUCount(); return Context::getTextureGPUCount();
} }
uint32_t Texture::getTextureGPUSparseCount() {
return Context::getTextureGPUSparseCount();
}
Texture::Size Texture::getTextureGPUMemoryUsage() { Texture::Size Texture::getTextureGPUMemoryUsage() {
return Context::getTextureGPUMemoryUsage(); return Context::getTextureGPUMemoryUsage();
} }
@ -90,6 +102,10 @@ Texture::Size Texture::getTextureGPUVirtualMemoryUsage() {
return Context::getTextureGPUVirtualMemoryUsage(); return Context::getTextureGPUVirtualMemoryUsage();
} }
Texture::Size Texture::getTextureGPUSparseMemoryUsage() {
return Context::getTextureGPUSparseMemoryUsage();
}
uint32_t Texture::getTextureGPUTransferCount() { uint32_t Texture::getTextureGPUTransferCount() {
return Context::getTextureGPUTransferCount(); return Context::getTextureGPUTransferCount();
} }

View file

@ -151,14 +151,16 @@ public:
static uint32_t getTextureCPUCount(); static uint32_t getTextureCPUCount();
static Size getTextureCPUMemoryUsage(); static Size getTextureCPUMemoryUsage();
static uint32_t getTextureGPUCount(); static uint32_t getTextureGPUCount();
static uint32_t getTextureGPUSparseCount();
static Size getTextureGPUMemoryUsage(); static Size getTextureGPUMemoryUsage();
static Size getTextureGPUVirtualMemoryUsage(); static Size getTextureGPUVirtualMemoryUsage();
static Size getTextureGPUSparseMemoryUsage();
static uint32_t getTextureGPUTransferCount(); static uint32_t getTextureGPUTransferCount();
static Size getAllowedGPUMemoryUsage(); static Size getAllowedGPUMemoryUsage();
static void setAllowedGPUMemoryUsage(Size size); static void setAllowedGPUMemoryUsage(Size size);
static bool getEnableSparseTextures() { return _enableSparseTextures.load(); } static bool getEnableSparseTextures();
static bool getEnableIncrementalTextureTransfers() { return _enableIncrementalTextureTransfers.load(); } static bool getEnableIncrementalTextureTransfers();
static void setEnableSparseTextures(bool enabled); static void setEnableSparseTextures(bool enabled);
static void setEnableIncrementalTextureTransfers(bool enabled); static void setEnableIncrementalTextureTransfers(bool enabled);