Image Operations are steps performed by SPIR-V image instructions, where
those instructions which take an OpTypeImage (representing a
VkImageView) or OpTypeSampledImage (representing a
(VkImageView, VkSampler) pair) and texel coordinates as
operands, and return a value based on one or more neighboring texture
elements (texels) in the image.
| Note | |
|---|---|
Texel is a term which is a combination of the words texture and element. Early interactive computer graphics supported texture operations on textures, a small subset of the image operations on images described here. The discrete samples remain essentially equivalent, however, so we retain the historical term texel to refer to them. |
SPIR-V Image Instructions include the following functionality:
OpImageSample* and OpImageSparseSample* read one or more
neighboring texels of the image, and filter
the texel values based on the state of the sampler.
ImplicitLod in the name
determine the level of detail
used in the sampling operation based on the coordinates used in
neighboring fragments.
ExplicitLod in the name
determine the level of detail
used in the sampling operation based on additional coordinates.
Proj in the name apply homogeneous
projection to the coordinates.
OpImageFetch and OpImageSparseFetch return a single texel of
the image.
No sampler is used.
OpImage*Gather and OpImageSparse*Gather read
neighboring texels and return a single component of
each.
OpImageRead (and OpImageSparseRead) and OpImageWrite read
and write, respectively, a texel in the image.
No sampler is used.
Dref in the name apply
depth comparison on the texel
values.
Sparse in the name additionally return a
sparse residency code.
Images are addressed by texel coordinates. There are three texel coordinate systems:
SPIR-V OpImageFetch, OpImageSparseFetch, OpImageRead,
OpImageSparseRead, and OpImageWrite instructions use integer texel
coordinates.
Other image instructions can use either normalized or unnormalized texel
coordinates (selected by the unnormalizedCoordinates state of the
sampler used in the instruction), but there are
limitations on what operations, image
state, and sampler state is supported.
Normalized coordinates are logically
converted to unnormalized as part of
image operations, and certain steps are
only performed on normalized coordinates.
The array layer coordinate is always treated as unnormalized even when other
coordinates are normalized.
Normalized texel coordinates are referred to as (s,t,r,q,a), with the coordinates having the following meanings:
r: Coordinate in the third dimension of an image.
The coordinates are extracted from the SPIR-V operand based on the
dimensionality of the image variable and type of instruction.
For Proj instructions, the components are in order (s, [t,] [r,] q)
with t and r being conditionally present based on the Dim of the image.
For non-Proj instructions, the coordinates are (s [,t] [,r] [,a]), with
t and r being conditionally present based on the Dim of the image and a
being conditionally present based on the Arrayed property of the image.
Projective image instructions are not supported on Arrayed images.
Unnormalized texel coordinates are referred to as (u,v,w,a), with the coordinates having the following meanings:
Only the u and v coordinates are directly extracted from the
SPIR-V operand, because only 1D and 2D (non-Arrayed) dimensionalities
support unnormalized coordinates.
The components are in order (u [,v]), with v being conditionally
present when the dimensionality is 2D.
When normalized coordinates are converted to unnormalized coordinates, all
four coordinates are used.
Integer texel coordinates are referred to as (i,j,k,l,n), and the
first four in that order have the same meanings as unnormalized texel
coordinates.
They are extracted from the SPIR-V operand in order (i, [,j], [,k],
[,l]), with j and k conditionally present based on the Dim
of the image, and l conditionally present based on the Arrayed property
of the image.
n is the sample index and is taken from the Sample image operand.
For all coordinate types, unused coordinates are assigned a value of zero.
The Texel Coordinate Systems - For the example shown of an 8x4 texel two dimensional image.
Normalized texel coordinates:
Unnormalized texel coordinates:
Integer texel coordinates:
Also shown for linear filtering:
The Texel Coordinate Systems - For the example shown of an 8x4 texel two dimensional image.
Texel coordinates as above. Also shown for nearest filtering: