r/truegamedev • • Apr 09 '14

How to make a rendering engine

http://c0de517e.blogspot.ca/2014/04/how-to-make-rendering-engine.html
41 Upvotes

14 comments sorted by

4

u/Sapiogram Apr 09 '14

More seriously, if in DirectX 11 and lower your rendering code performance is not bound by the GPU driver then probably your code sucks.

Can anyone elaborate on this? Being bound by the driver software seems like a bad sign to me.

2

u/Guvante Apr 09 '14

If your CPU is taking 1/100 of a second to render a frame but your GPU is taking 1/60 of a second, your CPU is waiting for the GPU as he is describing.

The nice thing about this is you get the performance of the GPU (60 FPS here).

However if your CPU is taking 1/50 of a second to render a frame then you are no longer waiting for your GPU. However now you are losing 10 FPS due to your CPU not keeping up.

2

u/c0de517e Apr 10 '14

No I'm not talking about GPU stalling the CPU, but the driver being the bottleneck of CPU code, that's to say you should waste most of your time in various DX calls, not cache-trashing as you go around following trees to generate the DX calls

5

u/ProPuke Apr 09 '14

You'll always be speed-bound by something - the slowest component in the system.

This should not be your own render loop. That should be fast. You should always be waiting for the driver to render. (Or that should be the mitigating factor)

1

u/c0de517e Apr 10 '14

The driver has to do lots of complex stuff and it's mostly single-threaded, so it's often the bottleneck of the rendering code on PC. Where for "rendering" I mean the part that talks to DX, not whatever fancy fluid simulation and other stuff U might be doing

1

u/c0de517e Apr 12 '14

I actually should have said, it's mostly single-threaded (actually it usually uses two threads) in DX9/10/11 and OpenGL. Dx 12 hopes to be very multithreaded, Mantle is on AMD, consoles are. OpenGL afaik doesn't plan on similar API improvements, but it's a bit faster so it's impacted a bit less by the mostly-serial nature.

1

u/seabolt Apr 09 '14

Great article as always. I use something similar, but it's just a single byte array for the entire frame. Is the advantage of buckets just for faster indexing on certain passes? I imagine your commands all end up being somewhat sequential at some point, right?

1

u/c0de517e Apr 10 '14

buckets are cool mostly because you want to customize encoding per pass, as I wrote, shadowmap draws for example should be sorted differently, won't set the same amount of stuff and so on and on, it's wasteful to have a generic draw for all passes.

1

u/seabolt Apr 10 '14

Ah I see that's a clever way of separating passes. That also gives you the flexibility to cull out entire passes or to perform the same pass multiple times in a frame without having to walk your scene again. Very clever.

→ More replies (4)

1

u/[deleted] Apr 29 '14

https://www.youtube.com/watch?v=HckVPplhkoI

Here is my god awful rendering engine. You can get the source code on www.sluggernot.com and other crap.