Module vulkano::pipeline::graphics[][src]

Expand description

A pipeline that performs graphics processing operations.

Unlike a compute pipeline, which performs general-purpose work, a graphics pipeline is geared specifically towards doing graphical processing. To that end, it consists of several shaders, with additional state and glue logic in between.

A graphics pipeline performs many separate steps, that execute more or less in sequence. Due to the parallel nature of a GPU, no strict ordering guarantees may exist.

  1. Vertex input and assembly: vertex input data is read from data buffers and then assembled into primitives (points, lines, triangles etc.).
  2. Vertex shader invocations: the vertex data of each primitive is fed as input to the vertex shader, which performs transformations on the data and generates new data as output.
  3. (Optional) Tessellation: primitives are subdivided by the operations of two shaders, the tessellation control and tessellation evaluation shaders. The control shader produces the tessellation level to apply for the primitive, while the evaluation shader postprocesses the newly created vertices.
  4. (Optional) Geometry shading: whole primitives are fed as input and processed into a new set of output primitives.
  5. Vertex post-processing, including:
    • Clipping primitives to the view frustum and user-defined clipping planes.
    • Perspective division.
    • Viewport mapping.
  6. Rasterization: converting primitives into a two-dimensional representation. Primitives may be discarded depending on their orientation, and are then converted into a collection of fragments that are processed further.
  7. Fragment operations. These include invocations of the fragment shader, which generates the values to be written to the color attachment. Various testing and discarding operations can be performed both before and after the fragment shader (“early” and “late” fragment tests), including:
    • Discard rectangle test
    • Scissor test
    • Sample mask test
    • Depth bounds test
    • Stencil test
    • Depth test
  8. Color attachment output: the final pixel data is written to a framebuffer. Blending and logical operations can be applied to combine incoming pixel data with data already present in the framebuffer.

A graphics pipeline contains many configuration options, which are grouped into collections of “state”. Often, these directly correspond to one or more steps in the graphics pipeline. Each state collection has a dedicated submodule.

Once a graphics pipeline has been created, you can execute it by first binding it in a command buffer, binding the necessary vertex buffers, binding any descriptor sets, setting push constants, and setting any dynamic state that the pipeline may need. Then you issue a draw command.

Modules

Configures how the color output of the fragment shader is written to the attachment.

Configures the operation of the depth, stencil and depth bounds tests.

A test to discard pixels that would be written to certain areas of a framebuffer.

Configures how input vertices are assembled into primitives.

Generates multiple fragments per framebuffer pixel when rasterizing. This can be used for anti-aliasing.

Configures how primitives should be converted into collections of fragments.

Subdivides primitives into smaller primitives.

Configures how data from vertex buffers is read into vertex shader input locations.

Configures the area of the framebuffer that pixels will be written to.

Structs

Defines how the implementation should perform a draw operation.

Prototype for a GraphicsPipeline.

Enums

Error that can happen when creating a graphics pipeline.