Add buffer stats to love.graphics.getStats.

- Add 'buffers' field, to count the total number of graphics buffer objects.
- Add 'buffermemory' field, to estimate the total number of bytes of graphics memory used by all buffers.
This commit is contained in:
Sasha Szpakowski
2023-12-25 23:25:46 +01:00
parent 9c6417776f
commit e42019c59e
5 changed files with 23 additions and 2 deletions
+8
View File
@@ -29,6 +29,9 @@ namespace graphics
love::Type Buffer::type("GraphicsBuffer", &Object::type);
int Buffer::bufferCount = 0;
int64 Buffer::totalGraphicsMemory = 0;
Buffer::Buffer(Graphics *gfx, const Settings &settings, const std::vector<DataDeclaration> &bufferformat, size_t size, size_t arraylength)
: arrayLength(0)
, arrayStride(0)
@@ -240,10 +243,15 @@ Buffer::Buffer(Graphics *gfx, const Settings &settings, const std::vector<DataDe
if (texelbuffer && arraylength * dataMembers.size() > caps.limits[Graphics::LIMIT_TEXEL_BUFFER_SIZE])
throw love::Exception("Cannot create texel buffer: total number of values in the buffer (%d * %d) is too large for this system (maximum %d).",
(int) dataMembers.size(), (int) arraylength, caps.limits[Graphics::LIMIT_TEXEL_BUFFER_SIZE]);
++bufferCount;
totalGraphicsMemory += size;
}
Buffer::~Buffer()
{
totalGraphicsMemory -= size;
--bufferCount;
}
int Buffer::getDataMemberIndex(const std::string &name) const