mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 23:53:54 +02:00
Cleaning up counters and naming schemes...
This commit is contained in:
parent
b19b0007c8
commit
80b6fd65ae
24 changed files with 279 additions and 501 deletions
|
@ -276,24 +276,20 @@ Item {
|
|||
StatText {
|
||||
text: " Count: " + root.gpuTextures;
|
||||
}
|
||||
StatText {
|
||||
text: " Rectified: " + root.rectifiedTextureCount;
|
||||
}
|
||||
StatText {
|
||||
text: " Decimated: " + root.decimatedTextureCount;
|
||||
}
|
||||
StatText {
|
||||
text: " Pending Transfer: " + root.texturePendingTransfers + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Resource Memory: " + root.gpuTextureMemory + " MB";
|
||||
text: " Resource Memory: " + root.gpuTextureResourceMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Resident Memory: " + root.gpuTextureResidentMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Framebuffer Memory: " + root.gpuTextureFramebufferMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: " Sparse Memory: " + root.gpuTextureSparseMemory + " MB";
|
||||
visible: 0 != root.gpuSparseTextureEnabled;
|
||||
text: " External Memory: " + root.gpuTextureExternalMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: "GPU Buffers: "
|
||||
|
@ -302,7 +298,7 @@ Item {
|
|||
text: " Count: " + root.gpuBuffers;
|
||||
}
|
||||
StatText {
|
||||
text: " Memory: " + root.gpuBufferMemory;
|
||||
text: " Memory: " + root.gpuBufferMemory + " MB";
|
||||
}
|
||||
StatText {
|
||||
text: "GL Swapchain Memory: " + root.glContextSwapchainMemory + " MB";
|
||||
|
|
|
@ -1340,8 +1340,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
|
||||
auto glInfo = getGLContextData();
|
||||
properties["gl_info"] = glInfo;
|
||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemory());
|
||||
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory());
|
||||
properties["gpu_used_memory"] = (int)BYTES_TO_MB(gpu::Context::getUsedGPUMemSize());
|
||||
properties["gpu_free_memory"] = (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize());
|
||||
properties["gpu_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerGPUAverage());
|
||||
properties["batch_frame_time"] = (float)(qApp->getGPUContext()->getFrameTimerBatchAverage());
|
||||
properties["ideal_thread_count"] = QThread::idealThreadCount();
|
||||
|
|
|
@ -31,7 +31,7 @@ void TestScriptingInterface::quit() {
|
|||
|
||||
void TestScriptingInterface::waitForTextureIdle() {
|
||||
waitForCondition(0, []()->bool {
|
||||
return (0 == gpu::Context::getTextureGPUTransferCount());
|
||||
return (0 == gpu::Context::getTexturePendingGPUTransferCount());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -345,21 +345,20 @@ void Stats::updateStats(bool force) {
|
|||
|
||||
|
||||
STAT_UPDATE(gpuBuffers, (int)gpu::Context::getBufferGPUCount());
|
||||
STAT_UPDATE(gpuBufferMemory, (int)BYTES_TO_MB(gpu::Context::getBufferGPUMemoryUsage()));
|
||||
STAT_UPDATE(gpuBufferMemory, (int)BYTES_TO_MB(gpu::Context::getBufferGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextures, (int)gpu::Context::getTextureGPUCount());
|
||||
STAT_UPDATE(gpuTexturesSparse, (int)gpu::Context::getTextureGPUSparseCount());
|
||||
|
||||
STAT_UPDATE(glContextSwapchainMemory, (int)BYTES_TO_MB(gl::Context::getSwapchainMemoryUsage()));
|
||||
|
||||
STAT_UPDATE(qmlTextureMemory, (int)BYTES_TO_MB(OffscreenQmlSurface::getUsedTextureMemory()));
|
||||
STAT_UPDATE(texturePendingTransfers, (int)BYTES_TO_MB(gpu::Texture::getTextureTransferPendingSize()));
|
||||
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureVirtualMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUVirtualMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUFramebufferMemoryUsage()));
|
||||
STAT_UPDATE(gpuTextureSparseMemory, (int)BYTES_TO_MB(gpu::Texture::getTextureGPUSparseMemoryUsage()));
|
||||
STAT_UPDATE(texturePendingTransfers, (int)BYTES_TO_MB(gpu::Context::getTexturePendingGPUTransferMemSize()));
|
||||
STAT_UPDATE(gpuTextureMemory, (int)BYTES_TO_MB(gpu::Context::getTextureGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureResidentMemory, (int)BYTES_TO_MB(gpu::Context::getTextureResidentGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureFramebufferMemory, (int)BYTES_TO_MB(gpu::Context::getTextureFramebufferGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureResourceMemory, (int)BYTES_TO_MB(gpu::Context::getTextureResourceGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureExternalMemory, (int)BYTES_TO_MB(gpu::Context::getTextureExternalGPUMemSize()));
|
||||
STAT_UPDATE(gpuTextureMemoryPressureState, getTextureMemoryPressureModeString());
|
||||
STAT_UPDATE(gpuSparseTextureEnabled, gpuContext->getBackend()->isTextureManagementSparseEnabled() ? 1 : 0);
|
||||
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemory()));
|
||||
STAT_UPDATE(gpuFreeMemory, (int)BYTES_TO_MB(gpu::Context::getFreeGPUMemSize()));
|
||||
STAT_UPDATE(rectifiedTextureCount, (int)RECTIFIED_TEXTURE_COUNT.load());
|
||||
STAT_UPDATE(decimatedTextureCount, (int)DECIMATED_TEXTURE_COUNT.load());
|
||||
|
||||
|
|
|
@ -117,15 +117,14 @@ class Stats : public QQuickItem {
|
|||
STATS_PROPERTY(int, gpuBuffers, 0)
|
||||
STATS_PROPERTY(int, gpuBufferMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextures, 0)
|
||||
STATS_PROPERTY(int, gpuTexturesSparse, 0)
|
||||
STATS_PROPERTY(int, glContextSwapchainMemory, 0)
|
||||
STATS_PROPERTY(int, qmlTextureMemory, 0)
|
||||
STATS_PROPERTY(int, texturePendingTransfers, 0)
|
||||
STATS_PROPERTY(int, gpuTextureMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureVirtualMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureResidentMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureFramebufferMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureSparseMemory, 0)
|
||||
STATS_PROPERTY(int, gpuSparseTextureEnabled, 0)
|
||||
STATS_PROPERTY(int, gpuTextureResourceMemory, 0)
|
||||
STATS_PROPERTY(int, gpuTextureExternalMemory, 0)
|
||||
STATS_PROPERTY(QString, gpuTextureMemoryPressureState, QString())
|
||||
STATS_PROPERTY(int, gpuFreeMemory, 0)
|
||||
STATS_PROPERTY(float, gpuFrameTime, 0)
|
||||
|
@ -245,13 +244,12 @@ signals:
|
|||
void gpuBuffersChanged();
|
||||
void gpuBufferMemoryChanged();
|
||||
void gpuTexturesChanged();
|
||||
void gpuTexturesSparseChanged();
|
||||
void gpuTextureMemoryChanged();
|
||||
void gpuTextureVirtualMemoryChanged();
|
||||
void gpuTextureResidentMemoryChanged();
|
||||
void gpuTextureFramebufferMemoryChanged();
|
||||
void gpuTextureSparseMemoryChanged();
|
||||
void gpuTextureResourceMemoryChanged();
|
||||
void gpuTextureExternalMemoryChanged();
|
||||
void gpuTextureMemoryPressureStateChanged();
|
||||
void gpuSparseTextureEnabledChanged();
|
||||
void gpuFreeMemoryChanged();
|
||||
void gpuFrameTimeChanged();
|
||||
void batchFrameTimeChanged();
|
||||
|
|
|
@ -645,7 +645,7 @@ void OpenGLDisplayPlugin::present() {
|
|||
internalPresent();
|
||||
}
|
||||
|
||||
gpu::Backend::setFreeGPUMemory(gpu::gl::getFreeDedicatedMemory());
|
||||
gpu::Backend::freeGPUMemSize.set(gpu::gl::getFreeDedicatedMemory());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -644,8 +644,8 @@ void GLBackend::recycle() const {
|
|||
ids.reserve(buffersTrash.size());
|
||||
for (auto pair : buffersTrash) {
|
||||
ids.push_back(pair.first);
|
||||
decrementBufferGPUCount();
|
||||
updateBufferGPUMemoryUsage(pair.second, 0);
|
||||
bufferCount.decrement();
|
||||
bufferGPUMemSize.update(pair.second, 0);
|
||||
}
|
||||
if (!ids.empty()) {
|
||||
glDeleteBuffers((GLsizei)ids.size(), ids.data());
|
||||
|
@ -678,8 +678,8 @@ void GLBackend::recycle() const {
|
|||
ids.reserve(texturesTrash.size());
|
||||
for (auto pair : texturesTrash) {
|
||||
ids.push_back(pair.first);
|
||||
decrementTextureGPUCount();
|
||||
updateTextureGPUMemoryUsage(pair.second, 0);
|
||||
textureCount.decrement();
|
||||
textureGPUMemSize.update(pair.second, 0);
|
||||
}
|
||||
if (!ids.empty()) {
|
||||
glDeleteTextures((GLsizei)ids.size(), ids.data());
|
||||
|
|
|
@ -26,7 +26,7 @@ GLBuffer::GLBuffer(const std::weak_ptr<GLBackend>& backend, const Buffer& buffer
|
|||
_size((GLuint)buffer._renderSysmem.getSize()),
|
||||
_stamp(buffer._renderSysmem.getStamp())
|
||||
{
|
||||
Backend::incrementBufferGPUCount();
|
||||
Backend::updateBufferGPUMemoryUsage(0, _size);
|
||||
Backend::bufferCount.increment();
|
||||
Backend::bufferGPUMemSize.update(0, _size);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,9 @@ void GLTexture::copyMipFaceFromTexture(uint16_t sourceMip, uint16_t targetMip, u
|
|||
|
||||
|
||||
GLExternalTexture::GLExternalTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint id)
|
||||
: Parent(backend, texture, id) { }
|
||||
: Parent(backend, texture, id) {
|
||||
Backend::textureExternalCount.increment();
|
||||
}
|
||||
|
||||
GLExternalTexture::~GLExternalTexture() {
|
||||
auto backend = _backend.lock();
|
||||
|
@ -145,6 +147,7 @@ GLExternalTexture::~GLExternalTexture() {
|
|||
}
|
||||
const_cast<GLuint&>(_id) = 0;
|
||||
}
|
||||
Backend::textureExternalCount.decrement();
|
||||
}
|
||||
|
||||
|
||||
|
@ -211,7 +214,7 @@ TransferJob::TransferJob(const GLTexture& parent, uint16_t sourceMip, uint16_t t
|
|||
_transferSize = bytesPerLine * lines;
|
||||
}
|
||||
|
||||
Backend::updateTextureTransferPendingSize(0, _transferSize);
|
||||
Backend::texturePendingGPUTransferMemSize.update(0, _transferSize);
|
||||
|
||||
if (_transferSize > GLVariableAllocationSupport::MAX_TRANSFER_SIZE) {
|
||||
qCWarning(gpugllogging) << "Transfer size of " << _transferSize << " exceeds theoretical maximum transfer size";
|
||||
|
@ -233,7 +236,7 @@ TransferJob::TransferJob(const GLTexture& parent, std::function<void()> transfer
|
|||
}
|
||||
|
||||
TransferJob::~TransferJob() {
|
||||
Backend::updateTextureTransferPendingSize(_transferSize, 0);
|
||||
Backend::texturePendingGPUTransferMemSize.update(_transferSize, 0);
|
||||
}
|
||||
|
||||
bool TransferJob::tryTransfer() {
|
||||
|
|
|
@ -76,7 +76,7 @@ using GL41Texture = GL41Backend::GL41Texture;
|
|||
|
||||
GL41Texture::GL41Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture)
|
||||
: GLTexture(backend, texture, allocate(texture)) {
|
||||
incrementTextureGPUCount();
|
||||
Backend::textureCount.increment();
|
||||
}
|
||||
|
||||
GLuint GL41Texture::allocate(const Texture& texture) {
|
||||
|
@ -210,11 +210,13 @@ void GL41FixedAllocationTexture::syncSampler() const {
|
|||
using GL41AttachmentTexture = GL41Backend::GL41AttachmentTexture;
|
||||
|
||||
GL41AttachmentTexture::GL41AttachmentTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL41FixedAllocationTexture(backend, texture) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(0, size());
|
||||
Backend::textureFramebufferCount.increment();
|
||||
Backend::textureFramebufferGPUMemSize.update(0, size());
|
||||
}
|
||||
|
||||
GL41AttachmentTexture::~GL41AttachmentTexture() {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(size(), 0);
|
||||
Backend::textureFramebufferCount.decrement();
|
||||
Backend::textureFramebufferGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
// Strict resource textures
|
||||
|
@ -243,6 +245,8 @@ using GL41VariableAllocationTexture = GL41Backend::GL41VariableAllocationTexture
|
|||
GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) :
|
||||
GL41Texture(backend, texture)
|
||||
{
|
||||
Backend::textureResourceCount.increment();
|
||||
|
||||
auto mipLevels = texture.getNumMips();
|
||||
_allocatedMip = mipLevels;
|
||||
_maxAllocatedMip = _populatedMip = mipLevels;
|
||||
|
@ -272,7 +276,8 @@ GL41VariableAllocationTexture::GL41VariableAllocationTexture(const std::weak_ptr
|
|||
}
|
||||
|
||||
GL41VariableAllocationTexture::~GL41VariableAllocationTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
Backend::textureResourceCount.decrement();
|
||||
Backend::textureResourceGPUMemSize.update(_size, 0);
|
||||
}
|
||||
|
||||
void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
||||
|
@ -291,7 +296,8 @@ void GL41VariableAllocationTexture::allocateStorage(uint16 allocatedMip) {
|
|||
for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) {
|
||||
_size += _gpuObject.evalMipSize(mip);
|
||||
}
|
||||
Backend::updateTextureGPUMemoryUsage(0, _size);
|
||||
Backend::textureResourceGPUMemSize.update(0, _size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,7 +468,7 @@ void GL41VariableAllocationTexture::promote() {
|
|||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
@ -493,7 +499,7 @@ void GL41VariableAllocationTexture::demote() {
|
|||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ using GL45Texture = GL45Backend::GL45Texture;
|
|||
|
||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture)
|
||||
: GLTexture(backend, texture, allocate(texture)) {
|
||||
incrementTextureGPUCount();
|
||||
Backend::textureCount.increment();
|
||||
}
|
||||
|
||||
GLuint GL45Texture::allocate(const Texture& texture) {
|
||||
|
@ -241,11 +241,11 @@ void GL45FixedAllocationTexture::syncSampler() const {
|
|||
using GL45AttachmentTexture = GL45Backend::GL45AttachmentTexture;
|
||||
|
||||
GL45AttachmentTexture::GL45AttachmentTexture(const std::weak_ptr<GLBackend>& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(0, size());
|
||||
Backend::textureFramebufferGPUMemSize.update(0, size());
|
||||
}
|
||||
|
||||
GL45AttachmentTexture::~GL45AttachmentTexture() {
|
||||
Backend::updateTextureGPUFramebufferMemoryUsage(size(), 0);
|
||||
Backend::textureFramebufferGPUMemSize.update(size(), 0);
|
||||
}
|
||||
|
||||
// Strict resource textures
|
||||
|
|
|
@ -34,7 +34,7 @@ GL45VariableAllocationTexture::GL45VariableAllocationTexture(const std::weak_ptr
|
|||
}
|
||||
|
||||
GL45VariableAllocationTexture::~GL45VariableAllocationTexture() {
|
||||
Backend::updateTextureGPUMemoryUsage(_size, 0);
|
||||
Backend::textureGPUMemSize.update(_size, 0);
|
||||
}
|
||||
|
||||
// Managed size resource textures
|
||||
|
@ -77,8 +77,7 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) {
|
|||
_size += _gpuObject.evalMipSize(mip);
|
||||
}
|
||||
|
||||
Backend::updateTextureGPUMemoryUsage(0, _size);
|
||||
|
||||
Backend::textureResourceGPUMemSize.update(0, _size);
|
||||
}
|
||||
|
||||
void GL45ResourceTexture::copyMipsFromTexture() {
|
||||
|
@ -139,7 +138,7 @@ void GL45ResourceTexture::promote() {
|
|||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
syncSampler();
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
@ -163,7 +162,7 @@ void GL45ResourceTexture::demote() {
|
|||
// destroy the old texture
|
||||
glDeleteTextures(1, &oldId);
|
||||
// update the memory usage
|
||||
Backend::updateTextureGPUMemoryUsage(oldSize, 0);
|
||||
Backend::textureResourceGPUMemSize.update(oldSize, 0);
|
||||
syncSampler();
|
||||
populateTransferQueue();
|
||||
}
|
||||
|
|
|
@ -11,47 +11,20 @@
|
|||
|
||||
using namespace gpu;
|
||||
|
||||
std::atomic<uint32_t> Buffer::_bufferCPUCount{ 0 };
|
||||
std::atomic<Buffer::Size> Buffer::_bufferCPUMemoryUsage{ 0 };
|
||||
|
||||
void Buffer::updateBufferCPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (prevObjectSize > newObjectSize) {
|
||||
_bufferCPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
} else {
|
||||
_bufferCPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Buffer::incrementBufferCPUCount() {
|
||||
_bufferCPUCount++;
|
||||
}
|
||||
|
||||
void Buffer::decrementBufferCPUCount() {
|
||||
_bufferCPUCount--;
|
||||
}
|
||||
ContextMetricCount Buffer::_bufferCPUCount;
|
||||
ContextMetricSize Buffer::_bufferCPUMemSize;
|
||||
|
||||
uint32_t Buffer::getBufferCPUCount() {
|
||||
return _bufferCPUCount.load();
|
||||
return _bufferCPUCount.getValue();
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::getBufferCPUMemoryUsage() {
|
||||
return _bufferCPUMemoryUsage.load();
|
||||
}
|
||||
|
||||
uint32_t Buffer::getBufferGPUCount() {
|
||||
return Context::getBufferGPUCount();
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::getBufferGPUMemoryUsage() {
|
||||
return Context::getBufferGPUMemoryUsage();
|
||||
Buffer::Size Buffer::getBufferCPUMemSize() {
|
||||
return _bufferCPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Buffer::Buffer(Size pageSize) :
|
||||
_renderPages(pageSize), _pages(pageSize) {
|
||||
Buffer::incrementBufferCPUCount();
|
||||
_bufferCPUCount.increment();
|
||||
}
|
||||
|
||||
Buffer::Buffer(Size size, const Byte* bytes, Size pageSize) : Buffer(pageSize) {
|
||||
|
@ -69,8 +42,8 @@ Buffer& Buffer::operator=(const Buffer& buf) {
|
|||
}
|
||||
|
||||
Buffer::~Buffer() {
|
||||
Buffer::decrementBufferCPUCount();
|
||||
Buffer::updateBufferCPUMemoryUsage(_sysmem.getSize(), 0);
|
||||
_bufferCPUCount.decrement();
|
||||
_bufferCPUMemSize.update(_sysmem.getSize(), 0);
|
||||
}
|
||||
|
||||
Buffer::Size Buffer::resize(Size size) {
|
||||
|
@ -78,7 +51,7 @@ Buffer::Size Buffer::resize(Size size) {
|
|||
auto prevSize = _sysmem.getSize();
|
||||
if (prevSize < size) {
|
||||
_sysmem.resize(_pages.accommodate(_end));
|
||||
Buffer::updateBufferCPUMemoryUsage(prevSize, _sysmem.getSize());
|
||||
_bufferCPUMemSize.update(prevSize, _sysmem.getSize());
|
||||
}
|
||||
return _end;
|
||||
}
|
||||
|
|
|
@ -21,16 +21,12 @@
|
|||
#include "Resource.h"
|
||||
#include "Sysmem.h"
|
||||
#include "PageManager.h"
|
||||
#include "Metric.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
class Buffer : public Resource {
|
||||
static std::atomic<uint32_t> _bufferCPUCount;
|
||||
static std::atomic<Size> _bufferCPUMemoryUsage;
|
||||
static void updateBufferCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void incrementBufferCPUCount();
|
||||
static void decrementBufferCPUCount();
|
||||
|
||||
static ContextMetricCount _bufferCPUCount;
|
||||
static ContextMetricSize _bufferCPUMemSize;
|
||||
public:
|
||||
using Flag = PageManager::Flag;
|
||||
|
||||
|
@ -50,9 +46,7 @@ public:
|
|||
};
|
||||
|
||||
static uint32_t getBufferCPUCount();
|
||||
static Size getBufferCPUMemoryUsage();
|
||||
static uint32_t getBufferGPUCount();
|
||||
static Size getBufferGPUMemoryUsage();
|
||||
static Size getBufferCPUMemSize();
|
||||
|
||||
Buffer(Size pageSize = PageManager::DEFAULT_PAGE_SIZE);
|
||||
Buffer(Size size, const Byte* bytes, Size pageSize = PageManager::DEFAULT_PAGE_SIZE);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
using namespace gpu;
|
||||
|
||||
|
||||
void ContextStats::evalDelta(const ContextStats& begin, const ContextStats& end) {
|
||||
_ISNumFormatChanges = end._ISNumFormatChanges - begin._ISNumFormatChanges;
|
||||
_ISNumInputBufferChanges = end._ISNumInputBufferChanges - begin._ISNumInputBufferChanges;
|
||||
|
@ -238,213 +237,75 @@ Backend::TransformCamera Backend::TransformCamera::getEyeCamera(int eye, const S
|
|||
}
|
||||
|
||||
// Counters for Buffer and Texture usage in GPU/Context
|
||||
std::atomic<Size> Context::_freeGPUMemory { 0 };
|
||||
std::atomic<uint32_t> Context::_fenceCount { 0 };
|
||||
std::atomic<uint32_t> Context::_bufferGPUCount { 0 };
|
||||
std::atomic<Buffer::Size> Context::_bufferGPUMemoryUsage { 0 };
|
||||
|
||||
std::atomic<uint32_t> Context::_textureGPUCount{ 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUSparseCount { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureTransferPendingSize { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUVirtualMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUFramebufferMemoryUsage { 0 };
|
||||
std::atomic<Texture::Size> Context::_textureGPUSparseMemoryUsage { 0 };
|
||||
std::atomic<uint32_t> Context::_textureGPUTransferCount { 0 };
|
||||
ContextMetricSize Backend::freeGPUMemSize;
|
||||
|
||||
void Context::setFreeGPUMemory(Size size) {
|
||||
_freeGPUMemory.store(size);
|
||||
ContextMetricCount Backend::bufferCount;
|
||||
ContextMetricSize Backend::bufferGPUMemSize;
|
||||
|
||||
ContextMetricCount Backend::textureCount;
|
||||
ContextMetricCount Backend::textureFramebufferCount;
|
||||
ContextMetricCount Backend::textureResourceCount;
|
||||
ContextMetricCount Backend::textureExternalCount;
|
||||
|
||||
ContextMetricSize Backend::textureGPUMemSize;
|
||||
ContextMetricSize Backend::textureResidentGPUMemSize;
|
||||
ContextMetricSize Backend::textureFramebufferGPUMemSize;
|
||||
ContextMetricSize Backend::textureResourceGPUMemSize;
|
||||
ContextMetricSize Backend::textureExternalGPUMemSize;
|
||||
|
||||
ContextMetricCount Backend::texturePendingGPUTransferCount;
|
||||
ContextMetricSize Backend::texturePendingGPUTransferMemSize;
|
||||
|
||||
Size Context::getFreeGPUMemSize() {
|
||||
return Backend::freeGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Size Context::getFreeGPUMemory() {
|
||||
return _freeGPUMemory.load();
|
||||
}
|
||||
|
||||
Size Context::getUsedGPUMemory() {
|
||||
return getTextureGPUMemoryUsage() + getBufferGPUMemoryUsage();
|
||||
Size Context::getUsedGPUMemSize() {
|
||||
return getTextureGPUMemSize() + getBufferGPUMemSize();
|
||||
};
|
||||
|
||||
void Context::incrementBufferGPUCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_bufferGPUCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU buffers " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementBufferGPUCount() {
|
||||
--_bufferGPUCount;
|
||||
}
|
||||
void Context::updateBufferGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_bufferGPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_bufferGPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::incrementFenceCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_fenceCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
qCDebug(gpulogging) << "New max Fences " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementFenceCount() {
|
||||
--_fenceCount;
|
||||
}
|
||||
|
||||
void Context::incrementTextureGPUCount() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_textureGPUCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU textures " << total;
|
||||
}
|
||||
}
|
||||
void Context::decrementTextureGPUCount() {
|
||||
--_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::updateTextureTransferPendingSize(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureTransferPendingSize.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureTransferPendingSize.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUVirtualMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUVirtualMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUVirtualMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Context::updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (newObjectSize > prevObjectSize) {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
} else {
|
||||
_textureGPUFramebufferMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
static std::atomic<uint32_t> max { 0 };
|
||||
auto total = ++_textureGPUTransferCount;
|
||||
if (total > max.load()) {
|
||||
max = total;
|
||||
// qCDebug(gpulogging) << "New max GPU textures transfers" << total;
|
||||
}
|
||||
}
|
||||
|
||||
void Context::decrementTextureGPUTransferCount() {
|
||||
--_textureGPUTransferCount;
|
||||
}
|
||||
|
||||
uint32_t Context::getBufferGPUCount() {
|
||||
return _bufferGPUCount.load();
|
||||
return Backend::bufferCount.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getBufferGPUMemoryUsage() {
|
||||
return _bufferGPUMemoryUsage.load();
|
||||
Context::Size Context::getBufferGPUMemSize() {
|
||||
return Backend::bufferGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUCount() {
|
||||
return _textureGPUCount.load();
|
||||
return Backend::textureCount.getValue();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUSparseCount() {
|
||||
return _textureGPUSparseCount.load();
|
||||
uint32_t Context::getTextureFramebufferGPUCount() {
|
||||
return Backend::textureFramebufferCount.getValue();
|
||||
}
|
||||
uint32_t Context::getTextureResourceGPUCount() {
|
||||
return Backend::textureResourceCount.getValue();
|
||||
}
|
||||
uint32_t Context::getTextureExternalGPUCount() {
|
||||
return Backend::textureExternalCount.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureTransferPendingSize() {
|
||||
return _textureTransferPendingSize.load();
|
||||
Size Context::getTextureGPUMemSize() {
|
||||
return Backend::textureGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureResidentGPUMemSize() {
|
||||
return Backend::textureResidentGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureFramebufferGPUMemSize() {
|
||||
return Backend::textureFramebufferGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureResourceGPUMemSize() {
|
||||
return Backend::textureResourceGPUMemSize.getValue();
|
||||
}
|
||||
Size Context::getTextureExternalGPUMemSize() {
|
||||
return Backend::textureExternalGPUMemSize.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUMemoryUsage() {
|
||||
return _textureGPUMemoryUsage.load();
|
||||
uint32_t Context::getTexturePendingGPUTransferCount() {
|
||||
return Backend::texturePendingGPUTransferCount.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUVirtualMemoryUsage() {
|
||||
return _textureGPUVirtualMemoryUsage.load();
|
||||
Size Context::getTexturePendingGPUTransferMemSize() {
|
||||
return Backend::texturePendingGPUTransferMemSize.getValue();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUFramebufferMemoryUsage() {
|
||||
return _textureGPUFramebufferMemoryUsage.load();
|
||||
}
|
||||
|
||||
Context::Size Context::getTextureGPUSparseMemoryUsage() {
|
||||
return _textureGPUSparseMemoryUsage.load();
|
||||
}
|
||||
|
||||
uint32_t Context::getTextureGPUTransferCount() {
|
||||
return _textureGPUTransferCount.load();
|
||||
}
|
||||
|
||||
void Backend::setFreeGPUMemory(Size size) { Context::setFreeGPUMemory(size); }
|
||||
Resource::Size Backend::getFreeGPUMemory() { return Context::getFreeGPUMemory(); }
|
||||
void Backend::incrementBufferGPUCount() { Context::incrementBufferGPUCount(); }
|
||||
void Backend::decrementBufferGPUCount() { Context::decrementBufferGPUCount(); }
|
||||
void Backend::updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateBufferGPUMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::incrementTextureGPUCount() { Context::incrementTextureGPUCount(); }
|
||||
void Backend::decrementTextureGPUCount() { Context::decrementTextureGPUCount(); }
|
||||
void Backend::incrementTextureGPUSparseCount() { Context::incrementTextureGPUSparseCount(); }
|
||||
void Backend::decrementTextureGPUSparseCount() { Context::decrementTextureGPUSparseCount(); }
|
||||
void Backend::updateTextureTransferPendingSize(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureTransferPendingSize(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::updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUFramebufferMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::updateTextureGPUSparseMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize) { Context::updateTextureGPUSparseMemoryUsage(prevObjectSize, newObjectSize); }
|
||||
void Backend::incrementTextureGPUTransferCount() { Context::incrementTextureGPUTransferCount(); }
|
||||
void Backend::decrementTextureGPUTransferCount() { Context::decrementTextureGPUTransferCount(); }
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "Forward.h"
|
||||
#include "Batch.h"
|
||||
#include "Resource.h"
|
||||
#include "Buffer.h"
|
||||
#include "Texture.h"
|
||||
#include "Pipeline.h"
|
||||
#include "Framebuffer.h"
|
||||
|
@ -28,47 +28,6 @@ class QImage;
|
|||
|
||||
namespace gpu {
|
||||
|
||||
template <typename T>
|
||||
struct ContextMetric {
|
||||
std::atomic<T> _value { 0 };
|
||||
std::atomic<T> _maximum { 0 };
|
||||
|
||||
T getValue() { return _value; }
|
||||
T getMaximum() { return _maximum; }
|
||||
|
||||
void increment() {
|
||||
auto total = ++_value;
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
}
|
||||
void increment() {
|
||||
--_value;
|
||||
}
|
||||
|
||||
void update(T prevValue, T newValue) {
|
||||
if (prevValue == newValue) {
|
||||
return;
|
||||
}
|
||||
if (newValue > prevValue) {
|
||||
auto total = _value.fetch_add(newValue - prevValue);
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
} else {
|
||||
_value.fetch_sub(prevValue - newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_value = 0;
|
||||
_maximum = 0;
|
||||
}
|
||||
};
|
||||
|
||||
using ContextMetricCount = ContextMetric<uint32_t>;
|
||||
using ContextMetricSize = ContextMetric<Size>;
|
||||
|
||||
struct ContextStats {
|
||||
public:
|
||||
int _ISNumFormatChanges = 0;
|
||||
|
@ -135,38 +94,27 @@ public:
|
|||
|
||||
virtual bool isTextureManagementSparseEnabled() const = 0;
|
||||
|
||||
// These should only be accessed by Backend implementation to repport the buffer and texture allocations,
|
||||
// they are NOT public calls
|
||||
static Resource::Size getFreeGPUMemory();
|
||||
static void setFreeGPUMemory(Resource::Size prevObjectSize);
|
||||
static void incrementBufferGPUCount();
|
||||
static void decrementBufferGPUCount();
|
||||
static void updateBufferGPUMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void incrementTextureGPUCount();
|
||||
static void decrementTextureGPUCount();
|
||||
static void incrementTextureGPUSparseCount();
|
||||
static void decrementTextureGPUSparseCount();
|
||||
static void updateTextureTransferPendingSize(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 updateTextureGPUFramebufferMemoryUsage(Resource::Size prevObjectSize, Resource::Size newObjectSize);
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
|
||||
static ContextMetricSize freeGPUMemSize;
|
||||
// These should only be accessed by Backend implementation to report the buffer and texture allocations,
|
||||
// they are NOT public objects
|
||||
static ContextMetricSize freeGPUMemSize;
|
||||
|
||||
static ContextMetricCount bufferCount;
|
||||
static ContextMetricSize bufferGPUMemSize;
|
||||
static ContextMetricSize bufferGPUMemSize;
|
||||
|
||||
static ContextMetricCount textureCount;
|
||||
static ContextMetricSize textureGPUMemSize;
|
||||
static ContextMetricSize textureResidentGPUMemSize;
|
||||
static ContextMetricSize textureResourceGPUMemSize;
|
||||
static ContextMetricSize textureFramebufferGPUMemSize;
|
||||
static ContextMetricCount textureFramebufferCount;
|
||||
static ContextMetricCount textureResourceCount;
|
||||
static ContextMetricCount textureExternalCount;
|
||||
|
||||
static ContextMetricCount textureTransferCount;
|
||||
static ContextMetricSize textureGPUMemSize;
|
||||
|
||||
static ContextMetricSize textureResidentGPUMemSize;
|
||||
static ContextMetricSize textureFramebufferGPUMemSize;
|
||||
static ContextMetricSize textureResourceGPUMemSize;
|
||||
static ContextMetricSize textureExternalGPUMemSize;
|
||||
|
||||
static ContextMetricCount texturePendingGPUTransferCount;
|
||||
static ContextMetricSize texturePendingGPUTransferMemSize;
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -276,21 +224,25 @@ public:
|
|||
double getFrameTimerGPUAverage() const;
|
||||
double getFrameTimerBatchAverage() const;
|
||||
|
||||
static Size getFreeGPUMemSize();
|
||||
static Size getUsedGPUMemSize();
|
||||
|
||||
static uint32_t getBufferGPUCount();
|
||||
static Size getBufferGPUMemoryUsage();
|
||||
static Size getBufferGPUMemSize();
|
||||
|
||||
static uint32_t getTextureGPUCount();
|
||||
static uint32_t getTextureGPUResourceCount();
|
||||
static Size getFreeGPUMemory();
|
||||
static Size getUsedGPUMemory();
|
||||
static Size getTextureTransferPendingSize();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static uint32_t getTextureFramebufferGPUCount();
|
||||
static uint32_t getTextureResourceGPUCount();
|
||||
static uint32_t getTextureExternalGPUCount();
|
||||
|
||||
static Size getTextureGPUResourceMemoryUsage();
|
||||
static Size getTextureGPUResidentMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static Size getTextureGPUMemSize();
|
||||
static Size getTextureResidentGPUMemSize();
|
||||
static Size getTextureFramebufferGPUMemSize();
|
||||
static Size getTextureResourceGPUMemSize();
|
||||
static Size getTextureExternalGPUMemSize();
|
||||
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
static uint32_t getTexturePendingGPUTransferCount();
|
||||
static Size getTexturePendingGPUTransferMemSize();
|
||||
|
||||
protected:
|
||||
Context(const Context& context);
|
||||
|
@ -315,49 +267,6 @@ protected:
|
|||
static std::once_flag _initialized;
|
||||
|
||||
friend class Shader;
|
||||
|
||||
// These should only be accessed by the Backend, they are NOT public calls
|
||||
static void incrementBufferGPUCount();
|
||||
static void decrementBufferGPUCount();
|
||||
static void updateBufferGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
static void incrementFenceCount();
|
||||
static void decrementFenceCount();
|
||||
|
||||
static void setFreeGPUMemory(Size size);
|
||||
static void incrementTextureGPUCount();
|
||||
static void decrementTextureGPUCount();
|
||||
static void incrementTextureGPUResourceCount();
|
||||
static void decrementTextureGPUResourceCount();
|
||||
|
||||
static void incrementTextureGPUTransferCount();
|
||||
static void decrementTextureGPUTransferCount();
|
||||
|
||||
static void updateTextureTransferPendingSize(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
static void updateTextureGPUResourceMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUResidentMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
static void updateTextureGPUFramebufferMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
|
||||
|
||||
// Buffer, Texture and Fence Counters
|
||||
static std::atomic<Size> _freeGPUMemory;
|
||||
static std::atomic<uint32_t> _fenceCount;
|
||||
|
||||
static std::atomic<uint32_t> _bufferGPUCount;
|
||||
static std::atomic<Size> _bufferGPUMemoryUsage;
|
||||
|
||||
static std::atomic<uint32_t> _textureGPUCount;
|
||||
static std::atomic<uint32_t> _textureGPUSparseCount;
|
||||
static std::atomic<Size> _textureTransferPendingSize;
|
||||
static std::atomic<Size> _textureGPUMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUSparseMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUVirtualMemoryUsage;
|
||||
static std::atomic<Size> _textureGPUFramebufferMemoryUsage;
|
||||
static std::atomic<uint32_t> _textureGPUTransferCount;
|
||||
|
||||
friend class Backend;
|
||||
};
|
||||
typedef std::shared_ptr<Context> ContextPointer;
|
||||
|
|
64
libraries/gpu/src/gpu/Metric.h
Normal file
64
libraries/gpu/src/gpu/Metric.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// Metric.h
|
||||
// libraries/gpu/src/gpu
|
||||
//
|
||||
// Created by Sam Gateau on 5/17/2017.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#ifndef hifi_gpu_Metric_h
|
||||
#define hifi_gpu_Metric_h
|
||||
|
||||
#include "Forward.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
template <typename T>
|
||||
class Metric {
|
||||
std::atomic<T> _value { 0 };
|
||||
std::atomic<T> _maximum { 0 };
|
||||
|
||||
public:
|
||||
T getValue() { return _value; }
|
||||
T getMaximum() { return _maximum; }
|
||||
|
||||
void set(T newValue) {
|
||||
_value = newValue;
|
||||
}
|
||||
void increment() {
|
||||
auto total = ++_value;
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
}
|
||||
void decrement() {
|
||||
--_value;
|
||||
}
|
||||
|
||||
void update(T prevValue, T newValue) {
|
||||
if (prevValue == newValue) {
|
||||
return;
|
||||
}
|
||||
if (newValue > prevValue) {
|
||||
auto total = _value.fetch_add(newValue - prevValue);
|
||||
if (total > _maximum.load()) {
|
||||
_maximum = total;
|
||||
}
|
||||
} else {
|
||||
_value.fetch_sub(prevValue - newValue);
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_value = 0;
|
||||
_maximum = 0;
|
||||
}
|
||||
};
|
||||
|
||||
using ContextMetricCount = Metric<uint32_t>;
|
||||
using ContextMetricSize = Metric<Size>;
|
||||
|
||||
}
|
||||
#endif
|
|
@ -42,6 +42,7 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
|
||||
// FIXME Compatibility with headers that rely on Resource.h for the buffer and buffer view definitions
|
||||
#include "Buffer.h"
|
||||
|
||||
|
|
|
@ -31,8 +31,9 @@ using namespace gpu;
|
|||
|
||||
int TexturePointerMetaTypeId = qRegisterMetaType<TexturePointer>();
|
||||
|
||||
std::atomic<uint32_t> Texture::_textureCPUCount{ 0 };
|
||||
std::atomic<Texture::Size> Texture::_textureCPUMemoryUsage{ 0 };
|
||||
|
||||
ContextMetricCount Texture::_textureCPUCount;
|
||||
ContextMetricSize Texture::_textureCPUMemSize;
|
||||
std::atomic<Texture::Size> Texture::_allowedCPUMemoryUsage { 0 };
|
||||
|
||||
|
||||
|
@ -58,56 +59,18 @@ void Texture::setEnableSparseTextures(bool enabled) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Texture::updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
}
|
||||
if (prevObjectSize > newObjectSize) {
|
||||
_textureCPUMemoryUsage.fetch_sub(prevObjectSize - newObjectSize);
|
||||
} else {
|
||||
_textureCPUMemoryUsage.fetch_add(newObjectSize - prevObjectSize);
|
||||
}
|
||||
}
|
||||
|
||||
bool Texture::getEnableSparseTextures() {
|
||||
return _enableSparseTextures.load();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureCPUCount() {
|
||||
return _textureCPUCount.load();
|
||||
return _textureCPUCount.getValue();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureCPUMemoryUsage() {
|
||||
return _textureCPUMemoryUsage.load();
|
||||
Texture::Size Texture::getTextureCPUMemSize() {
|
||||
return _textureCPUMemSize.getValue();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureGPUCount() {
|
||||
return Context::getTextureGPUCount();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureTransferPendingSize() {
|
||||
return Context::getTextureTransferPendingSize();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUMemoryUsage() {
|
||||
return Context::getTextureGPUMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size getTextureGPUResourceMemoryUsage() {
|
||||
return Context::getTextureGPUResourceMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size getTextureGPUResidentMemoryUsage() {
|
||||
return Context::getTextureGPUResidentMemoryUsage();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getTextureGPUFramebufferMemoryUsage() {
|
||||
return Context::getTextureGPUFramebufferMemoryUsage();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureGPUTransferCount() {
|
||||
return Context::getTextureGPUTransferCount();
|
||||
}
|
||||
|
||||
Texture::Size Texture::getAllowedGPUMemoryUsage() {
|
||||
return _allowedCPUMemoryUsage;
|
||||
|
@ -257,11 +220,11 @@ TexturePointer Texture::create(TextureUsageType usageType, Type type, const Elem
|
|||
|
||||
Texture::Texture(TextureUsageType usageType) :
|
||||
Resource(), _usageType(usageType) {
|
||||
_textureCPUCount++;
|
||||
_textureCPUCount.increment();
|
||||
}
|
||||
|
||||
Texture::~Texture() {
|
||||
_textureCPUCount--;
|
||||
_textureCPUCount.decrement();
|
||||
if (_usageType == TextureUsageType::EXTERNAL) {
|
||||
Texture::ExternalUpdates externalUpdates;
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "Forward.h"
|
||||
#include "Resource.h"
|
||||
#include "Metric.h"
|
||||
|
||||
const int ABSOLUTE_MAX_TEXTURE_NUM_PIXELS = 8192 * 8192;
|
||||
|
||||
|
@ -167,8 +168,9 @@ enum class TextureUsageType : uint8 {
|
|||
};
|
||||
|
||||
class Texture : public Resource {
|
||||
static std::atomic<uint32_t> _textureCPUCount;
|
||||
static std::atomic<Size> _textureCPUMemoryUsage;
|
||||
static ContextMetricCount _textureCPUCount;
|
||||
static ContextMetricSize _textureCPUMemSize;
|
||||
|
||||
static std::atomic<Size> _allowedCPUMemoryUsage;
|
||||
static std::atomic<bool> _enableSparseTextures;
|
||||
static void updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
@ -176,14 +178,8 @@ class Texture : public Resource {
|
|||
public:
|
||||
static const uint32_t CUBE_FACE_COUNT { 6 };
|
||||
static uint32_t getTextureCPUCount();
|
||||
static Size getTextureCPUMemoryUsage();
|
||||
static uint32_t getTextureGPUCount();
|
||||
static Size getTextureTransferPendingSize();
|
||||
static Size getTextureGPUMemoryUsage();
|
||||
static Size getTextureGPUResourceMemoryUsage();
|
||||
static Size getTextureGPUResidentMemoryUsage();
|
||||
static Size getTextureGPUFramebufferMemoryUsage();
|
||||
static uint32_t getTextureGPUTransferCount();
|
||||
static Size getTextureCPUMemSize();
|
||||
|
||||
static Size getAllowedGPUMemoryUsage();
|
||||
static void setAllowedGPUMemoryUsage(Size size);
|
||||
|
||||
|
|
|
@ -24,19 +24,22 @@ void EngineStats::run(const RenderContextPointer& renderContext) {
|
|||
auto config = std::static_pointer_cast<Config>(renderContext->jobConfig);
|
||||
|
||||
config->bufferCPUCount = gpu::Buffer::getBufferCPUCount();
|
||||
config->bufferGPUCount = gpu::Buffer::getBufferGPUCount();
|
||||
config->bufferCPUMemoryUsage = gpu::Buffer::getBufferCPUMemoryUsage();
|
||||
config->bufferGPUMemoryUsage = gpu::Buffer::getBufferGPUMemoryUsage();
|
||||
config->bufferGPUCount = gpu::Context::getBufferGPUCount();
|
||||
config->bufferCPUMemSize = gpu::Buffer::getBufferCPUMemSize();
|
||||
config->bufferGPUMemSize = gpu::Context::getBufferGPUMemSize();
|
||||
|
||||
config->textureCPUCount = gpu::Texture::getTextureCPUCount();
|
||||
config->textureGPUCount = gpu::Texture::getTextureGPUCount();
|
||||
config->textureCPUMemoryUsage = gpu::Texture::getTextureCPUMemoryUsage();
|
||||
config->textureGPUMemoryUsage = gpu::Texture::getTextureGPUMemoryUsage();
|
||||
config->textureGPUVirtualMemoryUsage = gpu::Texture::getTextureGPUVirtualMemoryUsage();
|
||||
config->textureGPUTransferCount = gpu::Texture::getTextureGPUTransferCount();
|
||||
config->textureTransferPendingSize = gpu::Texture::getTextureTransferPendingSize();
|
||||
config->textureGPUCount = gpu::Context::getTextureGPUCount();
|
||||
config->textureCPUMemSize = gpu::Texture::getTextureCPUMemSize();
|
||||
config->textureGPUMemSize = gpu::Context::getTextureGPUMemSize();
|
||||
|
||||
config->textureGPUFramebufferSize = gpu::Texture::getTextureGPUFramebufferMemoryUsage();
|
||||
config->textureResidentGPUMemSize = gpu::Context::getTextureResidentGPUMemSize();
|
||||
config->textureFramebufferGPUMemSize = gpu::Context::getTextureFramebufferGPUMemSize();
|
||||
config->textureResourceGPUMemSize = gpu::Context::getTextureResourceGPUMemSize();
|
||||
config->textureExternalGPUMemSize = gpu::Context::getTextureExternalGPUMemSize();
|
||||
|
||||
config->texturePendingGPUTransferCount = gpu::Context::getTexturePendingGPUTransferCount();
|
||||
config->texturePendingGPUTransferSize = gpu::Context::getTexturePendingGPUTransferMemSize();
|
||||
|
||||
renderContext->args->_context->getFrameStats(_gpuStats);
|
||||
|
||||
|
|
|
@ -26,19 +26,21 @@ namespace render {
|
|||
|
||||
Q_PROPERTY(quint32 bufferCPUCount MEMBER bufferCPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 bufferGPUCount MEMBER bufferGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferCPUMemoryUsage MEMBER bufferCPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferGPUMemoryUsage MEMBER bufferGPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferCPUMemSize MEMBER bufferCPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 bufferGPUMemSize MEMBER bufferGPUMemSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 textureCPUCount MEMBER textureCPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureGPUCount MEMBER textureGPUCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureCPUMemoryUsage MEMBER textureCPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUMemoryUsage MEMBER textureGPUMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUVirtualMemoryUsage MEMBER textureGPUVirtualMemoryUsage NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 textureGPUTransferCount MEMBER textureGPUTransferCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureCPUMemSize MEMBER textureCPUMemSize NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 textureGPUMemSize MEMBER textureGPUMemSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 textureTransferPendingSize MEMBER textureTransferPendingSize 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 textureGPUFramebufferSize MEMBER textureGPUFramebufferSize NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY dirty)
|
||||
Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY dirty)
|
||||
Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY dirty)
|
||||
|
@ -60,18 +62,19 @@ namespace render {
|
|||
|
||||
quint32 bufferCPUCount{ 0 };
|
||||
quint32 bufferGPUCount{ 0 };
|
||||
qint64 bufferCPUMemoryUsage{ 0 };
|
||||
qint64 bufferGPUMemoryUsage{ 0 };
|
||||
qint64 bufferCPUMemSize { 0 };
|
||||
qint64 bufferGPUMemSize { 0 };
|
||||
|
||||
quint32 textureCPUCount{ 0 };
|
||||
quint32 textureGPUCount{ 0 };
|
||||
qint64 textureCPUMemoryUsage{ 0 };
|
||||
qint64 textureGPUMemoryUsage{ 0 };
|
||||
qint64 textureGPUVirtualMemoryUsage{ 0 };
|
||||
quint32 textureGPUTransferCount { 0 };
|
||||
qint64 textureTransferPendingSize { 0 };
|
||||
|
||||
qint64 textureGPUFramebufferSize { 0 };
|
||||
qint64 textureCPUMemSize { 0 };
|
||||
qint64 textureGPUMemSize { 0 };
|
||||
qint64 textureResidentGPUMemSize { 0 };
|
||||
qint64 textureFramebufferGPUMemSize { 0 };
|
||||
qint64 textureResourceGPUMemSize { 0 };
|
||||
qint64 textureExternalGPUMemSize { 0 };
|
||||
quint32 texturePendingGPUTransferCount { 0 };
|
||||
qint64 texturePendingGPUTransferSize { 0 };
|
||||
|
||||
quint32 frameAPIDrawcallCount{ 0 };
|
||||
quint32 frameDrawcallCount{ 0 };
|
||||
|
|
|
@ -44,7 +44,7 @@ Item {
|
|||
color: "#1AC567"
|
||||
},
|
||||
{
|
||||
prop: "textureGPUTransferCount",
|
||||
prop: "texturePendingGPUTransferCount",
|
||||
label: "Transfer",
|
||||
color: "#9495FF"
|
||||
}
|
||||
|
@ -59,12 +59,12 @@ Item {
|
|||
valueNumDigits: "1"
|
||||
plots: [
|
||||
{
|
||||
prop: "textureCPUMemoryUsage",
|
||||
prop: "textureCPUMemSize",
|
||||
label: "CPU",
|
||||
color: "#00B4EF"
|
||||
},
|
||||
{
|
||||
prop: "textureGPUMemoryUsage",
|
||||
prop: "textureGPUMemSize",
|
||||
label: "GPU",
|
||||
color: "#1AC567"
|
||||
},
|
||||
|
@ -74,7 +74,17 @@ Item {
|
|||
color: "#9495FF"
|
||||
},
|
||||
{
|
||||
prop: "textureGPUFramebufferSize",
|
||||
prop: "textureResourceGPUMemSize",
|
||||
label: "Resource",
|
||||
color: "#1FC6A6"
|
||||
},
|
||||
{
|
||||
prop: "textureResidentGPUMemSize",
|
||||
label: "Resident",
|
||||
color: "#FF6309"
|
||||
},
|
||||
{
|
||||
prop: "textureFramebufferGPUMemSize",
|
||||
label: "Framebuffer",
|
||||
color: "#EF93D1"
|
||||
}
|
||||
|
|
|
@ -753,8 +753,8 @@ private:
|
|||
void updateText() {
|
||||
QString title = QString("FPS %1 Culling %2 TextureMemory GPU %3 CPU %4 Max GPU %5")
|
||||
.arg(_fps).arg(_cullingEnabled)
|
||||
.arg(toHumanSize(gpu::Context::getTextureGPUMemoryUsage(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getTextureCPUMemoryUsage(), 2))
|
||||
.arg(toHumanSize(gpu::Context::getTextureGPUMemSize(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getTextureCPUMemSize(), 2))
|
||||
.arg(toHumanSize(gpu::Texture::getAllowedGPUMemoryUsage(), 2));
|
||||
setTitle(title);
|
||||
#if 0
|
||||
|
|
Loading…
Reference in a new issue