Add "hello world" for gc3000 OpenCL
diff --git a/.gitignore b/.gitignore
index a2d6486..01415a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,5 +12,6 @@
 *.a
 *.swp
 
-src/etnaviv_cl_test
+src/etnaviv_cl_test_gc2000
+src/etnaviv_cl_test_gc3000
 src/etnaviv_verifyops
diff --git a/src/Makefile.am b/src/Makefile.am
index e03ba35..9ecbbf8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,13 +1,19 @@
-bin_PROGRAMS = etnaviv_cl_test etnaviv_verifyops
+bin_PROGRAMS = etnaviv_cl_test_gc2000 \
+	       etnaviv_cl_test_gc3000 \
+	       etnaviv_verifyops
 
 EXTRA_LIBRARIES = shared.a
 
 shared_a_SOURCES = drm_setup.c
 shared_a_CFLAGS = $(LIBDRM_CFLAGS) $(LIBDRM_ETNAVIV_CFLAGS)
 
-etnaviv_cl_test_SOURCES = etnaviv_cl_test.c
-etnaviv_cl_test_LDADD = shared.a $(LIBDRM_LIBS) $(LIBDRM_ETNAVIV_LIBS)
-etnaviv_cl_test_CFLAGS = $(LIBDRM_CFLAGS) $(LIBDRM_ETNAVIV_CFLAGS)
+etnaviv_cl_test_gc2000_SOURCES = etnaviv_cl_test_gc2000.c
+etnaviv_cl_test_gc2000_LDADD = shared.a $(LIBDRM_LIBS) $(LIBDRM_ETNAVIV_LIBS)
+etnaviv_cl_test_gc2000_CFLAGS = $(LIBDRM_CFLAGS) $(LIBDRM_ETNAVIV_CFLAGS)
+
+etnaviv_cl_test_gc3000_SOURCES = etnaviv_cl_test_gc3000.c
+etnaviv_cl_test_gc3000_LDADD = shared.a $(LIBDRM_LIBS) $(LIBDRM_ETNAVIV_LIBS)
+etnaviv_cl_test_gc3000_CFLAGS = $(LIBDRM_CFLAGS) $(LIBDRM_ETNAVIV_CFLAGS)
 
 etnaviv_verifyops_SOURCES = etnaviv_verifyops.c
 etnaviv_verifyops_LDADD = shared.a $(LIBDRM_LIBS) $(LIBDRM_ETNAVIV_LIBS)
diff --git a/src/cmdstream.xml.h b/src/cmdstream.xml.h
index 050c91e..4114b71 100644
--- a/src/cmdstream.xml.h
+++ b/src/cmdstream.xml.h
@@ -8,9 +8,9 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- cmdstream.xml (  13632 bytes, from 2016-11-02 13:52:32)
+- cmdstream.xml (  14313 bytes, from 2016-11-17 18:46:23)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 
 Copyright (C) 2012-2016 by the following authors:
 - Wladimir J. van der Laan <laanwj@gmail.com>
@@ -50,7 +50,7 @@
 #define FE_OPCODE_STALL						0x00000009
 #define FE_OPCODE_CALL						0x0000000a
 #define FE_OPCODE_RETURN					0x0000000b
-#define FE_OPCODE_DRAW_NEW					0x0000000c
+#define FE_OPCODE_DRAW_INSTANCED				0x0000000c
 #define FE_OPCODE_CHIP_SELECT					0x0000000d
 #define PRIMITIVE_TYPE_POINTS					0x00000001
 #define PRIMITIVE_TYPE_LINES					0x00000002
@@ -239,22 +239,32 @@
 #define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP1			0x00000002
 #define VIV_FE_CHIP_SELECT_HEADER_ENABLE_CHIP0			0x00000001
 
-#define VIV_FE_DRAW_NEW						0x00000000
+#define VIV_FE_DRAW_INSTANCED					0x00000000
 
