Mesa (master): tgsi: add generic instruction builder

Keith Whitwell keithw at kemper.freedesktop.org
Mon Aug 24 10:33:47 UTC 2009


Module: Mesa
Branch: master
Commit: b570a7e6b6ebd05e94fd91f2df53de7d2e2e05d2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b570a7e6b6ebd05e94fd91f2df53de7d2e2e05d2

Author: Keith Whitwell <keithw at vmware.com>
Date:   Mon Aug 24 11:32:06 2009 +0100

tgsi: add generic instruction builder

When translating an incoming shader (rather than building one from scratch)
it's preferable to be able to call a single, generic instruction emitter
rather than figuring out which of the opcode-specific functions to call.

---

 src/gallium/auxiliary/tgsi/tgsi_ureg.c |   23 +++++++++++++++++++++++
 src/gallium/auxiliary/tgsi/tgsi_ureg.h |   10 ++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index 7922931..7762243 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -605,6 +605,29 @@ ureg_fixup_insn_size(struct ureg_program *ureg,
 }
 
 
+void
+ureg_insn(struct ureg_program *ureg,
+          unsigned opcode,
+          const struct ureg_dst *dst,
+          unsigned nr_dst,
+          const struct ureg_src *src,
+          unsigned nr_src )
+{
+   unsigned insn, i;
+   boolean saturate;
+
+   saturate = nr_dst ? dst[0].Saturate : FALSE;
+
+   insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
+
+   for (i = 0; i < nr_dst; i++)
+      ureg_emit_dst( ureg, dst[i] );
+
+   for (i = 0; i < nr_src; i++)
+      ureg_emit_src( ureg, src[i] );
+
+   ureg_fixup_insn_size( ureg, insn );
+}
 
 
 
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index 5a48bb7..fbf174b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -199,6 +199,16 @@ ureg_fixup_label(struct ureg_program *ureg,
                  unsigned instruction_number );
 
 
+/* Generic instruction emitter.  Use if you need to pass the opcode as
+ * a parameter, rather than using the emit_OP() varients below.
+ */
+void
+ureg_insn(struct ureg_program *ureg,
+          unsigned opcode,
+          const struct ureg_dst *dst,
+          unsigned nr_dst,
+          const struct ureg_src *src,
+          unsigned nr_src );
 
 
 /***********************************************************************




More information about the mesa-commit mailing list