Metal stats (#1781)

This commit is contained in:
Tim Sylvester
2023-10-20 15:45:08 -07:00
committed by GitHub
parent 07c70fe1c8
commit 1a1c826fa4
28 changed files with 347 additions and 116 deletions

View File

@@ -1,5 +1,6 @@
#include <mbgl/mtl/uniform_buffer.hpp>
#include <mbgl/mtl/context.hpp>
#include <mbgl/util/logging.hpp>
#include <cassert>
@@ -9,11 +10,20 @@ namespace mtl {
UniformBuffer::UniformBuffer(BufferResource&& buffer_)
: gfx::UniformBuffer(buffer_.getSizeInBytes()),
buffer(std::move(buffer_)) {}
buffer(std::move(buffer_)) {
buffer.getContext().renderingStats().numUniformBuffers++;
buffer.getContext().renderingStats().memUniformBuffers += size;
}
UniformBuffer::UniformBuffer(UniformBuffer&& other)
: gfx::UniformBuffer(std::move(other)),
buffer(std::move(other.buffer)) {}
UniformBuffer::~UniformBuffer() {
buffer.getContext().renderingStats().numUniformBuffers--;
buffer.getContext().renderingStats().memUniformBuffers -= size;
}
void UniformBuffer::update(const void* data, std::size_t size_) {
assert(size == size_);
if (size != size_ || size != buffer.getSizeInBytes()) {
@@ -23,6 +33,8 @@ void UniformBuffer::update(const void* data, std::size_t size_) {
return;
}
buffer.getContext().renderingStats().numUniformUpdates++;
buffer.getContext().renderingStats().uniformUpdateBytes += size_;
buffer.update(data, size, /*offset=*/0);
}