summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2023-06-05 15:15:21 +0200
committerMarge Bot <emma+marge@anholt.net>2023-06-15 13:34:49 +0000
commite1f4c7928832a1065b43a280a9e7bd6d71bb0f51 (patch)
tree166e92d709a5642faf64fe345722eca2f3f8ada0 /src/compiler
parent590e191e775290081c04e740caba7c525b68b611 (diff)
nir: add and use nir_fdiv_imm
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23461>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_builder.h6
-rw-r--r--src/compiler/nir/nir_format_convert.h2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index b6890b54c7d..13557f782ca 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -820,6 +820,12 @@ nir_fmul_imm(nir_builder *build, nir_ssa_def *x, double y)
}
static inline nir_ssa_def *
+nir_fdiv_imm(nir_builder *build, nir_ssa_def *x, double y)
+{
+ return nir_fdiv(build, x, nir_imm_floatN_t(build, y, x->bit_size));
+}
+
+static inline nir_ssa_def *
nir_iand_imm(nir_builder *build, nir_ssa_def *x, uint64_t y)
{
assert(x->bit_size <= 64);
diff --git a/src/compiler/nir/nir_format_convert.h b/src/compiler/nir/nir_format_convert.h
index 68c5b59854c..079d55d617e 100644
--- a/src/compiler/nir/nir_format_convert.h
+++ b/src/compiler/nir/nir_format_convert.h
@@ -314,7 +314,7 @@ nir_format_linear_to_srgb(nir_builder *b, nir_ssa_def *c)
static inline nir_ssa_def *
nir_format_srgb_to_linear(nir_builder *b, nir_ssa_def *c)
{
- nir_ssa_def *linear = nir_fdiv(b, c, nir_imm_float(b, 12.92f));
+ nir_ssa_def *linear = nir_fdiv_imm(b, c, 12.92f);
nir_ssa_def *curved =
nir_fpow(b, nir_fmul_imm(b, nir_fadd_imm(b, c, 0.055f),
1.0 / 1.055f),