Implement batch constant buffer updates

Avoids spamming the driver with hundreds of cbuf updates per frame by batching all consecutive updates into one.
This commit is contained in:
Billy Laws
2022-04-17 00:35:00 +01:00
parent 02f99273ac
commit 32fe01e145
3 changed files with 44 additions and 7 deletions

View File

@ -698,7 +698,7 @@ namespace skyline::gpu::interconnect {
return constantBufferSelector;
}
void ConstantBufferUpdate(u32 data, u32 offset) {
void ConstantBufferUpdate(std::vector<u32> data, u32 offset) {
auto constantBuffer{GetConstantBufferSelector().value()};
auto& constantBufferView{constantBuffer.view};
{
@ -708,9 +708,9 @@ namespace skyline::gpu::interconnect {
constantBufferView.Write(span<u32>(data).cast<u8>(), offset);
}
executor.AddOutsideRpCommand([constantBufferView, data, offset](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr<FenceCycle> &cycle, GPU &) {
executor.AddOutsideRpCommand([constantBufferView, data = std::move(data), offset](vk::raii::CommandBuffer &commandBuffer, const std::shared_ptr<FenceCycle> &cycle, GPU &) {
std::scoped_lock lock{constantBufferView};
commandBuffer.updateBuffer<u32>(constantBufferView->buffer->GetBacking(), constantBufferView->view->offset + offset, vk::ArrayProxy(1, &data));
commandBuffer.updateBuffer<u32>(constantBufferView->buffer->GetBacking(), constantBufferView->view->offset + offset, vk::ArrayProxy(static_cast<u32>(data.size()), data.data()));
});
}