Viewports and scissor boxes.
There are two different concepts to determine where things will be drawn:
- The viewport is the region of the image which corresponds to the
- Any pixel outside of the scissor box will be discarded.
In other words modifying the viewport will stretch the image, while modifying the scissor box acts like a filter.
It is legal and sensible to use a viewport that is larger than the target image or that only partially overlaps the target image.
In most situations, you only need a single viewport and a single scissor box.
If, however, you use a geometry shader, you can specify multiple viewports and scissor boxes.
Then in your geometry shader you can specify in which viewport and scissor box the primitive
should be written to. In GLSL this is done by writing to the special variable
If you don't use a geometry shader or use a geometry shader where don't set which viewport to use, then the first viewport and scissor box will be used.
Vulkan allows four different setups:
- The state of both the viewports and scissor boxes is known at pipeline creation.
- The state of viewports is known at pipeline creation, but the state of scissor boxes is only known when submitting the draw command.
- The state of scissor boxes is known at pipeline creation, but the state of viewports is only known when submitting the draw command.
- The state of both the viewports and scissor boxes is only known when submitting the draw command.
In all cases the number of viewports and scissor boxes must be the same.
State of a single scissor box.
State of a single viewport.
List of viewports and scissors that are used when creating a graphics pipeline object.