SDL GPU update... (Patreon)
Content
(Quick patron-only upkeep: I'm up to thirteen videos in this "build WinAmp with SDL2" YouTube series; if you want your name in the credits on the fourteenth, click through here. Thanks!)
So the Epic MegaGrant work is starting to make some progress, so I'm going to talk about it quickly.
I scratched out the initial API, which you can see here, and depending on when you click that link, it might look wildly different...but I think it's settling into the sort of thing I want it to be now.
So having that rough idea of an interface, I starting writing small apps to see if it sucked to use it, before actually implementing it, finding out I hate it, and throwing it out. I've never done it this way before, and it's sort of interesting. You write a little app, feel around with your hands in the dark, and make little notes on the map you're using as you try to navigate through.
Some APIs changed a little ("oh, that doesn't cover this use-case"), some changed a lot ("oh, that doesn't work at all"), sometimes the API was okay but generated a bunch of obvious boilerplate, so I slotted in some helper functions that aren't required but can make it easier to build things.
So here are some examples.
First, it's important to consider SDL's Vulkan test app, where at over 1100 lines of C, we still weren't drawing anything and just left it at clearing the window to a solid color.
https://github.com/icculus/SDL/blob/gpu-api/test/testvulkan.c
Here's the same thing with the new API, which isn't Vulkan-specific and does the same thing in under 150 lines of code:
https://github.com/icculus/SDL/blob/gpu-api/test/testgpu_simple_clear.c
But since I had all these extra lines of code I wasn't using, I also rewrote the GLES2 test app...
https://github.com/icculus/SDL/blob/gpu-api/test/testgles2.c
...which now looks like this:
https://github.com/icculus/SDL/blob/gpu-api/test/testgpu_spinning_cube.c
This is slightly smaller, although (outside of the Vulkan levels of verbosity) I don't feel this is the most important metric. I do like that you can get access to shaders and vertex buffers and such without having to target a specific API, and that it feeds the hardware like modern GPUs expect is an added plus.
This has a long way to go--these are test apps that compile but fail to link because the APIs do not exist yet--but it's starting to have the feel I want, so we can start to move forward on implementation soon.
There are still a ton of decisions to make, some of them big, but this is progress, and progress is good.