Graphics pipeline

Poby’s Home
3 min readMar 11, 2022

--

introduction

Resource 1

Resource 2

Stages

Input assembler

  • collects the raw vertex data from the buffers you specify
  • may also use an index buffer to repeat certain elements without having to duplicate the vertex data itself.

Vertex shader

  • run for every vertex and generally applies transformations to turn vertex positions from model space to screen space.
  • It also passes per-vertex data down the pipeline.

Tessellation shaders

  • allow you to subdivide geometry based on certain rules to increase the mesh quality.
  • This is often used to make surfaces like brick walls and staircases look less flat when they are nearby.

Geometry shader

  • run on every primitive (triangle, line, point) and can discard it or output more primitives than came in.
  • This is similar to the tessellation shader, but much more flexible.
  • However, it is not used much in today’s applications because the performance is not that good on most graphics cards except for Intel’s integrated GPUs.

Rasterization stage

  • discretizes the primitives into fragments.
  • These are the pixel elements that they fill on the framebuffer.
  • Any fragments that fall outside the screen are discarded and the attributes outputted by the vertex shader are interpolated across the fragments, as shown in the figure.
  • Usually the fragments that are behind other primitive fragments are also discarded here because of depth testing.

Fragment shader

  • invoked for every fragment that survives and determines which framebuffer(s) the fragments are written to and with which color and depth values.
  • It can do this using the interpolated data from the vertex shader, which can include things like texture coordinates and normals for lighting.

Color blending stage

  • applies operations to mix different fragments that map to the same pixel in the framebuffer.
  • Fragments can simply overwrite each other, add up or be mixed based upon transparency.

Fixed vs Programmable stages

The graphics pipeline in Vulkan is almost completely immutable, so you must recreate the pipeline from scratch if you want to change shaders, bind different framebuffers or change the blend function.

  • Disadvantage: you’ll have to create a number of pipelines that represent all of the different combinations of states you want to use in your rendering operations.
  • Advantage: However, because all of the operations you’ll be doing in the pipeline are known in advance, the driver can optimize for it much better.

Fixed function stage

  • Stages with a green color are known as fixed-function stages.
  • These stages allow you to tweak their operations using parameters, but the way they work is predefined.

Programmable stage

  • Stages with an orange color on the other hand are programmable, which means that you can upload your own code to the graphics card to apply exactly the operations you want.
  • This allows you to use fragment shaders, for example, to implement anything from texturing and lighting to ray tracers.
  • These programs run on many GPU cores simultaneously to process many objects, like vertices and fragments in parallel.
  • Some of the programmable stages are optional based on what you intend to do. For example, the tessellation and geometry stages can be disabled if you are just drawing simple geometry.

--

--

No responses yet