UBO consolidation (#3089)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Alex Cristici
2025-01-08 17:41:29 +02:00
committed by GitHub
parent cf9f41cf61
commit f582327191
262 changed files with 6968 additions and 6928 deletions

View File

@@ -25,18 +25,18 @@ UniformBuffer::~UniformBuffer() {
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_));
void UniformBuffer::update(const void* data, std::size_t dataSize) {
assert(dataSize <= size);
if (dataSize > size || dataSize > buffer.getSizeInBytes()) {
Log::Error(Event::General,
"Mismatched size given to UBO update, expected max " + std::to_string(size) + ", got " +
std::to_string(dataSize));
return;
}
buffer.getContext().renderingStats().numUniformUpdates++;
buffer.getContext().renderingStats().uniformUpdateBytes += size_;
buffer.update(data, size, /*offset=*/0);
buffer.getContext().renderingStats().uniformUpdateBytes += dataSize;
buffer.update(data, dataSize, /*offset=*/0);
}
const std::shared_ptr<gfx::UniformBuffer>& UniformBufferArray::set(const size_t id,
@@ -73,7 +73,7 @@ void UniformBufferArray::bindDescriptorSets(CommandEncoder& encoder) {
descriptorSet = std::make_unique<UniformDescriptorSet>(encoder.getContext(), descriptorSetType);
}
descriptorSet->update(*this, descriptorStartIndex, descriptorBindingCount);
descriptorSet->update(*this, descriptorStartIndex, descriptorStorageCount, descriptorUniformCount);
descriptorSet->bind(encoder);
}