Vulkan renderer backend (#2564)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
Adrian Cojocaru
2024-08-01 22:49:49 +03:00
committed by GitHub
parent 88993b9420
commit 072aa32e8b
103 changed files with 11459 additions and 135 deletions

View File

@@ -0,0 +1,42 @@
#include <mbgl/vulkan/uniform_buffer.hpp>
#include <mbgl/vulkan/context.hpp>
#include <mbgl/util/logging.hpp>
#include <cassert>
namespace mbgl {
namespace vulkan {
UniformBuffer::UniformBuffer(BufferResource&& buffer_)
: gfx::UniformBuffer(buffer_.getSizeInBytes()),
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()) {
Log::Error(
Event::General,
"Mismatched size given to UBO update, expected " + std::to_string(size) + ", got " + std::to_string(size_));
return;
}
buffer.getContext().renderingStats().numUniformUpdates++;
buffer.getContext().renderingStats().uniformUpdateBytes += size_;
buffer.update(data, size, /*offset=*/0);
}
} // namespace vulkan
} // namespace mbgl