-#define VIV_FE_DRAW_NEW_HEADER					0x00000000
-#define VIV_FE_DRAW_NEW_HEADER_OP__MASK				0xf8000000
-#define VIV_FE_DRAW_NEW_HEADER_OP__SHIFT			27
-#define VIV_FE_DRAW_NEW_HEADER_OP_DRAW_NEW			0x60000000
-#define VIV_FE_DRAW_NEW_HEADER_TYPE__MASK			0x00ff0000
-#define VIV_FE_DRAW_NEW_HEADER_TYPE__SHIFT			16
-#define VIV_FE_DRAW_NEW_HEADER_TYPE(x)				(((x) << VIV_FE_DRAW_NEW_HEADER_TYPE__SHIFT) & VIV_FE_DRAW_NEW_HEADER_TYPE__MASK)
-#define VIV_FE_DRAW_NEW_HEADER_UNK0				0x00000001
+#define VIV_FE_DRAW_INSTANCED_HEADER				0x00000000
+#define VIV_FE_DRAW_INSTANCED_HEADER_OP__MASK			0xf8000000
+#define VIV_FE_DRAW_INSTANCED_HEADER_OP__SHIFT			27
+#define VIV_FE_DRAW_INSTANCED_HEADER_OP_DRAW_INSTANCED		0x60000000
+#define VIV_FE_DRAW_INSTANCED_HEADER_INDEXED			0x00100000
+#define VIV_FE_DRAW_INSTANCED_HEADER_TYPE__MASK			0x000f0000
+#define VIV_FE_DRAW_INSTANCED_HEADER_TYPE__SHIFT		16
+#define VIV_FE_DRAW_INSTANCED_HEADER_TYPE(x)			(((x) << VIV_FE_DRAW_INSTANCED_HEADER_TYPE__SHIFT) & VIV_FE_DRAW_INSTANCED_HEADER_TYPE__MASK)
+#define VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO__MASK	0x0000ffff
+#define VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO__SHIFT	0
+#define VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO(x)	(((x) << VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO__SHIFT) & VIV_FE_DRAW_INSTANCED_HEADER_INSTANCE_COUNT_LO__MASK)
 
-#define VIV_FE_DRAW_NEW_COUNT					0x00000004
+#define VIV_FE_DRAW_INSTANCED_COUNT				0x00000004
+#define VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI__MASK	0xff000000
+#define VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI__SHIFT	24
+#define VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI(x)	(((x) << VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI__SHIFT) & VIV_FE_DRAW_INSTANCED_COUNT_INSTANCE_COUNT_HI__MASK)
+#define VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT__MASK		0x00ffffff
+#define VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT__SHIFT		0
+#define VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT(x)		(((x) << VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT__SHIFT) & VIV_FE_DRAW_INSTANCED_COUNT_VERTEX_COUNT__MASK)
 
-#define VIV_FE_DRAW_NEW_START					0x00000008
-
-#define VIV_FE_DRAW_NEW_UNKNOWN					0x0000000c
+#define VIV_FE_DRAW_INSTANCED_START				0x00000008
+#define VIV_FE_DRAW_INSTANCED_START_INDEX__MASK			0xffffffff
+#define VIV_FE_DRAW_INSTANCED_START_INDEX__SHIFT		0
+#define VIV_FE_DRAW_INSTANCED_START_INDEX(x)			(((x) << VIV_FE_DRAW_INSTANCED_START_INDEX__SHIFT) & VIV_FE_DRAW_INSTANCED_START_INDEX__MASK)
 
 
 #endif /* CMDSTREAM_XML */
diff --git a/src/common.xml.h b/src/common.xml.h
index 45cb7a5..06bfb0b 100644
--- a/src/common.xml.h
+++ b/src/common.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
@@ -311,7 +311,7 @@
 #define chipMinorFeatures5_UNK24				0x01000000
 #define chipMinorFeatures5_UNK25				0x02000000
 #define chipMinorFeatures5_UNK26				0x04000000
-#define chipMinorFeatures5_DEPTHSTENCIL_NATIVE_SUPPORT		0x08000000
+#define chipMinorFeatures5_RS_DEPTHSTENCIL_NATIVE_SUPPORT	0x08000000
 #define chipMinorFeatures5_V2_MSAA_COMP_FIX			0x10000000
 #define chipMinorFeatures5_UNK29				0x20000000
 #define chipMinorFeatures5_UNK30				0x40000000
