r/GraphicsProgramming • • Oct 18 '26

Progress on Software Rendered game in C

This is some progress of a free game i have been working. This is fully software rendered on the CPU and OpenGL is only used to render the image. I use multiple threads to render the game at full 1080p. Using SIMD instructions helps a lot to get a decent frame rate. But i am still kinda dissapointed by the performance, i think Michael Abrash's binning technique would improve it, but right now, it is decent. I am getting around 70-140 frames with I5-12400.

502 Upvotes

34 comments sorted by

View all comments

Show parent comment

1

u/deftware Oct 20 '26

OpenGL is less boilerplate, for one - and since all that OP is doing is taking a buffer of pixels and putting it onscreen, it almost makes no difference what API you use. Pixel Buffer Objects allow for asynchronous transfer so it's going to be pretty quick, minimal API calls on the whole. I would be very surprised if there was any performance difference between DX12/VK/GL.

2

u/iRainbowsaur Oct 21 '26 edited Oct 21 '26

Ohhh, thats right vulkan is only good when you absolutely need more cpu overhead room, because it can essentially send stuff more efficiently to the gpu. But since nothing leaves it, it doesn't matter in a sense? and all the shit you have to deal with in vulkan is essentially useless ey?

My dumb ass needs to learn more. I am very niave on this. Shows how little I know, but yeah this is neat.

I have much to learn.

2

u/deftware Oct 21 '26

Yeah, basically if you are drawing a bunch of stuff and having the GPU change state to do all kinds of things then a thinner API like Vulkan is what you want, so you are in control of what memory different data sits in and when/how everything happens on the GPU. With OpenGL it abstracts all of that away from you, resulting a simpler and easier to use API but also one that doesn't afford the fine grained control that a complex renderer would benefit from.

In OP's case, they're just using whatever graphics API was handiest for them to take their CPU-generated buffer of pixel RGB values and putting it up in a window or fullscreen, which can be a vkCmdBlitImage(), probably after some pipeline barriers to change image layouts. With OpenGL you would use a PBO to async transfer the pixels to a texture image that's attached to a framebuffer object and then blit the framebuffer object to the main framebuffer that the window has. Or you can upload the pixel data to a texture image and then draw the texture image to the main framebuffer. It's arguable which is faster. The key is making it asynchronous, so a ring buffer of pixel buffers that you output to, and submit each one to OpenGL, leaving it alone for a few frames so that OpenGL has a chance to actually grab the data while you're already rendering the next frame on the CPU to the next buffer in the ring.

Alternatively, OS-specific APIs might be fast too, like win32 GDI on Windows.