ureg: add generic emitters for tex and branch instructions
authorKeith Whitwell <keithw@vmware.com>
Sat, 12 Sep 2009 21:18:00 +0000 (14:18 -0700)
committerKeith Whitwell <keithw@vmware.com>
Sat, 12 Sep 2009 21:18:00 +0000 (14:18 -0700)
Couldn't previously emit these except by calling the opcode-specific helper.

src/gallium/auxiliary/tgsi/tgsi_ureg.c
src/gallium/auxiliary/tgsi/tgsi_ureg.h

index 9222af91fe1e92358be4f80bdeffb62e4d0c200a..352cb5a1e3205aee825e21da7b899014c681843e 100644 (file)
@@ -564,6 +564,19 @@ ureg_emit_dst( struct ureg_program *ureg,
 }
 
 
+static void validate( unsigned opcode,
+                      unsigned nr_dst,
+                      unsigned nr_src )
+{
+#ifdef DEBUG
+   const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode );
+   assert(info);
+   if(info) {
+      assert(nr_dst == info->num_dst);
+      assert(nr_src == info->num_src);
+   }
+#endif
+}
 
 unsigned
 ureg_emit_insn(struct ureg_program *ureg,
@@ -574,6 +587,8 @@ ureg_emit_insn(struct ureg_program *ureg,
 {
    union tgsi_any_token *out;
 
+   validate( opcode, num_dst, num_src );
+   
    out = get_tokens( ureg, DOMAIN_INSN, 1 );
    out[0].value = 0;
    out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
@@ -676,17 +691,6 @@ ureg_insn(struct ureg_program *ureg,
    unsigned insn, i;
    boolean saturate;
 
-#ifdef DEBUG
-   {
-      const struct tgsi_opcode_info *info = tgsi_get_opcode_info( opcode );
-      assert(info);
-      if(info) {
-         assert(nr_dst == info->num_dst);
-         assert(nr_src == info->num_src);
-      }
-   }
-#endif
-   
    saturate = nr_dst ? dst[0].Saturate : FALSE;
 
    insn = ureg_emit_insn( ureg, opcode, saturate, nr_dst, nr_src );
@@ -700,6 +704,53 @@ ureg_insn(struct ureg_program *ureg,
    ureg_fixup_insn_size( ureg, insn );
 }
 
+void
+ureg_tex_insn(struct ureg_program *ureg,
+              unsigned opcode,
+              const struct ureg_dst *dst,
+              unsigned nr_dst,
+              unsigned target,
+              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 );
+
+   ureg_emit_texture( ureg, insn, target );                             \
+
+   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 );
+}
+
+
+void
+ureg_label_insn(struct ureg_program *ureg,
+                unsigned opcode,
+                const struct ureg_src *src,
+                unsigned nr_src,
+                unsigned *label_token )
+{
+   unsigned insn, i;
+
+   insn = ureg_emit_insn( ureg, opcode, FALSE, 0, nr_src );
+
+   ureg_emit_label( ureg, insn, label_token );                  \
+
+   for (i = 0; i < nr_src; i++)
+      ureg_emit_src( ureg, src[i] );
+
+   ureg_fixup_insn_size( ureg, insn );
+}
+
 
 
 static void emit_decl( struct ureg_program *ureg,
index 627a5b0c523c88c6af34309664ab394cfa87bb06..48aeaaf459daf9c6462ba40866bd7cd8c952cd6d 100644 (file)
@@ -233,6 +233,24 @@ ureg_insn(struct ureg_program *ureg,
           unsigned nr_src );
 
 
+void
+ureg_tex_insn(struct ureg_program *ureg,
+              unsigned opcode,
+              const struct ureg_dst *dst,
+              unsigned nr_dst,
+              unsigned target,
+              const struct ureg_src *src,
+              unsigned nr_src );
+
+
+void
+ureg_label_insn(struct ureg_program *ureg,
+                unsigned opcode,
+                const struct ureg_src *src,
+                unsigned nr_src,
+                unsigned *label);
+
+
 /***********************************************************************
  * Internal instruction helpers, don't call these directly:
  */