Whats faster Updating a Vertex Buffer or a StorageBuffer?

With webGPU which is faster? Im assuming its essentially the same thing.

claude.ai:

Let me help explain the performance characteristics of Vertex Buffers versus Storage Buffers.

In general, Storage Buffers tend to be faster for frequent updates compared to Vertex Buffers, especially when using persistent mapping. Here’s why:

  1. Vertex Buffer updates usually involve:
  • Synchronization overhead to ensure GPU isn’t reading while CPU writes
  • Memory copy operations between staging and device memory
  • Potential pipeline stalls waiting for vertex data
  1. Storage Buffer advantages:
  • Can be persistently mapped for direct CPU writes
  • Often utilizes host-coherent memory
  • Better suited for dynamic data that changes frequently
  • Less synchronization overhead when properly managed

However, some important caveats:

  • The actual performance depends heavily on your specific hardware and driver
  • Vertex Buffers are still optimal for static geometry
  • Using Buffer Device Address (BDA) feature can improve Storage Buffer performance further
  • Some architectures might have special optimizations for vertex data

Me: write me a benchmark example in babylon.js

Claude:
benchmark | Babylon.js Playground

Result:

Starting Vertex Buffer test…
VM80:72 Vertex Buffer Updates: 562.50ms
VM80:73 Average update time: 0.56ms
VM80:95 Starting Transform Node test…
VM80:108 Transform Node Updates: 2823.50ms
VM80:109 Average update time: 2.82ms
VM80:128
Benchmark Results:
VM80:129 Vertex Buffer total time: 562.50ms
VM80:130 Transform Node total time: 2823.50ms
VM80:131 Performance difference: 19.92%

4 Likes

See my answer in your other thread, a good place to ask this question would be the Matrix channel: https://app.element.io/#/room/#WebGPU:matrix.org