diff --git a/src/etnaviv_cl_test.c b/src/etnaviv_cl_test_gc2000.c
similarity index 100%
rename from src/etnaviv_cl_test.c
rename to src/etnaviv_cl_test_gc2000.c
diff --git a/src/etnaviv_cl_test_gc3000.c b/src/etnaviv_cl_test_gc3000.c
new file mode 100644
index 0000000..5d9e69a
--- /dev/null
+++ b/src/etnaviv_cl_test_gc3000.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2016 Etnaviv Project.
+ * Distributed under the MIT software license, see the accompanying
+ * file COPYING or http://www.opensource.org/licenses/mit-license.php.
+ */
+/* Basic "hello world" test */
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "drm_setup.h"
+#include "cmdstream.h"
+
+#include "state.xml.h"
+#include "state_3d.xml.h"
+#include "common.xml.h"
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/* GPU code to write "hello world" */
+uint32_t hello_code[] = {
+/*   0: */ 0x00801009, 0x00000000, 0x00000000, 0x20000008,  /* mov	t0.x___, void, void, u0.xxxx */
+/*   1: */ 0x01001009, 0x00000000, 0x00000000, 0x00000008,  /* mov	t0._y__, void, void, t0.xxxx */
+/*   2: */ 0x00800033, 0x15400c00, 0x80aa0040, 0x7400048a,  /* store.s8	mem.x___, t0.yyyy, u0.yyyy, ? */
+/*   3: */ 0x00800033, 0x00000c00, 0x900000c0, 0x7400065f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   4: */ 0x00800033, 0x00000c00, 0x90000140, 0x740006cf,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   5: */ 0x00800033, 0x00000c00, 0x900001c0, 0x740006cf,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   6: */ 0x00800033, 0x00000c00, 0x90000240, 0x740006ff,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   7: */ 0x00800033, 0x00000c00, 0x900002c0, 0x740002cf,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   8: */ 0x00800033, 0x00000c00, 0x90000340, 0x7400020f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*   9: */ 0x00800033, 0x00000c00, 0x900003c0, 0x7400057f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  10: */ 0x00800033, 0x00000c00, 0x90000440, 0x740006ff,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  11: */ 0x00800033, 0x00000c00, 0x900004c0, 0x7400072f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  12: */ 0x00800033, 0x00000c00, 0x90000540, 0x740006cf,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  13: */ 0x00800033, 0x00000c00, 0x900005c0, 0x7400064f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  14: */ 0x00800033, 0x00000c00, 0x90000640, 0x7400021f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  15: */ 0x00800033, 0x00000c00, 0x900006c0, 0x7400000f,  /* store.s8	mem.x___, t0.xxxx, ?, ? */
+/*  16: */ 0x00000000, 0x00000000, 0x00000000, 0x00000000,  /* nop	void, void, void, void */
+};
+
+static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo *code, struct etna_bo *bmp)
+{
+    etna_set_state(stream, VIVS_PS_INPUT_COUNT, VIVS_PS_INPUT_COUNT_COUNT(1) | VIVS_PS_INPUT_COUNT_UNK8(31));
+    etna_set_state(stream, VIVS_PS_TEMP_REGISTER_CONTROL, VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(4));
+    etna_set_state(stream, VIVS_VS_OUTPUT_COUNT, 0);
+    etna_set_state(stream, VIVS_CL_UNK00924, 0x0);
+    etna_set_state(stream, VIVS_VS_NEW_UNK00860, 0x1011);
+    etna_set_state_from_bo(stream, VIVS_SH_UNIFORMS(0), bmp, ETNA_RELOC_WRITE);
+    etna_stall(stream, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+    etna_set_state(stream, VIVS_RA_CONTROL, VIVS_RA_CONTROL_UNK0);
+    etna_set_state(stream, VIVS_PS_OUTPUT_REG, 0x0);
+    etna_set_state(stream, VIVS_PS_TEMP_REGISTER_CONTROL, VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(4));
+    etna_set_state(stream, VIVS_GL_VARYING_NUM_COMPONENTS, VIVS_GL_VARYING_NUM_COMPONENTS_VAR0(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR1(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR2(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR3(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR4(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR5(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR6(0x0) | VIVS_GL_VARYING_NUM_COMPONENTS_VAR7(0x0));
+    etna_set_state(stream, VIVS_GL_UNK03834, 0x0);
+    etna_set_state(stream, VIVS_VS_NEW_UNK00860, 0x1011);
+    etna_set_state(stream, VIVS_PS_UNK01024, 0x0);
+    etna_set_state(stream, VIVS_SH_UNIFORMS(1), 0x0);
+    etna_set_state(stream, VIVS_VS_UNK00868, 0x21);
+    etna_set_state(stream, VIVS_PS_RANGE, VIVS_PS_RANGE_LOW(0x0) | VIVS_PS_RANGE_HIGH(0xf));
+    etna_set_state_from_bo(stream, VIVS_PS_INST_ADDR, code, ETNA_RELOC_READ);
+    etna_set_state(stream, VIVS_PS_INPUT_COUNT, VIVS_PS_INPUT_COUNT_COUNT(1) | VIVS_PS_INPUT_COUNT_UNK8(31));
+    etna_set_state(stream, VIVS_PS_TEMP_REGISTER_CONTROL, VIVS_PS_TEMP_REGISTER_CONTROL_NUM_TEMPS(4));
+    etna_set_state(stream, VIVS_PS_CONTROL, 0);
+    etna_set_state(stream, VIVS_PA_ATTRIBUTE_ELEMENT_COUNT, VIVS_PA_ATTRIBUTE_ELEMENT_COUNT_UNK0(0x0) | VIVS_PA_ATTRIBUTE_ELEMENT_COUNT_COUNT(0x0));
+    etna_set_state(stream, VIVS_GL_VARYING_TOTAL_COMPONENTS, VIVS_GL_VARYING_TOTAL_COMPONENTS_NUM(0x0));
+    etna_set_state(stream, VIVS_PS_UNK01030, 0x0);
+    etna_set_state(stream, VIVS_VS_LOAD_BALANCING, VIVS_VS_LOAD_BALANCING_A(0x0) | VIVS_VS_LOAD_BALANCING_B(0x0) | VIVS_VS_LOAD_BALANCING_C(0x3f) | VIVS_VS_LOAD_BALANCING_D(0xf));
+    etna_set_state(stream, VIVS_VS_OUTPUT_COUNT, 1);
+    etna_set_state(stream, VIVS_CL_CONFIG, VIVS_CL_CONFIG_DIMENSIONS(0x1) | VIVS_CL_CONFIG_TRAVERSE_ORDER(0x0) | VIVS_CL_CONFIG_SWATH_SIZE_X(0x0) | VIVS_CL_CONFIG_SWATH_SIZE_Y(0x0) | VIVS_CL_CONFIG_SWATH_SIZE_Z(0x0) | VIVS_CL_CONFIG_VALUE_ORDER(0x3));
+    etna_set_state(stream, VIVS_CL_GLOBAL_X, VIVS_CL_GLOBAL_X_SIZE(0x1) | VIVS_CL_GLOBAL_X_OFFSET(0x0));
+    etna_set_state(stream, VIVS_CL_GLOBAL_Y, VIVS_CL_GLOBAL_Y_SIZE(0x0) | VIVS_CL_GLOBAL_Y_OFFSET(0x0));
+    etna_set_state(stream, VIVS_CL_GLOBAL_Z, VIVS_CL_GLOBAL_Z_SIZE(0x0) | VIVS_CL_GLOBAL_Z_OFFSET(0x0));
+    etna_set_state(stream, VIVS_CL_WORKGROUP_X, VIVS_CL_WORKGROUP_X_SIZE(0x0) | VIVS_CL_WORKGROUP_X_COUNT(0x0));
+    etna_set_state(stream, VIVS_CL_WORKGROUP_Y, VIVS_CL_WORKGROUP_Y_SIZE(0x3ff) | VIVS_CL_WORKGROUP_Y_COUNT(0xffff));
+    etna_set_state(stream, VIVS_CL_WORKGROUP_Z, VIVS_CL_WORKGROUP_Z_SIZE(0x3ff) | VIVS_CL_WORKGROUP_Z_COUNT(0xffff));
+    etna_set_state(stream, VIVS_CL_THREAD_ALLOCATION, 0x1);
+    etna_set_state(stream, VIVS_CL_UNK00940, 0x0);
+    etna_set_state(stream, VIVS_CL_UNK00944, 0xffffffff);
+    etna_set_state(stream, VIVS_CL_UNK00948, 0xffffffff);
+    etna_set_state(stream, VIVS_CL_UNK0094C, 0x0);
+    etna_set_state(stream, VIVS_CL_UNK00950, 0x3ff);
+    etna_set_state(stream, VIVS_CL_UNK00954, 0x3ff);
+    etna_set_state(stream, VIVS_CL_KICKER, 0xbadabeeb);
+    etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_TEXTURE | VIVS_GL_FLUSH_CACHE_SHADER_L1);
+    etna_stall(stream, SYNC_RECIPIENT_FE, SYNC_RECIPIENT_PE);
+    etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_DEPTH | VIVS_GL_FLUSH_CACHE_COLOR);
+}
+
+int main(int argc, char *argv[])
+{
+    struct drm_test_info *info;
+    struct etna_bo *bmp, *code;
+    static const size_t out_size = 65536;
+    static const size_t code_size = 4096;
+    if ((info = drm_test_setup(argc, argv)) == NULL) {
+        return 1;
+    }
+
+    code = etna_bo_new(info->dev, code_size, DRM_ETNA_GEM_CACHE_UNCACHED);
+    if (!code) {
+        fprintf(stderr, "Unable to allocate buffer\n");
+        goto out;
+    }
+    memcpy(etna_bo_map(code), hello_code, sizeof(hello_code));
+
+    bmp = etna_bo_new(info->dev, out_size, DRM_ETNA_GEM_CACHE_UNCACHED);
+    if (!bmp) {
+        fprintf(stderr, "Unable to allocate buffer\n");
+        goto out;
+    }
+    memset(etna_bo_map(bmp), 0, out_size);
+
+    /* generate command sequence */
+    gen_cmd_stream(info->stream, code, bmp);
+
+    etna_cmd_stream_finish(info->stream);
+
+    const unsigned char *data = etna_bo_map(bmp);
+    for(int i=0; i<0x100; ++i) {
+        printf("%02x ", data[i]);
+    }
+    printf("\n");
+    printf("%s\n", data);
+
+    drm_test_teardown(info);
+    return 0;
+out:
+    drm_test_teardown(info);
+    return 1;
+}
diff --git a/src/isa.xml.h b/src/isa.xml.h
index 02831ad..1eccfb0 100644
--- a/src/isa.xml.h
+++ b/src/isa.xml.h
@@ -8,7 +8,7 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- isa.xml       (  19227 bytes, from 2016-10-29 07:29:22)
+- isa.xml       (  24392 bytes, from 2016-11-10 15:14:07)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
@@ -83,6 +83,7 @@
 #define INST_OPCODE_STORE					0x00000033
 #define INST_OPCODE_IMULLO0					0x0000003c
 #define INST_OPCODE_IMULHI0					0x00000040
+#define INST_OPCODE_IMADLO0					0x0000004c
 #define INST_OPCODE_LEADZERO					0x00000058
 #define INST_OPCODE_LSHIFT					0x00000059
 #define INST_OPCODE_RSHIFT					0x0000005a
@@ -120,6 +121,14 @@
 #define INST_SWIZ_COMP_Y					0x00000001
 #define INST_SWIZ_COMP_Z					0x00000002
 #define INST_SWIZ_COMP_W					0x00000003
+#define INST_TYPE_F32						0x00000000
+#define INST_TYPE_S32						0x00000001
+#define INST_TYPE_S8						0x00000002
+#define INST_TYPE_U16						0x00000003
+#define INST_TYPE_F16						0x00000004
+#define INST_TYPE_S16						0x00000005
+#define INST_TYPE_U32						0x00000006
+#define INST_TYPE_U8						0x00000007
 #define INST_COMPS_X						0x00000001
 #define INST_COMPS_Y						0x00000002
 #define INST_COMPS_Z						0x00000004
@@ -169,7 +178,7 @@
 #define VIV_ISA_WORD_1_SRC0_REG__MASK				0x001ff000
 #define VIV_ISA_WORD_1_SRC0_REG__SHIFT				12
 #define VIV_ISA_WORD_1_SRC0_REG(x)				(((x) << VIV_ISA_WORD_1_SRC0_REG__SHIFT) & VIV_ISA_WORD_1_SRC0_REG__MASK)
-#define VIV_ISA_WORD_1_UNK1_21					0x00200000
+#define VIV_ISA_WORD_1_TYPE_BIT2				0x00200000
 #define VIV_ISA_WORD_1_SRC0_SWIZ__MASK				0x3fc00000
 #define VIV_ISA_WORD_1_SRC0_SWIZ__SHIFT				22
 #define VIV_ISA_WORD_1_SRC0_SWIZ(x)				(((x) << VIV_ISA_WORD_1_SRC0_SWIZ__SHIFT) & VIV_ISA_WORD_1_SRC0_SWIZ__MASK)
@@ -196,9 +205,9 @@
 #define VIV_ISA_WORD_2_SRC1_AMODE__MASK				0x38000000
 #define VIV_ISA_WORD_2_SRC1_AMODE__SHIFT			27
 #define VIV_ISA_WORD_2_SRC1_AMODE(x)				(((x) << VIV_ISA_WORD_2_SRC1_AMODE__SHIFT) & VIV_ISA_WORD_2_SRC1_AMODE__MASK)
-#define VIV_ISA_WORD_2_UNK2_30__MASK				0xc0000000
-#define VIV_ISA_WORD_2_UNK2_30__SHIFT				30
-#define VIV_ISA_WORD_2_UNK2_30(x)				(((x) << VIV_ISA_WORD_2_UNK2_30__SHIFT) & VIV_ISA_WORD_2_UNK2_30__MASK)
+#define VIV_ISA_WORD_2_TYPE_BIT01__MASK				0xc0000000
+#define VIV_ISA_WORD_2_TYPE_BIT01__SHIFT			30
+#define VIV_ISA_WORD_2_TYPE_BIT01(x)				(((x) << VIV_ISA_WORD_2_TYPE_BIT01__SHIFT) & VIV_ISA_WORD_2_TYPE_BIT01__MASK)
 
 #define VIV_ISA_WORD_3						0x0000000c
 #define VIV_ISA_WORD_3_SRC1_RGROUP__MASK			0x00000007
diff --git a/src/state.xml.h b/src/state.xml.h
index f9a7a19..7ce3dc8 100644
--- a/src/state.xml.h
+++ b/src/state.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
@@ -50,6 +50,9 @@
 #define FE_VERTEX_STREAM_CONTROL_VERTEX_STRIDE__MASK		0x000000ff
 #define FE_VERTEX_STREAM_CONTROL_VERTEX_STRIDE__SHIFT		0
 #define FE_VERTEX_STREAM_CONTROL_VERTEX_STRIDE(x)		(((x) << FE_VERTEX_STREAM_CONTROL_VERTEX_STRIDE__SHIFT) & FE_VERTEX_STREAM_CONTROL_VERTEX_STRIDE__MASK)
+#define FE_VERTEX_STREAM_CONTROL_VERTEX_DIVISOR__MASK		0x00ff0000
+#define FE_VERTEX_STREAM_CONTROL_VERTEX_DIVISOR__SHIFT		16
+#define FE_VERTEX_STREAM_CONTROL_VERTEX_DIVISOR(x)		(((x) << FE_VERTEX_STREAM_CONTROL_VERTEX_DIVISOR__SHIFT) & FE_VERTEX_STREAM_CONTROL_VERTEX_DIVISOR__MASK)
 #define VIVS_FE							0x00000000
 
 #define VIVS_FE_VERTEX_ELEMENT_CONFIG(i0)		       (0x00000600 + 0x4*(i0))
@@ -99,6 +102,7 @@
 #define VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_CHAR		0x00000000
 #define VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_SHORT	0x00000001
 #define VIVS_FE_INDEX_STREAM_CONTROL_TYPE_UNSIGNED_INT		0x00000002
+#define VIVS_FE_INDEX_STREAM_CONTROL_PRIMITIVE_RESTART		0x00000100
 
 #define VIVS_FE_VERTEX_STREAM_BASE_ADDR				0x0000064c
 
@@ -174,7 +178,7 @@
 
 #define VIVS_FE_AUTO_FLUSH					0x00000670
 
-#define VIVS_FE_UNK00674					0x00000674
+#define VIVS_FE_PRIMITIVE_RESTART_INDEX				0x00000674
 
 #define VIVS_FE_UNK00678					0x00000678
 
diff --git a/src/state_2d.xml.h b/src/state_2d.xml.h
index bab6741..33ac5d5 100644
--- a/src/state_2d.xml.h
+++ b/src/state_2d.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
diff --git a/src/state_3d.xml.h b/src/state_3d.xml.h
index 61c8997..7e1015a 100644
--- a/src/state_3d.xml.h
+++ b/src/state_3d.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
@@ -337,6 +337,18 @@
 
 #define VIVS_CL_UNK00924					0x00000924
 
+#define VIVS_CL_UNK00940					0x00000940
+
+#define VIVS_CL_UNK00944					0x00000944
+
+#define VIVS_CL_UNK00948					0x00000948
+
+#define VIVS_CL_UNK0094C					0x0000094c
+
+#define VIVS_CL_UNK00950					0x00000950
+
+#define VIVS_CL_UNK00954					0x00000954
+
 #define VIVS_PA							0x00000000
 
 #define VIVS_PA_VIEWPORT_SCALE_X				0x00000a00
@@ -413,9 +425,11 @@
 
 #define VIVS_PA_VIEWPORT_UNK00A84				0x00000a84
 
-#define VIVS_PA_UNK00A88					0x00000a88
+#define VIVS_PA_FLAGS						0x00000a88
+#define VIVS_PA_FLAGS_UNK24					0x01000000
+#define VIVS_PA_FLAGS_ZCONVERT_BYPASS				0x40000000
 
-#define VIVS_PA_VIEWPORT_UNK00A8C				0x00000a8c
+#define VIVS_PA_ZFARCLIPPING					0x00000a8c
 
 #define VIVS_SE							0x00000000
 
@@ -456,9 +470,11 @@
 #define VIVS_RA_MULTISAMPLE_UNK00E10__ESIZE			0x00000004
 #define VIVS_RA_MULTISAMPLE_UNK00E10__LEN			0x00000004
 
-#define VIVS_RA_UNK00E20(i0)				       (0x00000e20 + 0x4*(i0))
-#define VIVS_RA_UNK00E20__ESIZE					0x00000004
-#define VIVS_RA_UNK00E20__LEN					0x00000004
+#define VIVS_RA_HDEPTH_CONTROL					0x00000e20
+#define VIVS_RA_HDEPTH_CONTROL_UNK0				0x00000001
+#define VIVS_RA_HDEPTH_CONTROL_COMPARE__MASK			0x00007000
+#define VIVS_RA_HDEPTH_CONTROL_COMPARE__SHIFT			12
+#define VIVS_RA_HDEPTH_CONTROL_COMPARE(x)			(((x) << VIVS_RA_HDEPTH_CONTROL_COMPARE__SHIFT) & VIVS_RA_HDEPTH_CONTROL_COMPARE__MASK)
 
 #define VIVS_RA_CENTROID_TABLE(i0)			       (0x00000e40 + 0x4*(i0))
 #define VIVS_RA_CENTROID_TABLE__ESIZE				0x00000004
@@ -501,7 +517,7 @@
 
 #define VIVS_PS_UNK01024					0x00001024
 
-#define VIVS_PS_UNK01028					0x00001028
+#define VIVS_PS_INST_ADDR					0x00001028
 
 #define VIVS_PS_UNK01030					0x00001030
 
@@ -535,6 +551,7 @@
 #define VIVS_PE_DEPTH_CONFIG_WRITE_ENABLE_MASK			0x00002000
 #define VIVS_PE_DEPTH_CONFIG_EARLY_Z				0x00010000
 #define VIVS_PE_DEPTH_CONFIG_EARLY_Z_MASK			0x00020000
+#define VIVS_PE_DEPTH_CONFIG_UNK18				0x00040000
 #define VIVS_PE_DEPTH_CONFIG_ONLY_DEPTH				0x00100000
 #define VIVS_PE_DEPTH_CONFIG_ONLY_DEPTH_MASK			0x00200000
 #define VIVS_PE_DEPTH_CONFIG_DISABLE_ZS				0x01000000
@@ -602,9 +619,9 @@
 #define VIVS_PE_STENCIL_CONFIG_MASK_FRONT__MASK			0x00ff0000
 #define VIVS_PE_STENCIL_CONFIG_MASK_FRONT__SHIFT		16
 #define VIVS_PE_STENCIL_CONFIG_MASK_FRONT(x)			(((x) << VIVS_PE_STENCIL_CONFIG_MASK_FRONT__SHIFT) & VIVS_PE_STENCIL_CONFIG_MASK_FRONT__MASK)
-#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK__MASK			0xff000000
-#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK__SHIFT		24
-#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK(x)			(((x) << VIVS_PE_STENCIL_CONFIG_WRITE_MASK__SHIFT) & VIVS_PE_STENCIL_CONFIG_WRITE_MASK__MASK)
+#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK_FRONT__MASK		0xff000000
+#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK_FRONT__SHIFT		24
+#define VIVS_PE_STENCIL_CONFIG_WRITE_MASK_FRONT(x)		(((x) << VIVS_PE_STENCIL_CONFIG_WRITE_MASK_FRONT__SHIFT) & VIVS_PE_STENCIL_CONFIG_WRITE_MASK_FRONT__MASK)
 
 #define VIVS_PE_ALPHA_OP					0x00001420
 #define VIVS_PE_ALPHA_OP_ALPHA_TEST				0x00000001
@@ -675,6 +692,8 @@
 #define VIVS_PE_COLOR_FORMAT_OVERWRITE_MASK			0x00020000
 #define VIVS_PE_COLOR_FORMAT_SUPER_TILED			0x00100000
 #define VIVS_PE_COLOR_FORMAT_SUPER_TILED_MASK			0x00200000
+#define VIVS_PE_COLOR_FORMAT_UNK25				0x02000000
+#define VIVS_PE_COLOR_FORMAT_UNK26				0x04000000
 
 #define VIVS_PE_COLOR_ADDR					0x00001430
 
@@ -723,11 +742,29 @@
 #define VIVS_PE_DITHER__ESIZE					0x00000004
 #define VIVS_PE_DITHER__LEN					0x00000002
 
-#define VIVS_PE_UNK014B0					0x000014b0
+#define VIVS_PE_ALPHA_COLOR_EXT0				0x000014b0
+#define VIVS_PE_ALPHA_COLOR_EXT0_B__MASK			0x0000ffff
+#define VIVS_PE_ALPHA_COLOR_EXT0_B__SHIFT			0
+#define VIVS_PE_ALPHA_COLOR_EXT0_B(x)				(((x) << VIVS_PE_ALPHA_COLOR_EXT0_B__SHIFT) & VIVS_PE_ALPHA_COLOR_EXT0_B__MASK)
+#define VIVS_PE_ALPHA_COLOR_EXT0_G__MASK			0xffff0000
+#define VIVS_PE_ALPHA_COLOR_EXT0_G__SHIFT			16
+#define VIVS_PE_ALPHA_COLOR_EXT0_G(x)				(((x) << VIVS_PE_ALPHA_COLOR_EXT0_G__SHIFT) & VIVS_PE_ALPHA_COLOR_EXT0_G__MASK)
 
-#define VIVS_PE_UNK014B4					0x000014b4
+#define VIVS_PE_ALPHA_COLOR_EXT1				0x000014b4
+#define VIVS_PE_ALPHA_COLOR_EXT1_R__MASK			0x0000ffff
+#define VIVS_PE_ALPHA_COLOR_EXT1_R__SHIFT			0
+#define VIVS_PE_ALPHA_COLOR_EXT1_R(x)				(((x) << VIVS_PE_ALPHA_COLOR_EXT1_R__SHIFT) & VIVS_PE_ALPHA_COLOR_EXT1_R__MASK)
+#define VIVS_PE_ALPHA_COLOR_EXT1_A__MASK			0xffff0000
+#define VIVS_PE_ALPHA_COLOR_EXT1_A__SHIFT			16
+#define VIVS_PE_ALPHA_COLOR_EXT1_A(x)				(((x) << VIVS_PE_ALPHA_COLOR_EXT1_A__SHIFT) & VIVS_PE_ALPHA_COLOR_EXT1_A__MASK)
 
-#define VIVS_PE_UNK014B8					0x000014b8
+#define VIVS_PE_STENCIL_CONFIG_EXT2				0x000014b8
+#define VIVS_PE_STENCIL_CONFIG_EXT2_MASK_BACK__MASK		0x000000ff
+#define VIVS_PE_STENCIL_CONFIG_EXT2_MASK_BACK__SHIFT		0
+#define VIVS_PE_STENCIL_CONFIG_EXT2_MASK_BACK(x)		(((x) << VIVS_PE_STENCIL_CONFIG_EXT2_MASK_BACK__SHIFT) & VIVS_PE_STENCIL_CONFIG_EXT2_MASK_BACK__MASK)
+#define VIVS_PE_STENCIL_CONFIG_EXT2_WRITE_MASK_BACK__MASK	0x0000ff00
+#define VIVS_PE_STENCIL_CONFIG_EXT2_WRITE_MASK_BACK__SHIFT	8
+#define VIVS_PE_STENCIL_CONFIG_EXT2_WRITE_MASK_BACK(x)		(((x) << VIVS_PE_STENCIL_CONFIG_EXT2_WRITE_MASK_BACK__SHIFT) & VIVS_PE_STENCIL_CONFIG_EXT2_WRITE_MASK_BACK__MASK)
 
 #define VIVS_PE_UNK01580(i0)				       (0x00001580 + 0x4*(i0))
 #define VIVS_PE_UNK01580__ESIZE					0x00000004
@@ -865,6 +902,8 @@
 #define VIVS_RS_EXTRA_CONFIG_ENDIAN__MASK			0x00000300
 #define VIVS_RS_EXTRA_CONFIG_ENDIAN__SHIFT			8
 #define VIVS_RS_EXTRA_CONFIG_ENDIAN(x)				(((x) << VIVS_RS_EXTRA_CONFIG_ENDIAN__SHIFT) & VIVS_RS_EXTRA_CONFIG_ENDIAN__MASK)
+#define VIVS_RS_EXTRA_CONFIG_UNK20				0x00100000
+#define VIVS_RS_EXTRA_CONFIG_UNK28				0x10000000
 
 #define VIVS_RS_UNK016B0					0x000016b0
 
diff --git a/src/state_hi.xml.h b/src/state_hi.xml.h
index b5f739d..ecb968d 100644
--- a/src/state_hi.xml.h
+++ b/src/state_hi.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors:
diff --git a/src/state_vg.xml.h b/src/state_vg.xml.h
index 02a36c4..ff5aea7 100644
--- a/src/state_vg.xml.h
+++ b/src/state_vg.xml.h
@@ -8,12 +8,12 @@
 git clone git://0x04.net/rules-ng-ng
 
 The rules-ng-ng source files this header was generated from are:
-- state.xml     (  19487 bytes, from 2016-11-05 06:17:49)
-- common.xml    (  23272 bytes, from 2016-10-29 14:18:57)
+- state.xml     (  19792 bytes, from 2016-11-15 06:55:13)
+- common.xml    (  23422 bytes, from 2016-11-15 06:55:13)
 - state_hi.xml  (  25653 bytes, from 2016-10-29 07:29:22)
 - copyright.xml (   1597 bytes, from 2016-10-29 07:29:22)
 - state_2d.xml  (  51552 bytes, from 2016-10-29 07:29:22)
-- state_3d.xml  (  55854 bytes, from 2016-11-05 06:17:49)
+- state_3d.xml  (  58006 bytes, from 2016-11-25 14:15:12)
 - state_vg.xml  (   5975 bytes, from 2016-10-29 07:29:22)
 
 Copyright (C) 2012-2016 by the following authors: