15.7. Unnormalized Texel Coordinate Operations

15.7.1. (u,v,w,a) to (i,j,k,l,n) Transformation And Array Layer Selection

The unnormalized texel coordinates are transformed to integer texel coordinates relative to the selected mipmap level.

The layer index l is computed as:

\begin{align*} l & = \operatorname{clamp}( \operatorname{RNE}(a), 0, layerCount - 1 ) + baseArrayLayer \end{align*}

where layerCount is the number of layers in the image subresource range of the image view, baseArrayLayer is the first layer from the subresource range, and where:

\begin{align*} \operatorname{RNE}(a) & = \begin{cases} \operatorname{roundTiesToEven}(a) & \textrm{preferred, from IEEE Std 754-2008 Floating-Point Arithmetic} \\ \left \lfloor a + \frac{1}{2} \right \rfloor & \textrm{alternative} \end{cases} \end{align*}

The sample index n is assigned the value zero.

Nearest filtering (VK_FILTER_NEAREST) computes the integer texel coordinates that the unnormalized coordinates lie within:

\begin{align*} i & = \left \lfloor u \right \rfloor \\ j & = \left \lfloor v \right \rfloor \\ k & = \left \lfloor w \right \rfloor \end{align*}

Linear filtering (VK_FILTER_LINEAR) computes a set of neighboring coordinates which bound the unnormalized coordinates. The integer texel coordinates are combinations of $i_0\textrm{ or }i_1,j_0\textrm{ or }j_1,k_0\textrm{ or }k_1$ , as well as weights $\alpha, \beta, and \gamma$ .

\begin{align*} i_{0} & = \left \lfloor u - \frac{1}{2} \right \rfloor & i_{1} & = i_{0} + 1 \\ j_{0} & = \left \lfloor v - \frac{1}{2} \right \rfloor & j_{1} & = j_{0} + 1 \\ k_{0} & = \left \lfloor w - \frac{1}{2} \right \rfloor & k_{1} & = k_{0} + 1 \\ \\ \alpha & = \operatorname{frac} \left ( u - \frac{1}{2} \right ) \\ \beta & = \operatorname{frac} \left ( v - \frac{1}{2} \right ) \\ \gamma & = \operatorname{frac} \left ( w - \frac{1}{2} \right ) \end{align*}

If the image instruction includes a $ConstOffset$ operand, the constant offsets $(\Delta_{i},\Delta_{j},\Delta_{k})$ are added to $(i,j,k)$ components of the integer texel coordinates.