Reuse allocated descriptor sets (#3002)

This commit is contained in:
Adrian Cojocaru
2024-11-12 22:19:20 +02:00
committed by GitHub
parent c613731e3d
commit b30397005c
11 changed files with 128 additions and 22 deletions

View File

@@ -3,6 +3,7 @@
#include <mbgl/vulkan/context.hpp>
#include <mbgl/vulkan/renderer_backend.hpp>
#include <mbgl/util/logging.hpp>
#include <mbgl/util/instrumentation.hpp>
#include <algorithm>
@@ -48,6 +49,8 @@ BufferResource::BufferResource(
size(size_),
usage(usage_),
persistent(persistent_) {
MLN_TRACE_FUNC();
const auto& allocator = context.getBackend().getAllocator();
std::size_t totalSize = size;
@@ -141,6 +144,8 @@ BufferResource& BufferResource::operator=(BufferResource&& other) noexcept {
}
void BufferResource::update(const void* newData, std::size_t updateSize, std::size_t offset) noexcept {
MLN_TRACE_FUNC();
assert(updateSize + offset <= size);
updateSize = std::min(updateSize, size - offset);
if (updateSize <= 0) {