diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-03-16 10:42:12 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-03-18 22:59:20 +0300 |
commit | 7ee816e32f3655d4ca8abb555f885d8de9ba0520 (patch) | |
tree | 50190c369e80c20fadc1bc55d56f160188a1ff90 /source/blender/gpu/intern/gpu_storage_buffer.cc | |
parent | 5bd38f3be8542f09ece0d936b04dba3f8854cb51 (diff) |
GPU: StorageBuf: Add method to clear the buffer in place.
This is a faster way to clear a buffer instead of reuploading new data.
It is equivalent to `memset` and runs directly on the GPU.
This is better to clear huge buffers and to avoid the sync cost of data upload.
Diffstat (limited to 'source/blender/gpu/intern/gpu_storage_buffer.cc')
-rw-r--r-- | source/blender/gpu/intern/gpu_storage_buffer.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_storage_buffer.cc b/source/blender/gpu/intern/gpu_storage_buffer.cc index 3ea0bef5403..806acad90fe 100644 --- a/source/blender/gpu/intern/gpu_storage_buffer.cc +++ b/source/blender/gpu/intern/gpu_storage_buffer.cc @@ -89,4 +89,18 @@ void GPU_storagebuf_unbind_all() /* FIXME */ } +void GPU_storagebuf_clear(GPUStorageBuf *ssbo, + eGPUTextureFormat internal_format, + eGPUDataFormat data_format, + void *data) +{ + unwrap(ssbo)->clear(internal_format, data_format, data); +} + +void GPU_storagebuf_clear_to_zero(GPUStorageBuf *ssbo) +{ + uint32_t data = 0u; + GPU_storagebuf_clear(ssbo, GPU_R32UI, GPU_DATA_UINT, &data); +} + /** \} */ |