Hacker News new | ask | show | jobs
by sqrt_1 1511 days ago
I assume each sprite is moved on the CPU and the position data is passed to the GPU for rendering.

Curious how you are passing the data to the GPU - are you having a single dynamic vertex buffer that is uploaded each frame?

Is the vertex data a single position and the GPU is generating the quad from this?

2 comments

You can do it in SO many ways! You can have one vertex buffer or double buffer it, or you can run the entire simulation on the GPU too. In general, uploading data to the GPU can be the slowest part. OpenGL, and more modern Graphics APIs have evolved in the direction of minimizing the communication between CPU and GPU since it is almost always a big bottle neck. Modern GPUs are designed to manage themselves with work queues, local data and sometimes even local storage to avoid the need to interact with the CPU.
you can write 100% of the code on the gpu. but that's impractical to work with. i did that here to see how fast webgl can go, since javascript is so slow https://www.youtube.com/watch?v=UNX4PR92BpI

for this bunnymark i have 1 VBO containing my 200k bunnies array (just positions). and 1 VBO containing just the 6 verts required to render a quad. turns out the VAO can just read from both of them like that. the processing is all on the CPU and just overwrites the bunnies VBO each frame