Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the Graphics Pipeline so highly specialized? (OpenGL)

Tags:

c++

opengl

The OpenGL Graphics Pipeline is changing every year. So the programmable Pipelines are growing. At the end, as an opengl Programmer we create many little programms (Vertex, Fragment, Geometry, Tessellation, ..)

Why is there such a high specialization between the stages? Are they all running on a different part of the hardware? Why not just writing one code-block to describe what should be come out at the end instead of juggling between the stages?

http://www.g-truc.net/doc/OpenGL%204.3%20Pipeline%20Map.pdf

In this Pipeline PDF we see the beast.

like image 946
user1767754 Avatar asked May 12 '14 07:05

user1767754


People also ask

Why are graphics pipelines important in computer graphics?

Within a graphics processor, all stages are working in parallel. Because of this pipeline architecture, today's graphics processing units (GPUs) perform billions of geometry calculations per second. They are increasingly designed with more memory and more stages, so that more data can be worked on at the same time.

What is the OpenGL pipeline?

The OpenGL pipeline performs conditional or selection operations at a number of stages in the pipeline. One or more of these stages can be used together to implement simple conditional operations in a multipass algorithm. Examples include the depth and alpha tests.

How do pipeline graphics work?

During the application step, changes are made to the scene as required, for example, by user interaction by means of input devices or during an animation. The new scene with all its primitives, usually triangles, lines and points, is then passed on to the next step in the pipeline.

What are the three main stages of graphics pipeline?

A graphics pipeline can be divided into three major steps: application, geometry and rasterization.


3 Answers

In the days of "Quake" (the game), developers had the freedom to do anything with their CPU rendering implementations, they were in control of everything in the "pipeline".

With the introduction of fixed pipeline and GPUs, you get "better" performance, but lose a lot of the freedom. Graphics developers are pushing to get that freedom back. Hence, more customization pipeline everyday. GPUs are even "fully" programmable now using tech such as CUDA/OpenCL, even if it's not strictly about graphics.

On the other hand, GPU vendors cannot replace the whole pipeline with fully programmable one overnight. In my opinion, this boils down to multiple reasons;

  • GPU capabilities and cost; GPUs evolve with each iteration, it's nonsense to throw away all the architecture you have and replace it overnight, instead you add new features and enhancements every iteration, especially when developers ask for it (example: Tessellation stage). Think of CPUs, Intel tried to replace the x86 architecture with Itanium, losing backward compatibility, having failed, they eventually copied what AMD did with AMDx64 architecture.
  • They also can't fully replace it due to legacy applications support, which are more widely used than someone might expect.
like image 51
concept3d Avatar answered Sep 22 '22 15:09

concept3d


Historically, there were actually different processing units for the different programmable parts - there were Vertex Shader processors and Fragment Shader processors, for example. Nowadays, GPUs employ a "unified shader architecture" where all types of shaders are executed on the same processing units. That's why non-graphic use of GPUs such as CUDA or OpenCL is possible (or at least easy).

Notice that the different shaders have different inputs/outputs - a vertex shader is executed for each vertex, a geometry shader for each primitive, a fragment shader for each fragment. I don't think this could be easily captured in one big block of code.

And last but definitely far from least, performance. There are still fixed-function stages between the programmable parts (such as rasterisation). And for some of these, it's simply impossible to make them programmable (or callable outside of their specific time in the pipeline) without reducing performance to a crawl.

like image 25
Angew is no longer proud of SO Avatar answered Sep 21 '22 15:09

Angew is no longer proud of SO


Because each stage has a different purpose

Vertex is to transform the points to where they should be on the screen

Fragment is for each fragment (read: pixel of the triangles) and applying lighting and color

Geometry and Tessellation both do things the classic vertex and fragment shaders cannot (replacing the drawn primitives with other primitives) and are both optional.

If you look carefully at that PDF you'll see different inputs and outputs for each shader/

like image 32
ratchet freak Avatar answered Sep 20 '22 15:09

ratchet freak