r/GraphicsProgramming • u/wojti_zielon • Dec 23 '20
Efficient CPU rasterizer. I decided to improve my C++ skills by implementing a rasterizer which uses AVX2 8 pixels. Together with other optimization methods (tiled rendering, lock-free threading) I got this results. Maybe some of you would like to join project and explore more? Link in the comment.
14
u/Deadly_Mindbeam Dec 23 '20
Very impressive. That's months of work at my pace. And I don't see any rasterization artifacts, which is a big accomplishment :)
2
3
u/obp5599 Dec 23 '20
Why lock free threading? Seems people think locks are the boogy man
9
u/hyperchromatica Dec 24 '20
I mean if you can do it without leaving any threads waiting thats better utilization and less wasted context switches.
6
u/felipunkerito Dec 23 '20
Can you elaborate? Legit won't get why wouldn't it be better to have lockless threading, but my stupid ass maybe missing something.
14
u/obp5599 Dec 23 '20 edited Dec 24 '20
Its overly complicated and extremely bug prone. Also incredibly hard to debug when there is one. Not worth the upkeep imo.
We banned it at my work because people try to show off their fancy lockless stuff and it always breaks
2
u/felipunkerito Dec 23 '20
That makes sense! Same train of thought at my workplace: no raw pointers... To be a real reddit user: happy cake day!
2
u/moon-chilled Dec 24 '20 edited Dec 24 '20
Eh, I recently worked on a codebase that used locks to protect reference counts.
...yeah
1
Dec 24 '20
Wait, why is that bad?
1
u/RaptorDotCpp Dec 24 '20
Not OP, and it's been many many years since I did any concurrent programming, but I think you would rather just use atomic volatile reference counters.
But again, I'm not sure because it's been so long.
1
u/moon-chilled Dec 24 '20
Not volatile; just atomic. The compiler understands the rules for reordering stores/loads of atomics.
1
u/moon-chilled Dec 24 '20
It's incredibly wasteful, and an atomic will do just as well.
There may be an argument to be made for locks over atomics when implementing more complex algorithms; but this is not one such.
7
u/wojti_zielon Dec 23 '20
Link to the repo https://github.com/Zielon/CPURasterizer