diff --git a/src/modules/graphics/Buffer.cpp b/src/modules/graphics/Buffer.cpp index 8cb3cf797..c9c9828f1 100644 --- a/src/modules/graphics/Buffer.cpp +++ b/src/modules/graphics/Buffer.cpp @@ -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 &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 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 diff --git a/src/modules/graphics/Buffer.h b/src/modules/graphics/Buffer.h index 1afa6c6b1..51717c7f5 100644 --- a/src/modules/graphics/Buffer.h +++ b/src/modules/graphics/Buffer.h @@ -49,6 +49,9 @@ public: static love::Type type; + static int bufferCount; + static int64 totalGraphicsMemory; + static const size_t SHADER_STORAGE_BUFFER_MAX_STRIDE = 2048; enum MapType diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 4704daabc..c06cf548e 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -2422,8 +2422,10 @@ Graphics::Stats Graphics::getStats() const stats.drawCallsBatched = drawCallsBatched; stats.textures = Texture::textureCount; stats.fonts = Font::fontCount; + stats.buffers = Buffer::bufferCount; stats.textureMemory = Texture::totalGraphicsMemory; - + stats.bufferMemory = Buffer::totalGraphicsMemory; + return stats; } diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 32ac208b0..320e95497 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -230,7 +230,9 @@ public: int shaderSwitches; int textures; int fonts; + int buffers; int64 textureMemory; + int64 bufferMemory; }; struct DrawCommand diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index bc92aa97e..ef879fc2f 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -3005,9 +3005,15 @@ int w_getStats(lua_State *L) lua_pushinteger(L, stats.fonts); lua_setfield(L, -2, "fonts"); - lua_pushinteger(L, stats.textureMemory); + lua_pushinteger(L, stats.buffers); + lua_setfield(L, -2, "buffers"); + + lua_pushnumber(L, (lua_Number) stats.textureMemory); lua_setfield(L, -2, "texturememory"); + lua_pushnumber(L, (lua_Number) stats.bufferMemory); + lua_setfield(L, -2, "buffermemory"); + return 1; }