HLSL Core

HLSL core defines and functions.

Functions

Return type

Description

FfxUInt32

Pack 2×32-bit floating point values in a single 32bit value.

FfxFloat32x2

Broadcast a scalar value to a 2-dimensional floating point vector.

FfxFloat32x3

Broadcast a scalar value to a 3-dimensional floating point vector.

FfxFloat32x4

Broadcast a scalar value to a 4-dimensional floating point vector.

FfxInt32x2

Broadcast a scalar value to a 2-dimensional signed integer vector.

FfxInt32x3

Broadcast a scalar value to a 3-dimensional signed integer vector.

FfxInt32x4

Broadcast a scalar value to a 4-dimensional signed integer vector.

FfxUInt32x2

Broadcast a scalar value to a 2-dimensional unsigned integer vector.

FfxUInt32x3

Broadcast a scalar value to a 3-dimensional unsigned integer vector.

FfxUInt32x4

Broadcast a scalar value to a 4-dimensional unsigned integer vector.

FfxUInt32

Interprets the bit pattern of x as an unsigned integer.

FfxUInt32x2

Interprets the bit pattern of x as an unsigned integer.

FfxUInt32x3

Interprets the bit pattern of x as an unsigned integer.

FfxUInt32x4

Interprets the bit pattern of x as an unsigned integer.

FfxFloat32

Interprets the bit pattern of x as a floating-point number.

FfxFloat32x2

Interprets the bit pattern of x as a floating-point number.

FfxFloat32x3

Interprets the bit pattern of x as a floating-point number.

FfxFloat32x4

Interprets the bit pattern of x as a floating-point number.

FfxFloat32

Compute the inverse of a value.

FfxFloat32x2

Compute the inverse of a value.

FfxFloat32x3

Compute the inverse of a value.

FfxFloat32x4

Compute the inverse of a value.

FfxFloat32

Compute the inverse square root of a value.

FfxFloat32x2

Compute the inverse square root of a value.

FfxFloat32x3

Compute the inverse square root of a value.

FfxFloat32x4

Compute the inverse square root of a value.

FfxFloat32

Compute the linear interopation between two values.

FfxFloat32x2

Compute the linear interopation between two values.

FfxFloat32x2

Compute the linear interopation between two values.

FfxFloat32x3

Compute the linear interopation between two values.

FfxFloat32x3

Compute the linear interopation between two values.

FfxFloat32x4

Compute the linear interopation between two values.

FfxFloat32x4

Compute the linear interopation between two values.

FfxFloat32

Clamp a value to a [0..1] range.

FfxFloat32x2

Clamp a value to a [0..1] range.

FfxFloat32x3

Clamp a value to a [0..1] range.

FfxFloat32x4

Clamp a value to a [0..1] range.

FfxFloat32

Compute the factional part of a decimal value.

FfxFloat32x2

Compute the factional part of a decimal value.

FfxFloat32x3

Compute the factional part of a decimal value.

FfxFloat32x4

Compute the factional part of a decimal value.

FfxFloat32

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

FfxFloat32x2

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

FfxFloat32x3

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

FfxFloat32x4

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

FfxFloat32

Compute the maximum of three values.

FfxFloat32x2

Compute the maximum of three values.

FfxFloat32x3

Compute the maximum of three values.

FfxFloat32x4

Compute the maximum of three values.

FfxUInt32

Compute the maximum of three values.

FfxUInt32x2

Compute the maximum of three values.

FfxUInt32x3

Compute the maximum of three values.

FfxUInt32x4

Compute the maximum of three values.

FfxFloat32

Compute the median of three values.

FfxFloat32x2

Compute the median of three values.

FfxFloat32x3

Compute the median of three values.

FfxFloat32x4

Compute the median of three values.

FfxFloat32

Compute the minimum of three values.

FfxFloat32x2

Compute the minimum of three values.

FfxFloat32x3

Compute the minimum of three values.

FfxFloat32x4

Compute the minimum of three values.

FfxUInt32

Compute the minimum of three values.

FfxUInt32x2

Compute the minimum of three values.

FfxUInt32x3

Compute the minimum of three values.

