Designing a flexible GPU abstraction (C++/OpenGL)

> Coding, hacking, computer graphics, game dev, and such...
User avatar
fips
Site Admin
Posts: 166
Joined: Wed Nov 12, 2008 9:49 pm
Location: Prague
Contact:

Designing a flexible GPU abstraction (C++/OpenGL)

Post by fips »

The image below shows a GPU abstraction that I use in my pet project. It gives a great flexibility as it's BLOB driven (to reduce API complexity together with the internal bookkeeping cost) and completely decouples the client from the GPU as the whole system interacts with the GPU at just a single well defined point (through the flush() function, which runs in a background thread, using a double-buffered Command_queue).

It's also very convenient that the client decides whether to push resource data into Graphics or keep it on its side. This allows, among other great things, to ask Graphics for a temporary resource index, which is valid for just a single frame and make a draw call using that index, so the client side doesn't need to care about resource lifetime management at all, which is very useful especially for immediate rendering.

Image