1
\$\begingroup\$

Let's say I am implementing a simple game engine, particularly the rendering part. From the high-level view we have some vertices which are copied to the graphics card alongside shader information etc.

I do not really understand how this is done in a performant manner: Consider a basic OpenGL program (and all the tutorials or whatever I could find out there) which copies all the vertices to the graphics card at each draw call. This seems to be a lot of work.

And as far as I understand if I am doing some kind of third person game, for example, I have to copy every vertex of the character at each draw call (and possibly more). Even though the world is static and the character is representing only a small amount, this still seems to be a lot.

Do game engines apply some kind of "caching" here, to make sure they only copy what has actually changed, or is this a rather mindless copy of everything, and the performance is not such a big deal?

Essentially I want to learn about some kind of architectural choices concerning this vertex copy operation, however I cannot seem to find the right resources. Thank you for any input you could provide.

\$\endgroup\$
1
\$\begingroup\$

Usually games and game engines will upload vertices, textures and other render-relevant data to the graphic card once by putting it into buffers. Those then stay in the GPU RAM until the game tells the GPU it won't need that data anymore. This is the reason why graphic cards require several GB or RAM: So games do not need to pass all the vertices through the PCIe bus on every single frame.

When the game wants the GPU to render something, it just tells it which vertex- and pixel shader programs to run and which previously uploaded buffer(s) to use for that run. Position and orientation of the object(s) are usually communicated to the GPU by sending a projection matrix for that draw-call.

Skelettal animation is often also handled on the GPU. The CPU only tells the GPU the bone rotations and IK target locations for each frame. The GPU will then use that information to transform the mesh vertices before rendering the mesh.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It's also worth observing that for simpler games it's actually not that large an overhead to transfer all vertices each frame, and up to late 90s/early 2000s it was the only way. So if you see a game from that time period, you can logically conclude that it was able to handle it's level of geometric complexity despite transferring all vertices each frame. \$\endgroup\$ – Maximus Minimus Feb 3 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.