summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2015-11-07 22:31:22 -0800
committerKenneth Graunke <kenneth@whitecape.org>2015-11-08 18:10:55 -0800
commitfe2852f7e4c886a858e232c3c8ce304edd2ffd32 (patch)
treeaed86f22c7620bd99c141bd21153be5a4589d24e
parent16a2195bc1e10771cbae722dd3cdf36145ef13b9 (diff)
i965/fs: Implement get_nir_src_imm().
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_nir.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 67f9f59e5d..e1a1e3ea83 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -280,6 +280,7 @@ public:
void nir_emit_jump(const brw::fs_builder &bld,
nir_jump_instr *instr);
fs_reg get_nir_src(nir_src src);
+ fs_reg get_nir_src_imm(nir_src src);
fs_reg get_nir_dest(nir_dest dest);
fs_reg get_nir_image_deref(const nir_deref_var *deref);
void emit_percomp(const brw::fs_builder &bld, const fs_inst &inst,
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 63a44c7b79..559d47831c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1058,6 +1058,16 @@ fs_visitor::get_nir_src(nir_src src)
return retype(reg, BRW_REGISTER_TYPE_D);
}
+/**
+ * Return an IMM for constants; otherwise call get_nir_src() as normal.
+ */
+fs_reg
+fs_visitor::get_nir_src_imm(nir_src src)
+{
+ nir_const_value *val = nir_src_as_const_value(src);
+ return val ? fs_reg(val->i[0]) : get_nir_src(src);
+}
+
fs_reg
fs_visitor::get_nir_dest(nir_dest dest)
{