Optimising Pipelines#
In Vulkan, a pipeline object holds all the graphics state information. The following states are described:
Primitive type
Depth/stencil test
Blending
Which shaders to use
Vertex layout
Multi-sampling
Face culling
Polygon winding
Pipelines are created from a description of all shader stages and any relevant fixed-function stages. This allows the shaders to be optimised based on their inputs and outputs, and eliminates expensive draw-time state validation/error checking which is done when the object is created. This can increase performance and reduce hitching, which removes unpredictability.
Pipeline barriers#
On PowerVR hardware, Vulkan pipeline barriers are free if the application does not have to wait for work to be completed, and no data conversion is required.
The most efficient manner for the hardware to schedule tasks is vertex processing executing in parallel to fragment tasks. Therefore, the application should aim to remove unnecessary pipeline dependencies and barriers wherever possible. Smart usage of pipeline barriers can help to avoid pipeline bubbles, where no work can be carried out. An example of this is sub-pass dependencies, where the fragment stage is waiting on the vertex stage to finish.
It may be beneficial to define a dependency by region, which allows for finer control over fence granularity. This is particularly the case if the barriers are being used in fragment stages to fence reads of an input attachment.
Pipeline caching#
Pipeline cache objects allow the result of pipeline construction to be reused between pipelines and between runs of an application.
When using the Vulkan API, an application should always use pipeline caching wherever possible, as this means the driver can compile subsequent pipelines much quicker. Ideally, pipelines should be created at initialisation rather than during the main render loop. Using warm-up frames to cache pipeline objects before drawing is not needed, as optimisation is carried out when the pipeline is created, rather than when it is loaded for use.
Derivative pipelines#
A pipeline derivative is a child pipeline created from a parent pipeline, where the child and parent are expected to share much commonality. The benefit of derivative pipelines is that they are cheaper to create using the parent as a starting point, and that they are more efficient on either host or device to switch/bind between children of the same parent.
Currently the PowerVR graphics driver does not take advantage of derivative pipelines in Vulkan and therefore applications will see no performance benefits from using them. It is still advised to use Vulkan correctly by using derivative pipelines where applicable, so that the application can take advantage of the feature when future drivers support it.