-static nir_ssa_def *
-vc4_nir_srgb_decode(nir_builder *b, nir_ssa_def *srgb)
-{
- nir_ssa_def *is_low = nir_flt(b, srgb, nir_imm_float(b, 0.04045));
- nir_ssa_def *low = nir_fmul(b, srgb, nir_imm_float(b, 1.0 / 12.92));
- nir_ssa_def *high = nir_fpow(b,
- nir_fmul(b,
- nir_fadd(b, srgb,
- nir_imm_float(b, 0.055)),
- nir_imm_float(b, 1.0 / 1.055)),
- nir_imm_float(b, 2.4));
-
- return nir_bcsel(b, is_low, low, high);
-}
-
-static nir_ssa_def *
-vc4_nir_srgb_encode(nir_builder *b, nir_ssa_def *linear)
-{
- nir_ssa_def *is_low = nir_flt(b, linear, nir_imm_float(b, 0.0031308));
- nir_ssa_def *low = nir_fmul(b, linear, nir_imm_float(b, 12.92));
- nir_ssa_def *high = nir_fsub(b,
- nir_fmul(b,
- nir_imm_float(b, 1.055),
- nir_fpow(b,
- linear,
- nir_imm_float(b, 0.41666))),
- nir_imm_float(b, 0.055));
-
- return nir_bcsel(b, is_low, low, high);
-}
-