SDL_gpu Basics for FFI Users

I’m using SDL3 through my own FFI bindings. I want to emphasize the GPU API, but I’m having trouble understanding the C examples of its use. Is there a guide for using the GPU API outside of a C/C++ environment? How about a “getting started” workflow for a 3D game?

Not having played with SDL3 GPU API myself just-yet (will shortly), I can say this: as you probably picked up, the API mirrors the basic building blocks / hardware abstractions / workflows broadly common to all the “modern, low-level graphics APIs” as in Vulkan, Metal and (I guess) DX12. (“Low level” as compared to OpenGL or older D3D incarnations.) As such, my approach would be (and will be) to follow Vulkan and/or Metal tutorials and translate those to the SDL3 GPU equivalents, as far as possible, but from my current vantage and given the newness of the GPU API (not a lot of vids or tuts out there on it yet) it looks like the most promising direction.

“Outside a C/C++ environment” shouldn’t matter much, since you’re used to FFI then you know that C is “just functions, structs and pointers” and so surely the GPU API would look exactly the same on the other side of the FFI?

The problem is that the standard GPU API examples bundle a lot of things together all at once, so it’s difficult to follow. A lot of essential code is contained in “common.h”, and there are a lot of callbacks flying around. It’s hard to approach this from outside an FFI boundary.

EDIT: these are the examples I’m talking about:

Most of the examples use three simple Common.c functions… CommonInit, LoadShader, and LoadImage. We also don’t use callbacks at all in the API so I’m not sure what you’re referring to.

GPU programming involves setting up quite a bit of state. That’s just how it is.

I was confused. There are some function pointers used for switching between examples. Any idea how to learn the various state-setting functions? What’s a good reproducible approach to setting up a GPU pipeline? I’m very new to this.

I’d say any not-toooo-minimalist Vulkan-or-Metal-or-DX12 multi-lesson tutorial out there should cover this, and be broadly (except for minute or moniker differences) applicable and transferable to the others and thus to SDL3 GPU.