The creation of a GPU pipeline via SDL_GPUGraphicsPipelineCreateInfo requires a struct of type SDL_GPUDepthStencilState descrbing the dept-stencil state. The wiki gives a vague
“A structure specifying the parameters of the graphics pipeline depth stencil state.”
as an explanation for this struct but I don’t quite get what this is. What even is a depth-stencil state? What do all of its fields mean? Where does a depth-stencil state even fit inside the vertex shader to fragment shader pipeline?
In my case, I am just trying to learn how to make a 2D sprite renderer using the GPU. How should I use the depth-stencil state?
I am just trying to learn how to make a 2D sprite renderer using the GPU.
I don’t know the answer, I just want to point out that the simpler Render API will also use the GPU (assuming you don’t intentionally create a software renderer) so if all you want to do is draw 2D sprites with simple transformations like rotation, stretching and flipping then there is no need for the more complicated “GPU API”.
I also haven’t delved deep into SDL’s 3D GPU API yet. Personally I like making stuff with the 2D API too much and might never get to the 3D part.
Here’s a good example of where and how a depth-stencil could be used. This example is in OpenGL, but I’m pretty sure the idea caries over smoothly into SDL’s definition (I haven’t tried it myself, so I can’t guarantee similar execution between the two API).
In the example depth stencils determine situations of occlusion and are used to help simulate a reflection.