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:
42
src/mbgl/vulkan/uniform_buffer.cpp
Normal file
42
src/mbgl/vulkan/uniform_buffer.cpp
Normal 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
|
||||
Reference in New Issue
Block a user