FfxUInt32x4

Compute the minimum of three values.

Macros

Name

Description

FFX_ATOMIC_ADD (x, y) InterlockedAdd(x, y)

A define for abstracting compute atomic additions between shading languages.

FFX_ATOMIC_ADD_RETURN (x, y, r) InterlockedAdd(x, y, r)

A define for abstracting compute atomic additions between shading languages.

FFX_ATOMIC_MAX (x, y) InterlockedMax(x, y)

A define for abstracting compute atomic max between shading languages.

FFX_ATOMIC_MIN (x, y) InterlockedMin(x, y)

A define for abstracting compute atomic min between shading languages.

FFX_ATOMIC_OR (x, y) InterlockedOr(x, y)

A define for abstracting compute atomic OR between shading languages.

FFX_BROADCAST_FLOAT32 (x) FfxFloat32(x)

Broadcast a scalar value to a 1-dimensional floating point vector.

FFX_BROADCAST_FLOAT32X2 (x) FfxFloat32(x)

Broadcast a scalar value to a 2-dimensional floating point vector.

FFX_BROADCAST_FLOAT32X3 (x) FfxFloat32(x)

Broadcast a scalar value to a 3-dimensional floating point vector.

FFX_BROADCAST_FLOAT32X4 (x) FfxFloat32(x)

Broadcast a scalar value to a 4-dimensional floating point vector.

FFX_BROADCAST_INT32 (x) FfxInt32(x)

Broadcast a scalar value to a 1-dimensional signed integer vector.

FFX_BROADCAST_INT32X2 (x) FfxInt32(x)

Broadcast a scalar value to a 2-dimensional signed integer vector.

FFX_BROADCAST_INT32X3 (x) FfxInt32(x)

Broadcast a scalar value to a 3-dimensional signed integer vector.

FFX_BROADCAST_INT32X4 (x) FfxInt32(x)

Broadcast a scalar value to a 4-dimensional signed integer vector.

FFX_BROADCAST_MIN_FLOAT16 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 1-dimensional half-precision floating point vector.

FFX_BROADCAST_MIN_FLOAT16X2 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 2-dimensional half-precision floating point vector.

FFX_BROADCAST_MIN_FLOAT16X3 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 3-dimensional half-precision floating point vector.

FFX_BROADCAST_MIN_FLOAT16X4 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 4-dimensional half-precision floating point vector.

FFX_BROADCAST_MIN_INT16 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 1-dimensional half-precision signed integer vector.

FFX_BROADCAST_MIN_INT16X2 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 2-dimensional half-precision signed integer vector.

FFX_BROADCAST_MIN_INT16X3 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 3-dimensional half-precision signed integer vector.

FFX_BROADCAST_MIN_INT16X4 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 4-dimensional half-precision signed integer vector.

FFX_BROADCAST_MIN_UINT16 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 1-dimensional half-precision unsigned integer vector.

FFX_BROADCAST_MIN_UINT16X2 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 2-dimensional half-precision unsigned integer vector.

FFX_BROADCAST_MIN_UINT16X3 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 3-dimensional half-precision unsigned integer vector.

FFX_BROADCAST_MIN_UINT16X4 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 4-dimensional half-precision unsigned integer vector.

FFX_BROADCAST_UINT32 (x) FfxUInt32(x)

Broadcast a scalar value to a 1-dimensional unsigned integer vector.

FFX_BROADCAST_UINT32X2 (x) FfxUInt32(x)

Broadcast a scalar value to a 2-dimensional unsigned integer vector.

FFX_BROADCAST_UINT32X3 (x) FfxUInt32(x)

Broadcast a scalar value to a 4-dimensional unsigned integer vector.

FFX_BROADCAST_UINT32X4 (x) FfxUInt32(x)

Broadcast a scalar value to a 4-dimensional unsigned integer vector.

FFX_EQUAL (x, y) x == y

A define for abstracting an ‘equal’ comparison operator between two types.

FFX_GREATER_THAN (x, y) x > y

A define for abstracting a ‘greater than’ comparison operator between two types.

FFX_GREATER_THAN_EQUAL (x, y) x >= y

