Created
August 10, 2020 14:39
-
-
Save bbrezillon/9283df26059db636a12a8f7668aeeafd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static nir_ssa_def * | |
| build_round(nir_builder *nb, nir_ssa_def *src) | |
| { | |
| nir_ssa_def *half = nir_imm_floatN_t(nb, 0.5, src->bit_size); | |
| nir_ssa_def *truncated = nir_ftrunc(nb, src); | |
| nir_ssa_def *remainder = nir_fsub(nb, src, truncated); | |
| return nir_bcsel(nb, nir_fge(nb, nir_fabs(nb, remainder), half), | |
| nir_fadd(nb, truncated, nir_fsign(nb, src)), truncated); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment