Bug 198684
Summary: | [WebGPU] Performance: Cache staging MTLBuffers used by GPUBuffer.unmap | ||
---|---|---|---|
Product: | WebKit | Reporter: | Justin Fan <justin_fan> |
Component: | WebGPU | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW | ||
Severity: | Normal | CC: | webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Justin Fan
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/51539224>
Radar WebKit Bug Importer
<rdar://problem/51539225>
Justin Fan
Small addition: Specify MTLResourceCPUCacheModeWriteCombined in the creation option for these staging buffers, as the CPU never reads from them.