A.4. Precision and Operation of SPIR-V Instructions

The following rules apply to both single and double-precision floating point instructions:

The precision of double-precision instructions is at least that of single precision. For single precision (32 bit) instructions, precisions are required to be at least as follows, unless decorated with RelaxedPrecision:

Table A.2. Precision of core SPIR-V Instructions

Instruction Precision

OpFAdd

Correctly rounded.

OpFSub

Correctly rounded.

OpFMul

Correctly rounded.

OpFOrdEqual, OpFUnordEqual

Correct result.

OpFOrdLessThan, OpFUnordLessThan

Correct result.

OpFOrdGreaterThan, OpFUnordGreaterThan

Correct result.

OpFOrdLessThanEqual, OpFUnordLessThanEqual

Correct result.

OpFOrdGreaterThanEqual, OpFUnordGreaterThanEqual

Correct result.

OpFDiv

2.5 ULP for b in the range [2-126, 2126].

conversions between types

Correctly rounded.


Precision of GLSL.std.450 Instructions

Instruction Precision

fma()

Inherited from OpFMul followed by OpFAdd.

exp(x), exp2(x)

$(3 + 2 \times |x|)$ ULP.

log(), log2()

3 ULP outside the range [0.5, 2.0]. Absolute error < 2-21 inside the range [0.5, 2.0].

pow(x, y)

Inherited from exp2(y × log2(x)).

sqrt()

Inherited from 1.0 / inversesqrt().

inversesqrt()

2 ULP.

GLSL.std.450 extended instructions specifically defined in terms of the above instructions inherit the above errors. GLSL.std.450 extended instructions not listed above and not defined in terms of the above have undefined precision. These include, for example, the trigonometric functions and determinant.

For the OpSRem and OpSMod instructions, if either operand is negative the result is undefined.

[Note]Note

While the OpSRem and OpSMod instructions are supported by the Vulkan environment, they require non-negative values and thus do not enable additional functionality beyond what OpUMod provides.