A define for abstracting a ‘greater than or equal’ comparison operator between two types.

FFX_GROUPSHARED groupshared

A define for abstracting shared memory between shading languages.

FFX_GROUP_MEMORY_BARRIER GroupMemoryBarrierWithGroupSync()

A define for abstracting compute memory barriers between shading languages.

FFX_LESS_THAN (x, y) x < y

A define for abstracting a ‘less than’ comparison operator between two types.

FFX_LESS_THAN_EQUAL (x, y) x <= y

A define for abstracting a ‘less than or equal’ comparison operator between two types.

FFX_MATRIX_MULTIPLY (a, b) mul(a, b)

A define for abstracting matrix multiply operations between shading languages.

FFX_MODULO (a, b) (fmod(a, b))

A define for abstracting modulo operations between shading languages.

FFX_NOT_EQUAL (x, y) x != y

A define for abstracting a ‘not equal’ comparison operator between two types.

FFX_SELECT (cond, arg1, arg2) cond ? arg1 : arg2

A define for abstracting select functionality for pre/post HLSL 21.

FFX_STATIC static

A define added to accept static markup on functions to aid CPU/GPU portability of code.

FFX_TRANSFORM_VECTOR (a, b) mul(a, b)

A define for abstracting vector transformations between shading languages.

FFX_UNROLL [unroll]

A define for abstracting loop unrolling between shading languages.

ffxF32ToF16 f32tof16

Convert FfxFloat32 to half (in lower 16-bits of output).

Detailed description

HLSL core defines and functions.

Global functions

ffxPackHalf2x16

Copied!

FfxUInt32  ffxPackHalf2x16 (FfxFloat32x2  value)

Pack 2×32-bit floating point values in a single 32bit value.

This function first converts each component of value into their nearest 16-bit floating point representation, and then stores the X and Y components in the lower and upper 16 bits of the 32bit unsigned integer respectively.

Parameters:

value

A 2-dimensional floating point value to convert and pack.

Returns:

A packed 32bit value containing 2 16bit floating point values.


ffxBroadcast2

Copied!

FfxFloat32x2  ffxBroadcast2 (FfxFloat32  value)

Broadcast a scalar value to a 2-dimensional floating point vector.

Parameters:

value

The value to to broadcast.

Returns:

A 2-dimensional floating point vector with value in each component.


ffxBroadcast3

Copied!

FfxFloat32x3  ffxBroadcast3 (FfxFloat32  value)

Broadcast a scalar value to a 3-dimensional floating point vector.

Parameters:

value

The value to to broadcast.

Returns:

A 3-dimensional floating point vector with value in each component.


ffxBroadcast4

Copied!

FfxFloat32x4  ffxBroadcast4 (FfxFloat32  value)

Broadcast a scalar value to a 4-dimensional floating point vector.

Parameters:

value

The value to to broadcast.

Returns:

A 4-dimensional floating point vector with value in each component.


ffxBroadcast2

Copied!

FfxInt32x2  ffxBroadcast2 (FfxInt32  value)

Broadcast a scalar value to a 2-dimensional signed integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 2-dimensional signed integer vector with value in each component.


ffxBroadcast3

Copied!

FfxInt32x3  ffxBroadcast3 (FfxInt32  value)

Broadcast a scalar value to a 3-dimensional signed integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 3-dimensional signed integer vector with value in each component.


ffxBroadcast4

Copied!

FfxInt32x4  ffxBroadcast4 (FfxInt32  value)

Broadcast a scalar value to a 4-dimensional signed integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 4-dimensional signed integer vector with value in each component.


ffxBroadcast2

Copied!

FfxUInt32x2  ffxBroadcast2 (FfxUInt32  value)

Broadcast a scalar value to a 2-dimensional unsigned integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 2-dimensional unsigned integer vector with value in each component.


ffxBroadcast3

Copied!

FfxUInt32x3  ffxBroadcast3 (FfxUInt32  value)

Broadcast a scalar value to a 3-dimensional unsigned integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 3-dimensional unsigned integer vector with value in each component.


ffxBroadcast4

Copied!

