diff options
| author | Dario <dariosamo@gmail.com> | 2023-08-08 14:41:34 -0300 |
|---|---|---|
| committer | Dario <dariosamo@gmail.com> | 2023-08-12 09:38:39 -0300 |
| commit | 0d7deca4e278e28d5707d941790d4a99a663d9be (patch) | |
| tree | 294717182fac9330cb0e2e105ed2af0fb574cdfb /servers/rendering/renderer_rd/storage_rd | |
| parent | 4714e95896c8db02616ea6ec7f9aff92dec1cae4 (diff) | |
| download | redot-engine-0d7deca4e278e28d5707d941790d4a99a663d9be.tar.gz | |
Add buffer_copy method to RenderingDevice interface and an implementation for the Vulkan driver.
Direct buffer copies are required to perform certain operations more efficiently, as the only current alternative is to download the buffer to the CPU and upload it again. As the first use case, the new function is used when enabling motion vectors on multimeshes.
Diffstat (limited to 'servers/rendering/renderer_rd/storage_rd')
| -rw-r--r-- | servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp index 4bfec8ae8d..97fc38fab4 100644 --- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp +++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp @@ -1309,13 +1309,10 @@ void MeshStorage::_multimesh_enable_motion_vectors(MultiMesh *multimesh) { RID new_buffer = RD::get_singleton()->storage_buffer_create(new_buffer_size); if (multimesh->buffer_set && multimesh->data_cache.is_empty()) { - // If the buffer was set but there's no data cached in the CPU, we must download it from the GPU and - // upload it because RD does not provide a way to copy the buffer directly yet. + // If the buffer was set but there's no data cached in the CPU, we copy the buffer directly on the GPU. RD::get_singleton()->barrier(); - Vector<uint8_t> buffer_data = RD::get_singleton()->buffer_get_data(multimesh->buffer); - ERR_FAIL_COND(buffer_data.size() != int(buffer_size)); - RD::get_singleton()->buffer_update(new_buffer, 0, buffer_size, buffer_data.ptr(), RD::BARRIER_MASK_NO_BARRIER); - RD::get_singleton()->buffer_update(new_buffer, buffer_size, buffer_size, buffer_data.ptr()); + RD::get_singleton()->buffer_copy(multimesh->buffer, new_buffer, 0, 0, buffer_size, RD::BARRIER_MASK_NO_BARRIER); + RD::get_singleton()->buffer_copy(multimesh->buffer, new_buffer, 0, buffer_size, buffer_size); } else if (!multimesh->data_cache.is_empty()) { // Simply upload the data cached in the CPU, which should already be doubled in size. ERR_FAIL_COND(multimesh->data_cache.size() != int(new_buffer_size)); |
