NEW 198684
[WebGPU] Performance: Cache staging MTLBuffers used by GPUBuffer.unmap
https://bugs.webkit.org/show_bug.cgi?id=198684
Summary [WebGPU] Performance: Cache staging MTLBuffers used by GPUBuffer.unmap
Justin Fan
Reported 2019-06-07 15:55:28 PDT
GPUBuffers created with GPUDevice.createBufferMapped are not CPU-accessible if they are not created with MAP_WRITE or MAP_READ usage. This necessitates a copy of written data to a CPU/GPU shared MTLBuffer, before copying this staging buffer to the intended destination on the GPU, during the call to GPUBuffer.unmap. Since MTLBuffer creation is expensive, we can cache reasonably-sized (TBD size) staging buffers for re-use on the GPUDevice. A GPUBuffer can re-use the device's staging buffer for its unmap call, or create a new one if one does not exist or is too small. If the staging buffer is not used within a certain time (TBD, i.e. ~10 frames), it is released. Bonus points: implement a (sorted?) LRU-cache of different-sized staging buffers and use the smallest one that will suffice. This would release unusually large staging buffers earlier, but require more storage overall.
Attachments
Radar WebKit Bug Importer
Comment 1 2019-06-07 15:58:48 PDT
Radar WebKit Bug Importer
Comment 2 2019-06-07 15:58:48 PDT
Justin Fan
Comment 3 2019-06-07 16:00:33 PDT
Small addition: Specify MTLResourceCPUCacheModeWriteCombined in the creation option for these staging buffers, as the CPU never reads from them.
Note You need to log in before you can comment on or make changes to this bug.