tgsi: Add ureg_DECL_immediate_block_uint().
authorMichal Krol <michal@vmware.com>
Mon, 18 Jan 2010 11:11:05 +0000 (12:11 +0100)
committerMichal Krol <michal@vmware.com>
Mon, 18 Jan 2010 18:13:42 +0000 (19:13 +0100)
Allows declaring a contiguous block of immediates. Useful for
relative indexing.

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

index 8bd6f68dcc088b93c258ccf82f40f0a0a96eb9fa..a67d9c37f87c321a117b6af03974aa09a9e8b665 100644 (file)
@@ -655,6 +655,35 @@ ureg_DECL_immediate_uint( struct ureg_program *ureg,
 }
 
 
+struct ureg_src
+ureg_DECL_immediate_block_uint( struct ureg_program *ureg,
+                                const unsigned *v,
+                                unsigned nr )
+{
+   uint index;
+   uint i;
+
+   if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) {
+      set_bad(ureg);
+      return ureg_src_register(TGSI_FILE_IMMEDIATE, 0);
+   }
+
+   index = ureg->nr_immediates;
+   ureg->nr_immediates += (nr + 3) / 4;
+
+   for (i = index; i < ureg->nr_immediates; i++) {
+      ureg->immediate[i].type = TGSI_IMM_UINT32;
+      ureg->immediate[i].nr = nr > 4 ? 4 : nr;
+      memcpy(ureg->immediate[i].value.u,
+             &v[(i - index) * 4],
+             ureg->immediate[i].nr * sizeof(uint));
+      nr -= 4;
+   }
+
+   return ureg_src_register(TGSI_FILE_IMMEDIATE, index);
+}
+
+
 struct ureg_src
 ureg_DECL_immediate_int( struct ureg_program *ureg,
                          const int *v,
index 03eaf24854c331ebb7eaacadddbf011bdc0c6b52..a743be702b44f889d369b8d21327ee9461197688 100644 (file)
@@ -167,6 +167,11 @@ ureg_DECL_immediate_uint( struct ureg_program *,
                           const unsigned *v,
                           unsigned nr );
 
+struct ureg_src
+ureg_DECL_immediate_block_uint( struct ureg_program *,
+                                const unsigned *v,
+                                unsigned nr );
+
 struct ureg_src
 ureg_DECL_immediate_int( struct ureg_program *,
                          const int *v,