FfxUInt32x4  ffxBroadcast4 (FfxUInt32  value)

Broadcast a scalar value to a 4-dimensional unsigned integer vector.

Parameters:

value

The value to to broadcast.

Returns:

A 4-dimensional unsigned integer vector with value in each component.


ffxAsUInt32

Copied!

FfxUInt32  ffxAsUInt32 (FfxFloat32  x)

Interprets the bit pattern of x as an unsigned integer.

Parameters:

x

The input value.

Returns:

The input interpreted as an unsigned integer.


ffxAsUInt32

Copied!

FfxUInt32x2  ffxAsUInt32 (FfxFloat32x2  x)

Interprets the bit pattern of x as an unsigned integer.

Parameters:

x

The input value.

Returns:

The input interpreted as an unsigned integer.


ffxAsUInt32

Copied!

FfxUInt32x3  ffxAsUInt32 (FfxFloat32x3  x)

Interprets the bit pattern of x as an unsigned integer.

Parameters:

x

The input value.

Returns:

The input interpreted as an unsigned integer.


ffxAsUInt32

Copied!

FfxUInt32x4  ffxAsUInt32 (FfxFloat32x4  x)

Interprets the bit pattern of x as an unsigned integer.

Parameters:

x

The input value.

Returns:

The input interpreted as an unsigned integer.


ffxAsFloat

Copied!

FfxFloat32  ffxAsFloat (FfxUInt32  x)

Interprets the bit pattern of x as a floating-point number.

Parameters:

x

The input value.

Returns:

The input interpreted as a floating-point number.


ffxAsFloat

Copied!

FfxFloat32x2  ffxAsFloat (FfxUInt32x2  x)

Interprets the bit pattern of x as a floating-point number.

Parameters:

x

The input value.

Returns:

The input interpreted as a floating-point number.


ffxAsFloat

Copied!

FfxFloat32x3  ffxAsFloat (FfxUInt32x3  x)

Interprets the bit pattern of x as a floating-point number.

Parameters:

x

The input value.

Returns:

The input interpreted as a floating-point number.


ffxAsFloat

Copied!

FfxFloat32x4  ffxAsFloat (FfxUInt32x4  x)

Interprets the bit pattern of x as a floating-point number.

Parameters:

x

The input value.

Returns:

The input interpreted as a floating-point number.


ffxReciprocal

Copied!

FfxFloat32  ffxReciprocal (FfxFloat32  x)

Compute the inverse of a value.

Parameters:

x

The value to calulate the inverse of.

Returns:

The inverse of x.


ffxReciprocal

Copied!

FfxFloat32x2  ffxReciprocal (FfxFloat32x2  x)

Compute the inverse of a value.

Parameters:

x

The value to calulate the inverse of.

Returns:

The inverse of x.


ffxReciprocal

Copied!

FfxFloat32x3  ffxReciprocal (FfxFloat32x3  x)

Compute the inverse of a value.

Parameters:

x

The value to calulate the inverse of.

Returns:

The inverse of x.


ffxReciprocal

Copied!

FfxFloat32x4  ffxReciprocal (FfxFloat32x4  x)

Compute the inverse of a value.

Parameters:

x

The value to calulate the inverse of.

Returns:

The inverse of x.


ffxRsqrt

Copied!

FfxFloat32  ffxRsqrt (FfxFloat32  x)

Compute the inverse square root of a value.

Parameters:

x

The value to calulate the inverse square root of.

Returns:

The inverse square root of x.


ffxRsqrt

Copied!

FfxFloat32x2  ffxRsqrt (FfxFloat32x2  x)

Compute the inverse square root of a value.

Parameters:

x

The value to calulate the inverse square root of.

Returns:

The inverse square root of x.


ffxRsqrt

Copied!

FfxFloat32x3  ffxRsqrt (FfxFloat32x3  x)

Compute the inverse square root of a value.

Parameters:

x

The value to calulate the inverse square root of.

Returns:

The inverse square root of x.


ffxRsqrt

Copied!

FfxFloat32x4  ffxRsqrt (FfxFloat32x4  x)

Compute the inverse square root of a value.

Parameters:

x

The value to calulate the inverse square root of.

