C Specification
The VkViewport
structure is defined as:
typedef struct VkViewport {
float x;
float y;
float width;
float height;
float minDepth;
float maxDepth;
} VkViewport;
Members

x
andy
are the viewport’s upper left corner (x,y). 
width
andheight
are the viewport’s width and height, respectively. 
minDepth
andmaxDepth
are the depth range for the viewport. It is valid forminDepth
to be greater than or equal tomaxDepth
.
Description
The framebuffer depth coordinate z
_{f} may be represented using
either a fixedpoint or floatingpoint representation.
However, a floatingpoint representation must be used if the depth/stencil
attachment has a floatingpoint depth component.
If an mbit fixedpoint representation is used, we assume that it
represents each value \(\frac{k}{2^m  1}\), where k ∈ {
0, 1, …, 2^{m}1 }, as k (e.g. 1.0 is represented in binary as a
string of all ones).
The viewport parameters shown in the above equations are found from these values as

o_{x} =
x
+width
/ 2 
o_{y} =
y
+height
/ 2 
o_{z} =
minDepth

p_{x} =
width

p_{y} =
height

p_{z} =
maxDepth
minDepth
.
The application can specify a negative term for height
, which has the
effect of negating the y coordinate in clip space before performing the
transform.
When using a negative height
, the application should also adjust the
y
value to point to the lower left corner of the viewport instead of
the upper left corner.
Using the negative height
allows the application to avoid having to
negate the y component of the Position
output from the last vertex
processing stage in shaders that also target other graphics APIs.
The width and height of the implementationdependent maximum viewport dimensions must be greater than or equal to the width and height of the largest image which can be created and attached to a framebuffer.
The floatingpoint viewport bounds are represented with an implementationdependent precision.
Document Notes
For more information, see the Vulkan Specification at URL
This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.
Copyright
Copyright (c) 20142018 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.