## 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:

  l = clamp(RNE(a), 0, `layerCount` - 1) + `baseArrayLayer`

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:

  i = ⌊ u ⌋
  j = ⌊ v ⌋
  k = ⌊ w ⌋

Linear filtering (`VK_FILTER_LINEAR`) computes a set of neighboring coordinates which bound the unnormalized coordinates. The integer texel coordinates are combinations of i0 or i1, j0 or j1, k0 or k1, as well as weights α, β, and γ.

  i0 = ⌊u - ½⌋
  i1 = i0 + 1
  j0 = ⌊v - ½⌋
  j1 = j0 + 1
  k0 = ⌊w - ½⌋
  k1 = k0 + 1
  α = frac(u - ½)
  β = frac(v - ½)
  γ = frac(w - ½)

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