Returns:

The inverse square root of x.


ffxLerp

Copied!

FfxFloat32  ffxLerp (FfxFloat32  x, FfxFloat32  y, FfxFloat32  t)

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Copied!

FfxFloat32x2  ffxLerp (FfxFloat32x2  x, FfxFloat32x2  y, FfxFloat32  t)

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Copied!

FfxFloat32x3  ffxLerp (FfxFloat32x3  x, FfxFloat32x3  y, FfxFloat32  t)

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Copied!

FfxFloat32x4  ffxLerp (FfxFloat32x4  x, FfxFloat32x4  y, FfxFloat32  t)

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxLerp

Compute the linear interopation between two values.

Implemented by calling the HLSL mix instrinsic function. Implements the following math:

Copied!

(1 - t) * x + t * y

Parameters:

x

The first value to lerp between.

y

The second value to lerp between.

t

The value to determine how much of x and how much of y.

Returns:

A linearly interpolated value between x and y according to t.


ffxSaturate

Copied!

FfxFloat32  ffxSaturate (FfxFloat32  x)

Clamp a value to a [0..1] range.

Parameters:

x

The value to clamp to [0..1] range.

Returns:

The clamped version of x.


ffxSaturate

Copied!

FfxFloat32x2  ffxSaturate (FfxFloat32x2  x)

Clamp a value to a [0..1] range.

Parameters:

x

The value to clamp to [0..1] range.

Returns:

The clamped version of x.


ffxSaturate

Copied!

FfxFloat32x3  ffxSaturate (FfxFloat32x3  x)

Clamp a value to a [0..1] range.

Parameters:

x

The value to clamp to [0..1] range.

Returns:

The clamped version of x.


ffxSaturate

Copied!

FfxFloat32x4  ffxSaturate (FfxFloat32x4  x)

Clamp a value to a [0..1] range.

Parameters:

x

The value to clamp to [0..1] range.

Returns:

The clamped version of x.


ffxFract

Copied!

FfxFloat32  ffxFract (FfxFloat32  x)

Compute the factional part of a decimal value.

This function calculates x - floor(x). Where floor is the intrinsic HLSL function.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is worth further noting that this function is intentionally distinct from the HLSL frac intrinsic function.

Parameters:

x

The value to compute the fractional part from.

Returns:

The fractional part of x.


ffxFract

Copied!

FfxFloat32x2  ffxFract (FfxFloat32x2  x)

Compute the factional part of a decimal value.

This function calculates x - floor(x). Where floor is the intrinsic HLSL function.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is worth further noting that this function is intentionally distinct from the HLSL frac intrinsic function.

Parameters:

x

The value to compute the fractional part from.

Returns:

The fractional part of x.


ffxFract

Copied!

FfxFloat32x3  ffxFract (FfxFloat32x3  x)

Compute the factional part of a decimal value.

This function calculates x - floor(x). Where floor is the intrinsic HLSL function.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is worth further noting that this function is intentionally distinct from the HLSL frac intrinsic function.

Parameters:

x

The value to compute the fractional part from.

Returns:

The fractional part of x.


ffxFract

Copied!

FfxFloat32x4  ffxFract (FfxFloat32x4  x)

Compute the factional part of a decimal value.

This function calculates x - floor(x). Where floor is the intrinsic HLSL function.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware. It is worth further noting that this function is intentionally distinct from the HLSL frac intrinsic function.

Parameters:

x

The value to compute the fractional part from.

Returns:

The fractional part of x.


ffxRound

Copied!

FfxFloat32  ffxRound (FfxFloat32  x)

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

Parameters:

x

The value to be rounded.

Returns:

The nearest integer from x. The nearest even integer from x if equidistant from 2 integer.


ffxRound

Copied!

FfxFloat32x2  ffxRound (FfxFloat32x2  x)

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

Parameters:

x

The value to be rounded.

Returns:

The nearest integer from x. The nearest even integer from x if equidistant from 2 integer.


ffxRound

Copied!

FfxFloat32x3  ffxRound (FfxFloat32x3  x)

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

Parameters:

x

The value to be rounded.

Returns:

