Search code examples
c++openglshaderpipeline

Can you make your own rendering pipeline?


I want to write a renderer, but do i really have to use the OpenGL pipeline, cant i make my own? Is there a way i can write all the code for the GPU and CPU, from memory management to rasterization, or do i have to use the already provided pipeline? If i cant do it in OpenGL where can i? Can i get some directions? In what language do i write the GPU code and how do i use it on the GPU?


Solution

  • Consumer-grade GPUs as they currently standard are not CPUs. You don't "program" a graphics pipeline. The graphics pipeline is what it is because that's how GPUs are designed to work. Obviously, different specific GPUs will have different implementations, but basic elements of the rendering pipeline are all fundamental parts of the hardware. The parts of the pipeline which are programmable are only programmable to the extent the GPU allows it and for the purpose for which that stage is intended (with some flexibility).

    Future GPUs may be more flexible, and there are even some alternative pipelines for vertex processing in certain modern GPUs. But we're not at the point yet where you can just make things up as you like. GPUs are designed for efficiency; their limitations are there to help things stay on an efficient path.

    Memory management is an entirely separate issue. Vulkan and similar command-buffer APIs allow much more low-level memory management functionality compared to immediate APIs like OpenGL. However, it should be well understood that command buffer APIs are not for hobby programmers. These APIs are not friendly in the slightest; they require you to be keenly aware of many details that immediate APIs hide from you, and they will not tell you when you break their rules.