TinyRenderer – how OpenGL works: software rendering in 500 lines of code
github.com
github.com
If you want to understand how the GPU driver thinks under the hood read through https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-...
If you want to see the OpenGL state machine in action, check out https://webglfundamentals.org/webgl/lessons/resources/webgl-...
It's more like you have a fairly high number of cores each of which consists of a large number (typically 32 or 64) of ALUs executing the same instructions in parallel.
This means that while you cannot execute a thousand different instructions in parallel you can in theory run somewhere between tens and hundreds of different instructions each across 32 or 64 different sets of input data.
The GPU does not need high single-thread performance so it has lots of simpler and smaller cores, and as a result the total IPC goes way up.
And then of course the GPU has dedicated hardware for operations like rasterization and texture interpolation which the CPU lacks. On the other hand, the CPU needs to run an OS so each core has support for virtual memory, interrupts and other types of instructions that are either not needed on the GPU or at least do not need to be supported by each one of the little cores and are handled in a more global manner, making these cores even smaller.
I'd not come across the state machine site before, it looks pretty useful.
Man, it was impossible to find a decent OpenGL tutorial in 2008.
https://nehe.gamedev.net/tutorial/playing_avi_files_in_openg...
Of course, now everyone who does SIMD writes it with compiler intrinsics or some code wrapper that generates terrible asm which really is slower, but they think it's "cleaner". (Which on Intel it isn't, because their intrinsics are even less readable than their asm.)
I used to go through these, and other similar sites.. Which reminded me of Sulaco [1] :(
I remember loving his stuff, especially as I too was involved in quake modding and 3d engines at the time.
RIP.
1: http://www.sulaco.co.za/news_in_loving_memory_of_jan_horn.ht...
Highly recommend.
[1] https://www.rayvertex.com/ [2] https://github.com/tylermorganwall/rayvertex
Will be the case though, since I never really know how GPU are made and wired, and what their constraints are?
GPU often had a lot of "fixed" computing capabilities, meaning you have to do things in a certain way to exploit its performance, but with Vulkan being too complex, and chips getting more and more transistors, maybe a day will come where GPUs can finally become easier to program, at the expense of top performance, a bit like interpreted languages being slower to run but faster to write with. In the software industry, it was always better to use faster computers and write less than optimal programs, because chips are always cheaper than developers.
I guess most game developers would gladly want to use a GPU for a fraction of the performance, if it was just easier to program with. Modern GPU are so fast that it would feel okay to use 5 or 10% of the speed if it meant not having to deal with vulkan or shaders.
Didn't succeed at the time. Maybe it'll happen one day. Or maybe not.
If Vulkan and co. are too difficult personally I suspect it's more fruitful to build better abstractions on top of the underlying constraints dictated by the need for massive parallelism, not trying to make the x86-style programming paradigms fast enough for graphics-type workloads.
I think this also informs recent academic work on RISC-V based GPU work such as RV64X. These are mostly a lot of generic cores with just a little graphics hardware added. The results are not yet compelling compared with shipping GPUs, but I think it's a promising approach.
[1]: https://research.nvidia.com/publication/high-performance-sof...
Cell was originally supposed to act as both the CPU and GPU on the PS3, but that plan didn’t pan out in the actual hardware and Sony scrambled to include an Nvidia GPU.
Very little of that goes away as the GPU becomes more programmable / powerful. Rather it gets ever more complicated, as suddenly a texture isn't just a texture anymore. It's now a buffer. And buffers can be used for lots of things. This complexity really could only go away if the GPU & CPU merged into a single unit, which isn't entirely unlike Intel's failed Larrabee as a sibling comment mentioned.
As for shaders, those are just arbitrary programs. The complexity there is entirely the complexity of whatever your renderer does, compounded by the extreme parallelism of a GPU. So this complexity really never goes away.
For your core question, the problem is that fixed function hardware is just always faster & more efficient than a programmable one. So as long as games commonly do the same set of easily ASIC-able work (like render triangles), then you really won't ever see that fixed-function unit go away. But something like Unreal Engine 5's Nanite is kinda the productization of the idea of doing triangle rasterization in a "software" renderer instead of the fixed-function parts of the GPU: https://www.unrealengine.com/en-US/blog/understanding-nanite...
https://developer.apple.com/documentation/metal/setting_reso...
And there's also the complexity of things like Vulkan want to work on both unified and non-unified systems.
Also unified doesn't necessarily mean coherent, so there's additional complexities there.
Does anyone here know of something of similar good-quality OpenGL resources[1] for mathematical/scientific visualization[2]. Currently, I've started going through the source codes and documentation of manim-web[3] and CindyJs[4] to learn the basics; however, I would love to learn the fundamentals and be able to write my own visualization library (or confidently be able to extend an existing one) if/when needed. Thanks in advance.
---
[1] - Personally I prefer books but I don't mind any other high-quality resources something similar to the one OP has shared here.
[2] - https://github.com/topics/scientific-visualization
Well, this wasn't the case for all my Amiga 500 optimization efforts back then in the early 90th. Mix that with machine language and you simply hate yourself a couple of weeks/months/years/decades later, when you simply do not understand what you were doing at the time of writing the code, even though you commented it.
While I really enjoyed pushing the technical limits for fun and visual effects, too much trickery killed understanding and I am glad to use compilers nowadays. It is like plain text vs encrypted text going though my old source code. Very hard to read, very hard to understand.