The nearest integer from x. The nearest even integer from x if equidistant from 2 integer.


ffxRound

Copied!

FfxFloat32x4  ffxRound (FfxFloat32x4  x)

Rounds to the nearest integer. In case the fractional part is 0.5, it will round to the nearest even integer.

Parameters:

x

The value to be rounded.

Returns:

The nearest integer from x. The nearest even integer from x if equidistant from 2 integer.


ffxMax3

Copied!

FfxFloat32  ffxMax3 (FfxFloat32  x, FfxFloat32  y, FfxFloat32  z)

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Copied!

FfxUInt32  ffxMax3 (FfxUInt32  x, FfxUInt32  y, FfxUInt32  z)

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Copied!

FfxUInt32x2  ffxMax3 (FfxUInt32x2  x, FfxUInt32x2  y, FfxUInt32x2  z)

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Copied!

FfxUInt32x3  ffxMax3 (FfxUInt32x3  x, FfxUInt32x3  y, FfxUInt32x3  z)

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMax3

Copied!

FfxUInt32x4  ffxMax3 (FfxUInt32x4  x, FfxUInt32x4  y, FfxUInt32x4  z)

Compute the maximum of three values.

NOTE: This function should compile down to a single V_MAX3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the max calculation.

y

The second value to include in the max calcuation.

z

The third value to include in the max calcuation.

Returns:

The maximum value of x, y, and z.


ffxMed3

Copied!

FfxFloat32  ffxMed3 (FfxFloat32  x, FfxFloat32  y, FfxFloat32  z)

Compute the median of three values.

NOTE: This function should compile down to a single V_MED3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the median calculation.

y

The second value to include in the median calcuation.

z

The third value to include in the median calcuation.

Returns:

The median value of x, y, and z.


ffxMed3

Compute the median of three values.

NOTE: This function should compile down to a single V_MED3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the median calculation.

y

The second value to include in the median calcuation.

z

The third value to include in the median calcuation.

Returns:

The median value of x, y, and z.


ffxMed3

Compute the median of three values.

NOTE: This function should compile down to a single V_MED3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the median calculation.

y

The second value to include in the median calcuation.

z

The third value to include in the median calcuation.

Returns:

The median value of x, y, and z.


ffxMed3

Compute the median of three values.

NOTE: This function should compile down to a single V_MED3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the median calculation.

y

The second value to include in the median calcuation.

z

The third value to include in the median calcuation.

Returns:

The median value of x, y, and z.


ffxMin3

Copied!

FfxFloat32  ffxMin3 (FfxFloat32  x, FfxFloat32  y, FfxFloat32  z)

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Copied!

FfxUInt32  ffxMin3 (FfxUInt32  x, FfxUInt32  y, FfxUInt32  z)

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Copied!

FfxUInt32x2  ffxMin3 (FfxUInt32x2  x, FfxUInt32x2  y, FfxUInt32x2  z)

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Copied!

FfxUInt32x3  ffxMin3 (FfxUInt32x3  x, FfxUInt32x3  y, FfxUInt32x3  z)

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calculation.

z

The third value to include in the min calculation.

Returns:

The minimum value of x, y, and z.


ffxMin3

Copied!

FfxUInt32x4  ffxMin3 (FfxUInt32x4  x, FfxUInt32x4  y, FfxUInt32x4  z)

Compute the minimum of three values.

NOTE: This function should compile down to a single V_MIN3_F32 operation on GCN/RDNA hardware.

Parameters:

x

The first value to include in the min calculation.

y

The second value to include in the min calcuation.

z

The third value to include in the min calcuation.

Returns:

The minimum value of x, y, and z.


Macros

FFX_ATOMIC_ADD

Copied!

#define FFX_ATOMIC_ADD (x, y) InterlockedAdd(x, y)

A define for abstracting compute atomic additions between shading languages.


FFX_ATOMIC_ADD_RETURN

Copied!

#define FFX_ATOMIC_ADD_RETURN (x, y, r) InterlockedAdd(x, y, r)

A define for abstracting compute atomic additions between shading languages.


FFX_ATOMIC_MAX

Copied!

#define FFX_ATOMIC_MAX (x, y) InterlockedMax(x, y)

A define for abstracting compute atomic max between shading languages.


FFX_ATOMIC_MIN

Copied!

#define FFX_ATOMIC_MIN (x, y) InterlockedMin(x, y)

A define for abstracting compute atomic min between shading languages.


FFX_ATOMIC_OR

Copied!

#define FFX_ATOMIC_OR (x, y) InterlockedOr(x, y)

A define for abstracting compute atomic OR between shading languages.


FFX_BROADCAST_FLOAT32

Copied!

#define FFX_BROADCAST_FLOAT32 (x) FfxFloat32(x)

Broadcast a scalar value to a 1-dimensional floating point vector.


FFX_BROADCAST_FLOAT32X2

Copied!

#define FFX_BROADCAST_FLOAT32X2 (x) FfxFloat32(x)

Broadcast a scalar value to a 2-dimensional floating point vector.


FFX_BROADCAST_FLOAT32X3

Copied!

#define FFX_BROADCAST_FLOAT32X3 (x) FfxFloat32(x)

Broadcast a scalar value to a 3-dimensional floating point vector.


FFX_BROADCAST_FLOAT32X4

Copied!

#define FFX_BROADCAST_FLOAT32X4 (x) FfxFloat32(x)

Broadcast a scalar value to a 4-dimensional floating point vector.


FFX_BROADCAST_INT32

Copied!

#define FFX_BROADCAST_INT32 (x) FfxInt32(x)

Broadcast a scalar value to a 1-dimensional signed integer vector.


FFX_BROADCAST_INT32X2

Copied!

#define FFX_BROADCAST_INT32X2 (x) FfxInt32(x)

Broadcast a scalar value to a 2-dimensional signed integer vector.


FFX_BROADCAST_INT32X3

Copied!

#define FFX_BROADCAST_INT32X3 (x) FfxInt32(x)

Broadcast a scalar value to a 3-dimensional signed integer vector.


FFX_BROADCAST_INT32X4

Copied!

#define FFX_BROADCAST_INT32X4 (x) FfxInt32(x)

Broadcast a scalar value to a 4-dimensional signed integer vector.


FFX_BROADCAST_MIN_FLOAT16

Copied!

#define FFX_BROADCAST_MIN_FLOAT16 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 1-dimensional half-precision floating point vector.


FFX_BROADCAST_MIN_FLOAT16X2

Copied!

#define FFX_BROADCAST_MIN_FLOAT16X2 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 2-dimensional half-precision floating point vector.


FFX_BROADCAST_MIN_FLOAT16X3

Copied!

#define FFX_BROADCAST_MIN_FLOAT16X3 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 3-dimensional half-precision floating point vector.


FFX_BROADCAST_MIN_FLOAT16X4

Copied!

#define FFX_BROADCAST_MIN_FLOAT16X4 (a) FFX_MIN16_F(a)

Broadcast a scalar value to a 4-dimensional half-precision floating point vector.


FFX_BROADCAST_MIN_INT16

Copied!

#define FFX_BROADCAST_MIN_INT16 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 1-dimensional half-precision signed integer vector.


FFX_BROADCAST_MIN_INT16X2

Copied!

#define FFX_BROADCAST_MIN_INT16X2 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 2-dimensional half-precision signed integer vector.


FFX_BROADCAST_MIN_INT16X3

Copied!

#define FFX_BROADCAST_MIN_INT16X3 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 3-dimensional half-precision signed integer vector.


FFX_BROADCAST_MIN_INT16X4

Copied!

#define FFX_BROADCAST_MIN_INT16X4 (a) FFX_MIN16_I(a)

Broadcast a scalar value to a 4-dimensional half-precision signed integer vector.


FFX_BROADCAST_MIN_UINT16

Copied!

#define FFX_BROADCAST_MIN_UINT16 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 1-dimensional half-precision unsigned integer vector.


FFX_BROADCAST_MIN_UINT16X2

Copied!

#define FFX_BROADCAST_MIN_UINT16X2 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 2-dimensional half-precision unsigned integer vector.


FFX_BROADCAST_MIN_UINT16X3

Copied!

#define FFX_BROADCAST_MIN_UINT16X3 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 3-dimensional half-precision unsigned integer vector.


FFX_BROADCAST_MIN_UINT16X4

Copied!

#define FFX_BROADCAST_MIN_UINT16X4 (a) FFX_MIN16_U(a)

Broadcast a scalar value to a 4-dimensional half-precision unsigned integer vector.


FFX_BROADCAST_UINT32

Copied!

#define FFX_BROADCAST_UINT32 (x) FfxUInt32(x)

Broadcast a scalar value to a 1-dimensional unsigned integer vector.


FFX_BROADCAST_UINT32X2

Copied!

#define FFX_BROADCAST_UINT32X2 (x) FfxUInt32(x)

Broadcast a scalar value to a 2-dimensional unsigned integer vector.


FFX_BROADCAST_UINT32X3

Copied!

#define FFX_BROADCAST_UINT32X3 (x) FfxUInt32(x)

Broadcast a scalar value to a 4-dimensional unsigned integer vector.


FFX_BROADCAST_UINT32X4

Copied!

#define FFX_BROADCAST_UINT32X4 (x) FfxUInt32(x)

Broadcast a scalar value to a 4-dimensional unsigned integer vector.


FFX_EQUAL

Copied!

#define FFX_EQUAL (x, y) x == y

A define for abstracting an ‘equal’ comparison operator between two types.


FFX_GREATER_THAN

Copied!

#define FFX_GREATER_THAN (x, y) x > y

A define for abstracting a ‘greater than’ comparison operator between two types.


FFX_GREATER_THAN_EQUAL

Copied!

#define FFX_GREATER_THAN_EQUAL (x, y) x >= y

A define for abstracting a ‘greater than or equal’ comparison operator between two types.


FFX_GROUPSHARED

Copied!

#define FFX_GROUPSHARED groupshared

A define for abstracting shared memory between shading languages.


FFX_GROUP_MEMORY_BARRIER

Copied!

#define FFX_GROUP_MEMORY_BARRIER GroupMemoryBarrierWithGroupSync()

A define for abstracting compute memory barriers between shading languages.


FFX_LESS_THAN

Copied!

#define FFX_LESS_THAN (x, y) x < y

A define for abstracting a ‘less than’ comparison operator between two types.


FFX_LESS_THAN_EQUAL

Copied!

#define FFX_LESS_THAN_EQUAL (x, y) x <= y

A define for abstracting a ‘less than or equal’ comparison operator between two types.


FFX_MATRIX_MULTIPLY

Copied!

#define FFX_MATRIX_MULTIPLY (a, b) mul(a, b)

A define for abstracting matrix multiply operations between shading languages.


FFX_MODULO

Copied!

#define FFX_MODULO (a, b) (fmod(a, b))

A define for abstracting modulo operations between shading languages.


FFX_NOT_EQUAL

Copied!

#define FFX_NOT_EQUAL (x, y) x != y

A define for abstracting a ‘not equal’ comparison operator between two types.


FFX_SELECT

Copied!

#define FFX_SELECT (cond, arg1, arg2) cond ? arg1 : arg2

A define for abstracting select functionality for pre/post HLSL 21.


FFX_STATIC

Copied!

#define FFX_STATIC static

A define added to accept static markup on functions to aid CPU/GPU portability of code.


FFX_TRANSFORM_VECTOR

Copied!

#define FFX_TRANSFORM_VECTOR (a, b) mul(a, b)

A define for abstracting vector transformations between shading languages.


FFX_UNROLL

Copied!

#define FFX_UNROLL [unroll]

A define for abstracting loop unrolling between shading languages.


ffxF32ToF16

Copied!

#define ffxF32ToF16 f32tof16

Convert FfxFloat32 to half (in lower 16-bits of output).

This function implements the same fast technique that is documented here: ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf

The function supports denormals.

Some conversion rules are to make computations possibly “safer” on the GPU, -INF & -NaN -> -65504 +INF & +NaN -> +65504

Parameters:

f

The 32bit floating point value to convert.

Returns:

The closest 16bit floating point value to f.