[PATCH 2/5] gem_stress: make it library friendly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These are mostly just renames, and some very small refactors.

Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 lib/Makefile.am         |    5 +
 lib/gem_stress.h        |  118 ++++
 lib/gem_stress_gen6.c   |  581 ++++++++++++++++++
 lib/gem_stress_i830.c   |  354 +++++++++++
 lib/gem_stress_i915.c   |  190 ++++++
 lib/gen6_render.h       | 1553 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/intel_gpu_tools.h   |    5 +
 tests/Makefile.am       |    5 -
 tests/gem_stress.c      |   23 +-
 tests/gem_stress.h      |  100 ---
 tests/gem_stress_gen6.c |  595 ------------------
 tests/gem_stress_i830.c |  354 -----------
 tests/gem_stress_i915.c |  190 ------
 tests/gen6_render.h     | 1553 -----------------------------------------------
 14 files changed, 2822 insertions(+), 2804 deletions(-)
 create mode 100644 lib/gem_stress.h
 create mode 100644 lib/gem_stress_gen6.c
 create mode 100644 lib/gem_stress_i830.c
 create mode 100644 lib/gem_stress_i915.c
 create mode 100644 lib/gen6_render.h
 delete mode 100644 tests/gem_stress.h
 delete mode 100644 tests/gem_stress_gen6.c
 delete mode 100644 tests/gem_stress_i830.c
 delete mode 100644 tests/gem_stress_i915.c
 delete mode 100644 tests/gen6_render.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 9607fcb..6e6463a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -21,5 +21,10 @@ libintel_tools_la_SOURCES = 	\
 	intel_mmio.c		\
 	intel_pci.c		\
 	intel_reg.h		\
+	gem_stress.h		\
+	gem_stress_i915.c	\
+	gem_stress_i830.c	\
+	gen6_render.h		\
+	gem_stress_gen6.c	\
 	intel_reg_map.c
 
diff --git a/lib/gem_stress.h b/lib/gem_stress.h
new file mode 100644
index 0000000..0db2229
--- /dev/null
+++ b/lib/gem_stress.h
@@ -0,0 +1,118 @@
+#ifndef _GEM_STRESS_H_
+#define _GEM_STRESS_H_
+
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <getopt.h>
+#include "drm.h"
+#include "i915_drm.h"
+#include "drmtest.h"
+#include "intel_bufmgr.h"
+#include "intel_batchbuffer.h"
+#include "intel_gpu_tools.h"
+
+struct scratch_buf {
+    drm_intel_bo *bo;
+    uint32_t stride;
+    uint32_t tiling;
+    uint32_t *data;
+    uint32_t *cpu_mapping;
+    unsigned num_tiles;
+};
+
+struct option_struct {
+    unsigned scratch_buf_size;
+    unsigned max_dimension;
+    unsigned num_buffers;
+    int trace_tile;
+    int no_hw;
+    int gpu_busy_load;
+    int use_render;
+    int use_blt;
+    int forced_tiling;
+    int use_cpu_maps;
+    int total_rounds;
+    int fail;
+    int tiles_per_buf;
+    int ducttape;
+    int tile_size;
+    int check_render_cpyfn;
+    int use_signal_helper;
+};
+
+extern struct option_struct options;
+extern drm_intel_bufmgr *bufmgr;
+extern struct intel_batchbuffer *batch;
+extern int drm_fd;
+extern int devid;
+
+extern int fence_storm;
+
+#define MAX_BUFS		4096
+#define SCRATCH_BUF_SIZE	1024*1024
+#define BUSY_BUF_SIZE		(256*4096)
+#define TILE_BYTES(size)	((size)*(size)*sizeof(uint32_t))
+
+void keep_gpu_busy(void);
+
+static inline void emit_vertex_2s(int16_t x, int16_t y)
+{
+	OUT_BATCH((uint16_t)y << 16 | (uint16_t)x);
+}
+
+static inline void emit_vertex(float f)
+{
+	union { float f; uint32_t ui; } u;
+	u.f = f;
+	OUT_BATCH(u.ui);
+}
+
+static inline void emit_vertex_normalized(float f, float total)
+{
+	union { float f; uint32_t ui; } u;
+	u.f = f / total;
+	OUT_BATCH(u.ui);
+}
+
+static inline unsigned buf_width(struct scratch_buf *buf)
+{
+	return buf->stride/sizeof(uint32_t);
+}
+
+static inline unsigned buf_height(struct scratch_buf *buf)
+{
+	return options.scratch_buf_size/buf->stride;
+}
+
+static inline void
+gen6_render_flush(uint32_t batch_end)
+{
+	int ret;
+
+	ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
+	if (ret == 0)
+		ret = drm_intel_bo_mrb_exec(batch->bo, batch_end,
+					    NULL, 0, 0, 0);
+	assert(ret == 0);
+}
+
+
+uint32_t gen6_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			      struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+			      unsigned logical_tile_no);
+uint32_t gen3_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			      struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+			      unsigned logical_tile_no);
+uint32_t gen2_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			      struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+			      unsigned logical_tile_no);
+
+#endif
diff --git a/lib/gem_stress_gen6.c b/lib/gem_stress_gen6.c
new file mode 100644
index 0000000..e38b4f9
--- /dev/null
+++ b/lib/gem_stress_gen6.c
@@ -0,0 +1,581 @@
+#include "gem_stress.h"
+#include "gen6_render.h"
+
+#include <assert.h>
+
+#define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
+#define VERTEX_SIZE (3*4)
+
+static const uint32_t ps_kernel_nomask_affine[][4] = {
+	{ 0x0060005a, 0x204077be, 0x000000c0, 0x008d0040 },
+	{ 0x0060005a, 0x206077be, 0x000000c0, 0x008d0080 },
+	{ 0x0060005a, 0x208077be, 0x000000d0, 0x008d0040 },
+	{ 0x0060005a, 0x20a077be, 0x000000d0, 0x008d0080 },
+	{ 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
+	{ 0x00600001, 0x20200022, 0x008d0000, 0x00000000 },
+	{ 0x02800031, 0x21c01cc9, 0x00000020, 0x0a8a0001 },
+	{ 0x00600001, 0x204003be, 0x008d01c0, 0x00000000 },
+	{ 0x00600001, 0x206003be, 0x008d01e0, 0x00000000 },
+	{ 0x00600001, 0x208003be, 0x008d0200, 0x00000000 },
+	{ 0x00600001, 0x20a003be, 0x008d0220, 0x00000000 },
+	{ 0x00600001, 0x20c003be, 0x008d0240, 0x00000000 },
+	{ 0x00600001, 0x20e003be, 0x008d0260, 0x00000000 },
+	{ 0x00600001, 0x210003be, 0x008d0280, 0x00000000 },
+	{ 0x00600001, 0x212003be, 0x008d02a0, 0x00000000 },
+	{ 0x05800031, 0x24001cc8, 0x00000040, 0x90019000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
+};
+
+static uint32_t
+batch_used(void)
+{
+	return batch->ptr - batch->buffer;
+}
+
+static uint32_t
+batch_align(uint32_t align)
+{
+	uint32_t offset = batch_used();
+	offset = ALIGN(offset, align);
+	batch->ptr = batch->buffer + offset;
+	return offset;
+}
+
+static uint32_t
+batch_round_upto(uint32_t divisor)
+{
+	uint32_t offset = batch_used();
+	offset = (offset + divisor-1) / divisor * divisor;
+	batch->ptr = batch->buffer + offset;
+	return offset;
+}
+
+static void *
+batch_alloc(uint32_t size, uint32_t align)
+{
+	uint32_t offset = batch_align(align);
+	batch->ptr += size;
+	return memset(batch->buffer + offset, 0, size);
+}
+
+static uint32_t
+batch_offset(void *ptr)
+{
+	return (uint8_t *)ptr - batch->buffer;
+}
+
+static uint32_t
+batch_copy(const void *ptr, uint32_t size, uint32_t align)
+{
+	return batch_offset(memcpy(batch_alloc(size, align), ptr, size));
+}
+
+static uint32_t
+gen6_bind_buf(struct scratch_buf *buf,
+	      uint32_t format, int is_dst)
+{
+	struct gen6_surface_state *ss;
+	uint32_t write_domain, read_domain;
+	int ret;
+
+	if (is_dst) {
+		write_domain = read_domain = I915_GEM_DOMAIN_RENDER;
+	} else {
+		write_domain = 0;
+		read_domain = I915_GEM_DOMAIN_SAMPLER;
+	}
+
+	ss = batch_alloc(sizeof(*ss), 32);
+	ss->ss0.surface_type = GEN6_SURFACE_2D;
+	ss->ss0.surface_format = format;
+
+	ss->ss0.data_return_format = GEN6_SURFACERETURNFORMAT_FLOAT32;
+	ss->ss0.color_blend = 1;
+	ss->ss1.base_addr = buf->bo->offset;
+
+	ret = drm_intel_bo_emit_reloc(batch->bo,
+				      batch_offset(ss) + 4,
+				      buf->bo, 0,
+				      read_domain, write_domain);
+	assert(ret == 0);
+
+	ss->ss2.height = buf_height(buf) - 1;
+	ss->ss2.width  = buf_width(buf) - 1;
+	ss->ss3.pitch  = buf->stride - 1;
+	ss->ss3.tiled_surface = buf->tiling != I915_TILING_NONE;
+	ss->ss3.tile_walk     = buf->tiling == I915_TILING_Y;
+
+	return batch_offset(ss);
+}
+
+static uint32_t
+gen6_bind_surfaces(struct scratch_buf *src,
+		   struct scratch_buf *dst)
+{
+	uint32_t *binding_table;
+
+	binding_table = batch_alloc(32, 32);
+
+	binding_table[0] =
+		gen6_bind_buf(dst, GEN6_SURFACEFORMAT_B8G8R8A8_UNORM, 1);
+	binding_table[1] =
+		gen6_bind_buf(src, GEN6_SURFACEFORMAT_B8G8R8A8_UNORM, 0);
+
+	return batch_offset(binding_table);
+}
+
+static void
+gen6_emit_sip(void)
+{
+	OUT_BATCH(GEN6_STATE_SIP | 0);
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_urb(void)
+{
+	OUT_BATCH(GEN6_3DSTATE_URB | (3 - 2));
+	OUT_BATCH((1 - 1) << GEN6_3DSTATE_URB_VS_SIZE_SHIFT |
+		  24 << GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT); /* at least 24 on GEN6 */
+	OUT_BATCH(0 << GEN6_3DSTATE_URB_GS_SIZE_SHIFT |
+		  0 << GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT); /* no GS thread */
+}
+
+static void
+gen6_emit_state_base_address(void)
+{
+	OUT_BATCH(GEN6_STATE_BASE_ADDRESS | (10 - 2));
+	OUT_BATCH(0); /* general */
+	OUT_RELOC(batch->bo, /* surface */
+		  I915_GEM_DOMAIN_INSTRUCTION, 0,
+		  BASE_ADDRESS_MODIFY);
+	OUT_RELOC(batch->bo, /* instruction */
+		  I915_GEM_DOMAIN_INSTRUCTION, 0,
+		  BASE_ADDRESS_MODIFY);
+	OUT_BATCH(0); /* indirect */
+	OUT_RELOC(batch->bo, /* dynamic */
+		  I915_GEM_DOMAIN_INSTRUCTION, 0,
+		  BASE_ADDRESS_MODIFY);
+
+	/* upper bounds, disable */
+	OUT_BATCH(0);
+	OUT_BATCH(BASE_ADDRESS_MODIFY);
+	OUT_BATCH(0);
+	OUT_BATCH(BASE_ADDRESS_MODIFY);
+}
+
+static void
+gen6_emit_viewports(uint32_t cc_vp)
+{
+	OUT_BATCH(GEN6_3DSTATE_VIEWPORT_STATE_POINTERS |
+		  GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC |
+		  (4 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(cc_vp);
+}
+
+static void
+gen6_emit_vs(void)
+{
+	/* disable VS constant buffer */
+	OUT_BATCH(GEN6_3DSTATE_CONSTANT_VS | (5 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+
+	OUT_BATCH(GEN6_3DSTATE_VS | (6 - 2));
+	OUT_BATCH(0); /* no VS kernel */
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* pass-through */
+}
+
+static void
+gen6_emit_gs(void)
+{
+	/* disable GS constant buffer */
+	OUT_BATCH(GEN6_3DSTATE_CONSTANT_GS | (5 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+
+	OUT_BATCH(GEN6_3DSTATE_GS | (7 - 2));
+	OUT_BATCH(0); /* no GS kernel */
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* pass-through */
+}
+
+static void
+gen6_emit_clip(void)
+{
+	OUT_BATCH(GEN6_3DSTATE_CLIP | (4 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* pass-through */
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_wm_constants(void)
+{
+	/* disable WM constant buffer */
+	OUT_BATCH(GEN6_3DSTATE_CONSTANT_PS | (5 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_null_depth_buffer(void)
+{
+	OUT_BATCH(GEN6_3DSTATE_DEPTH_BUFFER | (7 - 2));
+	OUT_BATCH(GEN6_SURFACE_NULL << GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT |
+		  GEN6_DEPTHFORMAT_D32_FLOAT << GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+
+	OUT_BATCH(GEN6_3DSTATE_CLEAR_PARAMS | (2 - 2));
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_invariant(void)
+{
+	OUT_BATCH(GEN6_PIPELINE_SELECT | PIPELINE_SELECT_3D);
+
+	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE | (3 - 2));
+	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER |
+		  GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1); /* 1 sample/pixel */
+	OUT_BATCH(0);
+
+	OUT_BATCH(GEN6_3DSTATE_SAMPLE_MASK | (2 - 2));
+	OUT_BATCH(1);
+}
+
+static void
+gen6_emit_cc(uint32_t blend)
+{
+	OUT_BATCH(GEN6_3DSTATE_CC_STATE_POINTERS | (4 - 2));
+	OUT_BATCH(blend | 1);
+	OUT_BATCH(1024 | 1);
+	OUT_BATCH(1024 | 1);
+}
+
+static void
+gen6_emit_sampler(uint32_t state)
+{
+	OUT_BATCH(GEN6_3DSTATE_SAMPLER_STATE_POINTERS |
+		  GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS |
+		  (4 - 2));
+	OUT_BATCH(0); /* VS */
+	OUT_BATCH(0); /* GS */
+	OUT_BATCH(state);
+}
+
+static void
+gen6_emit_sf(void)
+{
+	OUT_BATCH(GEN6_3DSTATE_SF | (20 - 2));
+	OUT_BATCH(1 << GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT |
+		  1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT |
+		  1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT);
+	OUT_BATCH(0);
+	OUT_BATCH(GEN6_3DSTATE_SF_CULL_NONE);
+	OUT_BATCH(2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT); /* DW4 */
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* DW9 */
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* DW14 */
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+	OUT_BATCH(0); /* DW19 */
+}
+
+static void
+gen6_emit_wm(int kernel)
+{
+	OUT_BATCH(GEN6_3DSTATE_WM | (9 - 2));
+	OUT_BATCH(kernel);
+	OUT_BATCH(1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT |
+		  2 << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT);
+	OUT_BATCH(0);
+	OUT_BATCH(6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT); /* DW4 */
+	OUT_BATCH((40 - 1) << GEN6_3DSTATE_WM_MAX_THREADS_SHIFT |
+		  GEN6_3DSTATE_WM_DISPATCH_ENABLE |
+		  GEN6_3DSTATE_WM_16_DISPATCH_ENABLE);
+	OUT_BATCH(1 << GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT |
+		  GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC);
+	OUT_BATCH(0);
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_binding_table(uint32_t wm_table)
+{
+	OUT_BATCH(GEN6_3DSTATE_BINDING_TABLE_POINTERS |
+		  GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS |
+		  (4 - 2));
+	OUT_BATCH(0);		/* vs */
+	OUT_BATCH(0);		/* gs */
+	OUT_BATCH(wm_table);
+}
+
+static void
+gen6_emit_drawing_rectangle(struct scratch_buf *dst)
+{
+	OUT_BATCH(GEN6_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
+	OUT_BATCH(0);
+	OUT_BATCH((buf_height(dst) - 1) << 16 | (buf_width(dst) - 1));
+	OUT_BATCH(0);
+}
+
+static void
+gen6_emit_vertex_elements(void)
+{
+	/* The VUE layout
+	 *    dword 0-3: pad (0.0, 0.0, 0.0. 0.0)
+	 *    dword 4-7: position (x, y, 1.0, 1.0),
+	 *    dword 8-11: texture coordinate 0 (u0, v0, 0, 0)
+	 *
+	 * dword 4-11 are fetched from vertex buffer
+	 */
+	OUT_BATCH(GEN6_3DSTATE_VERTEX_ELEMENTS | (2 * 3 + 1 - 2));
+
+	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
+		  GEN6_SURFACEFORMAT_R32G32B32A32_FLOAT << VE0_FORMAT_SHIFT |
+		  0 << VE0_OFFSET_SHIFT);
+	OUT_BATCH(GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
+
+	/* x,y */
+	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
+		  GEN6_SURFACEFORMAT_R16G16_SSCALED << VE0_FORMAT_SHIFT |
+		  0 << VE0_OFFSET_SHIFT); /* offsets vb in bytes */
+	OUT_BATCH(GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
+
+	/* u0, v0 */
+	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
+		  GEN6_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT |
+		  4 << VE0_OFFSET_SHIFT);	/* offset vb in bytes */
+	OUT_BATCH(GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
+		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
+}
+
+static uint32_t
+gen6_create_cc_viewport(void)
+{
+	struct gen6_cc_viewport *vp;
+
+	vp = batch_alloc(sizeof(*vp), 32);
+
+	vp->min_depth = -1.e35;
+	vp->max_depth = 1.e35;
+
+	return batch_offset(vp);
+}
+
+static uint32_t
+gen6_create_cc_blend(void)
+{
+	struct gen6_blend_state *blend;
+
+	blend = batch_alloc(sizeof(*blend), 64);
+
+	blend->blend0.dest_blend_factor = GEN6_BLENDFACTOR_ZERO;
+	blend->blend0.source_blend_factor = GEN6_BLENDFACTOR_ONE;
+	blend->blend0.blend_func = GEN6_BLENDFUNCTION_ADD;
+	blend->blend0.blend_enable = 1;
+
+	blend->blend1.post_blend_clamp_enable = 1;
+	blend->blend1.pre_blend_clamp_enable = 1;
+
+	return batch_offset(blend);
+}
+
+static uint32_t
+gen6_create_kernel(void)
+{
+	return batch_copy(ps_kernel_nomask_affine,
+			  sizeof(ps_kernel_nomask_affine),
+			  64);
+}
+
+static uint32_t
+gen6_create_sampler(sampler_filter_t filter,
+		   sampler_extend_t extend)
+{
+	struct gen6_sampler_state *ss;
+
+	ss = batch_alloc(sizeof(*ss), 32);
+	ss->ss0.lod_preclamp = 1;	/* GL mode */
+
+	/* We use the legacy mode to get the semantics specified by
+	 * the Render extension. */
+	ss->ss0.border_color_mode = GEN6_BORDER_COLOR_MODE_LEGACY;
+
+	switch (filter) {
+	default:
+	case SAMPLER_FILTER_NEAREST:
+		ss->ss0.min_filter = GEN6_MAPFILTER_NEAREST;
+		ss->ss0.mag_filter = GEN6_MAPFILTER_NEAREST;
+		break;
+	case SAMPLER_FILTER_BILINEAR:
+		ss->ss0.min_filter = GEN6_MAPFILTER_LINEAR;
+		ss->ss0.mag_filter = GEN6_MAPFILTER_LINEAR;
+		break;
+	}
+
+	switch (extend) {
+	default:
+	case SAMPLER_EXTEND_NONE:
+		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
+		break;
+	case SAMPLER_EXTEND_REPEAT:
+		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
+		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
+		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
+		break;
+	case SAMPLER_EXTEND_PAD:
+		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
+		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
+		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
+		break;
+	case SAMPLER_EXTEND_REFLECT:
+		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
+		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
+		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
+		break;
+	}
+
+	return batch_offset(ss);
+}
+
+static void gen6_emit_vertex_buffer(void)
+{
+	OUT_BATCH(GEN6_3DSTATE_VERTEX_BUFFERS | 3);
+	OUT_BATCH(VB0_VERTEXDATA |
+		  0 << VB0_BUFFER_INDEX_SHIFT |
+		  VERTEX_SIZE << VB0_BUFFER_PITCH_SHIFT);
+	OUT_RELOC(batch->bo, I915_GEM_DOMAIN_VERTEX, 0, 0);
+	OUT_RELOC(batch->bo, I915_GEM_DOMAIN_VERTEX, 0, batch->bo->size-1);
+	OUT_BATCH(0);
+}
+
+static uint32_t gen6_emit_primitive(void)
+{
+	uint32_t offset;
+
+	OUT_BATCH(GEN6_3DPRIMITIVE |
+		  GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL |
+		  _3DPRIM_RECTLIST << GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT |
+		  0 << 9 |
+		  4);
+	OUT_BATCH(3);	/* vertex count */
+	offset = batch_used();
+	OUT_BATCH(0);	/* vertex_index */
+	OUT_BATCH(1);	/* single instance */
+	OUT_BATCH(0);	/* start instance location */
+	OUT_BATCH(0);	/* index buffer offset, ignored */
+
+	return offset;
+}
+
+uint32_t
+gen6_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+		     struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+		     unsigned logical_tile_no)
+{
+	uint32_t wm_state, wm_kernel, wm_table;
+	uint32_t cc_vp, cc_blend, offset;
+	uint32_t batch_end;
+
+	batch->ptr = batch->buffer + 1024;
+	batch_alloc(64, 64);
+	wm_table  = gen6_bind_surfaces(src, dst);
+	wm_kernel = gen6_create_kernel();
+	wm_state  = gen6_create_sampler(SAMPLER_FILTER_NEAREST,
+					SAMPLER_EXTEND_NONE);
+
+	cc_vp = gen6_create_cc_viewport();
+	cc_blend = gen6_create_cc_blend();
+
+	batch->ptr = batch->buffer;
+
+	gen6_emit_invariant();
+	gen6_emit_state_base_address();
+
+	gen6_emit_sip();
+	gen6_emit_urb();
+
+	gen6_emit_viewports(cc_vp);
+	gen6_emit_vs();
+	gen6_emit_gs();
+	gen6_emit_clip();
+	gen6_emit_wm_constants();
+	gen6_emit_null_depth_buffer();
+
+	gen6_emit_drawing_rectangle(dst);
+	gen6_emit_cc(cc_blend);
+	gen6_emit_sampler(wm_state);
+	gen6_emit_sf();
+	gen6_emit_wm(wm_kernel);
+	gen6_emit_vertex_elements();
+	gen6_emit_binding_table(wm_table);
+
+	gen6_emit_vertex_buffer();
+	offset = gen6_emit_primitive();
+
+	OUT_BATCH(MI_BATCH_BUFFER_END);
+	batch_end = batch_align(8);
+
+	*(uint32_t*)(batch->buffer + offset) =
+		batch_round_upto(VERTEX_SIZE)/VERTEX_SIZE;
+
+	emit_vertex_2s(dst_x + options.tile_size, dst_y + options.tile_size);
+	emit_vertex_normalized(src_x + options.tile_size, buf_width(src));
+	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
+
+	emit_vertex_2s(dst_x, dst_y + options.tile_size);
+	emit_vertex_normalized(src_x, buf_width(src));
+	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
+
+	emit_vertex_2s(dst_x, dst_y);
+	emit_vertex_normalized(src_x, buf_width(src));
+	emit_vertex_normalized(src_y, buf_height(src));
+
+	return batch_end;
+}
diff --git a/lib/gem_stress_i830.c b/lib/gem_stress_i830.c
new file mode 100644
index 0000000..23547fc
--- /dev/null
+++ b/lib/gem_stress_i830.c
@@ -0,0 +1,354 @@
+#include "i830_reg.h"
+#include "gem_stress.h"
+
+#define TB0C_LAST_STAGE	(1 << 31)
+#define TB0C_RESULT_SCALE_1X		(0 << 29)
+#define TB0C_RESULT_SCALE_2X		(1 << 29)
+#define TB0C_RESULT_SCALE_4X		(2 << 29)
+#define TB0C_OP_MODULE			(3 << 25)
+#define TB0C_OUTPUT_WRITE_CURRENT	(0 << 24)
+#define TB0C_OUTPUT_WRITE_ACCUM		(1 << 24)
+#define TB0C_ARG3_REPLICATE_ALPHA 	(1<<23)
+#define TB0C_ARG3_INVERT		(1<<22)
+#define TB0C_ARG3_SEL_XXX
+#define TB0C_ARG2_REPLICATE_ALPHA 	(1<<17)
+#define TB0C_ARG2_INVERT		(1<<16)
+#define TB0C_ARG2_SEL_ONE		(0 << 12)
+#define TB0C_ARG2_SEL_FACTOR		(1 << 12)
+#define TB0C_ARG2_SEL_TEXEL0		(6 << 12)
+#define TB0C_ARG2_SEL_TEXEL1		(7 << 12)
+#define TB0C_ARG2_SEL_TEXEL2		(8 << 12)
+#define TB0C_ARG2_SEL_TEXEL3		(9 << 12)
+#define TB0C_ARG1_REPLICATE_ALPHA 	(1<<11)
+#define TB0C_ARG1_INVERT		(1<<10)
+#define TB0C_ARG1_SEL_ONE		(0 << 6)
+#define TB0C_ARG1_SEL_TEXEL0		(6 << 6)
+#define TB0C_ARG1_SEL_TEXEL1		(7 << 6)
+#define TB0C_ARG1_SEL_TEXEL2		(8 << 6)
+#define TB0C_ARG1_SEL_TEXEL3		(9 << 6)
+#define TB0C_ARG0_REPLICATE_ALPHA 	(1<<5)
+#define TB0C_ARG0_SEL_XXX
+
+#define TB0A_CTR_STAGE_ENABLE 		(1<<31)
+#define TB0A_RESULT_SCALE_1X		(0 << 29)
+#define TB0A_RESULT_SCALE_2X		(1 << 29)
+#define TB0A_RESULT_SCALE_4X		(2 << 29)
+#define TB0A_OP_MODULE			(3 << 25)
+#define TB0A_OUTPUT_WRITE_CURRENT	(0<<24)
+#define TB0A_OUTPUT_WRITE_ACCUM		(1<<24)
+#define TB0A_CTR_STAGE_SEL_BITS_XXX
+#define TB0A_ARG3_SEL_XXX
+#define TB0A_ARG3_INVERT		(1<<17)
+#define TB0A_ARG2_INVERT		(1<<16)
+#define TB0A_ARG2_SEL_ONE		(0 << 12)
+#define TB0A_ARG2_SEL_TEXEL0		(6 << 12)
+#define TB0A_ARG2_SEL_TEXEL1		(7 << 12)
+#define TB0A_ARG2_SEL_TEXEL2		(8 << 12)
+#define TB0A_ARG2_SEL_TEXEL3		(9 << 12)
+#define TB0A_ARG1_INVERT		(1<<10)
+#define TB0A_ARG1_SEL_ONE		(0 << 6)
+#define TB0A_ARG1_SEL_TEXEL0		(6 << 6)
+#define TB0A_ARG1_SEL_TEXEL1		(7 << 6)
+#define TB0A_ARG1_SEL_TEXEL2		(8 << 6)
+#define TB0A_ARG1_SEL_TEXEL3		(9 << 6)
+
+uint32_t gen2_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			      struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+			      unsigned logical_tile_no)
+{
+	static unsigned keep_gpu_busy_counter = 0;
+
+	/* check both edges of the fence usage */
+	if (keep_gpu_busy_counter & 1)
+		keep_gpu_busy();
+
+	/* invariant state */
+	{
+		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(0));
+		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(1));
+		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(2));
+		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(3));
+
+		OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_FOG_MODE_CMD);
+		OUT_BATCH(FOGFUNC_ENABLE |
+			  FOG_LINEAR_CONST | FOGSRC_INDEX_Z | ENABLE_FOG_DENSITY);
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+			  MAP_UNIT(0) |
+			  DISABLE_TEX_STREAM_BUMP |
+			  ENABLE_TEX_STREAM_COORD_SET |
+			  TEX_STREAM_COORD_SET(0) |
+			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
+		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+			  MAP_UNIT(1) |
+			  DISABLE_TEX_STREAM_BUMP |
+			  ENABLE_TEX_STREAM_COORD_SET |
+			  TEX_STREAM_COORD_SET(1) |
+			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1));
+		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+			  MAP_UNIT(2) |
+			  DISABLE_TEX_STREAM_BUMP |
+			  ENABLE_TEX_STREAM_COORD_SET |
+			  TEX_STREAM_COORD_SET(2) |
+			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2));
+		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+			  MAP_UNIT(3) |
+			  DISABLE_TEX_STREAM_BUMP |
+			  ENABLE_TEX_STREAM_COORD_SET |
+			  TEX_STREAM_COORD_SET(3) |
+			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3));
+
+		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0));
+		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(1));
+		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(2));
+		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3));
+
+		OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
+			  ENABLE_POINT_RASTER_RULE |
+			  OGL_POINT_RASTER_RULE |
+			  ENABLE_LINE_STRIP_PROVOKE_VRTX |
+			  ENABLE_TRI_FAN_PROVOKE_VRTX |
+			  ENABLE_TRI_STRIP_PROVOKE_VRTX |
+			  LINE_STRIP_PROVOKE_VRTX(1) |
+			  TRI_FAN_PROVOKE_VRTX(2) | TRI_STRIP_PROVOKE_VRTX(2));
+
+		OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
+
+		OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM);
+		OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);
+
+		OUT_BATCH(_3DSTATE_W_STATE_CMD);
+		OUT_BATCH(MAGIC_W_STATE_DWORD1);
+		OUT_BATCH(0x3f800000 /* 1.0 in IEEE float */ );
+
+		OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD);
+		OUT_BATCH(0x80808080);	/* .5 required in alpha for GL_DOT3_RGBA_EXT */
+
+		OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
+		OUT_BATCH(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
+			  TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
+			  TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
+			  TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
+
+		/* copy from mesa */
+		OUT_BATCH(_3DSTATE_FOG_COLOR_CMD |
+			  FOG_COLOR_RED(0) | FOG_COLOR_GREEN(0) | FOG_COLOR_BLUE(0));
+
+		OUT_BATCH(_3DSTATE_CONST_BLEND_COLOR_CMD);
+		OUT_BATCH(0);
+
+		OUT_BATCH(_3DSTATE_MODES_1_CMD |
+			  ENABLE_COLR_BLND_FUNC |
+			  BLENDFUNC_ADD |
+			  ENABLE_SRC_BLND_FACTOR |
+			  SRC_BLND_FACT(BLENDFACTOR_ONE) |
+			  ENABLE_DST_BLND_FACTOR | DST_BLND_FACT(BLENDFACTOR_ZERO));
+		OUT_BATCH(_3DSTATE_MODES_2_CMD | ENABLE_GLOBAL_DEPTH_BIAS | GLOBAL_DEPTH_BIAS(0) | ENABLE_ALPHA_TEST_FUNC | ALPHA_TEST_FUNC(0) |	/* always */
+			  ALPHA_REF_VALUE(0));
+		OUT_BATCH(_3DSTATE_MODES_3_CMD |
+			  ENABLE_DEPTH_TEST_FUNC |
+			  DEPTH_TEST_FUNC(0x2) |	/* COMPAREFUNC_LESS */
+			  ENABLE_ALPHA_SHADE_MODE |
+			  ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
+			  ENABLE_FOG_SHADE_MODE |
+			  FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
+			  ENABLE_SPEC_SHADE_MODE |
+			  SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
+			  ENABLE_COLOR_SHADE_MODE |
+			  COLOR_SHADE_MODE(SHADE_MODE_LINEAR) |
+			  ENABLE_CULL_MODE | CULLMODE_NONE);
+
+		OUT_BATCH(_3DSTATE_MODES_4_CMD |
+			  ENABLE_LOGIC_OP_FUNC |
+			  LOGIC_OP_FUNC(LOGICOP_COPY) |
+			  ENABLE_STENCIL_TEST_MASK |
+			  STENCIL_TEST_MASK(0xff) |
+			  ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff));
+
+		OUT_BATCH(_3DSTATE_STENCIL_TEST_CMD |
+			  ENABLE_STENCIL_PARMS |
+			  STENCIL_FAIL_OP(0) |	/* STENCILOP_KEEP */
+			  STENCIL_PASS_DEPTH_FAIL_OP(0) |	/* STENCILOP_KEEP */
+			  STENCIL_PASS_DEPTH_PASS_OP(0) |	/* STENCILOP_KEEP */
+			  ENABLE_STENCIL_TEST_FUNC |
+			  STENCIL_TEST_FUNC(0) |	/* COMPAREFUNC_ALWAYS */
+			  ENABLE_STENCIL_REF_VALUE |
+			  STENCIL_REF_VALUE(0));
+
+		OUT_BATCH(_3DSTATE_MODES_5_CMD |
+			  FLUSH_TEXTURE_CACHE |
+			  ENABLE_SPRITE_POINT_TEX | SPRITE_POINT_TEX_OFF |
+			  ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(0x2) | /* 1.0 */
+			  ENABLE_FIXED_POINT_WIDTH | FIXED_POINT_WIDTH(1));
+
+		OUT_BATCH(_3DSTATE_STIPPLE);
+
+		/* Set default blend state */
+		OUT_BATCH(_3DSTATE_MAP_BLEND_OP_CMD(0) |
+			  TEXPIPE_COLOR |
+			  ENABLE_TEXOUTPUT_WRT_SEL |
+			  TEXOP_OUTPUT_CURRENT |
+			  DISABLE_TEX_CNTRL_STAGE |
+			  TEXOP_SCALE_1X |
+			  TEXOP_MODIFY_PARMS | TEXOP_LAST_STAGE | TEXBLENDOP_ARG1);
+		OUT_BATCH(_3DSTATE_MAP_BLEND_OP_CMD(0) |
+			  TEXPIPE_ALPHA |
+			  ENABLE_TEXOUTPUT_WRT_SEL |
+			  TEXOP_OUTPUT_CURRENT |
+			  TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1);
+		OUT_BATCH(_3DSTATE_MAP_BLEND_ARG_CMD(0) |
+			  TEXPIPE_COLOR |
+			  TEXBLEND_ARG1 |
+			  TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_DIFFUSE);
+		OUT_BATCH(_3DSTATE_MAP_BLEND_ARG_CMD(0) |
+			  TEXPIPE_ALPHA |
+			  TEXBLEND_ARG1 |
+			  TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_DIFFUSE);
+
+		OUT_BATCH(_3DSTATE_AA_CMD |
+			  AA_LINE_ECAAR_WIDTH_ENABLE |
+			  AA_LINE_ECAAR_WIDTH_1_0 |
+			  AA_LINE_REGION_WIDTH_ENABLE |
+			  AA_LINE_REGION_WIDTH_1_0 | AA_LINE_DISABLE);
+	}
+
+	/* render target state */
+	{
+		uint32_t tiling_bits = 0;
+		if (dst->tiling != I915_TILING_NONE)
+			tiling_bits = BUF_3D_TILED_SURFACE;
+		if (dst->tiling == I915_TILING_Y)
+			tiling_bits |= BUF_3D_TILE_WALK_Y;
+
+		OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
+		OUT_BATCH(BUF_3D_ID_COLOR_BACK | tiling_bits |
+			  BUF_3D_PITCH(dst->stride));
+		OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+
+		OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
+		OUT_BATCH(COLR_BUF_ARGB8888 |
+			  DSTORG_HORT_BIAS(0x8) |
+			  DSTORG_VERT_BIAS(0x8));
+
+		OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(0);		/* ymin, xmin */
+		OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
+			  DRAW_XMAX(buf_width(dst) - 1));
+		OUT_BATCH(0);		/* yorig, xorig */
+	}
+
+	/* dynamic state */
+	{
+		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+			  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
+		OUT_BATCH(1);		/* number of coordinate sets */
+		OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY);
+		OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |
+			  BLENDFACTOR_ONE << S8_SRC_BLEND_FACTOR_SHIFT |
+			  BLENDFACTOR_ZERO << S8_DST_BLEND_FACTOR_SHIFT |
+			  S8_ENABLE_COLOR_BUFFER_WRITE);
+
+		OUT_BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD | DISABLE_INDPT_ALPHA_BLEND);
+
+		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+			  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
+		OUT_BATCH(TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_MODULE |
+			  TB0C_OUTPUT_WRITE_CURRENT | TB0C_ARG1_SEL_TEXEL0 |
+			  TB0C_ARG2_SEL_ONE);
+		OUT_BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_MODULE |
+			  TB0A_OUTPUT_WRITE_CURRENT | TB0A_ARG1_SEL_TEXEL0 |
+			  TB0A_ARG2_SEL_ONE);
+
+		OUT_BATCH(_3DSTATE_ENABLES_1_CMD | DISABLE_LOGIC_OP |
+			  DISABLE_STENCIL_TEST | DISABLE_DEPTH_BIAS |
+			  DISABLE_SPEC_ADD | DISABLE_FOG | DISABLE_ALPHA_TEST |
+			  ENABLE_COLOR_BLEND | DISABLE_DEPTH_TEST);
+		/* We have to explicitly say we don't want write disabled */
+		OUT_BATCH(_3DSTATE_ENABLES_2_CMD | ENABLE_COLOR_MASK |
+			  DISABLE_STENCIL_WRITE | ENABLE_TEX_CACHE |
+			  DISABLE_DITHER | ENABLE_COLOR_WRITE | DISABLE_DEPTH_WRITE);
+
+		OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD |
+			  TEXCOORDFMT_2D << 0);
+	}
+
+	/* sampler state */
+	{
+		uint32_t tiling_bits = 0;
+		if (src->tiling != I915_TILING_NONE)
+			tiling_bits = TM0S1_TILED_SURFACE;
+		if (src->tiling == I915_TILING_Y)
+			tiling_bits |= TM0S1_TILE_WALK;
+
+		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+			  LOAD_TEXTURE_MAP(0) | 4);
+		OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
+		OUT_BATCH((buf_height(src) - 1) << TM0S1_HEIGHT_SHIFT |
+			  (buf_width(src) - 1) << TM0S1_WIDTH_SHIFT |
+			  MAPSURF_32BIT | MT_32BIT_ARGB8888 | tiling_bits);
+		OUT_BATCH((src->stride / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D);
+		OUT_BATCH(FILTER_NEAREST << TM0S3_MAG_FILTER_SHIFT |
+			  FILTER_NEAREST << TM0S3_MIN_FILTER_SHIFT |
+			  MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT);
+		OUT_BATCH(0);	/* default color */
+		OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(0) |
+			  ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL |
+			  TEXCOORDTYPE_CARTESIAN |
+			  ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP_BORDER) |
+			  ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP_BORDER));
+		/* map texel stream */
+		OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
+		OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) |
+			  TEXBIND_SET1(TEXCOORDSRC_KEEP) |
+			  TEXBIND_SET2(TEXCOORDSRC_KEEP) |
+			  TEXBIND_SET3(TEXCOORDSRC_KEEP));
+		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | (0 << 16) |
+			  DISABLE_TEX_STREAM_BUMP |
+			  ENABLE_TEX_STREAM_COORD_SET |
+			  TEX_STREAM_COORD_SET(0) |
+			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
+	}
+
+	OUT_BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST | (3*4 -1));
+	emit_vertex(dst_x + options.tile_size);
+	emit_vertex(dst_y + options.tile_size);
+	emit_vertex_normalized(src_x + options.tile_size, buf_width(src));
+	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
+
+	emit_vertex(dst_x);
+	emit_vertex(dst_y + options.tile_size);
+	emit_vertex_normalized(src_x, buf_width(src));
+	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
+
+	emit_vertex(dst_x);
+	emit_vertex(dst_y);
+	emit_vertex_normalized(src_x, buf_width(src));
+	emit_vertex_normalized(src_y, buf_height(src));
+
+	if (!(keep_gpu_busy_counter & 1))
+		keep_gpu_busy();
+
+	keep_gpu_busy_counter++;
+
+	return 0;
+}
diff --git a/lib/gem_stress_i915.c b/lib/gem_stress_i915.c
new file mode 100644
index 0000000..55e9ae8
--- /dev/null
+++ b/lib/gem_stress_i915.c
@@ -0,0 +1,190 @@
+#include "i915_reg.h"
+#include "i915_3d.h"
+#include "gem_stress.h"
+
+uint32_t gen3_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
+			      struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
+			      unsigned logical_tile_no)
+{
+	static unsigned keep_gpu_busy_counter = 0;
+
+	/* check both edges of the fence usage */
+	if (keep_gpu_busy_counter & 1)
+		keep_gpu_busy();
+
+	/* invariant state */
+	{
+		OUT_BATCH(_3DSTATE_AA_CMD |
+			  AA_LINE_ECAAR_WIDTH_ENABLE |
+			  AA_LINE_ECAAR_WIDTH_1_0 |
+			  AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0);
+		OUT_BATCH(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
+			  IAB_MODIFY_ENABLE |
+			  IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) |
+			  IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE <<
+						   IAB_SRC_FACTOR_SHIFT) |
+			  IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO <<
+						   IAB_DST_FACTOR_SHIFT));
+		OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS |
+			  CSB_TCB(0, 0) |
+			  CSB_TCB(1, 1) |
+			  CSB_TCB(2, 2) |
+			  CSB_TCB(3, 3) |
+			  CSB_TCB(4, 4) |
+			  CSB_TCB(5, 5) | CSB_TCB(6, 6) | CSB_TCB(7, 7));
+		OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
+			  ENABLE_POINT_RASTER_RULE |
+			  OGL_POINT_RASTER_RULE |
+			  ENABLE_LINE_STRIP_PROVOKE_VRTX |
+			  ENABLE_TRI_FAN_PROVOKE_VRTX |
+			  LINE_STRIP_PROVOKE_VRTX(1) |
+			  TRI_FAN_PROVOKE_VRTX(2) | ENABLE_TEXKILL_3D_4D | TEXKILL_4D);
+		OUT_BATCH(_3DSTATE_MODES_4_CMD |
+			  ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) |
+			  ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) |
+			  ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff));
+		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | 2);
+		OUT_BATCH(0x00000000);	/* Disable texture coordinate wrap-shortest */
+		OUT_BATCH((1 << S4_POINT_WIDTH_SHIFT) |
+			  S4_LINE_WIDTH_ONE |
+			  S4_CULLMODE_NONE |
+			  S4_VFMT_XY);
+		OUT_BATCH(0x00000000);	/* Stencil. */
+		OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
+		OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+		OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
+		OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0);	/* disable indirect state */
+		OUT_BATCH(0);
+		OUT_BATCH(_3DSTATE_STIPPLE);
+		OUT_BATCH(0x00000000);
+		OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0);
+	}
+
+	/* samler state */
+	{
+#define TEX_COUNT 1
+		uint32_t tiling_bits = 0;
+		if (src->tiling != I915_TILING_NONE)
+			tiling_bits = MS3_TILED_SURFACE;
+		if (src->tiling == I915_TILING_Y)
+			tiling_bits |= MS3_TILE_WALK;
+
+		OUT_BATCH(_3DSTATE_MAP_STATE | (3 * TEX_COUNT));
+		OUT_BATCH((1 << TEX_COUNT) - 1);
+		OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
+		OUT_BATCH(MAPSURF_32BIT | MT_32BIT_ARGB8888 |
+			  tiling_bits |
+			  (buf_height(src) - 1) << MS3_HEIGHT_SHIFT |
+			  (buf_width(src) - 1) << MS3_WIDTH_SHIFT);
+		OUT_BATCH((src->stride/4-1) << MS4_PITCH_SHIFT);
+
+		OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * TEX_COUNT));
+		OUT_BATCH((1 << TEX_COUNT) - 1);
+		OUT_BATCH(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT |
+			  FILTER_NEAREST << SS2_MAG_FILTER_SHIFT |
+			  FILTER_NEAREST << SS2_MIN_FILTER_SHIFT);
+		OUT_BATCH(TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT |
+			  TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT |
+			  0 << SS3_TEXTUREMAP_INDEX_SHIFT);
+		OUT_BATCH(0x00000000);
+	}
+
+	/* render target state */
+	{
+		uint32_t tiling_bits = 0;
+		if (dst->tiling != I915_TILING_NONE)
+			tiling_bits = BUF_3D_TILED_SURFACE;
+		if (dst->tiling == I915_TILING_Y)
+			tiling_bits |= BUF_3D_TILE_WALK_Y;
+
+		OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
+		OUT_BATCH(BUF_3D_ID_COLOR_BACK | tiling_bits |
+			  BUF_3D_PITCH(dst->stride));
+		OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+
+		OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
+		OUT_BATCH(COLR_BUF_ARGB8888 |
+			  DSTORG_HORT_BIAS(0x8) |
+			  DSTORG_VERT_BIAS(0x8));
+
+		/* draw rect is unconditional */
+		OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
+		OUT_BATCH(0x00000000);
+		OUT_BATCH(0x00000000);	/* ymin, xmin */
+		OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
+			  DRAW_XMAX(buf_width(dst) - 1));
+		/* yorig, xorig (relate to color buffer?) */
+		OUT_BATCH(0x00000000);
+	}
+
+	/* texfmt */
+	{
+		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+			  I1_LOAD_S(1) | I1_LOAD_S(2) | I1_LOAD_S(6) | 2);
+		OUT_BATCH((4 << S1_VERTEX_WIDTH_SHIFT) |
+			  (4 << S1_VERTEX_PITCH_SHIFT));
+		OUT_BATCH(~S2_TEXCOORD_FMT(0, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D));
+		OUT_BATCH(S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE |
+			  BLENDFUNC_ADD << S6_CBUF_BLEND_FUNC_SHIFT |
+			  BLENDFACT_ONE << S6_CBUF_SRC_BLEND_FACT_SHIFT |
+			  BLENDFACT_ZERO << S6_CBUF_DST_BLEND_FACT_SHIFT);
+	}
+
+	/* frage shader */
+	{
+		OUT_BATCH(_3DSTATE_PIXEL_SHADER_PROGRAM | (1 + 3*3 - 2));
+		/* decl FS_T0 */
+		OUT_BATCH(D0_DCL |
+			  REG_TYPE(FS_T0) << D0_TYPE_SHIFT |
+			  REG_NR(FS_T0) << D0_NR_SHIFT |
+			  ((REG_TYPE(FS_T0) != REG_TYPE_S) ? D0_CHANNEL_ALL : 0));
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+		/* decl FS_S0 */
+		OUT_BATCH(D0_DCL |
+			  (REG_TYPE(FS_S0) << D0_TYPE_SHIFT) |
+			  (REG_NR(FS_S0) << D0_NR_SHIFT) |
+			  ((REG_TYPE(FS_S0) != REG_TYPE_S) ? D0_CHANNEL_ALL : 0));
+		OUT_BATCH(0);
+		OUT_BATCH(0);
+		/* texld(FS_OC, FS_S0, FS_T0 */
+		OUT_BATCH(T0_TEXLD |
+			  (REG_TYPE(FS_OC) << T0_DEST_TYPE_SHIFT) |
+			  (REG_NR(FS_OC) << T0_DEST_NR_SHIFT) |
+			  (REG_NR(FS_S0) << T0_SAMPLER_NR_SHIFT));
+		OUT_BATCH((REG_TYPE(FS_T0) << T1_ADDRESS_REG_TYPE_SHIFT) |
+			  (REG_NR(FS_T0) << T1_ADDRESS_REG_NR_SHIFT));
+		OUT_BATCH(0);
+	}
+
+	OUT_BATCH(PRIM3D_RECTLIST | (3*4 - 1));
+	emit_vertex(dst_x + options.tile_size);
+	emit_vertex(dst_y + options.tile_size);
+	emit_vertex(src_x + options.tile_size);
+	emit_vertex(src_y + options.tile_size);
+
+	emit_vertex(dst_x);
+	emit_vertex(dst_y + options.tile_size);
+	emit_vertex(src_x);
+	emit_vertex(src_y + options.tile_size);
+
+	emit_vertex(dst_x);
+	emit_vertex(dst_y);
+	emit_vertex(src_x);
+	emit_vertex(src_y);
+
+	if (!(keep_gpu_busy_counter & 1))
+		keep_gpu_busy();
+
+	keep_gpu_busy_counter++;
+
+	return 0;
+}
diff --git a/lib/gen6_render.h b/lib/gen6_render.h
new file mode 100644
index 0000000..2c63c9e
--- /dev/null
+++ b/lib/gen6_render.h
@@ -0,0 +1,1553 @@
+#ifndef GEN6_RENDER_H
+#define GEN6_RENDER_H
+
+#define GEN6_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
+					   ((Pipeline) << 27) | \
+					   ((Opcode) << 24) | \
+					   ((Subopcode) << 16))
+
+#define GEN6_STATE_BASE_ADDRESS			GEN6_3D(0, 1, 1)
+#define GEN6_STATE_SIP				GEN6_3D(0, 1, 2)
+
+#define GEN6_PIPELINE_SELECT			GEN6_3D(1, 1, 4)
+
+#define GEN6_MEDIA_STATE_POINTERS		GEN6_3D(2, 0, 0)
+#define GEN6_MEDIA_OBJECT			GEN6_3D(2, 1, 0)
+
+#define GEN6_3DSTATE_BINDING_TABLE_POINTERS	GEN6_3D(3, 0, 1)
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS  (1 << 12)/* for GEN6 */
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_GS  (1 << 9) /* for GEN6 */
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_VS  (1 << 8) /* for GEN6 */
+
+#define GEN6_3DSTATE_VERTEX_BUFFERS		GEN6_3D(3, 0, 8)
+#define GEN6_3DSTATE_VERTEX_ELEMENTS		GEN6_3D(3, 0, 9)
+#define GEN6_3DSTATE_INDEX_BUFFER		GEN6_3D(3, 0, 0xa)
+#define GEN6_3DSTATE_VF_STATISTICS		GEN6_3D(3, 0, 0xb)
+
+#define GEN6_3DSTATE_DRAWING_RECTANGLE		GEN6_3D(3, 1, 0)
+#define GEN6_3DSTATE_CONSTANT_COLOR		GEN6_3D(3, 1, 1)
+#define GEN6_3DSTATE_SAMPLER_PALETTE_LOAD	GEN6_3D(3, 1, 2)
+#define GEN6_3DSTATE_CHROMA_KEY			GEN6_3D(3, 1, 4)
+#define GEN6_3DSTATE_DEPTH_BUFFER		GEN6_3D(3, 1, 5)
+# define GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT	29
+# define GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT	18
+
+#define GEN6_3DSTATE_POLY_STIPPLE_OFFSET		GEN6_3D(3, 1, 6)
+#define GEN6_3DSTATE_POLY_STIPPLE_PATTERN	GEN6_3D(3, 1, 7)
+#define GEN6_3DSTATE_LINE_STIPPLE		GEN6_3D(3, 1, 8)
+#define GEN6_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP	GEN6_3D(3, 1, 9)
+/* These two are BLC and CTG only, not BW or CL */
+#define GEN6_3DSTATE_AA_LINE_PARAMS		GEN6_3D(3, 1, 0xa)
+#define GEN6_3DSTATE_GS_SVB_INDEX		GEN6_3D(3, 1, 0xb)
+
+#define GEN6_3DPRIMITIVE				GEN6_3D(3, 3, 0)
+
+#define GEN6_3DSTATE_CLEAR_PARAMS		GEN6_3D(3, 1, 0x10)
+/* DW1 */
+# define GEN6_3DSTATE_DEPTH_CLEAR_VALID		(1 << 15)
+
+#define GEN6_3DSTATE_SAMPLER_STATE_POINTERS	GEN6_3D(3, 0, 0x02)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS	(1 << 12)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_GS	(1 << 9)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_VS	(1 << 8)
+
+#define GEN6_3DSTATE_URB			GEN6_3D(3, 0, 0x05)
+/* DW1 */
+# define GEN6_3DSTATE_URB_VS_SIZE_SHIFT		16
+# define GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT	0
+/* DW2 */
+# define GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT	8
+# define GEN6_3DSTATE_URB_GS_SIZE_SHIFT		0
+
+#define GEN6_3DSTATE_VIEWPORT_STATE_POINTERS	GEN6_3D(3, 0, 0x0d)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC		(1 << 12)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_SF		(1 << 11)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CLIP	(1 << 10)
+
+#define GEN6_3DSTATE_CC_STATE_POINTERS		GEN6_3D(3, 0, 0x0e)
+
+#define GEN6_3DSTATE_VS				GEN6_3D(3, 0, 0x10)
+
+#define GEN6_3DSTATE_GS				GEN6_3D(3, 0, 0x11)
+/* DW4 */
+# define GEN6_3DSTATE_GS_DISPATCH_START_GRF_SHIFT	0
+
+#define GEN6_3DSTATE_CLIP			GEN6_3D(3, 0, 0x12)
+
+#define GEN6_3DSTATE_SF				GEN6_3D(3, 0, 0x13)
+/* DW1 */
+# define GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT		22
+# define GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT	11
+# define GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT	4
+/* DW2 */
+/* DW3 */
+# define GEN6_3DSTATE_SF_CULL_BOTH			(0 << 29)
+# define GEN6_3DSTATE_SF_CULL_NONE			(1 << 29)
+# define GEN6_3DSTATE_SF_CULL_FRONT			(2 << 29)
+# define GEN6_3DSTATE_SF_CULL_BACK			(3 << 29)
+/* DW4 */
+# define GEN6_3DSTATE_SF_TRI_PROVOKE_SHIFT		29
+# define GEN6_3DSTATE_SF_LINE_PROVOKE_SHIFT		27
+# define GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT		25
+
+#define GEN6_3DSTATE_WM				GEN6_3D(3, 0, 0x14)
+/* DW2 */
+# define GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT			27
+# define GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
+/* DW4 */
+# define GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT		16
+/* DW5 */
+# define GEN6_3DSTATE_WM_MAX_THREADS_SHIFT			25
+# define GEN6_3DSTATE_WM_DISPATCH_ENABLE			(1 << 19)
+# define GEN6_3DSTATE_WM_16_DISPATCH_ENABLE			(1 << 1)
+# define GEN6_3DSTATE_WM_8_DISPATCH_ENABLE			(1 << 0)
+/* DW6 */
+# define GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT			20
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	(1 << 15)
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 14)
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	(1 << 13)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC		(1 << 12)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 11)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		(1 << 10)
+
+
+#define GEN6_3DSTATE_CONSTANT_VS		GEN6_3D(3, 0, 0x15)
+#define GEN6_3DSTATE_CONSTANT_GS		GEN6_3D(3, 0, 0x16)
+#define GEN6_3DSTATE_CONSTANT_PS		GEN6_3D(3, 0, 0x17)
+
+#define GEN6_3DSTATE_SAMPLE_MASK		GEN6_3D(3, 0, 0x18)
+
+#define GEN6_3DSTATE_MULTISAMPLE		GEN6_3D(3, 1, 0x0d)
+/* DW1 */
+# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER		(0 << 4)
+# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_UPPER_LEFT	(1 << 4)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1			(0 << 1)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_4			(2 << 1)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_8			(3 << 1)
+
+#define PIPELINE_SELECT_3D		0
+#define PIPELINE_SELECT_MEDIA		1
+
+/* for GEN6_STATE_BASE_ADDRESS */
+#define BASE_ADDRESS_MODIFY		(1 << 0)
+
+/* for GEN6_PIPE_CONTROL */
+#define GEN6_PIPE_CONTROL_NOWRITE       (0 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_QWORD   (1 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_DEPTH   (2 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_TIME    (3 << 14)
+#define GEN6_PIPE_CONTROL_DEPTH_STALL   (1 << 13)
+#define GEN6_PIPE_CONTROL_WC_FLUSH      (1 << 12)
+#define GEN6_PIPE_CONTROL_IS_FLUSH      (1 << 11)
+#define GEN6_PIPE_CONTROL_TC_FLUSH      (1 << 10)
+#define GEN6_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
+#define GEN6_PIPE_CONTROL_GLOBAL_GTT    (1 << 2)
+#define GEN6_PIPE_CONTROL_LOCAL_PGTT    (0 << 2)
+#define GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH	(1 << 0)
+
+/* VERTEX_BUFFER_STATE Structure */
+#define VB0_BUFFER_INDEX_SHIFT	26
+#define VB0_VERTEXDATA			(0 << 20)
+#define VB0_INSTANCEDATA		(1 << 20)
+#define VB0_BUFFER_PITCH_SHIFT		0
+
+/* VERTEX_ELEMENT_STATE Structure */
+#define VE0_VERTEX_BUFFER_INDEX_SHIFT	26 /* for GEN6 */
+#define VE0_VALID			(1 << 25) /* for GEN6 */
+#define VE0_FORMAT_SHIFT		16
+#define VE0_OFFSET_SHIFT		0
+#define VE1_VFCOMPONENT_0_SHIFT		28
+#define VE1_VFCOMPONENT_1_SHIFT		24
+#define VE1_VFCOMPONENT_2_SHIFT		20
+#define VE1_VFCOMPONENT_3_SHIFT		16
+#define VE1_DESTINATION_ELEMENT_OFFSET_SHIFT	0
+
+/* 3DPRIMITIVE bits */
+#define GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
+#define GEN6_3DPRIMITIVE_VERTEX_RANDOM	  (1 << 15)
+/* Primitive types are in gen6_defines.h */
+#define GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT	  10
+
+#define GEN6_SVG_CTL		       0x7400
+
+#define GEN6_SVG_CTL_GS_BA	       (0 << 8)
+#define GEN6_SVG_CTL_SS_BA	       (1 << 8)
+#define GEN6_SVG_CTL_IO_BA	       (2 << 8)
+#define GEN6_SVG_CTL_GS_AUB	       (3 << 8)
+#define GEN6_SVG_CTL_IO_AUB	       (4 << 8)
+#define GEN6_SVG_CTL_SIP		       (5 << 8)
+
+#define GEN6_SVG_RDATA		       0x7404
+#define GEN6_SVG_WORK_CTL	       0x7408
+
+#define GEN6_VF_CTL		       0x7500
+
+#define GEN6_VF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID	   (0 << 8)
+#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG	   (1 << 8)
+#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE   (0 << 4)
+#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX	   (1 << 4)
+#define GEN6_VF_CTL_SKIP_INITIAL_PRIMITIVES	   (1 << 3)
+#define GEN6_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE	   (1 << 2)
+#define GEN6_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE	   (1 << 1)
+#define GEN6_VF_CTL_SNAPSHOT_ENABLE	     	   (1 << 0)
+
+#define GEN6_VF_STRG_VAL		       0x7504
+#define GEN6_VF_STR_VL_OVR	       0x7508
+#define GEN6_VF_VC_OVR		       0x750c
+#define GEN6_VF_STR_PSKIP	       0x7510
+#define GEN6_VF_MAX_PRIM		       0x7514
+#define GEN6_VF_RDATA		       0x7518
+
+#define GEN6_VS_CTL		       0x7600
+#define GEN6_VS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_0	   (0 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_1	   (1 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VALID_COUNT	   (2 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER  (3 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
+#define GEN6_VS_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
+#define GEN6_VS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_VS_STRG_VAL		       0x7604
+#define GEN6_VS_RDATA		       0x7608
+
+#define GEN6_SF_CTL		       0x7b00
+#define GEN6_SF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID	   (0 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID	   (2 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID	   (4 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT	   (6 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER  (7 << 8)
+#define GEN6_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE  (1 << 4)
+#define GEN6_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE	   (1 << 3)
+#define GEN6_SF_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
+#define GEN6_SF_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
+#define GEN6_SF_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_SF_STRG_VAL		       0x7b04
+#define GEN6_SF_RDATA		       0x7b18
+
+#define GEN6_WIZ_CTL		       0x7c00
+#define GEN6_WIZ_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT	   16
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER   (0 << 8)
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE     (1 << 8)
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE   (2 << 8)
+#define GEN6_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH	      (1 << 6)
+#define GEN6_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS    (1 << 5)
+#define GEN6_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE   (1 << 4)
+#define GEN6_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG	      (1 << 3)
+#define GEN6_WIZ_CTL_SNAPSHOT_ALL_THREADS	      (1 << 2)
+#define GEN6_WIZ_CTL_THREAD_SNAPSHOT_ENABLE	      (1 << 1)
+#define GEN6_WIZ_CTL_SNAPSHOT_ENABLE		      (1 << 0)
+
+#define GEN6_WIZ_STRG_VAL			      0x7c04
+#define GEN6_WIZ_RDATA				      0x7c18
+
+#define GEN6_TS_CTL		       0x7e00
+#define GEN6_TS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_TS_CTL_SNAPSHOT_MESSAGE_ERROR	   (0 << 8)
+#define GEN6_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR   (3 << 8)
+#define GEN6_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS	   (1 << 2)
+#define GEN6_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS  	   (1 << 1)
+#define GEN6_TS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_TS_STRG_VAL		       0x7e04
+#define GEN6_TS_RDATA		       0x7e08
+
+/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
+#ifndef GEN6_TD_CTL
+#define GEN6_TD_CTL		       0x8000
+#endif
+#define GEN6_TD_CTL_MUX_SHIFT	       8
+#define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
+#define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
+#define GEN6_TD_CTL_EXCEPTION_MASK_OVERRIDE	   (1 << 5)
+#define GEN6_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE  (1 << 4)
+#define GEN6_TD_CTL_BREAKPOINT_ENABLE		   (1 << 2)
+#define GEN6_TD_CTL2		       0x8004
+#define GEN6_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
+#define GEN6_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE      (1 << 26)
+#define GEN6_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE	      (1 << 25)
+#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT	      16
+#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE	      (1 << 8)
+#define GEN6_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
+#define GEN6_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE	      (1 << 6)
+#define GEN6_TD_CTL2_SF_EXECUTION_MASK_ENABLE	      (1 << 5)
+#define GEN6_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE     (1 << 4)
+#define GEN6_TD_CTL2_GS_EXECUTION_MASK_ENABLE	      (1 << 3)
+#define GEN6_TD_CTL2_VS_EXECUTION_MASK_ENABLE	      (1 << 0)
+#define GEN6_TD_VF_VS_EMSK	       0x8008
+#define GEN6_TD_GS_EMSK		       0x800c
+#define GEN6_TD_CLIP_EMSK	       0x8010
+#define GEN6_TD_SF_EMSK		       0x8014
+#define GEN6_TD_WIZ_EMSK		       0x8018
+#define GEN6_TD_0_6_EHTRG_VAL	       0x801c
+#define GEN6_TD_0_7_EHTRG_VAL	       0x8020
+#define GEN6_TD_0_6_EHTRG_MSK           0x8024
+#define GEN6_TD_0_7_EHTRG_MSK	       0x8028
+#define GEN6_TD_RDATA		       0x802c
+#define GEN6_TD_TS_EMSK		       0x8030
+
+#define GEN6_EU_CTL		       0x8800
+#define GEN6_EU_CTL_SELECT_SHIFT	       16
+#define GEN6_EU_CTL_DATA_MUX_SHIFT      8
+#define GEN6_EU_ATT_0		       0x8810
+#define GEN6_EU_ATT_1		       0x8814
+#define GEN6_EU_ATT_DATA_0	       0x8820
+#define GEN6_EU_ATT_DATA_1	       0x8824
+#define GEN6_EU_ATT_CLR_0	       0x8830
+#define GEN6_EU_ATT_CLR_1	       0x8834
+#define GEN6_EU_RDATA		       0x8840
+
+#define GEN6_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
+					   ((Pipeline) << 27) | \
+					   ((Opcode) << 24) | \
+					   ((Subopcode) << 16))
+
+#define GEN6_STATE_BASE_ADDRESS			GEN6_3D(0, 1, 1)
+#define GEN6_STATE_SIP				GEN6_3D(0, 1, 2)
+
+#define GEN6_PIPELINE_SELECT			GEN6_3D(1, 1, 4)
+
+#define GEN6_MEDIA_STATE_POINTERS		GEN6_3D(2, 0, 0)
+#define GEN6_MEDIA_OBJECT			GEN6_3D(2, 1, 0)
+
+#define GEN6_3DSTATE_BINDING_TABLE_POINTERS	GEN6_3D(3, 0, 1)
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS  (1 << 12)/* for GEN6 */
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_GS  (1 << 9) /* for GEN6 */
+# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_VS  (1 << 8) /* for GEN6 */
+
+#define GEN6_3DSTATE_VERTEX_BUFFERS		GEN6_3D(3, 0, 8)
+#define GEN6_3DSTATE_VERTEX_ELEMENTS		GEN6_3D(3, 0, 9)
+#define GEN6_3DSTATE_INDEX_BUFFER		GEN6_3D(3, 0, 0xa)
+#define GEN6_3DSTATE_VF_STATISTICS		GEN6_3D(3, 0, 0xb)
+
+#define GEN6_3DSTATE_DRAWING_RECTANGLE		GEN6_3D(3, 1, 0)
+#define GEN6_3DSTATE_CONSTANT_COLOR		GEN6_3D(3, 1, 1)
+#define GEN6_3DSTATE_SAMPLER_PALETTE_LOAD	GEN6_3D(3, 1, 2)
+#define GEN6_3DSTATE_CHROMA_KEY			GEN6_3D(3, 1, 4)
+#define GEN6_3DSTATE_DEPTH_BUFFER		GEN6_3D(3, 1, 5)
+# define GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT	29
+# define GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT	18
+
+#define GEN6_3DSTATE_POLY_STIPPLE_OFFSET		GEN6_3D(3, 1, 6)
+#define GEN6_3DSTATE_POLY_STIPPLE_PATTERN	GEN6_3D(3, 1, 7)
+#define GEN6_3DSTATE_LINE_STIPPLE		GEN6_3D(3, 1, 8)
+#define GEN6_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP	GEN6_3D(3, 1, 9)
+/* These two are BLC and CTG only, not BW or CL */
+#define GEN6_3DSTATE_AA_LINE_PARAMS		GEN6_3D(3, 1, 0xa)
+#define GEN6_3DSTATE_GS_SVB_INDEX		GEN6_3D(3, 1, 0xb)
+
+#define GEN6_PIPE_CONTROL			GEN6_3D(3, 2, 0)
+
+#define GEN6_3DPRIMITIVE				GEN6_3D(3, 3, 0)
+
+#define GEN6_3DSTATE_CLEAR_PARAMS		GEN6_3D(3, 1, 0x10)
+/* DW1 */
+# define GEN6_3DSTATE_DEPTH_CLEAR_VALID		(1 << 15)
+
+/* for GEN6+ */
+#define GEN6_3DSTATE_SAMPLER_STATE_POINTERS	GEN6_3D(3, 0, 0x02)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS	(1 << 12)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_GS	(1 << 9)
+# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_VS	(1 << 8)
+
+#define GEN6_3DSTATE_URB			GEN6_3D(3, 0, 0x05)
+/* DW1 */
+# define GEN6_3DSTATE_URB_VS_SIZE_SHIFT		16
+# define GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT	0
+/* DW2 */
+# define GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT	8
+# define GEN6_3DSTATE_URB_GS_SIZE_SHIFT		0
+
+#define GEN6_3DSTATE_VIEWPORT_STATE_POINTERS	GEN6_3D(3, 0, 0x0d)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC		(1 << 12)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_SF		(1 << 11)
+# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CLIP	(1 << 10)
+
+#define GEN6_3DSTATE_CC_STATE_POINTERS		GEN6_3D(3, 0, 0x0e)
+
+#define GEN6_3DSTATE_VS				GEN6_3D(3, 0, 0x10)
+
+#define GEN6_3DSTATE_GS				GEN6_3D(3, 0, 0x11)
+/* DW4 */
+# define GEN6_3DSTATE_GS_DISPATCH_START_GRF_SHIFT	0
+
+#define GEN6_3DSTATE_CLIP			GEN6_3D(3, 0, 0x12)
+
+#define GEN6_3DSTATE_SF				GEN6_3D(3, 0, 0x13)
+/* DW1 */
+# define GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT		22
+# define GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT	11
+# define GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT	4
+/* DW2 */
+/* DW3 */
+# define GEN6_3DSTATE_SF_CULL_BOTH			(0 << 29)
+# define GEN6_3DSTATE_SF_CULL_NONE			(1 << 29)
+# define GEN6_3DSTATE_SF_CULL_FRONT			(2 << 29)
+# define GEN6_3DSTATE_SF_CULL_BACK			(3 << 29)
+/* DW4 */
+# define GEN6_3DSTATE_SF_TRI_PROVOKE_SHIFT		29
+# define GEN6_3DSTATE_SF_LINE_PROVOKE_SHIFT		27
+# define GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT		25
+
+
+#define GEN6_3DSTATE_WM				GEN6_3D(3, 0, 0x14)
+/* DW2 */
+# define GEN6_3DSTATE_WM_SAMPLER_COUNT_SHITF			27
+# define GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
+/* DW4 */
+# define GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT		16
+/* DW5 */
+# define GEN6_3DSTATE_WM_MAX_THREADS_SHIFT			25
+# define GEN6_3DSTATE_WM_DISPATCH_ENABLE			(1 << 19)
+# define GEN6_3DSTATE_WM_16_DISPATCH_ENABLE			(1 << 1)
+# define GEN6_3DSTATE_WM_8_DISPATCH_ENABLE			(1 << 0)
+/* DW6 */
+# define GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT			20
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	(1 << 15)
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 14)
+# define GEN6_3DSTATE_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	(1 << 13)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC		(1 << 12)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 11)
+# define GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		(1 << 10)
+
+
+#define GEN6_3DSTATE_CONSTANT_VS		GEN6_3D(3, 0, 0x15)
+#define GEN6_3DSTATE_CONSTANT_GS          	GEN6_3D(3, 0, 0x16)
+#define GEN6_3DSTATE_CONSTANT_PS          	GEN6_3D(3, 0, 0x17)
+
+#define GEN6_3DSTATE_SAMPLE_MASK		GEN6_3D(3, 0, 0x18)
+
+#define GEN6_3DSTATE_MULTISAMPLE		GEN6_3D(3, 1, 0x0d)
+/* DW1 */
+# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER		(0 << 4)
+# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_UPPER_LEFT	(1 << 4)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1			(0 << 1)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_4			(2 << 1)
+# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_8			(3 << 1)
+
+#define PIPELINE_SELECT_3D		0
+#define PIPELINE_SELECT_MEDIA		1
+
+#define UF0_CS_REALLOC			(1 << 13)
+#define UF0_VFE_REALLOC			(1 << 12)
+#define UF0_SF_REALLOC			(1 << 11)
+#define UF0_CLIP_REALLOC		(1 << 10)
+#define UF0_GS_REALLOC			(1 << 9)
+#define UF0_VS_REALLOC			(1 << 8)
+#define UF1_CLIP_FENCE_SHIFT		20
+#define UF1_GS_FENCE_SHIFT		10
+#define UF1_VS_FENCE_SHIFT		0
+#define UF2_CS_FENCE_SHIFT		20
+#define UF2_VFE_FENCE_SHIFT		10
+#define UF2_SF_FENCE_SHIFT		0
+
+/* for GEN6_STATE_BASE_ADDRESS */
+#define BASE_ADDRESS_MODIFY		(1 << 0)
+
+/* for GEN6_3DSTATE_PIPELINED_POINTERS */
+#define GEN6_GS_DISABLE		       0
+#define GEN6_GS_ENABLE		       1
+#define GEN6_CLIP_DISABLE	       0
+#define GEN6_CLIP_ENABLE		       1
+
+/* for GEN6_PIPE_CONTROL */
+#define GEN6_PIPE_CONTROL_NOWRITE       (0 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_QWORD   (1 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_DEPTH   (2 << 14)
+#define GEN6_PIPE_CONTROL_WRITE_TIME    (3 << 14)
+#define GEN6_PIPE_CONTROL_DEPTH_STALL   (1 << 13)
+#define GEN6_PIPE_CONTROL_WC_FLUSH      (1 << 12)
+#define GEN6_PIPE_CONTROL_IS_FLUSH      (1 << 11)
+#define GEN6_PIPE_CONTROL_TC_FLUSH      (1 << 10)
+#define GEN6_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
+#define GEN6_PIPE_CONTROL_GLOBAL_GTT    (1 << 2)
+#define GEN6_PIPE_CONTROL_LOCAL_PGTT    (0 << 2)
+#define GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH	(1 << 0)
+
+/* 3DPRIMITIVE bits */
+#define GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
+#define GEN6_3DPRIMITIVE_VERTEX_RANDOM	  (1 << 15)
+/* Primitive types are in gen6_defines.h */
+#define GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT	  10
+
+#define GEN6_SVG_CTL		       0x7400
+
+#define GEN6_SVG_CTL_GS_BA	       (0 << 8)
+#define GEN6_SVG_CTL_SS_BA	       (1 << 8)
+#define GEN6_SVG_CTL_IO_BA	       (2 << 8)
+#define GEN6_SVG_CTL_GS_AUB	       (3 << 8)
+#define GEN6_SVG_CTL_IO_AUB	       (4 << 8)
+#define GEN6_SVG_CTL_SIP		       (5 << 8)
+
+#define GEN6_SVG_RDATA		       0x7404
+#define GEN6_SVG_WORK_CTL	       0x7408
+
+#define GEN6_VF_CTL		       0x7500
+
+#define GEN6_VF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID	   (0 << 8)
+#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG	   (1 << 8)
+#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE   (0 << 4)
+#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX	   (1 << 4)
+#define GEN6_VF_CTL_SKIP_INITIAL_PRIMITIVES	   (1 << 3)
+#define GEN6_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE	   (1 << 2)
+#define GEN6_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE	   (1 << 1)
+#define GEN6_VF_CTL_SNAPSHOT_ENABLE	     	   (1 << 0)
+
+#define GEN6_VF_STRG_VAL		       0x7504
+#define GEN6_VF_STR_VL_OVR	       0x7508
+#define GEN6_VF_VC_OVR		       0x750c
+#define GEN6_VF_STR_PSKIP	       0x7510
+#define GEN6_VF_MAX_PRIM		       0x7514
+#define GEN6_VF_RDATA		       0x7518
+
+#define GEN6_VS_CTL		       0x7600
+#define GEN6_VS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_0	   (0 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_1	   (1 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VALID_COUNT	   (2 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER  (3 << 8)
+#define GEN6_VS_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
+#define GEN6_VS_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
+#define GEN6_VS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_VS_STRG_VAL		       0x7604
+#define GEN6_VS_RDATA		       0x7608
+
+#define GEN6_SF_CTL		       0x7b00
+#define GEN6_SF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID	   (0 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID	   (2 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID	   (4 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT	   (6 << 8)
+#define GEN6_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER  (7 << 8)
+#define GEN6_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE  (1 << 4)
+#define GEN6_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE	   (1 << 3)
+#define GEN6_SF_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
+#define GEN6_SF_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
+#define GEN6_SF_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_SF_STRG_VAL		       0x7b04
+#define GEN6_SF_RDATA		       0x7b18
+
+#define GEN6_WIZ_CTL		       0x7c00
+#define GEN6_WIZ_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT	   16
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER   (0 << 8)
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE     (1 << 8)
+#define GEN6_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE   (2 << 8)
+#define GEN6_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH	      (1 << 6)
+#define GEN6_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS    (1 << 5)
+#define GEN6_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE   (1 << 4)
+#define GEN6_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG	      (1 << 3)
+#define GEN6_WIZ_CTL_SNAPSHOT_ALL_THREADS	      (1 << 2)
+#define GEN6_WIZ_CTL_THREAD_SNAPSHOT_ENABLE	      (1 << 1)
+#define GEN6_WIZ_CTL_SNAPSHOT_ENABLE		      (1 << 0)
+
+#define GEN6_WIZ_STRG_VAL			      0x7c04
+#define GEN6_WIZ_RDATA				      0x7c18
+
+#define GEN6_TS_CTL		       0x7e00
+#define GEN6_TS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
+#define GEN6_TS_CTL_SNAPSHOT_MESSAGE_ERROR	   (0 << 8)
+#define GEN6_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR   (3 << 8)
+#define GEN6_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS	   (1 << 2)
+#define GEN6_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS  	   (1 << 1)
+#define GEN6_TS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
+
+#define GEN6_TS_STRG_VAL		       0x7e04
+#define GEN6_TS_RDATA		       0x7e08
+
+/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
+#ifndef GEN6_TD_CTL
+#define GEN6_TD_CTL                   0x8000
+#endif
+#define GEN6_TD_CTL_MUX_SHIFT	       8
+#define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
+#define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
+#define GEN6_TD_CTL_EXCEPTION_MASK_OVERRIDE	   (1 << 5)
+#define GEN6_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE  (1 << 4)
+#define GEN6_TD_CTL_BREAKPOINT_ENABLE		   (1 << 2)
+#define GEN6_TD_CTL2		       0x8004
+#define GEN6_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
+#define GEN6_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE      (1 << 26)
+#define GEN6_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE	      (1 << 25)
+#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT	      16
+#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE	      (1 << 8)
+#define GEN6_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
+#define GEN6_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE	      (1 << 6)
+#define GEN6_TD_CTL2_SF_EXECUTION_MASK_ENABLE	      (1 << 5)
+#define GEN6_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE     (1 << 4)
+#define GEN6_TD_CTL2_GS_EXECUTION_MASK_ENABLE	      (1 << 3)
+#define GEN6_TD_CTL2_VS_EXECUTION_MASK_ENABLE	      (1 << 0)
+#define GEN6_TD_VF_VS_EMSK	       0x8008
+#define GEN6_TD_GS_EMSK		       0x800c
+#define GEN6_TD_CLIP_EMSK	       0x8010
+#define GEN6_TD_SF_EMSK		       0x8014
+#define GEN6_TD_WIZ_EMSK		       0x8018
+#define GEN6_TD_0_6_EHTRG_VAL	       0x801c
+#define GEN6_TD_0_7_EHTRG_VAL	       0x8020
+#define GEN6_TD_0_6_EHTRG_MSK           0x8024
+#define GEN6_TD_0_7_EHTRG_MSK	       0x8028
+#define GEN6_TD_RDATA		       0x802c
+#define GEN6_TD_TS_EMSK		       0x8030
+
+#define GEN6_EU_CTL		       0x8800
+#define GEN6_EU_CTL_SELECT_SHIFT	       16
+#define GEN6_EU_CTL_DATA_MUX_SHIFT      8
+#define GEN6_EU_ATT_0		       0x8810
+#define GEN6_EU_ATT_1		       0x8814
+#define GEN6_EU_ATT_DATA_0	       0x8820
+#define GEN6_EU_ATT_DATA_1	       0x8824
+#define GEN6_EU_ATT_CLR_0	       0x8830
+#define GEN6_EU_ATT_CLR_1	       0x8834
+#define GEN6_EU_RDATA		       0x8840
+
+/* 3D state:
+ */
+#define _3DOP_3DSTATE_PIPELINED       0x0
+#define _3DOP_3DSTATE_NONPIPELINED    0x1
+#define _3DOP_3DCONTROL               0x2
+#define _3DOP_3DPRIMITIVE             0x3
+
+#define _3DSTATE_PIPELINED_POINTERS       0x00
+#define _3DSTATE_BINDING_TABLE_POINTERS   0x01
+#define _3DSTATE_VERTEX_BUFFERS           0x08
+#define _3DSTATE_VERTEX_ELEMENTS          0x09
+#define _3DSTATE_INDEX_BUFFER             0x0A
+#define _3DSTATE_VF_STATISTICS            0x0B
+#define _3DSTATE_DRAWING_RECTANGLE            0x00
+#define _3DSTATE_CONSTANT_COLOR               0x01
+#define _3DSTATE_SAMPLER_PALETTE_LOAD         0x02
+#define _3DSTATE_CHROMA_KEY                   0x04
+#define _3DSTATE_DEPTH_BUFFER                 0x05
+#define _3DSTATE_POLY_STIPPLE_OFFSET          0x06
+#define _3DSTATE_POLY_STIPPLE_PATTERN         0x07
+#define _3DSTATE_LINE_STIPPLE                 0x08
+#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP    0x09
+#define _3DCONTROL    0x00
+#define _3DPRIMITIVE  0x00
+
+#define _3DPRIM_POINTLIST         0x01
+#define _3DPRIM_LINELIST          0x02
+#define _3DPRIM_LINESTRIP         0x03
+#define _3DPRIM_TRILIST           0x04
+#define _3DPRIM_TRISTRIP          0x05
+#define _3DPRIM_TRIFAN            0x06
+#define _3DPRIM_QUADLIST          0x07
+#define _3DPRIM_QUADSTRIP         0x08
+#define _3DPRIM_LINELIST_ADJ      0x09
+#define _3DPRIM_LINESTRIP_ADJ     0x0A
+#define _3DPRIM_TRILIST_ADJ       0x0B
+#define _3DPRIM_TRISTRIP_ADJ      0x0C
+#define _3DPRIM_TRISTRIP_REVERSE  0x0D
+#define _3DPRIM_POLYGON           0x0E
+#define _3DPRIM_RECTLIST          0x0F
+#define _3DPRIM_LINELOOP          0x10
+#define _3DPRIM_POINTLIST_BF      0x11
+#define _3DPRIM_LINESTRIP_CONT    0x12
+#define _3DPRIM_LINESTRIP_BF      0x13
+#define _3DPRIM_LINESTRIP_CONT_BF 0x14
+#define _3DPRIM_TRIFAN_NOSTIPPLE  0x15
+
+#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
+#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     1
+
+#define GEN6_ANISORATIO_2     0 
+#define GEN6_ANISORATIO_4     1 
+#define GEN6_ANISORATIO_6     2 
+#define GEN6_ANISORATIO_8     3 
+#define GEN6_ANISORATIO_10    4 
+#define GEN6_ANISORATIO_12    5 
+#define GEN6_ANISORATIO_14    6 
+#define GEN6_ANISORATIO_16    7
+
+#define GEN6_BLENDFACTOR_ONE                 0x1
+#define GEN6_BLENDFACTOR_SRC_COLOR           0x2
+#define GEN6_BLENDFACTOR_SRC_ALPHA           0x3
+#define GEN6_BLENDFACTOR_DST_ALPHA           0x4
+#define GEN6_BLENDFACTOR_DST_COLOR           0x5
+#define GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE  0x6
+#define GEN6_BLENDFACTOR_CONST_COLOR         0x7
+#define GEN6_BLENDFACTOR_CONST_ALPHA         0x8
+#define GEN6_BLENDFACTOR_SRC1_COLOR          0x9
+#define GEN6_BLENDFACTOR_SRC1_ALPHA          0x0A
+#define GEN6_BLENDFACTOR_ZERO                0x11
+#define GEN6_BLENDFACTOR_INV_SRC_COLOR       0x12
+#define GEN6_BLENDFACTOR_INV_SRC_ALPHA       0x13
+#define GEN6_BLENDFACTOR_INV_DST_ALPHA       0x14
+#define GEN6_BLENDFACTOR_INV_DST_COLOR       0x15
+#define GEN6_BLENDFACTOR_INV_CONST_COLOR     0x17
+#define GEN6_BLENDFACTOR_INV_CONST_ALPHA     0x18
+#define GEN6_BLENDFACTOR_INV_SRC1_COLOR      0x19
+#define GEN6_BLENDFACTOR_INV_SRC1_ALPHA      0x1A
+
+#define GEN6_BLENDFUNCTION_ADD               0
+#define GEN6_BLENDFUNCTION_SUBTRACT          1
+#define GEN6_BLENDFUNCTION_REVERSE_SUBTRACT  2
+#define GEN6_BLENDFUNCTION_MIN               3
+#define GEN6_BLENDFUNCTION_MAX               4
+
+#define GEN6_ALPHATEST_FORMAT_UNORM8         0
+#define GEN6_ALPHATEST_FORMAT_FLOAT32        1
+
+#define GEN6_CHROMAKEY_KILL_ON_ANY_MATCH  0
+#define GEN6_CHROMAKEY_REPLACE_BLACK      1
+
+#define GEN6_CLIP_API_OGL     0
+#define GEN6_CLIP_API_DX      1
+
+#define GEN6_CLIPMODE_NORMAL              0
+#define GEN6_CLIPMODE_CLIP_ALL            1
+#define GEN6_CLIPMODE_CLIP_NON_REJECTED   2
+#define GEN6_CLIPMODE_REJECT_ALL          3
+#define GEN6_CLIPMODE_ACCEPT_ALL          4
+
+#define GEN6_CLIP_NDCSPACE     0
+#define GEN6_CLIP_SCREENSPACE  1
+
+#define GEN6_COMPAREFUNCTION_ALWAYS       0
+#define GEN6_COMPAREFUNCTION_NEVER        1
+#define GEN6_COMPAREFUNCTION_LESS         2
+#define GEN6_COMPAREFUNCTION_EQUAL        3
+#define GEN6_COMPAREFUNCTION_LEQUAL       4
+#define GEN6_COMPAREFUNCTION_GREATER      5
+#define GEN6_COMPAREFUNCTION_NOTEQUAL     6
+#define GEN6_COMPAREFUNCTION_GEQUAL       7
+
+#define GEN6_COVERAGE_PIXELS_HALF     0
+#define GEN6_COVERAGE_PIXELS_1        1
+#define GEN6_COVERAGE_PIXELS_2        2
+#define GEN6_COVERAGE_PIXELS_4        3
+
+#define GEN6_CULLMODE_BOTH        0
+#define GEN6_CULLMODE_NONE        1
+#define GEN6_CULLMODE_FRONT       2
+#define GEN6_CULLMODE_BACK        3
+
+#define GEN6_DEFAULTCOLOR_R8G8B8A8_UNORM      0
+#define GEN6_DEFAULTCOLOR_R32G32B32A32_FLOAT  1
+
+#define GEN6_DEPTHFORMAT_D32_FLOAT_S8X24_UINT     0
+#define GEN6_DEPTHFORMAT_D32_FLOAT                1
+#define GEN6_DEPTHFORMAT_D24_UNORM_S8_UINT        2
+#define GEN6_DEPTHFORMAT_D16_UNORM                5
+
+#define GEN6_FLOATING_POINT_IEEE_754        0
+#define GEN6_FLOATING_POINT_NON_IEEE_754    1
+
+#define GEN6_FRONTWINDING_CW      0
+#define GEN6_FRONTWINDING_CCW     1
+
+#define GEN6_INDEX_BYTE     0
+#define GEN6_INDEX_WORD     1
+#define GEN6_INDEX_DWORD    2
+
+#define GEN6_LOGICOPFUNCTION_CLEAR            0
+#define GEN6_LOGICOPFUNCTION_NOR              1
+#define GEN6_LOGICOPFUNCTION_AND_INVERTED     2
+#define GEN6_LOGICOPFUNCTION_COPY_INVERTED    3
+#define GEN6_LOGICOPFUNCTION_AND_REVERSE      4
+#define GEN6_LOGICOPFUNCTION_INVERT           5
+#define GEN6_LOGICOPFUNCTION_XOR              6
+#define GEN6_LOGICOPFUNCTION_NAND             7
+#define GEN6_LOGICOPFUNCTION_AND              8
+#define GEN6_LOGICOPFUNCTION_EQUIV            9
+#define GEN6_LOGICOPFUNCTION_NOOP             10
+#define GEN6_LOGICOPFUNCTION_OR_INVERTED      11
+#define GEN6_LOGICOPFUNCTION_COPY             12
+#define GEN6_LOGICOPFUNCTION_OR_REVERSE       13
+#define GEN6_LOGICOPFUNCTION_OR               14
+#define GEN6_LOGICOPFUNCTION_SET              15  
+
+#define GEN6_MAPFILTER_NEAREST        0x0 
+#define GEN6_MAPFILTER_LINEAR         0x1 
+#define GEN6_MAPFILTER_ANISOTROPIC    0x2
+
+#define GEN6_MIPFILTER_NONE        0   
+#define GEN6_MIPFILTER_NEAREST     1   
+#define GEN6_MIPFILTER_LINEAR      3
+
+#define GEN6_POLYGON_FRONT_FACING     0
+#define GEN6_POLYGON_BACK_FACING      1
+
+#define GEN6_PREFILTER_ALWAYS     0x0 
+#define GEN6_PREFILTER_NEVER      0x1
+#define GEN6_PREFILTER_LESS       0x2
+#define GEN6_PREFILTER_EQUAL      0x3
+#define GEN6_PREFILTER_LEQUAL     0x4
+#define GEN6_PREFILTER_GREATER    0x5
+#define GEN6_PREFILTER_NOTEQUAL   0x6
+#define GEN6_PREFILTER_GEQUAL     0x7
+
+#define GEN6_PROVOKING_VERTEX_0    0
+#define GEN6_PROVOKING_VERTEX_1    1 
+#define GEN6_PROVOKING_VERTEX_2    2
+
+#define GEN6_RASTRULE_UPPER_LEFT  0    
+#define GEN6_RASTRULE_UPPER_RIGHT 1
+
+#define GEN6_RENDERTARGET_CLAMPRANGE_UNORM    0
+#define GEN6_RENDERTARGET_CLAMPRANGE_SNORM    1
+#define GEN6_RENDERTARGET_CLAMPRANGE_FORMAT   2
+
+#define GEN6_STENCILOP_KEEP               0
+#define GEN6_STENCILOP_ZERO               1
+#define GEN6_STENCILOP_REPLACE            2
+#define GEN6_STENCILOP_INCRSAT            3
+#define GEN6_STENCILOP_DECRSAT            4
+#define GEN6_STENCILOP_INCR               5
+#define GEN6_STENCILOP_DECR               6
+#define GEN6_STENCILOP_INVERT             7
+
+#define GEN6_SURFACE_MIPMAPLAYOUT_BELOW   0
+#define GEN6_SURFACE_MIPMAPLAYOUT_RIGHT   1
+
+#define GEN6_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
+#define GEN6_SURFACEFORMAT_R32G32B32A32_SINT              0x001
+#define GEN6_SURFACEFORMAT_R32G32B32A32_UINT              0x002
+#define GEN6_SURFACEFORMAT_R32G32B32A32_UNORM             0x003
+#define GEN6_SURFACEFORMAT_R32G32B32A32_SNORM             0x004
+#define GEN6_SURFACEFORMAT_R64G64_FLOAT                   0x005
+#define GEN6_SURFACEFORMAT_R32G32B32X32_FLOAT             0x006
+#define GEN6_SURFACEFORMAT_R32G32B32A32_SSCALED           0x007
+#define GEN6_SURFACEFORMAT_R32G32B32A32_USCALED           0x008
+#define GEN6_SURFACEFORMAT_R32G32B32_FLOAT                0x040
+#define GEN6_SURFACEFORMAT_R32G32B32_SINT                 0x041
+#define GEN6_SURFACEFORMAT_R32G32B32_UINT                 0x042
+#define GEN6_SURFACEFORMAT_R32G32B32_UNORM                0x043
+#define GEN6_SURFACEFORMAT_R32G32B32_SNORM                0x044
+#define GEN6_SURFACEFORMAT_R32G32B32_SSCALED              0x045
+#define GEN6_SURFACEFORMAT_R32G32B32_USCALED              0x046
+#define GEN6_SURFACEFORMAT_R16G16B16A16_UNORM             0x080
+#define GEN6_SURFACEFORMAT_R16G16B16A16_SNORM             0x081
+#define GEN6_SURFACEFORMAT_R16G16B16A16_SINT              0x082
+#define GEN6_SURFACEFORMAT_R16G16B16A16_UINT              0x083
+#define GEN6_SURFACEFORMAT_R16G16B16A16_FLOAT             0x084
+#define GEN6_SURFACEFORMAT_R32G32_FLOAT                   0x085
+#define GEN6_SURFACEFORMAT_R32G32_SINT                    0x086
+#define GEN6_SURFACEFORMAT_R32G32_UINT                    0x087
+#define GEN6_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS       0x088
+#define GEN6_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT        0x089
+#define GEN6_SURFACEFORMAT_L32A32_FLOAT                   0x08A
+#define GEN6_SURFACEFORMAT_R32G32_UNORM                   0x08B
+#define GEN6_SURFACEFORMAT_R32G32_SNORM                   0x08C
+#define GEN6_SURFACEFORMAT_R64_FLOAT                      0x08D
+#define GEN6_SURFACEFORMAT_R16G16B16X16_UNORM             0x08E
+#define GEN6_SURFACEFORMAT_R16G16B16X16_FLOAT             0x08F
+#define GEN6_SURFACEFORMAT_A32X32_FLOAT                   0x090
+#define GEN6_SURFACEFORMAT_L32X32_FLOAT                   0x091
+#define GEN6_SURFACEFORMAT_I32X32_FLOAT                   0x092
+#define GEN6_SURFACEFORMAT_R16G16B16A16_SSCALED           0x093
+#define GEN6_SURFACEFORMAT_R16G16B16A16_USCALED           0x094
+#define GEN6_SURFACEFORMAT_R32G32_SSCALED                 0x095
+#define GEN6_SURFACEFORMAT_R32G32_USCALED                 0x096
+#define GEN6_SURFACEFORMAT_B8G8R8A8_UNORM                 0x0C0
+#define GEN6_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB            0x0C1
+#define GEN6_SURFACEFORMAT_R10G10B10A2_UNORM              0x0C2
+#define GEN6_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB         0x0C3
+#define GEN6_SURFACEFORMAT_R10G10B10A2_UINT               0x0C4
+#define GEN6_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM       0x0C5
+#define GEN6_SURFACEFORMAT_R8G8B8A8_UNORM                 0x0C7
+#define GEN6_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB            0x0C8
+#define GEN6_SURFACEFORMAT_R8G8B8A8_SNORM                 0x0C9
+#define GEN6_SURFACEFORMAT_R8G8B8A8_SINT                  0x0CA
+#define GEN6_SURFACEFORMAT_R8G8B8A8_UINT                  0x0CB
+#define GEN6_SURFACEFORMAT_R16G16_UNORM                   0x0CC
+#define GEN6_SURFACEFORMAT_R16G16_SNORM                   0x0CD
+#define GEN6_SURFACEFORMAT_R16G16_SINT                    0x0CE
+#define GEN6_SURFACEFORMAT_R16G16_UINT                    0x0CF
+#define GEN6_SURFACEFORMAT_R16G16_FLOAT                   0x0D0
+#define GEN6_SURFACEFORMAT_B10G10R10A2_UNORM              0x0D1
+#define GEN6_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB         0x0D2
+#define GEN6_SURFACEFORMAT_R11G11B10_FLOAT                0x0D3
+#define GEN6_SURFACEFORMAT_R32_SINT                       0x0D6
+#define GEN6_SURFACEFORMAT_R32_UINT                       0x0D7
+#define GEN6_SURFACEFORMAT_R32_FLOAT                      0x0D8
+#define GEN6_SURFACEFORMAT_R24_UNORM_X8_TYPELESS          0x0D9
+#define GEN6_SURFACEFORMAT_X24_TYPELESS_G8_UINT           0x0DA
+#define GEN6_SURFACEFORMAT_L16A16_UNORM                   0x0DF
+#define GEN6_SURFACEFORMAT_I24X8_UNORM                    0x0E0
+#define GEN6_SURFACEFORMAT_L24X8_UNORM                    0x0E1
+#define GEN6_SURFACEFORMAT_A24X8_UNORM                    0x0E2
+#define GEN6_SURFACEFORMAT_I32_FLOAT                      0x0E3
+#define GEN6_SURFACEFORMAT_L32_FLOAT                      0x0E4
+#define GEN6_SURFACEFORMAT_A32_FLOAT                      0x0E5
+#define GEN6_SURFACEFORMAT_B8G8R8X8_UNORM                 0x0E9
+#define GEN6_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB            0x0EA
+#define GEN6_SURFACEFORMAT_R8G8B8X8_UNORM                 0x0EB
+#define GEN6_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB            0x0EC
+#define GEN6_SURFACEFORMAT_R9G9B9E5_SHAREDEXP             0x0ED
+#define GEN6_SURFACEFORMAT_B10G10R10X2_UNORM              0x0EE
+#define GEN6_SURFACEFORMAT_L16A16_FLOAT                   0x0F0
+#define GEN6_SURFACEFORMAT_R32_UNORM                      0x0F1
+#define GEN6_SURFACEFORMAT_R32_SNORM                      0x0F2
+#define GEN6_SURFACEFORMAT_R10G10B10X2_USCALED            0x0F3
+#define GEN6_SURFACEFORMAT_R8G8B8A8_SSCALED               0x0F4
+#define GEN6_SURFACEFORMAT_R8G8B8A8_USCALED               0x0F5
+#define GEN6_SURFACEFORMAT_R16G16_SSCALED                 0x0F6
+#define GEN6_SURFACEFORMAT_R16G16_USCALED                 0x0F7
+#define GEN6_SURFACEFORMAT_R32_SSCALED                    0x0F8
+#define GEN6_SURFACEFORMAT_R32_USCALED                    0x0F9
+#define GEN6_SURFACEFORMAT_B5G6R5_UNORM                   0x100
+#define GEN6_SURFACEFORMAT_B5G6R5_UNORM_SRGB              0x101
+#define GEN6_SURFACEFORMAT_B5G5R5A1_UNORM                 0x102
+#define GEN6_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB            0x103
+#define GEN6_SURFACEFORMAT_B4G4R4A4_UNORM                 0x104
+#define GEN6_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB            0x105
+#define GEN6_SURFACEFORMAT_R8G8_UNORM                     0x106
+#define GEN6_SURFACEFORMAT_R8G8_SNORM                     0x107
+#define GEN6_SURFACEFORMAT_R8G8_SINT                      0x108
+#define GEN6_SURFACEFORMAT_R8G8_UINT                      0x109
+#define GEN6_SURFACEFORMAT_R16_UNORM                      0x10A
+#define GEN6_SURFACEFORMAT_R16_SNORM                      0x10B
+#define GEN6_SURFACEFORMAT_R16_SINT                       0x10C
+#define GEN6_SURFACEFORMAT_R16_UINT                       0x10D
+#define GEN6_SURFACEFORMAT_R16_FLOAT                      0x10E
+#define GEN6_SURFACEFORMAT_I16_UNORM                      0x111
+#define GEN6_SURFACEFORMAT_L16_UNORM                      0x112
+#define GEN6_SURFACEFORMAT_A16_UNORM                      0x113
+#define GEN6_SURFACEFORMAT_L8A8_UNORM                     0x114
+#define GEN6_SURFACEFORMAT_I16_FLOAT                      0x115
+#define GEN6_SURFACEFORMAT_L16_FLOAT                      0x116
+#define GEN6_SURFACEFORMAT_A16_FLOAT                      0x117
+#define GEN6_SURFACEFORMAT_R5G5_SNORM_B6_UNORM            0x119
+#define GEN6_SURFACEFORMAT_B5G5R5X1_UNORM                 0x11A
+#define GEN6_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB            0x11B
+#define GEN6_SURFACEFORMAT_R8G8_SSCALED                   0x11C
+#define GEN6_SURFACEFORMAT_R8G8_USCALED                   0x11D
+#define GEN6_SURFACEFORMAT_R16_SSCALED                    0x11E
+#define GEN6_SURFACEFORMAT_R16_USCALED                    0x11F
+#define GEN6_SURFACEFORMAT_R8_UNORM                       0x140
+#define GEN6_SURFACEFORMAT_R8_SNORM                       0x141
+#define GEN6_SURFACEFORMAT_R8_SINT                        0x142
+#define GEN6_SURFACEFORMAT_R8_UINT                        0x143
+#define GEN6_SURFACEFORMAT_A8_UNORM                       0x144
+#define GEN6_SURFACEFORMAT_I8_UNORM                       0x145
+#define GEN6_SURFACEFORMAT_L8_UNORM                       0x146
+#define GEN6_SURFACEFORMAT_P4A4_UNORM                     0x147
+#define GEN6_SURFACEFORMAT_A4P4_UNORM                     0x148
+#define GEN6_SURFACEFORMAT_R8_SSCALED                     0x149
+#define GEN6_SURFACEFORMAT_R8_USCALED                     0x14A
+#define GEN6_SURFACEFORMAT_R1_UINT                        0x181
+#define GEN6_SURFACEFORMAT_YCRCB_NORMAL                   0x182
+#define GEN6_SURFACEFORMAT_YCRCB_SWAPUVY                  0x183
+#define GEN6_SURFACEFORMAT_BC1_UNORM                      0x186
+#define GEN6_SURFACEFORMAT_BC2_UNORM                      0x187
+#define GEN6_SURFACEFORMAT_BC3_UNORM                      0x188
+#define GEN6_SURFACEFORMAT_BC4_UNORM                      0x189
+#define GEN6_SURFACEFORMAT_BC5_UNORM                      0x18A
+#define GEN6_SURFACEFORMAT_BC1_UNORM_SRGB                 0x18B
+#define GEN6_SURFACEFORMAT_BC2_UNORM_SRGB                 0x18C
+#define GEN6_SURFACEFORMAT_BC3_UNORM_SRGB                 0x18D
+#define GEN6_SURFACEFORMAT_MONO8                          0x18E
+#define GEN6_SURFACEFORMAT_YCRCB_SWAPUV                   0x18F
+#define GEN6_SURFACEFORMAT_YCRCB_SWAPY                    0x190
+#define GEN6_SURFACEFORMAT_DXT1_RGB                       0x191
+#define GEN6_SURFACEFORMAT_FXT1                           0x192
+#define GEN6_SURFACEFORMAT_R8G8B8_UNORM                   0x193
+#define GEN6_SURFACEFORMAT_R8G8B8_SNORM                   0x194
+#define GEN6_SURFACEFORMAT_R8G8B8_SSCALED                 0x195
+#define GEN6_SURFACEFORMAT_R8G8B8_USCALED                 0x196
+#define GEN6_SURFACEFORMAT_R64G64B64A64_FLOAT             0x197
+#define GEN6_SURFACEFORMAT_R64G64B64_FLOAT                0x198
+#define GEN6_SURFACEFORMAT_BC4_SNORM                      0x199
+#define GEN6_SURFACEFORMAT_BC5_SNORM                      0x19A
+#define GEN6_SURFACEFORMAT_R16G16B16_UNORM                0x19C
+#define GEN6_SURFACEFORMAT_R16G16B16_SNORM                0x19D
+#define GEN6_SURFACEFORMAT_R16G16B16_SSCALED              0x19E
+#define GEN6_SURFACEFORMAT_R16G16B16_USCALED              0x19F
+
+#define GEN6_SURFACERETURNFORMAT_FLOAT32  0
+#define GEN6_SURFACERETURNFORMAT_S1       1
+
+#define GEN6_SURFACE_1D      0
+#define GEN6_SURFACE_2D      1
+#define GEN6_SURFACE_3D      2
+#define GEN6_SURFACE_CUBE    3
+#define GEN6_SURFACE_BUFFER  4
+#define GEN6_SURFACE_NULL    7
+
+#define GEN6_BORDER_COLOR_MODE_DEFAULT	0
+#define GEN6_BORDER_COLOR_MODE_LEGACY	1
+
+#define GEN6_TEXCOORDMODE_WRAP            0
+#define GEN6_TEXCOORDMODE_MIRROR          1
+#define GEN6_TEXCOORDMODE_CLAMP           2
+#define GEN6_TEXCOORDMODE_CUBE            3
+#define GEN6_TEXCOORDMODE_CLAMP_BORDER    4
+#define GEN6_TEXCOORDMODE_MIRROR_ONCE     5
+
+#define GEN6_THREAD_PRIORITY_NORMAL   0
+#define GEN6_THREAD_PRIORITY_HIGH     1
+
+#define GEN6_TILEWALK_XMAJOR                 0
+#define GEN6_TILEWALK_YMAJOR                 1
+
+#define GEN6_VERTEX_SUBPIXEL_PRECISION_8BITS  0
+#define GEN6_VERTEX_SUBPIXEL_PRECISION_4BITS  1
+
+#define GEN6_VERTEXBUFFER_ACCESS_VERTEXDATA     0
+#define GEN6_VERTEXBUFFER_ACCESS_INSTANCEDATA   1
+
+#define GEN6_VFCOMPONENT_NOSTORE      0
+#define GEN6_VFCOMPONENT_STORE_SRC    1
+#define GEN6_VFCOMPONENT_STORE_0      2
+#define GEN6_VFCOMPONENT_STORE_1_FLT  3
+#define GEN6_VFCOMPONENT_STORE_1_INT  4
+#define GEN6_VFCOMPONENT_STORE_VID    5
+#define GEN6_VFCOMPONENT_STORE_IID    6
+#define GEN6_VFCOMPONENT_STORE_PID    7
+
+
+
+/* Execution Unit (EU) defines
+ */
+
+#define GEN6_ALIGN_1   0
+#define GEN6_ALIGN_16  1
+
+#define GEN6_ADDRESS_DIRECT                        0
+#define GEN6_ADDRESS_REGISTER_INDIRECT_REGISTER    1
+
+#define GEN6_CHANNEL_X     0
+#define GEN6_CHANNEL_Y     1
+#define GEN6_CHANNEL_Z     2
+#define GEN6_CHANNEL_W     3
+
+#define GEN6_COMPRESSION_NONE          0
+#define GEN6_COMPRESSION_2NDHALF       1
+#define GEN6_COMPRESSION_COMPRESSED    2
+
+#define GEN6_CONDITIONAL_NONE  0
+#define GEN6_CONDITIONAL_Z     1
+#define GEN6_CONDITIONAL_NZ    2
+#define GEN6_CONDITIONAL_EQ    1	/* Z */
+#define GEN6_CONDITIONAL_NEQ   2	/* NZ */
+#define GEN6_CONDITIONAL_G     3
+#define GEN6_CONDITIONAL_GE    4
+#define GEN6_CONDITIONAL_L     5
+#define GEN6_CONDITIONAL_LE    6
+#define GEN6_CONDITIONAL_C     7
+#define GEN6_CONDITIONAL_O     8
+
+#define GEN6_DEBUG_NONE        0
+#define GEN6_DEBUG_BREAKPOINT  1
+
+#define GEN6_DEPENDENCY_NORMAL         0
+#define GEN6_DEPENDENCY_NOTCLEARED     1
+#define GEN6_DEPENDENCY_NOTCHECKED     2
+#define GEN6_DEPENDENCY_DISABLE        3
+
+#define GEN6_EXECUTE_1     0
+#define GEN6_EXECUTE_2     1
+#define GEN6_EXECUTE_4     2
+#define GEN6_EXECUTE_8     3
+#define GEN6_EXECUTE_16    4
+#define GEN6_EXECUTE_32    5
+
+#define GEN6_HORIZONTAL_STRIDE_0   0
+#define GEN6_HORIZONTAL_STRIDE_1   1
+#define GEN6_HORIZONTAL_STRIDE_2   2
+#define GEN6_HORIZONTAL_STRIDE_4   3
+
+#define GEN6_INSTRUCTION_NORMAL    0
+#define GEN6_INSTRUCTION_SATURATE  1
+
+#define GEN6_MASK_ENABLE   0
+#define GEN6_MASK_DISABLE  1
+
+#define GEN6_OPCODE_MOV        1
+#define GEN6_OPCODE_SEL        2
+#define GEN6_OPCODE_NOT        4
+#define GEN6_OPCODE_AND        5
+#define GEN6_OPCODE_OR         6
+#define GEN6_OPCODE_XOR        7
+#define GEN6_OPCODE_SHR        8
+#define GEN6_OPCODE_SHL        9
+#define GEN6_OPCODE_RSR        10
+#define GEN6_OPCODE_RSL        11
+#define GEN6_OPCODE_ASR        12
+#define GEN6_OPCODE_CMP        16
+#define GEN6_OPCODE_JMPI       32
+#define GEN6_OPCODE_IF         34
+#define GEN6_OPCODE_IFF        35
+#define GEN6_OPCODE_ELSE       36
+#define GEN6_OPCODE_ENDIF      37
+#define GEN6_OPCODE_DO         38
+#define GEN6_OPCODE_WHILE      39
+#define GEN6_OPCODE_BREAK      40
+#define GEN6_OPCODE_CONTINUE   41
+#define GEN6_OPCODE_HALT       42
+#define GEN6_OPCODE_MSAVE      44
+#define GEN6_OPCODE_MRESTORE   45
+#define GEN6_OPCODE_PUSH       46
+#define GEN6_OPCODE_POP        47
+#define GEN6_OPCODE_WAIT       48
+#define GEN6_OPCODE_SEND       49
+#define GEN6_OPCODE_ADD        64
+#define GEN6_OPCODE_MUL        65
+#define GEN6_OPCODE_AVG        66
+#define GEN6_OPCODE_FRC        67
+#define GEN6_OPCODE_RNDU       68
+#define GEN6_OPCODE_RNDD       69
+#define GEN6_OPCODE_RNDE       70
+#define GEN6_OPCODE_RNDZ       71
+#define GEN6_OPCODE_MAC        72
+#define GEN6_OPCODE_MACH       73
+#define GEN6_OPCODE_LZD        74
+#define GEN6_OPCODE_SAD2       80
+#define GEN6_OPCODE_SADA2      81
+#define GEN6_OPCODE_DP4        84
+#define GEN6_OPCODE_DPH        85
+#define GEN6_OPCODE_DP3        86
+#define GEN6_OPCODE_DP2        87
+#define GEN6_OPCODE_DPA2       88
+#define GEN6_OPCODE_LINE       89
+#define GEN6_OPCODE_NOP        126
+
+#define GEN6_PREDICATE_NONE             0
+#define GEN6_PREDICATE_NORMAL           1
+#define GEN6_PREDICATE_ALIGN1_ANYV             2
+#define GEN6_PREDICATE_ALIGN1_ALLV             3
+#define GEN6_PREDICATE_ALIGN1_ANY2H            4
+#define GEN6_PREDICATE_ALIGN1_ALL2H            5
+#define GEN6_PREDICATE_ALIGN1_ANY4H            6
+#define GEN6_PREDICATE_ALIGN1_ALL4H            7
+#define GEN6_PREDICATE_ALIGN1_ANY8H            8
+#define GEN6_PREDICATE_ALIGN1_ALL8H            9
+#define GEN6_PREDICATE_ALIGN1_ANY16H           10
+#define GEN6_PREDICATE_ALIGN1_ALL16H           11
+#define GEN6_PREDICATE_ALIGN16_REPLICATE_X     2
+#define GEN6_PREDICATE_ALIGN16_REPLICATE_Y     3
+#define GEN6_PREDICATE_ALIGN16_REPLICATE_Z     4
+#define GEN6_PREDICATE_ALIGN16_REPLICATE_W     5
+#define GEN6_PREDICATE_ALIGN16_ANY4H           6
+#define GEN6_PREDICATE_ALIGN16_ALL4H           7
+
+#define GEN6_ARCHITECTURE_REGISTER_FILE    0
+#define GEN6_GENERAL_REGISTER_FILE         1
+#define GEN6_MESSAGE_REGISTER_FILE         2
+#define GEN6_IMMEDIATE_VALUE               3
+
+#define GEN6_REGISTER_TYPE_UD  0
+#define GEN6_REGISTER_TYPE_D   1
+#define GEN6_REGISTER_TYPE_UW  2
+#define GEN6_REGISTER_TYPE_W   3
+#define GEN6_REGISTER_TYPE_UB  4
+#define GEN6_REGISTER_TYPE_B   5
+#define GEN6_REGISTER_TYPE_VF  5	/* packed float vector, immediates only? */
+#define GEN6_REGISTER_TYPE_HF  6
+#define GEN6_REGISTER_TYPE_V   6	/* packed int vector, immediates only, uword dest only */
+#define GEN6_REGISTER_TYPE_F   7
+
+#define GEN6_ARF_NULL                  0x00
+#define GEN6_ARF_ADDRESS               0x10
+#define GEN6_ARF_ACCUMULATOR           0x20   
+#define GEN6_ARF_FLAG                  0x30
+#define GEN6_ARF_MASK                  0x40
+#define GEN6_ARF_MASK_STACK            0x50
+#define GEN6_ARF_MASK_STACK_DEPTH      0x60
+#define GEN6_ARF_STATE                 0x70
+#define GEN6_ARF_CONTROL               0x80
+#define GEN6_ARF_NOTIFICATION_COUNT    0x90
+#define GEN6_ARF_IP                    0xA0
+
+#define GEN6_AMASK   0
+#define GEN6_IMASK   1
+#define GEN6_LMASK   2
+#define GEN6_CMASK   3
+
+
+
+#define GEN6_THREAD_NORMAL     0
+#define GEN6_THREAD_ATOMIC     1
+#define GEN6_THREAD_SWITCH     2
+
+#define GEN6_VERTICAL_STRIDE_0                 0
+#define GEN6_VERTICAL_STRIDE_1                 1
+#define GEN6_VERTICAL_STRIDE_2                 2
+#define GEN6_VERTICAL_STRIDE_4                 3
+#define GEN6_VERTICAL_STRIDE_8                 4
+#define GEN6_VERTICAL_STRIDE_16                5
+#define GEN6_VERTICAL_STRIDE_32                6
+#define GEN6_VERTICAL_STRIDE_64                7
+#define GEN6_VERTICAL_STRIDE_128               8
+#define GEN6_VERTICAL_STRIDE_256               9
+#define GEN6_VERTICAL_STRIDE_ONE_DIMENSIONAL   0xF
+
+#define GEN6_WIDTH_1       0
+#define GEN6_WIDTH_2       1
+#define GEN6_WIDTH_4       2
+#define GEN6_WIDTH_8       3
+#define GEN6_WIDTH_16      4
+
+#define GEN6_STATELESS_BUFFER_BOUNDARY_1K      0
+#define GEN6_STATELESS_BUFFER_BOUNDARY_2K      1
+#define GEN6_STATELESS_BUFFER_BOUNDARY_4K      2
+#define GEN6_STATELESS_BUFFER_BOUNDARY_8K      3
+#define GEN6_STATELESS_BUFFER_BOUNDARY_16K     4
+#define GEN6_STATELESS_BUFFER_BOUNDARY_32K     5
+#define GEN6_STATELESS_BUFFER_BOUNDARY_64K     6
+#define GEN6_STATELESS_BUFFER_BOUNDARY_128K    7
+#define GEN6_STATELESS_BUFFER_BOUNDARY_256K    8
+#define GEN6_STATELESS_BUFFER_BOUNDARY_512K    9
+#define GEN6_STATELESS_BUFFER_BOUNDARY_1M      10
+#define GEN6_STATELESS_BUFFER_BOUNDARY_2M      11
+
+#define GEN6_POLYGON_FACING_FRONT      0
+#define GEN6_POLYGON_FACING_BACK       1
+
+#define GEN6_MESSAGE_TARGET_NULL               0
+#define GEN6_MESSAGE_TARGET_MATH               1
+#define GEN6_MESSAGE_TARGET_SAMPLER            2
+#define GEN6_MESSAGE_TARGET_GATEWAY            3
+#define GEN6_MESSAGE_TARGET_DATAPORT_READ      4
+#define GEN6_MESSAGE_TARGET_DATAPORT_WRITE     5
+#define GEN6_MESSAGE_TARGET_URB                6
+#define GEN6_MESSAGE_TARGET_THREAD_SPAWNER     7
+
+#define GEN6_SAMPLER_RETURN_FORMAT_FLOAT32     0
+#define GEN6_SAMPLER_RETURN_FORMAT_UINT32      2
+#define GEN6_SAMPLER_RETURN_FORMAT_SINT32      3
+
+#define GEN6_SAMPLER_MESSAGE_SIMD8_SAMPLE              0
+#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE             0
+#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS        0
+#define GEN6_SAMPLER_MESSAGE_SIMD8_KILLPIX             1
+#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD        1
+#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD         1
+#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS  2
+#define GEN6_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS    2
+#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE    0
+#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE     2
+#define GEN6_SAMPLER_MESSAGE_SIMD4X2_RESINFO           2
+#define GEN6_SAMPLER_MESSAGE_SIMD8_RESINFO             2
+#define GEN6_SAMPLER_MESSAGE_SIMD16_RESINFO            2
+#define GEN6_SAMPLER_MESSAGE_SIMD4X2_LD                3
+#define GEN6_SAMPLER_MESSAGE_SIMD8_LD                  3
+#define GEN6_SAMPLER_MESSAGE_SIMD16_LD                 3
+
+#define GEN6_DATAPORT_OWORD_BLOCK_1_OWORDLOW   0
+#define GEN6_DATAPORT_OWORD_BLOCK_1_OWORDHIGH  1
+#define GEN6_DATAPORT_OWORD_BLOCK_2_OWORDS     2
+#define GEN6_DATAPORT_OWORD_BLOCK_4_OWORDS     3
+#define GEN6_DATAPORT_OWORD_BLOCK_8_OWORDS     4
+
+#define GEN6_DATAPORT_OWORD_DUAL_BLOCK_1OWORD     0
+#define GEN6_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS    2
+
+#define GEN6_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS   2
+#define GEN6_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS  3
+
+#define GEN6_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ          0
+#define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     1
+#define GEN6_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ          2
+#define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      3
+
+#define GEN6_DATAPORT_READ_TARGET_DATA_CACHE      0
+#define GEN6_DATAPORT_READ_TARGET_RENDER_CACHE    1
+#define GEN6_DATAPORT_READ_TARGET_SAMPLER_CACHE   2
+
+#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE                0
+#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED     1
+#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01         2
+#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23         3
+#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01       4
+
+#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE                0
+#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE           1
+#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE                2
+#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE            3
+#define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE              4
+#define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE     5
+#define GEN6_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE               7
+
+#define GEN6_MATH_FUNCTION_INV                              1
+#define GEN6_MATH_FUNCTION_LOG                              2
+#define GEN6_MATH_FUNCTION_EXP                              3
+#define GEN6_MATH_FUNCTION_SQRT                             4
+#define GEN6_MATH_FUNCTION_RSQ                              5
+#define GEN6_MATH_FUNCTION_SIN                              6 /* was 7 */
+#define GEN6_MATH_FUNCTION_COS                              7 /* was 8 */
+#define GEN6_MATH_FUNCTION_SINCOS                           8 /* was 6 */
+#define GEN6_MATH_FUNCTION_TAN                              9
+#define GEN6_MATH_FUNCTION_POW                              10
+#define GEN6_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER   11
+#define GEN6_MATH_FUNCTION_INT_DIV_QUOTIENT                 12
+#define GEN6_MATH_FUNCTION_INT_DIV_REMAINDER                13
+
+#define GEN6_MATH_INTEGER_UNSIGNED     0
+#define GEN6_MATH_INTEGER_SIGNED       1
+
+#define GEN6_MATH_PRECISION_FULL        0
+#define GEN6_MATH_PRECISION_PARTIAL     1
+
+#define GEN6_MATH_SATURATE_NONE         0
+#define GEN6_MATH_SATURATE_SATURATE     1
+
+#define GEN6_MATH_DATA_VECTOR  0
+#define GEN6_MATH_DATA_SCALAR  1
+
+#define GEN6_URB_OPCODE_WRITE  0
+
+#define GEN6_URB_SWIZZLE_NONE          0
+#define GEN6_URB_SWIZZLE_INTERLEAVE    1
+#define GEN6_URB_SWIZZLE_TRANSPOSE     2
+
+#define GEN6_SCRATCH_SPACE_SIZE_1K     0
+#define GEN6_SCRATCH_SPACE_SIZE_2K     1
+#define GEN6_SCRATCH_SPACE_SIZE_4K     2
+#define GEN6_SCRATCH_SPACE_SIZE_8K     3
+#define GEN6_SCRATCH_SPACE_SIZE_16K    4
+#define GEN6_SCRATCH_SPACE_SIZE_32K    5
+#define GEN6_SCRATCH_SPACE_SIZE_64K    6
+#define GEN6_SCRATCH_SPACE_SIZE_128K   7
+#define GEN6_SCRATCH_SPACE_SIZE_256K   8
+#define GEN6_SCRATCH_SPACE_SIZE_512K   9
+#define GEN6_SCRATCH_SPACE_SIZE_1M     10
+#define GEN6_SCRATCH_SPACE_SIZE_2M     11
+
+/* The hardware supports two different modes for border color. The
+ * default (OpenGL) mode uses floating-point color channels, while the
+ * legacy mode uses 4 bytes.
+ *
+ * More significantly, the legacy mode respects the components of the
+ * border color for channels not present in the source, (whereas the
+ * default mode will ignore the border color's alpha channel and use
+ * alpha==1 for an RGB source, for example).
+ *
+ * The legacy mode matches the semantics specified by the Render
+ * extension.
+ */
+struct gen6_sampler_default_border_color {
+   float color[4];
+};
+
+struct gen6_sampler_legacy_border_color {
+   uint8_t color[4];
+};
+
+struct gen6_sampler_state {
+   struct {
+      uint32_t shadow_function:3;
+      uint32_t lod_bias:11;
+      uint32_t min_filter:3;
+      uint32_t mag_filter:3;
+      uint32_t mip_filter:2;
+      uint32_t base_level:5;
+      uint32_t pad:1;
+      uint32_t lod_preclamp:1;
+      uint32_t border_color_mode:1;
+      uint32_t pad0:1;
+      uint32_t disable:1;
+   } ss0;
+
+   struct {
+      uint32_t r_wrap_mode:3;
+      uint32_t t_wrap_mode:3;
+      uint32_t s_wrap_mode:3;
+      uint32_t pad:3;
+      uint32_t max_lod:10;
+      uint32_t min_lod:10;
+   } ss1;
+
+   struct {
+      uint32_t border_color;
+   } ss2;
+
+   struct {
+      uint32_t pad:19;
+      uint32_t max_aniso:3;
+      uint32_t chroma_key_mode:1;
+      uint32_t chroma_key_index:2;
+      uint32_t chroma_key_enable:1;
+      uint32_t monochrome_filter_width:3;
+      uint32_t monochrome_filter_height:3;
+   } ss3;
+};
+
+struct gen6_blend_state {
+	struct {
+		uint32_t dest_blend_factor:5;
+		uint32_t source_blend_factor:5;
+		uint32_t pad3:1;
+		uint32_t blend_func:3;
+		uint32_t pad2:1;
+		uint32_t ia_dest_blend_factor:5;
+		uint32_t ia_source_blend_factor:5;
+		uint32_t pad1:1;
+		uint32_t ia_blend_func:3;
+		uint32_t pad0:1;
+		uint32_t ia_blend_enable:1;
+		uint32_t blend_enable:1;
+	} blend0;
+
+	struct {
+		uint32_t post_blend_clamp_enable:1;
+		uint32_t pre_blend_clamp_enable:1;
+		uint32_t clamp_range:2;
+		uint32_t pad0:4;
+		uint32_t x_dither_offset:2;
+		uint32_t y_dither_offset:2;
+		uint32_t dither_enable:1;
+		uint32_t alpha_test_func:3;
+		uint32_t alpha_test_enable:1;
+		uint32_t pad1:1;
+		uint32_t logic_op_func:4;
+		uint32_t logic_op_enable:1;
+		uint32_t pad2:1;
+		uint32_t write_disable_b:1;
+		uint32_t write_disable_g:1;
+		uint32_t write_disable_r:1;
+		uint32_t write_disable_a:1;
+		uint32_t pad3:1;
+		uint32_t alpha_to_coverage_dither:1;
+		uint32_t alpha_to_one:1;
+		uint32_t alpha_to_coverage:1;
+	} blend1;
+};
+
+struct gen6_color_calc_state {
+	struct {
+		uint32_t alpha_test_format:1;
+		uint32_t pad0:14;
+		uint32_t round_disable:1;
+		uint32_t bf_stencil_ref:8;
+		uint32_t stencil_ref:8;
+	} cc0;
+
+	union {
+		float alpha_ref_f;
+		struct {
+			uint32_t ui:8;
+			uint32_t pad0:24;
+		} alpha_ref_fi;
+	} cc1;
+
+	float constant_r;
+	float constant_g;
+	float constant_b;
+	float constant_a;
+};
+
+struct gen6_depth_stencil_state {
+	struct {
+		uint32_t pad0:3;
+		uint32_t bf_stencil_pass_depth_pass_op:3;
+		uint32_t bf_stencil_pass_depth_fail_op:3;
+		uint32_t bf_stencil_fail_op:3;
+		uint32_t bf_stencil_func:3;
+		uint32_t bf_stencil_enable:1;
+		uint32_t pad1:2;
+		uint32_t stencil_write_enable:1;
+		uint32_t stencil_pass_depth_pass_op:3;
+		uint32_t stencil_pass_depth_fail_op:3;
+		uint32_t stencil_fail_op:3;
+		uint32_t stencil_func:3;
+		uint32_t stencil_enable:1;
+	} ds0;
+
+	struct {
+		uint32_t bf_stencil_write_mask:8;
+		uint32_t bf_stencil_test_mask:8;
+		uint32_t stencil_write_mask:8;
+		uint32_t stencil_test_mask:8;
+	} ds1;
+
+	struct {
+		uint32_t pad0:26;
+		uint32_t depth_write_enable:1;
+		uint32_t depth_test_func:3;
+		uint32_t pad1:1;
+		uint32_t depth_test_enable:1;
+	} ds2;
+};
+
+struct gen6_surface_state {
+	struct {
+		uint32_t cube_pos_z:1;
+		uint32_t cube_neg_z:1;
+		uint32_t cube_pos_y:1;
+		uint32_t cube_neg_y:1;
+		uint32_t cube_pos_x:1;
+		uint32_t cube_neg_x:1;
+		uint32_t pad:3;
+		uint32_t render_cache_read_mode:1;
+		uint32_t mipmap_layout_mode:1;
+		uint32_t vert_line_stride_ofs:1;
+		uint32_t vert_line_stride:1;
+		uint32_t color_blend:1;
+		uint32_t writedisable_blue:1;
+		uint32_t writedisable_green:1;
+		uint32_t writedisable_red:1;
+		uint32_t writedisable_alpha:1;
+		uint32_t surface_format:9;
+		uint32_t data_return_format:1;
+		uint32_t pad0:1;
+		uint32_t surface_type:3;
+	} ss0;
+
+	struct {
+		uint32_t base_addr;
+	} ss1;
+
+	struct {
+		uint32_t render_target_rotation:2;
+		uint32_t mip_count:4;
+		uint32_t width:13;
+		uint32_t height:13;
+	} ss2;
+
+	struct {
+		uint32_t tile_walk:1;
+		uint32_t tiled_surface:1;
+		uint32_t pad:1;
+		uint32_t pitch:18;
+		uint32_t depth:11;
+	} ss3;
+
+	struct {
+		uint32_t pad:19;
+		uint32_t min_array_elt:9;
+		uint32_t min_lod:4;
+	} ss4;
+
+	struct {
+		uint32_t pad:20;
+		uint32_t y_offset:4;
+		uint32_t pad2:1;
+		uint32_t x_offset:7;
+	} ss5;
+};
+
+struct gen6_cc_viewport {
+	float min_depth;
+	float max_depth;
+};
+
+typedef enum {
+	SAMPLER_FILTER_NEAREST = 0,
+	SAMPLER_FILTER_BILINEAR,
+	FILTER_COUNT
+} sampler_filter_t;
+
+typedef enum {
+	SAMPLER_EXTEND_NONE = 0,
+	SAMPLER_EXTEND_REPEAT,
+	SAMPLER_EXTEND_PAD,
+	SAMPLER_EXTEND_REFLECT,
+	EXTEND_COUNT
+} sampler_extend_t;
+
+#endif
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index f2134bf..cd964bd 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -25,6 +25,9 @@
  *
  */
 
+#ifndef _IGT_H_
+#define _IGT_H_
+
 #include <stdint.h>
 #include <sys/types.h>
 #include <pciaccess.h>
@@ -93,3 +96,5 @@ extern enum pch_type pch;
 void intel_check_pch(void);
 
 #define HAS_CPT (pch == PCH_CPT)
+
+#endif
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 190d2d3..6fdc96f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,11 +6,6 @@ noinst_PROGRAMS = \
 
 gem_stress_SOURCES = \
 	gem_stress.c \
-	gem_stress.h \
-	gem_stress_i915.c \
-	gem_stress_i830.c \
-	gen6_render.h \
-	gem_stress_gen6.c \
 	$(NULL)
 
 TESTS_progs = \
diff --git a/tests/gem_stress.c b/tests/gem_stress.c
index 7f93964..8338705 100644
--- a/tests/gem_stress.c
+++ b/tests/gem_stress.c
@@ -297,22 +297,31 @@ static void render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned sr
 			    struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
 			    unsigned logical_tile_no)
 {
-	if (IS_GEN2(devid))
+
+	if (IS_GEN2(devid)) {
 		gen2_render_copyfunc(src, src_x, src_y,
 				     dst, dst_x, dst_y,
 				     logical_tile_no);
-	else if (IS_GEN3(devid))
+		intel_batchbuffer_flush(batch);
+	} else if (IS_GEN3(devid)) {
 		gen3_render_copyfunc(src, src_x, src_y,
 				     dst, dst_x, dst_y,
 				     logical_tile_no);
-	else if (IS_GEN6(devid))
-		gen6_render_copyfunc(src, src_x, src_y,
-				     dst, dst_x, dst_y,
-				     logical_tile_no);
-	else
+		intel_batchbuffer_flush(batch);
+	} else if (IS_GEN6(devid)) {
+		uint32_t ret;
+		intel_batchbuffer_flush(batch);
+		ret = gen6_render_copyfunc(src, src_x, src_y,
+					   dst, dst_x, dst_y,
+					   logical_tile_no);
+		gen6_render_flush(ret);
+		intel_batchbuffer_reset(batch);
+	} else {
 		blitter_copyfunc(src, src_x, src_y,
 				 dst, dst_x, dst_y,
 				 logical_tile_no);
+	}
+
 }
 
 static void next_copyfunc(int tile)
diff --git a/tests/gem_stress.h b/tests/gem_stress.h
deleted file mode 100644
index f44773d..0000000
--- a/tests/gem_stress.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <getopt.h>
-#include "drm.h"
-#include "i915_drm.h"
-#include "drmtest.h"
-#include "intel_bufmgr.h"
-#include "intel_batchbuffer.h"
-#include "intel_gpu_tools.h"
-
-struct scratch_buf {
-    drm_intel_bo *bo;
-    uint32_t stride;
-    uint32_t tiling;
-    uint32_t *data;
-    uint32_t *cpu_mapping;
-    unsigned num_tiles;
-};
-
-struct option_struct {
-    unsigned scratch_buf_size;
-    unsigned max_dimension;
-    unsigned num_buffers;
-    int trace_tile;
-    int no_hw;
-    int gpu_busy_load;
-    int use_render;
-    int use_blt;
-    int forced_tiling;
-    int use_cpu_maps;
-    int total_rounds;
-    int fail;
-    int tiles_per_buf;
-    int ducttape;
-    int tile_size;
-    int check_render_cpyfn;
-    int use_signal_helper;
-};
-
-extern struct option_struct options;
-extern drm_intel_bufmgr *bufmgr;
-extern struct intel_batchbuffer *batch;
-extern int drm_fd;
-extern int devid;
-
-extern int fence_storm;
-
-#define MAX_BUFS		4096
-#define SCRATCH_BUF_SIZE	1024*1024
-#define BUSY_BUF_SIZE		(256*4096)
-#define TILE_BYTES(size)	((size)*(size)*sizeof(uint32_t))
-
-void keep_gpu_busy(void);
-
-static inline void emit_vertex_2s(int16_t x, int16_t y)
-{
-	OUT_BATCH((uint16_t)y << 16 | (uint16_t)x);
-}
-
-static inline void emit_vertex(float f)
-{
-	union { float f; uint32_t ui; } u;
-	u.f = f;
-	OUT_BATCH(u.ui);
-}
-
-static inline void emit_vertex_normalized(float f, float total)
-{
-	union { float f; uint32_t ui; } u;
-	u.f = f / total;
-	OUT_BATCH(u.ui);
-}
-
-static inline unsigned buf_width(struct scratch_buf *buf)
-{
-	return buf->stride/sizeof(uint32_t);
-}
-
-static inline unsigned buf_height(struct scratch_buf *buf)
-{
-	return options.scratch_buf_size/buf->stride;
-}
-
-void gen6_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no);
-void gen3_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no);
-void gen2_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no);
diff --git a/tests/gem_stress_gen6.c b/tests/gem_stress_gen6.c
deleted file mode 100644
index 735c489..0000000
--- a/tests/gem_stress_gen6.c
+++ /dev/null
@@ -1,595 +0,0 @@
-#include "gem_stress.h"
-#include "gen6_render.h"
-
-#include <assert.h>
-
-#define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
-#define VERTEX_SIZE (3*4)
-
-static const uint32_t ps_kernel_nomask_affine[][4] = {
-	{ 0x0060005a, 0x204077be, 0x000000c0, 0x008d0040 },
-	{ 0x0060005a, 0x206077be, 0x000000c0, 0x008d0080 },
-	{ 0x0060005a, 0x208077be, 0x000000d0, 0x008d0040 },
-	{ 0x0060005a, 0x20a077be, 0x000000d0, 0x008d0080 },
-	{ 0x00000201, 0x20080061, 0x00000000, 0x00000000 },
-	{ 0x00600001, 0x20200022, 0x008d0000, 0x00000000 },
-	{ 0x02800031, 0x21c01cc9, 0x00000020, 0x0a8a0001 },
-	{ 0x00600001, 0x204003be, 0x008d01c0, 0x00000000 },
-	{ 0x00600001, 0x206003be, 0x008d01e0, 0x00000000 },
-	{ 0x00600001, 0x208003be, 0x008d0200, 0x00000000 },
-	{ 0x00600001, 0x20a003be, 0x008d0220, 0x00000000 },
-	{ 0x00600001, 0x20c003be, 0x008d0240, 0x00000000 },
-	{ 0x00600001, 0x20e003be, 0x008d0260, 0x00000000 },
-	{ 0x00600001, 0x210003be, 0x008d0280, 0x00000000 },
-	{ 0x00600001, 0x212003be, 0x008d02a0, 0x00000000 },
-	{ 0x05800031, 0x24001cc8, 0x00000040, 0x90019000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-	{ 0x0000007e, 0x00000000, 0x00000000, 0x00000000 },
-};
-
-static uint32_t
-batch_used(void)
-{
-	return batch->ptr - batch->buffer;
-}
-
-static uint32_t
-batch_align(uint32_t align)
-{
-	uint32_t offset = batch_used();
-	offset = ALIGN(offset, align);
-	batch->ptr = batch->buffer + offset;
-	return offset;
-}
-
-static uint32_t
-batch_round_upto(uint32_t divisor)
-{
-	uint32_t offset = batch_used();
-	offset = (offset + divisor-1) / divisor * divisor;
-	batch->ptr = batch->buffer + offset;
-	return offset;
-}
-
-static void *
-batch_alloc(uint32_t size, uint32_t align)
-{
-	uint32_t offset = batch_align(align);
-	batch->ptr += size;
-	return memset(batch->buffer + offset, 0, size);
-}
-
-static uint32_t
-batch_offset(void *ptr)
-{
-	return (uint8_t *)ptr - batch->buffer;
-}
-
-static uint32_t
-batch_copy(const void *ptr, uint32_t size, uint32_t align)
-{
-	return batch_offset(memcpy(batch_alloc(size, align), ptr, size));
-}
-
-static void
-gen6_render_flush(uint32_t batch_end)
-{
-	int ret;
-
-	ret = drm_intel_bo_subdata(batch->bo, 0, 4096, batch->buffer);
-	if (ret == 0)
-		ret = drm_intel_bo_mrb_exec(batch->bo, batch_end,
-					    NULL, 0, 0, 0);
-	assert(ret == 0);
-}
-
-static uint32_t
-gen6_bind_buf(struct scratch_buf *buf,
-	      uint32_t format, int is_dst)
-{
-	struct gen6_surface_state *ss;
-	uint32_t write_domain, read_domain;
-	int ret;
-
-	if (is_dst) {
-		write_domain = read_domain = I915_GEM_DOMAIN_RENDER;
-	} else {
-		write_domain = 0;
-		read_domain = I915_GEM_DOMAIN_SAMPLER;
-	}
-
-	ss = batch_alloc(sizeof(*ss), 32);
-	ss->ss0.surface_type = GEN6_SURFACE_2D;
-	ss->ss0.surface_format = format;
-
-	ss->ss0.data_return_format = GEN6_SURFACERETURNFORMAT_FLOAT32;
-	ss->ss0.color_blend = 1;
-	ss->ss1.base_addr = buf->bo->offset;
-
-	ret = drm_intel_bo_emit_reloc(batch->bo,
-				      batch_offset(ss) + 4,
-				      buf->bo, 0,
-				      read_domain, write_domain);
-	assert(ret == 0);
-
-	ss->ss2.height = buf_height(buf) - 1;
-	ss->ss2.width  = buf_width(buf) - 1;
-	ss->ss3.pitch  = buf->stride - 1;
-	ss->ss3.tiled_surface = buf->tiling != I915_TILING_NONE;
-	ss->ss3.tile_walk     = buf->tiling == I915_TILING_Y;
-
-	return batch_offset(ss);
-}
-
-static uint32_t
-gen6_bind_surfaces(struct scratch_buf *src,
-		   struct scratch_buf *dst)
-{
-	uint32_t *binding_table;
-
-	binding_table = batch_alloc(32, 32);
-
-	binding_table[0] =
-		gen6_bind_buf(dst, GEN6_SURFACEFORMAT_B8G8R8A8_UNORM, 1);
-	binding_table[1] =
-		gen6_bind_buf(src, GEN6_SURFACEFORMAT_B8G8R8A8_UNORM, 0);
-
-	return batch_offset(binding_table);
-}
-
-static void
-gen6_emit_sip(void)
-{
-	OUT_BATCH(GEN6_STATE_SIP | 0);
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_urb(void)
-{
-	OUT_BATCH(GEN6_3DSTATE_URB | (3 - 2));
-	OUT_BATCH((1 - 1) << GEN6_3DSTATE_URB_VS_SIZE_SHIFT |
-		  24 << GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT); /* at least 24 on GEN6 */
-	OUT_BATCH(0 << GEN6_3DSTATE_URB_GS_SIZE_SHIFT |
-		  0 << GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT); /* no GS thread */
-}
-
-static void
-gen6_emit_state_base_address(void)
-{
-	OUT_BATCH(GEN6_STATE_BASE_ADDRESS | (10 - 2));
-	OUT_BATCH(0); /* general */
-	OUT_RELOC(batch->bo, /* surface */
-		  I915_GEM_DOMAIN_INSTRUCTION, 0,
-		  BASE_ADDRESS_MODIFY);
-	OUT_RELOC(batch->bo, /* instruction */
-		  I915_GEM_DOMAIN_INSTRUCTION, 0,
-		  BASE_ADDRESS_MODIFY);
-	OUT_BATCH(0); /* indirect */
-	OUT_RELOC(batch->bo, /* dynamic */
-		  I915_GEM_DOMAIN_INSTRUCTION, 0,
-		  BASE_ADDRESS_MODIFY);
-
-	/* upper bounds, disable */
-	OUT_BATCH(0);
-	OUT_BATCH(BASE_ADDRESS_MODIFY);
-	OUT_BATCH(0);
-	OUT_BATCH(BASE_ADDRESS_MODIFY);
-}
-
-static void
-gen6_emit_viewports(uint32_t cc_vp)
-{
-	OUT_BATCH(GEN6_3DSTATE_VIEWPORT_STATE_POINTERS |
-		  GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC |
-		  (4 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(cc_vp);
-}
-
-static void
-gen6_emit_vs(void)
-{
-	/* disable VS constant buffer */
-	OUT_BATCH(GEN6_3DSTATE_CONSTANT_VS | (5 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-
-	OUT_BATCH(GEN6_3DSTATE_VS | (6 - 2));
-	OUT_BATCH(0); /* no VS kernel */
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* pass-through */
-}
-
-static void
-gen6_emit_gs(void)
-{
-	/* disable GS constant buffer */
-	OUT_BATCH(GEN6_3DSTATE_CONSTANT_GS | (5 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-
-	OUT_BATCH(GEN6_3DSTATE_GS | (7 - 2));
-	OUT_BATCH(0); /* no GS kernel */
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* pass-through */
-}
-
-static void
-gen6_emit_clip(void)
-{
-	OUT_BATCH(GEN6_3DSTATE_CLIP | (4 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* pass-through */
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_wm_constants(void)
-{
-	/* disable WM constant buffer */
-	OUT_BATCH(GEN6_3DSTATE_CONSTANT_PS | (5 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_null_depth_buffer(void)
-{
-	OUT_BATCH(GEN6_3DSTATE_DEPTH_BUFFER | (7 - 2));
-	OUT_BATCH(GEN6_SURFACE_NULL << GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT |
-		  GEN6_DEPTHFORMAT_D32_FLOAT << GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-
-	OUT_BATCH(GEN6_3DSTATE_CLEAR_PARAMS | (2 - 2));
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_invariant(void)
-{
-	OUT_BATCH(GEN6_PIPELINE_SELECT | PIPELINE_SELECT_3D);
-
-	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE | (3 - 2));
-	OUT_BATCH(GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER |
-		  GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1); /* 1 sample/pixel */
-	OUT_BATCH(0);
-
-	OUT_BATCH(GEN6_3DSTATE_SAMPLE_MASK | (2 - 2));
-	OUT_BATCH(1);
-}
-
-static void
-gen6_emit_cc(uint32_t blend)
-{
-	OUT_BATCH(GEN6_3DSTATE_CC_STATE_POINTERS | (4 - 2));
-	OUT_BATCH(blend | 1);
-	OUT_BATCH(1024 | 1);
-	OUT_BATCH(1024 | 1);
-}
-
-static void
-gen6_emit_sampler(uint32_t state)
-{
-	OUT_BATCH(GEN6_3DSTATE_SAMPLER_STATE_POINTERS |
-		  GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS |
-		  (4 - 2));
-	OUT_BATCH(0); /* VS */
-	OUT_BATCH(0); /* GS */
-	OUT_BATCH(state);
-}
-
-static void
-gen6_emit_sf(void)
-{
-	OUT_BATCH(GEN6_3DSTATE_SF | (20 - 2));
-	OUT_BATCH(1 << GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT |
-		  1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT |
-		  1 << GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT);
-	OUT_BATCH(0);
-	OUT_BATCH(GEN6_3DSTATE_SF_CULL_NONE);
-	OUT_BATCH(2 << GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT); /* DW4 */
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* DW9 */
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* DW14 */
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-	OUT_BATCH(0); /* DW19 */
-}
-
-static void
-gen6_emit_wm(int kernel)
-{
-	OUT_BATCH(GEN6_3DSTATE_WM | (9 - 2));
-	OUT_BATCH(kernel);
-	OUT_BATCH(1 << GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT |
-		  2 << GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT);
-	OUT_BATCH(0);
-	OUT_BATCH(6 << GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT); /* DW4 */
-	OUT_BATCH((40 - 1) << GEN6_3DSTATE_WM_MAX_THREADS_SHIFT |
-		  GEN6_3DSTATE_WM_DISPATCH_ENABLE |
-		  GEN6_3DSTATE_WM_16_DISPATCH_ENABLE);
-	OUT_BATCH(1 << GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT |
-		  GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC);
-	OUT_BATCH(0);
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_binding_table(uint32_t wm_table)
-{
-	OUT_BATCH(GEN6_3DSTATE_BINDING_TABLE_POINTERS |
-		  GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS |
-		  (4 - 2));
-	OUT_BATCH(0);		/* vs */
-	OUT_BATCH(0);		/* gs */
-	OUT_BATCH(wm_table);
-}
-
-static void
-gen6_emit_drawing_rectangle(struct scratch_buf *dst)
-{
-	OUT_BATCH(GEN6_3DSTATE_DRAWING_RECTANGLE | (4 - 2));
-	OUT_BATCH(0);
-	OUT_BATCH((buf_height(dst) - 1) << 16 | (buf_width(dst) - 1));
-	OUT_BATCH(0);
-}
-
-static void
-gen6_emit_vertex_elements(void)
-{
-	/* The VUE layout
-	 *    dword 0-3: pad (0.0, 0.0, 0.0. 0.0)
-	 *    dword 4-7: position (x, y, 1.0, 1.0),
-	 *    dword 8-11: texture coordinate 0 (u0, v0, 0, 0)
-	 *
-	 * dword 4-11 are fetched from vertex buffer
-	 */
-	OUT_BATCH(GEN6_3DSTATE_VERTEX_ELEMENTS | (2 * 3 + 1 - 2));
-
-	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
-		  GEN6_SURFACEFORMAT_R32G32B32A32_FLOAT << VE0_FORMAT_SHIFT |
-		  0 << VE0_OFFSET_SHIFT);
-	OUT_BATCH(GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_0_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_1_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
-
-	/* x,y */
-	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
-		  GEN6_SURFACEFORMAT_R16G16_SSCALED << VE0_FORMAT_SHIFT |
-		  0 << VE0_OFFSET_SHIFT); /* offsets vb in bytes */
-	OUT_BATCH(GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_2_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_1_FLT << VE1_VFCOMPONENT_3_SHIFT);
-
-	/* u0, v0 */
-	OUT_BATCH(0 << VE0_VERTEX_BUFFER_INDEX_SHIFT | VE0_VALID |
-		  GEN6_SURFACEFORMAT_R32G32_FLOAT << VE0_FORMAT_SHIFT |
-		  4 << VE0_OFFSET_SHIFT);	/* offset vb in bytes */
-	OUT_BATCH(GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_0_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_SRC << VE1_VFCOMPONENT_1_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_2_SHIFT |
-		  GEN6_VFCOMPONENT_STORE_0 << VE1_VFCOMPONENT_3_SHIFT);
-}
-
-static uint32_t
-gen6_create_cc_viewport(void)
-{
-	struct gen6_cc_viewport *vp;
-
-	vp = batch_alloc(sizeof(*vp), 32);
-
-	vp->min_depth = -1.e35;
-	vp->max_depth = 1.e35;
-
-	return batch_offset(vp);
-}
-
-static uint32_t
-gen6_create_cc_blend(void)
-{
-	struct gen6_blend_state *blend;
-
-	blend = batch_alloc(sizeof(*blend), 64);
-
-	blend->blend0.dest_blend_factor = GEN6_BLENDFACTOR_ZERO;
-	blend->blend0.source_blend_factor = GEN6_BLENDFACTOR_ONE;
-	blend->blend0.blend_func = GEN6_BLENDFUNCTION_ADD;
-	blend->blend0.blend_enable = 1;
-
-	blend->blend1.post_blend_clamp_enable = 1;
-	blend->blend1.pre_blend_clamp_enable = 1;
-
-	return batch_offset(blend);
-}
-
-static uint32_t
-gen6_create_kernel(void)
-{
-	return batch_copy(ps_kernel_nomask_affine,
-			  sizeof(ps_kernel_nomask_affine),
-			  64);
-}
-
-static uint32_t
-gen6_create_sampler(sampler_filter_t filter,
-		   sampler_extend_t extend)
-{
-	struct gen6_sampler_state *ss;
-
-	ss = batch_alloc(sizeof(*ss), 32);
-	ss->ss0.lod_preclamp = 1;	/* GL mode */
-
-	/* We use the legacy mode to get the semantics specified by
-	 * the Render extension. */
-	ss->ss0.border_color_mode = GEN6_BORDER_COLOR_MODE_LEGACY;
-
-	switch (filter) {
-	default:
-	case SAMPLER_FILTER_NEAREST:
-		ss->ss0.min_filter = GEN6_MAPFILTER_NEAREST;
-		ss->ss0.mag_filter = GEN6_MAPFILTER_NEAREST;
-		break;
-	case SAMPLER_FILTER_BILINEAR:
-		ss->ss0.min_filter = GEN6_MAPFILTER_LINEAR;
-		ss->ss0.mag_filter = GEN6_MAPFILTER_LINEAR;
-		break;
-	}
-
-	switch (extend) {
-	default:
-	case SAMPLER_EXTEND_NONE:
-		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
-		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
-		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_CLAMP_BORDER;
-		break;
-	case SAMPLER_EXTEND_REPEAT:
-		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
-		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
-		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_WRAP;
-		break;
-	case SAMPLER_EXTEND_PAD:
-		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
-		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
-		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_CLAMP;
-		break;
-	case SAMPLER_EXTEND_REFLECT:
-		ss->ss1.r_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
-		ss->ss1.s_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
-		ss->ss1.t_wrap_mode = GEN6_TEXCOORDMODE_MIRROR;
-		break;
-	}
-
-	return batch_offset(ss);
-}
-
-static void gen6_emit_vertex_buffer(void)
-{
-	OUT_BATCH(GEN6_3DSTATE_VERTEX_BUFFERS | 3);
-	OUT_BATCH(VB0_VERTEXDATA |
-		  0 << VB0_BUFFER_INDEX_SHIFT |
-		  VERTEX_SIZE << VB0_BUFFER_PITCH_SHIFT);
-	OUT_RELOC(batch->bo, I915_GEM_DOMAIN_VERTEX, 0, 0);
-	OUT_RELOC(batch->bo, I915_GEM_DOMAIN_VERTEX, 0, batch->bo->size-1);
-	OUT_BATCH(0);
-}
-
-static uint32_t gen6_emit_primitive(void)
-{
-	uint32_t offset;
-
-	OUT_BATCH(GEN6_3DPRIMITIVE |
-		  GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL |
-		  _3DPRIM_RECTLIST << GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT |
-		  0 << 9 |
-		  4);
-	OUT_BATCH(3);	/* vertex count */
-	offset = batch_used();
-	OUT_BATCH(0);	/* vertex_index */
-	OUT_BATCH(1);	/* single instance */
-	OUT_BATCH(0);	/* start instance location */
-	OUT_BATCH(0);	/* index buffer offset, ignored */
-
-	return offset;
-}
-
-void gen6_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no)
-{
-	uint32_t wm_state, wm_kernel, wm_table;
-	uint32_t cc_vp, cc_blend, offset;
-	uint32_t batch_end;
-
-	intel_batchbuffer_flush(batch);
-
-	batch->ptr = batch->buffer + 1024;
-	batch_alloc(64, 64);
-	wm_table  = gen6_bind_surfaces(src, dst);
-	wm_kernel = gen6_create_kernel();
-	wm_state  = gen6_create_sampler(SAMPLER_FILTER_NEAREST,
-					SAMPLER_EXTEND_NONE);
-
-	cc_vp = gen6_create_cc_viewport();
-	cc_blend = gen6_create_cc_blend();
-
-	batch->ptr = batch->buffer;
-
-	gen6_emit_invariant();
-	gen6_emit_state_base_address();
-
-	gen6_emit_sip();
-	gen6_emit_urb();
-
-	gen6_emit_viewports(cc_vp);
-	gen6_emit_vs();
-	gen6_emit_gs();
-	gen6_emit_clip();
-	gen6_emit_wm_constants();
-	gen6_emit_null_depth_buffer();
-
-	gen6_emit_drawing_rectangle(dst);
-	gen6_emit_cc(cc_blend);
-	gen6_emit_sampler(wm_state);
-	gen6_emit_sf();
-	gen6_emit_wm(wm_kernel);
-	gen6_emit_vertex_elements();
-	gen6_emit_binding_table(wm_table);
-
-	gen6_emit_vertex_buffer();
-	offset = gen6_emit_primitive();
-
-	OUT_BATCH(MI_BATCH_BUFFER_END);
-	batch_end = batch_align(8);
-
-	*(uint32_t*)(batch->buffer + offset) =
-		batch_round_upto(VERTEX_SIZE)/VERTEX_SIZE;
-
-	emit_vertex_2s(dst_x + options.tile_size, dst_y + options.tile_size);
-	emit_vertex_normalized(src_x + options.tile_size, buf_width(src));
-	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
-
-	emit_vertex_2s(dst_x, dst_y + options.tile_size);
-	emit_vertex_normalized(src_x, buf_width(src));
-	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
-
-	emit_vertex_2s(dst_x, dst_y);
-	emit_vertex_normalized(src_x, buf_width(src));
-	emit_vertex_normalized(src_y, buf_height(src));
-
-	gen6_render_flush(batch_end);
-	intel_batchbuffer_reset(batch);
-}
diff --git a/tests/gem_stress_i830.c b/tests/gem_stress_i830.c
deleted file mode 100644
index 317a492..0000000
--- a/tests/gem_stress_i830.c
+++ /dev/null
@@ -1,354 +0,0 @@
-#include "i830_reg.h"
-#include "gem_stress.h"
-
-#define TB0C_LAST_STAGE	(1 << 31)
-#define TB0C_RESULT_SCALE_1X		(0 << 29)
-#define TB0C_RESULT_SCALE_2X		(1 << 29)
-#define TB0C_RESULT_SCALE_4X		(2 << 29)
-#define TB0C_OP_MODULE			(3 << 25)
-#define TB0C_OUTPUT_WRITE_CURRENT	(0 << 24)
-#define TB0C_OUTPUT_WRITE_ACCUM		(1 << 24)
-#define TB0C_ARG3_REPLICATE_ALPHA 	(1<<23)
-#define TB0C_ARG3_INVERT		(1<<22)
-#define TB0C_ARG3_SEL_XXX
-#define TB0C_ARG2_REPLICATE_ALPHA 	(1<<17)
-#define TB0C_ARG2_INVERT		(1<<16)
-#define TB0C_ARG2_SEL_ONE		(0 << 12)
-#define TB0C_ARG2_SEL_FACTOR		(1 << 12)
-#define TB0C_ARG2_SEL_TEXEL0		(6 << 12)
-#define TB0C_ARG2_SEL_TEXEL1		(7 << 12)
-#define TB0C_ARG2_SEL_TEXEL2		(8 << 12)
-#define TB0C_ARG2_SEL_TEXEL3		(9 << 12)
-#define TB0C_ARG1_REPLICATE_ALPHA 	(1<<11)
-#define TB0C_ARG1_INVERT		(1<<10)
-#define TB0C_ARG1_SEL_ONE		(0 << 6)
-#define TB0C_ARG1_SEL_TEXEL0		(6 << 6)
-#define TB0C_ARG1_SEL_TEXEL1		(7 << 6)
-#define TB0C_ARG1_SEL_TEXEL2		(8 << 6)
-#define TB0C_ARG1_SEL_TEXEL3		(9 << 6)
-#define TB0C_ARG0_REPLICATE_ALPHA 	(1<<5)
-#define TB0C_ARG0_SEL_XXX
-
-#define TB0A_CTR_STAGE_ENABLE 		(1<<31)
-#define TB0A_RESULT_SCALE_1X		(0 << 29)
-#define TB0A_RESULT_SCALE_2X		(1 << 29)
-#define TB0A_RESULT_SCALE_4X		(2 << 29)
-#define TB0A_OP_MODULE			(3 << 25)
-#define TB0A_OUTPUT_WRITE_CURRENT	(0<<24)
-#define TB0A_OUTPUT_WRITE_ACCUM		(1<<24)
-#define TB0A_CTR_STAGE_SEL_BITS_XXX
-#define TB0A_ARG3_SEL_XXX
-#define TB0A_ARG3_INVERT		(1<<17)
-#define TB0A_ARG2_INVERT		(1<<16)
-#define TB0A_ARG2_SEL_ONE		(0 << 12)
-#define TB0A_ARG2_SEL_TEXEL0		(6 << 12)
-#define TB0A_ARG2_SEL_TEXEL1		(7 << 12)
-#define TB0A_ARG2_SEL_TEXEL2		(8 << 12)
-#define TB0A_ARG2_SEL_TEXEL3		(9 << 12)
-#define TB0A_ARG1_INVERT		(1<<10)
-#define TB0A_ARG1_SEL_ONE		(0 << 6)
-#define TB0A_ARG1_SEL_TEXEL0		(6 << 6)
-#define TB0A_ARG1_SEL_TEXEL1		(7 << 6)
-#define TB0A_ARG1_SEL_TEXEL2		(8 << 6)
-#define TB0A_ARG1_SEL_TEXEL3		(9 << 6)
-
-void gen2_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no)
-{
-	static unsigned keep_gpu_busy_counter = 0;
-
-	/* check both edges of the fence usage */
-	if (keep_gpu_busy_counter & 1)
-		keep_gpu_busy();
-
-	/* invariant state */
-	{
-		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(0));
-		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(1));
-		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(2));
-		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(3));
-
-		OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_FOG_MODE_CMD);
-		OUT_BATCH(FOGFUNC_ENABLE |
-			  FOG_LINEAR_CONST | FOGSRC_INDEX_Z | ENABLE_FOG_DENSITY);
-		OUT_BATCH(0);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
-			  MAP_UNIT(0) |
-			  DISABLE_TEX_STREAM_BUMP |
-			  ENABLE_TEX_STREAM_COORD_SET |
-			  TEX_STREAM_COORD_SET(0) |
-			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
-		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
-			  MAP_UNIT(1) |
-			  DISABLE_TEX_STREAM_BUMP |
-			  ENABLE_TEX_STREAM_COORD_SET |
-			  TEX_STREAM_COORD_SET(1) |
-			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1));
-		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
-			  MAP_UNIT(2) |
-			  DISABLE_TEX_STREAM_BUMP |
-			  ENABLE_TEX_STREAM_COORD_SET |
-			  TEX_STREAM_COORD_SET(2) |
-			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2));
-		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
-			  MAP_UNIT(3) |
-			  DISABLE_TEX_STREAM_BUMP |
-			  ENABLE_TEX_STREAM_COORD_SET |
-			  TEX_STREAM_COORD_SET(3) |
-			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3));
-
-		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
-		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0));
-		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
-		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(1));
-		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
-		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(2));
-		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
-		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3));
-
-		OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
-			  ENABLE_POINT_RASTER_RULE |
-			  OGL_POINT_RASTER_RULE |
-			  ENABLE_LINE_STRIP_PROVOKE_VRTX |
-			  ENABLE_TRI_FAN_PROVOKE_VRTX |
-			  ENABLE_TRI_STRIP_PROVOKE_VRTX |
-			  LINE_STRIP_PROVOKE_VRTX(1) |
-			  TRI_FAN_PROVOKE_VRTX(2) | TRI_STRIP_PROVOKE_VRTX(2));
-
-		OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
-
-		OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM);
-		OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);
-
-		OUT_BATCH(_3DSTATE_W_STATE_CMD);
-		OUT_BATCH(MAGIC_W_STATE_DWORD1);
-		OUT_BATCH(0x3f800000 /* 1.0 in IEEE float */ );
-
-		OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD);
-		OUT_BATCH(0x80808080);	/* .5 required in alpha for GL_DOT3_RGBA_EXT */
-
-		OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
-		OUT_BATCH(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
-			  TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
-			  TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
-			  TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
-
-		/* copy from mesa */
-		OUT_BATCH(_3DSTATE_FOG_COLOR_CMD |
-			  FOG_COLOR_RED(0) | FOG_COLOR_GREEN(0) | FOG_COLOR_BLUE(0));
-
-		OUT_BATCH(_3DSTATE_CONST_BLEND_COLOR_CMD);
-		OUT_BATCH(0);
-
-		OUT_BATCH(_3DSTATE_MODES_1_CMD |
-			  ENABLE_COLR_BLND_FUNC |
-			  BLENDFUNC_ADD |
-			  ENABLE_SRC_BLND_FACTOR |
-			  SRC_BLND_FACT(BLENDFACTOR_ONE) |
-			  ENABLE_DST_BLND_FACTOR | DST_BLND_FACT(BLENDFACTOR_ZERO));
-		OUT_BATCH(_3DSTATE_MODES_2_CMD | ENABLE_GLOBAL_DEPTH_BIAS | GLOBAL_DEPTH_BIAS(0) | ENABLE_ALPHA_TEST_FUNC | ALPHA_TEST_FUNC(0) |	/* always */
-			  ALPHA_REF_VALUE(0));
-		OUT_BATCH(_3DSTATE_MODES_3_CMD |
-			  ENABLE_DEPTH_TEST_FUNC |
-			  DEPTH_TEST_FUNC(0x2) |	/* COMPAREFUNC_LESS */
-			  ENABLE_ALPHA_SHADE_MODE |
-			  ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
-			  ENABLE_FOG_SHADE_MODE |
-			  FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
-			  ENABLE_SPEC_SHADE_MODE |
-			  SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
-			  ENABLE_COLOR_SHADE_MODE |
-			  COLOR_SHADE_MODE(SHADE_MODE_LINEAR) |
-			  ENABLE_CULL_MODE | CULLMODE_NONE);
-
-		OUT_BATCH(_3DSTATE_MODES_4_CMD |
-			  ENABLE_LOGIC_OP_FUNC |
-			  LOGIC_OP_FUNC(LOGICOP_COPY) |
-			  ENABLE_STENCIL_TEST_MASK |
-			  STENCIL_TEST_MASK(0xff) |
-			  ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff));
-
-		OUT_BATCH(_3DSTATE_STENCIL_TEST_CMD |
-			  ENABLE_STENCIL_PARMS |
-			  STENCIL_FAIL_OP(0) |	/* STENCILOP_KEEP */
-			  STENCIL_PASS_DEPTH_FAIL_OP(0) |	/* STENCILOP_KEEP */
-			  STENCIL_PASS_DEPTH_PASS_OP(0) |	/* STENCILOP_KEEP */
-			  ENABLE_STENCIL_TEST_FUNC |
-			  STENCIL_TEST_FUNC(0) |	/* COMPAREFUNC_ALWAYS */
-			  ENABLE_STENCIL_REF_VALUE |
-			  STENCIL_REF_VALUE(0));
-
-		OUT_BATCH(_3DSTATE_MODES_5_CMD |
-			  FLUSH_TEXTURE_CACHE |
-			  ENABLE_SPRITE_POINT_TEX | SPRITE_POINT_TEX_OFF |
-			  ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(0x2) | /* 1.0 */
-			  ENABLE_FIXED_POINT_WIDTH | FIXED_POINT_WIDTH(1));
-
-		OUT_BATCH(_3DSTATE_STIPPLE);
-
-		/* Set default blend state */
-		OUT_BATCH(_3DSTATE_MAP_BLEND_OP_CMD(0) |
-			  TEXPIPE_COLOR |
-			  ENABLE_TEXOUTPUT_WRT_SEL |
-			  TEXOP_OUTPUT_CURRENT |
-			  DISABLE_TEX_CNTRL_STAGE |
-			  TEXOP_SCALE_1X |
-			  TEXOP_MODIFY_PARMS | TEXOP_LAST_STAGE | TEXBLENDOP_ARG1);
-		OUT_BATCH(_3DSTATE_MAP_BLEND_OP_CMD(0) |
-			  TEXPIPE_ALPHA |
-			  ENABLE_TEXOUTPUT_WRT_SEL |
-			  TEXOP_OUTPUT_CURRENT |
-			  TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1);
-		OUT_BATCH(_3DSTATE_MAP_BLEND_ARG_CMD(0) |
-			  TEXPIPE_COLOR |
-			  TEXBLEND_ARG1 |
-			  TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_DIFFUSE);
-		OUT_BATCH(_3DSTATE_MAP_BLEND_ARG_CMD(0) |
-			  TEXPIPE_ALPHA |
-			  TEXBLEND_ARG1 |
-			  TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_DIFFUSE);
-
-		OUT_BATCH(_3DSTATE_AA_CMD |
-			  AA_LINE_ECAAR_WIDTH_ENABLE |
-			  AA_LINE_ECAAR_WIDTH_1_0 |
-			  AA_LINE_REGION_WIDTH_ENABLE |
-			  AA_LINE_REGION_WIDTH_1_0 | AA_LINE_DISABLE);
-	}
-
-	/* render target state */
-	{
-		uint32_t tiling_bits = 0;
-		if (dst->tiling != I915_TILING_NONE)
-			tiling_bits = BUF_3D_TILED_SURFACE;
-		if (dst->tiling == I915_TILING_Y)
-			tiling_bits |= BUF_3D_TILE_WALK_Y;
-
-		OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
-		OUT_BATCH(BUF_3D_ID_COLOR_BACK | tiling_bits |
-			  BUF_3D_PITCH(dst->stride));
-		OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
-
-		OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
-		OUT_BATCH(COLR_BUF_ARGB8888 |
-			  DSTORG_HORT_BIAS(0x8) |
-			  DSTORG_VERT_BIAS(0x8));
-
-		OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(0);		/* ymin, xmin */
-		OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
-			  DRAW_XMAX(buf_width(dst) - 1));
-		OUT_BATCH(0);		/* yorig, xorig */
-	}
-
-	/* dynamic state */
-	{
-		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
-			  I1_LOAD_S(2) | I1_LOAD_S(3) | I1_LOAD_S(8) | 2);
-		OUT_BATCH(1);		/* number of coordinate sets */
-		OUT_BATCH(S3_CULLMODE_NONE | S3_VERTEXHAS_XY);
-		OUT_BATCH(S8_ENABLE_COLOR_BLEND | S8_BLENDFUNC_ADD |
-			  BLENDFACTOR_ONE << S8_SRC_BLEND_FACTOR_SHIFT |
-			  BLENDFACTOR_ZERO << S8_DST_BLEND_FACTOR_SHIFT |
-			  S8_ENABLE_COLOR_BUFFER_WRITE);
-
-		OUT_BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD | DISABLE_INDPT_ALPHA_BLEND);
-
-		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
-			  LOAD_TEXTURE_BLEND_STAGE(0) | 1);
-		OUT_BATCH(TB0C_LAST_STAGE | TB0C_RESULT_SCALE_1X | TB0C_OP_MODULE |
-			  TB0C_OUTPUT_WRITE_CURRENT | TB0C_ARG1_SEL_TEXEL0 |
-			  TB0C_ARG2_SEL_ONE);
-		OUT_BATCH(TB0A_RESULT_SCALE_1X | TB0A_OP_MODULE |
-			  TB0A_OUTPUT_WRITE_CURRENT | TB0A_ARG1_SEL_TEXEL0 |
-			  TB0A_ARG2_SEL_ONE);
-
-		OUT_BATCH(_3DSTATE_ENABLES_1_CMD | DISABLE_LOGIC_OP |
-			  DISABLE_STENCIL_TEST | DISABLE_DEPTH_BIAS |
-			  DISABLE_SPEC_ADD | DISABLE_FOG | DISABLE_ALPHA_TEST |
-			  ENABLE_COLOR_BLEND | DISABLE_DEPTH_TEST);
-		/* We have to explicitly say we don't want write disabled */
-		OUT_BATCH(_3DSTATE_ENABLES_2_CMD | ENABLE_COLOR_MASK |
-			  DISABLE_STENCIL_WRITE | ENABLE_TEX_CACHE |
-			  DISABLE_DITHER | ENABLE_COLOR_WRITE | DISABLE_DEPTH_WRITE);
-
-		OUT_BATCH(_3DSTATE_VERTEX_FORMAT_2_CMD |
-			  TEXCOORDFMT_2D << 0);
-	}
-
-	/* sampler state */
-	{
-		uint32_t tiling_bits = 0;
-		if (src->tiling != I915_TILING_NONE)
-			tiling_bits = TM0S1_TILED_SURFACE;
-		if (src->tiling == I915_TILING_Y)
-			tiling_bits |= TM0S1_TILE_WALK;
-
-		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
-			  LOAD_TEXTURE_MAP(0) | 4);
-		OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
-		OUT_BATCH((buf_height(src) - 1) << TM0S1_HEIGHT_SHIFT |
-			  (buf_width(src) - 1) << TM0S1_WIDTH_SHIFT |
-			  MAPSURF_32BIT | MT_32BIT_ARGB8888 | tiling_bits);
-		OUT_BATCH((src->stride / 4 - 1) << TM0S2_PITCH_SHIFT | TM0S2_MAP_2D);
-		OUT_BATCH(FILTER_NEAREST << TM0S3_MAG_FILTER_SHIFT |
-			  FILTER_NEAREST << TM0S3_MIN_FILTER_SHIFT |
-			  MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT);
-		OUT_BATCH(0);	/* default color */
-		OUT_BATCH(_3DSTATE_MAP_COORD_SET_CMD | TEXCOORD_SET(0) |
-			  ENABLE_TEXCOORD_PARAMS | TEXCOORDS_ARE_NORMAL |
-			  TEXCOORDTYPE_CARTESIAN |
-			  ENABLE_ADDR_V_CNTL | TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP_BORDER) |
-			  ENABLE_ADDR_U_CNTL | TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP_BORDER));
-		/* map texel stream */
-		OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
-		OUT_BATCH(TEXBIND_SET0(TEXCOORDSRC_VTXSET_0) |
-			  TEXBIND_SET1(TEXCOORDSRC_KEEP) |
-			  TEXBIND_SET2(TEXCOORDSRC_KEEP) |
-			  TEXBIND_SET3(TEXCOORDSRC_KEEP));
-		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | (0 << 16) |
-			  DISABLE_TEX_STREAM_BUMP |
-			  ENABLE_TEX_STREAM_COORD_SET |
-			  TEX_STREAM_COORD_SET(0) |
-			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
-	}
-
-	OUT_BATCH(PRIM3D_INLINE | PRIM3D_RECTLIST | (3*4 -1));
-	emit_vertex(dst_x + options.tile_size);
-	emit_vertex(dst_y + options.tile_size);
-	emit_vertex_normalized(src_x + options.tile_size, buf_width(src));
-	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
-
-	emit_vertex(dst_x);
-	emit_vertex(dst_y + options.tile_size);
-	emit_vertex_normalized(src_x, buf_width(src));
-	emit_vertex_normalized(src_y + options.tile_size, buf_height(src));
-
-	emit_vertex(dst_x);
-	emit_vertex(dst_y);
-	emit_vertex_normalized(src_x, buf_width(src));
-	emit_vertex_normalized(src_y, buf_height(src));
-
-	if (!(keep_gpu_busy_counter & 1))
-		keep_gpu_busy();
-
-	keep_gpu_busy_counter++;
-
-	intel_batchbuffer_flush(batch);
-}
diff --git a/tests/gem_stress_i915.c b/tests/gem_stress_i915.c
deleted file mode 100644
index 396b8d3..0000000
--- a/tests/gem_stress_i915.c
+++ /dev/null
@@ -1,190 +0,0 @@
-#include "i915_reg.h"
-#include "i915_3d.h"
-#include "gem_stress.h"
-
-void gen3_render_copyfunc(struct scratch_buf *src, unsigned src_x, unsigned src_y,
-			  struct scratch_buf *dst, unsigned dst_x, unsigned dst_y,
-			  unsigned logical_tile_no)
-{
-	static unsigned keep_gpu_busy_counter = 0;
-
-	/* check both edges of the fence usage */
-	if (keep_gpu_busy_counter & 1)
-		keep_gpu_busy();
-
-	/* invariant state */
-	{
-		OUT_BATCH(_3DSTATE_AA_CMD |
-			  AA_LINE_ECAAR_WIDTH_ENABLE |
-			  AA_LINE_ECAAR_WIDTH_1_0 |
-			  AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0);
-		OUT_BATCH(_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
-			  IAB_MODIFY_ENABLE |
-			  IAB_MODIFY_FUNC | (BLENDFUNC_ADD << IAB_FUNC_SHIFT) |
-			  IAB_MODIFY_SRC_FACTOR | (BLENDFACT_ONE <<
-						   IAB_SRC_FACTOR_SHIFT) |
-			  IAB_MODIFY_DST_FACTOR | (BLENDFACT_ZERO <<
-						   IAB_DST_FACTOR_SHIFT));
-		OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS |
-			  CSB_TCB(0, 0) |
-			  CSB_TCB(1, 1) |
-			  CSB_TCB(2, 2) |
-			  CSB_TCB(3, 3) |
-			  CSB_TCB(4, 4) |
-			  CSB_TCB(5, 5) | CSB_TCB(6, 6) | CSB_TCB(7, 7));
-		OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
-			  ENABLE_POINT_RASTER_RULE |
-			  OGL_POINT_RASTER_RULE |
-			  ENABLE_LINE_STRIP_PROVOKE_VRTX |
-			  ENABLE_TRI_FAN_PROVOKE_VRTX |
-			  LINE_STRIP_PROVOKE_VRTX(1) |
-			  TRI_FAN_PROVOKE_VRTX(2) | ENABLE_TEXKILL_3D_4D | TEXKILL_4D);
-		OUT_BATCH(_3DSTATE_MODES_4_CMD |
-			  ENABLE_LOGIC_OP_FUNC | LOGIC_OP_FUNC(LOGICOP_COPY) |
-			  ENABLE_STENCIL_WRITE_MASK | STENCIL_WRITE_MASK(0xff) |
-			  ENABLE_STENCIL_TEST_MASK | STENCIL_TEST_MASK(0xff));
-		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | I1_LOAD_S(4) | I1_LOAD_S(5) | 2);
-		OUT_BATCH(0x00000000);	/* Disable texture coordinate wrap-shortest */
-		OUT_BATCH((1 << S4_POINT_WIDTH_SHIFT) |
-			  S4_LINE_WIDTH_ONE |
-			  S4_CULLMODE_NONE |
-			  S4_VFMT_XY);
-		OUT_BATCH(0x00000000);	/* Stencil. */
-		OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
-		OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
-		OUT_BATCH(0);
-		OUT_BATCH(0);
-		OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
-		OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0);	/* disable indirect state */
-		OUT_BATCH(0);
-		OUT_BATCH(_3DSTATE_STIPPLE);
-		OUT_BATCH(0x00000000);
-		OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS | BFO_ENABLE_STENCIL_TWO_SIDE | 0);
-	}
-
-	/* samler state */
-	{
-#define TEX_COUNT 1
-		uint32_t tiling_bits = 0;
-		if (src->tiling != I915_TILING_NONE)
-			tiling_bits = MS3_TILED_SURFACE;
-		if (src->tiling == I915_TILING_Y)
-			tiling_bits |= MS3_TILE_WALK;
-
-		OUT_BATCH(_3DSTATE_MAP_STATE | (3 * TEX_COUNT));
-		OUT_BATCH((1 << TEX_COUNT) - 1);
-		OUT_RELOC(src->bo, I915_GEM_DOMAIN_SAMPLER, 0, 0);
-		OUT_BATCH(MAPSURF_32BIT | MT_32BIT_ARGB8888 |
-			  tiling_bits |
-			  (buf_height(src) - 1) << MS3_HEIGHT_SHIFT |
-			  (buf_width(src) - 1) << MS3_WIDTH_SHIFT);
-		OUT_BATCH((src->stride/4-1) << MS4_PITCH_SHIFT);
-
-		OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3 * TEX_COUNT));
-		OUT_BATCH((1 << TEX_COUNT) - 1);
-		OUT_BATCH(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT |
-			  FILTER_NEAREST << SS2_MAG_FILTER_SHIFT |
-			  FILTER_NEAREST << SS2_MIN_FILTER_SHIFT);
-		OUT_BATCH(TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT |
-			  TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT |
-			  0 << SS3_TEXTUREMAP_INDEX_SHIFT);
-		OUT_BATCH(0x00000000);
-	}
-
-	/* render target state */
-	{
-		uint32_t tiling_bits = 0;
-		if (dst->tiling != I915_TILING_NONE)
-			tiling_bits = BUF_3D_TILED_SURFACE;
-		if (dst->tiling == I915_TILING_Y)
-			tiling_bits |= BUF_3D_TILE_WALK_Y;
-
-		OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
-		OUT_BATCH(BUF_3D_ID_COLOR_BACK | tiling_bits |
-			  BUF_3D_PITCH(dst->stride));
-		OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
-
-		OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
-		OUT_BATCH(COLR_BUF_ARGB8888 |
-			  DSTORG_HORT_BIAS(0x8) |
-			  DSTORG_VERT_BIAS(0x8));
-
-		/* draw rect is unconditional */
-		OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
-		OUT_BATCH(0x00000000);
-		OUT_BATCH(0x00000000);	/* ymin, xmin */
-		OUT_BATCH(DRAW_YMAX(buf_height(dst) - 1) |
-			  DRAW_XMAX(buf_width(dst) - 1));
-		/* yorig, xorig (relate to color buffer?) */
-		OUT_BATCH(0x00000000);
-	}
-
-	/* texfmt */
-	{
-		OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
-			  I1_LOAD_S(1) | I1_LOAD_S(2) | I1_LOAD_S(6) | 2);
-		OUT_BATCH((4 << S1_VERTEX_WIDTH_SHIFT) |
-			  (4 << S1_VERTEX_PITCH_SHIFT));
-		OUT_BATCH(~S2_TEXCOORD_FMT(0, TEXCOORDFMT_NOT_PRESENT) | S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D));
-		OUT_BATCH(S6_CBUF_BLEND_ENABLE | S6_COLOR_WRITE_ENABLE |
-			  BLENDFUNC_ADD << S6_CBUF_BLEND_FUNC_SHIFT |
-			  BLENDFACT_ONE << S6_CBUF_SRC_BLEND_FACT_SHIFT |
-			  BLENDFACT_ZERO << S6_CBUF_DST_BLEND_FACT_SHIFT);
-	}
-
-	/* frage shader */
-	{
-		OUT_BATCH(_3DSTATE_PIXEL_SHADER_PROGRAM | (1 + 3*3 - 2));
-		/* decl FS_T0 */
-		OUT_BATCH(D0_DCL |
-			  REG_TYPE(FS_T0) << D0_TYPE_SHIFT |
-			  REG_NR(FS_T0) << D0_NR_SHIFT |
-			  ((REG_TYPE(FS_T0) != REG_TYPE_S) ? D0_CHANNEL_ALL : 0));
-		OUT_BATCH(0);
-		OUT_BATCH(0);
-		/* decl FS_S0 */
-		OUT_BATCH(D0_DCL |
-			  (REG_TYPE(FS_S0) << D0_TYPE_SHIFT) |
-			  (REG_NR(FS_S0) << D0_NR_SHIFT) |
-			  ((REG_TYPE(FS_S0) != REG_TYPE_S) ? D0_CHANNEL_ALL : 0));
-		OUT_BATCH(0);
-		OUT_BATCH(0);
-		/* texld(FS_OC, FS_S0, FS_T0 */
-		OUT_BATCH(T0_TEXLD |
-			  (REG_TYPE(FS_OC) << T0_DEST_TYPE_SHIFT) |
-			  (REG_NR(FS_OC) << T0_DEST_NR_SHIFT) |
-			  (REG_NR(FS_S0) << T0_SAMPLER_NR_SHIFT));
-		OUT_BATCH((REG_TYPE(FS_T0) << T1_ADDRESS_REG_TYPE_SHIFT) |
-			  (REG_NR(FS_T0) << T1_ADDRESS_REG_NR_SHIFT));
-		OUT_BATCH(0);
-	}
-
-	OUT_BATCH(PRIM3D_RECTLIST | (3*4 - 1));
-	emit_vertex(dst_x + options.tile_size);
-	emit_vertex(dst_y + options.tile_size);
-	emit_vertex(src_x + options.tile_size);
-	emit_vertex(src_y + options.tile_size);
-
-	emit_vertex(dst_x);
-	emit_vertex(dst_y + options.tile_size);
-	emit_vertex(src_x);
-	emit_vertex(src_y + options.tile_size);
-
-	emit_vertex(dst_x);
-	emit_vertex(dst_y);
-	emit_vertex(src_x);
-	emit_vertex(src_y);
-
-	if (!(keep_gpu_busy_counter & 1))
-		keep_gpu_busy();
-
-	keep_gpu_busy_counter++;
-
-	intel_batchbuffer_flush(batch);
-}
diff --git a/tests/gen6_render.h b/tests/gen6_render.h
deleted file mode 100644
index 2c63c9e..0000000
--- a/tests/gen6_render.h
+++ /dev/null
@@ -1,1553 +0,0 @@
-#ifndef GEN6_RENDER_H
-#define GEN6_RENDER_H
-
-#define GEN6_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
-					   ((Pipeline) << 27) | \
-					   ((Opcode) << 24) | \
-					   ((Subopcode) << 16))
-
-#define GEN6_STATE_BASE_ADDRESS			GEN6_3D(0, 1, 1)
-#define GEN6_STATE_SIP				GEN6_3D(0, 1, 2)
-
-#define GEN6_PIPELINE_SELECT			GEN6_3D(1, 1, 4)
-
-#define GEN6_MEDIA_STATE_POINTERS		GEN6_3D(2, 0, 0)
-#define GEN6_MEDIA_OBJECT			GEN6_3D(2, 1, 0)
-
-#define GEN6_3DSTATE_BINDING_TABLE_POINTERS	GEN6_3D(3, 0, 1)
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS  (1 << 12)/* for GEN6 */
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_GS  (1 << 9) /* for GEN6 */
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_VS  (1 << 8) /* for GEN6 */
-
-#define GEN6_3DSTATE_VERTEX_BUFFERS		GEN6_3D(3, 0, 8)
-#define GEN6_3DSTATE_VERTEX_ELEMENTS		GEN6_3D(3, 0, 9)
-#define GEN6_3DSTATE_INDEX_BUFFER		GEN6_3D(3, 0, 0xa)
-#define GEN6_3DSTATE_VF_STATISTICS		GEN6_3D(3, 0, 0xb)
-
-#define GEN6_3DSTATE_DRAWING_RECTANGLE		GEN6_3D(3, 1, 0)
-#define GEN6_3DSTATE_CONSTANT_COLOR		GEN6_3D(3, 1, 1)
-#define GEN6_3DSTATE_SAMPLER_PALETTE_LOAD	GEN6_3D(3, 1, 2)
-#define GEN6_3DSTATE_CHROMA_KEY			GEN6_3D(3, 1, 4)
-#define GEN6_3DSTATE_DEPTH_BUFFER		GEN6_3D(3, 1, 5)
-# define GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT	29
-# define GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT	18
-
-#define GEN6_3DSTATE_POLY_STIPPLE_OFFSET		GEN6_3D(3, 1, 6)
-#define GEN6_3DSTATE_POLY_STIPPLE_PATTERN	GEN6_3D(3, 1, 7)
-#define GEN6_3DSTATE_LINE_STIPPLE		GEN6_3D(3, 1, 8)
-#define GEN6_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP	GEN6_3D(3, 1, 9)
-/* These two are BLC and CTG only, not BW or CL */
-#define GEN6_3DSTATE_AA_LINE_PARAMS		GEN6_3D(3, 1, 0xa)
-#define GEN6_3DSTATE_GS_SVB_INDEX		GEN6_3D(3, 1, 0xb)
-
-#define GEN6_3DPRIMITIVE				GEN6_3D(3, 3, 0)
-
-#define GEN6_3DSTATE_CLEAR_PARAMS		GEN6_3D(3, 1, 0x10)
-/* DW1 */
-# define GEN6_3DSTATE_DEPTH_CLEAR_VALID		(1 << 15)
-
-#define GEN6_3DSTATE_SAMPLER_STATE_POINTERS	GEN6_3D(3, 0, 0x02)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS	(1 << 12)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_GS	(1 << 9)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_VS	(1 << 8)
-
-#define GEN6_3DSTATE_URB			GEN6_3D(3, 0, 0x05)
-/* DW1 */
-# define GEN6_3DSTATE_URB_VS_SIZE_SHIFT		16
-# define GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT	0
-/* DW2 */
-# define GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT	8
-# define GEN6_3DSTATE_URB_GS_SIZE_SHIFT		0
-
-#define GEN6_3DSTATE_VIEWPORT_STATE_POINTERS	GEN6_3D(3, 0, 0x0d)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC		(1 << 12)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_SF		(1 << 11)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CLIP	(1 << 10)
-
-#define GEN6_3DSTATE_CC_STATE_POINTERS		GEN6_3D(3, 0, 0x0e)
-
-#define GEN6_3DSTATE_VS				GEN6_3D(3, 0, 0x10)
-
-#define GEN6_3DSTATE_GS				GEN6_3D(3, 0, 0x11)
-/* DW4 */
-# define GEN6_3DSTATE_GS_DISPATCH_START_GRF_SHIFT	0
-
-#define GEN6_3DSTATE_CLIP			GEN6_3D(3, 0, 0x12)
-
-#define GEN6_3DSTATE_SF				GEN6_3D(3, 0, 0x13)
-/* DW1 */
-# define GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT		22
-# define GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT	11
-# define GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT	4
-/* DW2 */
-/* DW3 */
-# define GEN6_3DSTATE_SF_CULL_BOTH			(0 << 29)
-# define GEN6_3DSTATE_SF_CULL_NONE			(1 << 29)
-# define GEN6_3DSTATE_SF_CULL_FRONT			(2 << 29)
-# define GEN6_3DSTATE_SF_CULL_BACK			(3 << 29)
-/* DW4 */
-# define GEN6_3DSTATE_SF_TRI_PROVOKE_SHIFT		29
-# define GEN6_3DSTATE_SF_LINE_PROVOKE_SHIFT		27
-# define GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT		25
-
-#define GEN6_3DSTATE_WM				GEN6_3D(3, 0, 0x14)
-/* DW2 */
-# define GEN6_3DSTATE_WM_SAMPLER_COUNT_SHIFT			27
-# define GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
-/* DW4 */
-# define GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT		16
-/* DW5 */
-# define GEN6_3DSTATE_WM_MAX_THREADS_SHIFT			25
-# define GEN6_3DSTATE_WM_DISPATCH_ENABLE			(1 << 19)
-# define GEN6_3DSTATE_WM_16_DISPATCH_ENABLE			(1 << 1)
-# define GEN6_3DSTATE_WM_8_DISPATCH_ENABLE			(1 << 0)
-/* DW6 */
-# define GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT			20
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	(1 << 15)
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 14)
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	(1 << 13)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC		(1 << 12)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 11)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		(1 << 10)
-
-
-#define GEN6_3DSTATE_CONSTANT_VS		GEN6_3D(3, 0, 0x15)
-#define GEN6_3DSTATE_CONSTANT_GS		GEN6_3D(3, 0, 0x16)
-#define GEN6_3DSTATE_CONSTANT_PS		GEN6_3D(3, 0, 0x17)
-
-#define GEN6_3DSTATE_SAMPLE_MASK		GEN6_3D(3, 0, 0x18)
-
-#define GEN6_3DSTATE_MULTISAMPLE		GEN6_3D(3, 1, 0x0d)
-/* DW1 */
-# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER		(0 << 4)
-# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_UPPER_LEFT	(1 << 4)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1			(0 << 1)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_4			(2 << 1)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_8			(3 << 1)
-
-#define PIPELINE_SELECT_3D		0
-#define PIPELINE_SELECT_MEDIA		1
-
-/* for GEN6_STATE_BASE_ADDRESS */
-#define BASE_ADDRESS_MODIFY		(1 << 0)
-
-/* for GEN6_PIPE_CONTROL */
-#define GEN6_PIPE_CONTROL_NOWRITE       (0 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_QWORD   (1 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_DEPTH   (2 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_TIME    (3 << 14)
-#define GEN6_PIPE_CONTROL_DEPTH_STALL   (1 << 13)
-#define GEN6_PIPE_CONTROL_WC_FLUSH      (1 << 12)
-#define GEN6_PIPE_CONTROL_IS_FLUSH      (1 << 11)
-#define GEN6_PIPE_CONTROL_TC_FLUSH      (1 << 10)
-#define GEN6_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
-#define GEN6_PIPE_CONTROL_GLOBAL_GTT    (1 << 2)
-#define GEN6_PIPE_CONTROL_LOCAL_PGTT    (0 << 2)
-#define GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH	(1 << 0)
-
-/* VERTEX_BUFFER_STATE Structure */
-#define VB0_BUFFER_INDEX_SHIFT	26
-#define VB0_VERTEXDATA			(0 << 20)
-#define VB0_INSTANCEDATA		(1 << 20)
-#define VB0_BUFFER_PITCH_SHIFT		0
-
-/* VERTEX_ELEMENT_STATE Structure */
-#define VE0_VERTEX_BUFFER_INDEX_SHIFT	26 /* for GEN6 */
-#define VE0_VALID			(1 << 25) /* for GEN6 */
-#define VE0_FORMAT_SHIFT		16
-#define VE0_OFFSET_SHIFT		0
-#define VE1_VFCOMPONENT_0_SHIFT		28
-#define VE1_VFCOMPONENT_1_SHIFT		24
-#define VE1_VFCOMPONENT_2_SHIFT		20
-#define VE1_VFCOMPONENT_3_SHIFT		16
-#define VE1_DESTINATION_ELEMENT_OFFSET_SHIFT	0
-
-/* 3DPRIMITIVE bits */
-#define GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
-#define GEN6_3DPRIMITIVE_VERTEX_RANDOM	  (1 << 15)
-/* Primitive types are in gen6_defines.h */
-#define GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT	  10
-
-#define GEN6_SVG_CTL		       0x7400
-
-#define GEN6_SVG_CTL_GS_BA	       (0 << 8)
-#define GEN6_SVG_CTL_SS_BA	       (1 << 8)
-#define GEN6_SVG_CTL_IO_BA	       (2 << 8)
-#define GEN6_SVG_CTL_GS_AUB	       (3 << 8)
-#define GEN6_SVG_CTL_IO_AUB	       (4 << 8)
-#define GEN6_SVG_CTL_SIP		       (5 << 8)
-
-#define GEN6_SVG_RDATA		       0x7404
-#define GEN6_SVG_WORK_CTL	       0x7408
-
-#define GEN6_VF_CTL		       0x7500
-
-#define GEN6_VF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID	   (0 << 8)
-#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG	   (1 << 8)
-#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE   (0 << 4)
-#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX	   (1 << 4)
-#define GEN6_VF_CTL_SKIP_INITIAL_PRIMITIVES	   (1 << 3)
-#define GEN6_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE	   (1 << 2)
-#define GEN6_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE	   (1 << 1)
-#define GEN6_VF_CTL_SNAPSHOT_ENABLE	     	   (1 << 0)
-
-#define GEN6_VF_STRG_VAL		       0x7504
-#define GEN6_VF_STR_VL_OVR	       0x7508
-#define GEN6_VF_VC_OVR		       0x750c
-#define GEN6_VF_STR_PSKIP	       0x7510
-#define GEN6_VF_MAX_PRIM		       0x7514
-#define GEN6_VF_RDATA		       0x7518
-
-#define GEN6_VS_CTL		       0x7600
-#define GEN6_VS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_0	   (0 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_1	   (1 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VALID_COUNT	   (2 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER  (3 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
-#define GEN6_VS_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
-#define GEN6_VS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_VS_STRG_VAL		       0x7604
-#define GEN6_VS_RDATA		       0x7608
-
-#define GEN6_SF_CTL		       0x7b00
-#define GEN6_SF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID	   (0 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID	   (2 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID	   (4 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT	   (6 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER  (7 << 8)
-#define GEN6_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE  (1 << 4)
-#define GEN6_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE	   (1 << 3)
-#define GEN6_SF_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
-#define GEN6_SF_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
-#define GEN6_SF_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_SF_STRG_VAL		       0x7b04
-#define GEN6_SF_RDATA		       0x7b18
-
-#define GEN6_WIZ_CTL		       0x7c00
-#define GEN6_WIZ_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT	   16
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER   (0 << 8)
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE     (1 << 8)
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE   (2 << 8)
-#define GEN6_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH	      (1 << 6)
-#define GEN6_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS    (1 << 5)
-#define GEN6_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE   (1 << 4)
-#define GEN6_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG	      (1 << 3)
-#define GEN6_WIZ_CTL_SNAPSHOT_ALL_THREADS	      (1 << 2)
-#define GEN6_WIZ_CTL_THREAD_SNAPSHOT_ENABLE	      (1 << 1)
-#define GEN6_WIZ_CTL_SNAPSHOT_ENABLE		      (1 << 0)
-
-#define GEN6_WIZ_STRG_VAL			      0x7c04
-#define GEN6_WIZ_RDATA				      0x7c18
-
-#define GEN6_TS_CTL		       0x7e00
-#define GEN6_TS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_TS_CTL_SNAPSHOT_MESSAGE_ERROR	   (0 << 8)
-#define GEN6_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR   (3 << 8)
-#define GEN6_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS	   (1 << 2)
-#define GEN6_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS  	   (1 << 1)
-#define GEN6_TS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_TS_STRG_VAL		       0x7e04
-#define GEN6_TS_RDATA		       0x7e08
-
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL		       0x8000
-#endif
-#define GEN6_TD_CTL_MUX_SHIFT	       8
-#define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
-#define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
-#define GEN6_TD_CTL_EXCEPTION_MASK_OVERRIDE	   (1 << 5)
-#define GEN6_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE  (1 << 4)
-#define GEN6_TD_CTL_BREAKPOINT_ENABLE		   (1 << 2)
-#define GEN6_TD_CTL2		       0x8004
-#define GEN6_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
-#define GEN6_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE      (1 << 26)
-#define GEN6_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE	      (1 << 25)
-#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT	      16
-#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE	      (1 << 8)
-#define GEN6_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
-#define GEN6_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE	      (1 << 6)
-#define GEN6_TD_CTL2_SF_EXECUTION_MASK_ENABLE	      (1 << 5)
-#define GEN6_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE     (1 << 4)
-#define GEN6_TD_CTL2_GS_EXECUTION_MASK_ENABLE	      (1 << 3)
-#define GEN6_TD_CTL2_VS_EXECUTION_MASK_ENABLE	      (1 << 0)
-#define GEN6_TD_VF_VS_EMSK	       0x8008
-#define GEN6_TD_GS_EMSK		       0x800c
-#define GEN6_TD_CLIP_EMSK	       0x8010
-#define GEN6_TD_SF_EMSK		       0x8014
-#define GEN6_TD_WIZ_EMSK		       0x8018
-#define GEN6_TD_0_6_EHTRG_VAL	       0x801c
-#define GEN6_TD_0_7_EHTRG_VAL	       0x8020
-#define GEN6_TD_0_6_EHTRG_MSK           0x8024
-#define GEN6_TD_0_7_EHTRG_MSK	       0x8028
-#define GEN6_TD_RDATA		       0x802c
-#define GEN6_TD_TS_EMSK		       0x8030
-
-#define GEN6_EU_CTL		       0x8800
-#define GEN6_EU_CTL_SELECT_SHIFT	       16
-#define GEN6_EU_CTL_DATA_MUX_SHIFT      8
-#define GEN6_EU_ATT_0		       0x8810
-#define GEN6_EU_ATT_1		       0x8814
-#define GEN6_EU_ATT_DATA_0	       0x8820
-#define GEN6_EU_ATT_DATA_1	       0x8824
-#define GEN6_EU_ATT_CLR_0	       0x8830
-#define GEN6_EU_ATT_CLR_1	       0x8834
-#define GEN6_EU_RDATA		       0x8840
-
-#define GEN6_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
-					   ((Pipeline) << 27) | \
-					   ((Opcode) << 24) | \
-					   ((Subopcode) << 16))
-
-#define GEN6_STATE_BASE_ADDRESS			GEN6_3D(0, 1, 1)
-#define GEN6_STATE_SIP				GEN6_3D(0, 1, 2)
-
-#define GEN6_PIPELINE_SELECT			GEN6_3D(1, 1, 4)
-
-#define GEN6_MEDIA_STATE_POINTERS		GEN6_3D(2, 0, 0)
-#define GEN6_MEDIA_OBJECT			GEN6_3D(2, 1, 0)
-
-#define GEN6_3DSTATE_BINDING_TABLE_POINTERS	GEN6_3D(3, 0, 1)
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_PS  (1 << 12)/* for GEN6 */
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_GS  (1 << 9) /* for GEN6 */
-# define GEN6_3DSTATE_BINDING_TABLE_MODIFY_VS  (1 << 8) /* for GEN6 */
-
-#define GEN6_3DSTATE_VERTEX_BUFFERS		GEN6_3D(3, 0, 8)
-#define GEN6_3DSTATE_VERTEX_ELEMENTS		GEN6_3D(3, 0, 9)
-#define GEN6_3DSTATE_INDEX_BUFFER		GEN6_3D(3, 0, 0xa)
-#define GEN6_3DSTATE_VF_STATISTICS		GEN6_3D(3, 0, 0xb)
-
-#define GEN6_3DSTATE_DRAWING_RECTANGLE		GEN6_3D(3, 1, 0)
-#define GEN6_3DSTATE_CONSTANT_COLOR		GEN6_3D(3, 1, 1)
-#define GEN6_3DSTATE_SAMPLER_PALETTE_LOAD	GEN6_3D(3, 1, 2)
-#define GEN6_3DSTATE_CHROMA_KEY			GEN6_3D(3, 1, 4)
-#define GEN6_3DSTATE_DEPTH_BUFFER		GEN6_3D(3, 1, 5)
-# define GEN6_3DSTATE_DEPTH_BUFFER_TYPE_SHIFT	29
-# define GEN6_3DSTATE_DEPTH_BUFFER_FORMAT_SHIFT	18
-
-#define GEN6_3DSTATE_POLY_STIPPLE_OFFSET		GEN6_3D(3, 1, 6)
-#define GEN6_3DSTATE_POLY_STIPPLE_PATTERN	GEN6_3D(3, 1, 7)
-#define GEN6_3DSTATE_LINE_STIPPLE		GEN6_3D(3, 1, 8)
-#define GEN6_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP	GEN6_3D(3, 1, 9)
-/* These two are BLC and CTG only, not BW or CL */
-#define GEN6_3DSTATE_AA_LINE_PARAMS		GEN6_3D(3, 1, 0xa)
-#define GEN6_3DSTATE_GS_SVB_INDEX		GEN6_3D(3, 1, 0xb)
-
-#define GEN6_PIPE_CONTROL			GEN6_3D(3, 2, 0)
-
-#define GEN6_3DPRIMITIVE				GEN6_3D(3, 3, 0)
-
-#define GEN6_3DSTATE_CLEAR_PARAMS		GEN6_3D(3, 1, 0x10)
-/* DW1 */
-# define GEN6_3DSTATE_DEPTH_CLEAR_VALID		(1 << 15)
-
-/* for GEN6+ */
-#define GEN6_3DSTATE_SAMPLER_STATE_POINTERS	GEN6_3D(3, 0, 0x02)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_PS	(1 << 12)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_GS	(1 << 9)
-# define GEN6_3DSTATE_SAMPLER_STATE_MODIFY_VS	(1 << 8)
-
-#define GEN6_3DSTATE_URB			GEN6_3D(3, 0, 0x05)
-/* DW1 */
-# define GEN6_3DSTATE_URB_VS_SIZE_SHIFT		16
-# define GEN6_3DSTATE_URB_VS_ENTRIES_SHIFT	0
-/* DW2 */
-# define GEN6_3DSTATE_URB_GS_ENTRIES_SHIFT	8
-# define GEN6_3DSTATE_URB_GS_SIZE_SHIFT		0
-
-#define GEN6_3DSTATE_VIEWPORT_STATE_POINTERS	GEN6_3D(3, 0, 0x0d)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CC		(1 << 12)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_SF		(1 << 11)
-# define GEN6_3DSTATE_VIEWPORT_STATE_MODIFY_CLIP	(1 << 10)
-
-#define GEN6_3DSTATE_CC_STATE_POINTERS		GEN6_3D(3, 0, 0x0e)
-
-#define GEN6_3DSTATE_VS				GEN6_3D(3, 0, 0x10)
-
-#define GEN6_3DSTATE_GS				GEN6_3D(3, 0, 0x11)
-/* DW4 */
-# define GEN6_3DSTATE_GS_DISPATCH_START_GRF_SHIFT	0
-
-#define GEN6_3DSTATE_CLIP			GEN6_3D(3, 0, 0x12)
-
-#define GEN6_3DSTATE_SF				GEN6_3D(3, 0, 0x13)
-/* DW1 */
-# define GEN6_3DSTATE_SF_NUM_OUTPUTS_SHIFT		22
-# define GEN6_3DSTATE_SF_URB_ENTRY_READ_LENGTH_SHIFT	11
-# define GEN6_3DSTATE_SF_URB_ENTRY_READ_OFFSET_SHIFT	4
-/* DW2 */
-/* DW3 */
-# define GEN6_3DSTATE_SF_CULL_BOTH			(0 << 29)
-# define GEN6_3DSTATE_SF_CULL_NONE			(1 << 29)
-# define GEN6_3DSTATE_SF_CULL_FRONT			(2 << 29)
-# define GEN6_3DSTATE_SF_CULL_BACK			(3 << 29)
-/* DW4 */
-# define GEN6_3DSTATE_SF_TRI_PROVOKE_SHIFT		29
-# define GEN6_3DSTATE_SF_LINE_PROVOKE_SHIFT		27
-# define GEN6_3DSTATE_SF_TRIFAN_PROVOKE_SHIFT		25
-
-
-#define GEN6_3DSTATE_WM				GEN6_3D(3, 0, 0x14)
-/* DW2 */
-# define GEN6_3DSTATE_WM_SAMPLER_COUNT_SHITF			27
-# define GEN6_3DSTATE_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
-/* DW4 */
-# define GEN6_3DSTATE_WM_DISPATCH_START_GRF_0_SHIFT		16
-/* DW5 */
-# define GEN6_3DSTATE_WM_MAX_THREADS_SHIFT			25
-# define GEN6_3DSTATE_WM_DISPATCH_ENABLE			(1 << 19)
-# define GEN6_3DSTATE_WM_16_DISPATCH_ENABLE			(1 << 1)
-# define GEN6_3DSTATE_WM_8_DISPATCH_ENABLE			(1 << 0)
-/* DW6 */
-# define GEN6_3DSTATE_WM_NUM_SF_OUTPUTS_SHIFT			20
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	(1 << 15)
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 14)
-# define GEN6_3DSTATE_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	(1 << 13)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC		(1 << 12)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 11)
-# define GEN6_3DSTATE_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		(1 << 10)
-
-
-#define GEN6_3DSTATE_CONSTANT_VS		GEN6_3D(3, 0, 0x15)
-#define GEN6_3DSTATE_CONSTANT_GS          	GEN6_3D(3, 0, 0x16)
-#define GEN6_3DSTATE_CONSTANT_PS          	GEN6_3D(3, 0, 0x17)
-
-#define GEN6_3DSTATE_SAMPLE_MASK		GEN6_3D(3, 0, 0x18)
-
-#define GEN6_3DSTATE_MULTISAMPLE		GEN6_3D(3, 1, 0x0d)
-/* DW1 */
-# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_CENTER		(0 << 4)
-# define GEN6_3DSTATE_MULTISAMPLE_PIXEL_LOCATION_UPPER_LEFT	(1 << 4)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_1			(0 << 1)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_4			(2 << 1)
-# define GEN6_3DSTATE_MULTISAMPLE_NUMSAMPLES_8			(3 << 1)
-
-#define PIPELINE_SELECT_3D		0
-#define PIPELINE_SELECT_MEDIA		1
-
-#define UF0_CS_REALLOC			(1 << 13)
-#define UF0_VFE_REALLOC			(1 << 12)
-#define UF0_SF_REALLOC			(1 << 11)
-#define UF0_CLIP_REALLOC		(1 << 10)
-#define UF0_GS_REALLOC			(1 << 9)
-#define UF0_VS_REALLOC			(1 << 8)
-#define UF1_CLIP_FENCE_SHIFT		20
-#define UF1_GS_FENCE_SHIFT		10
-#define UF1_VS_FENCE_SHIFT		0
-#define UF2_CS_FENCE_SHIFT		20
-#define UF2_VFE_FENCE_SHIFT		10
-#define UF2_SF_FENCE_SHIFT		0
-
-/* for GEN6_STATE_BASE_ADDRESS */
-#define BASE_ADDRESS_MODIFY		(1 << 0)
-
-/* for GEN6_3DSTATE_PIPELINED_POINTERS */
-#define GEN6_GS_DISABLE		       0
-#define GEN6_GS_ENABLE		       1
-#define GEN6_CLIP_DISABLE	       0
-#define GEN6_CLIP_ENABLE		       1
-
-/* for GEN6_PIPE_CONTROL */
-#define GEN6_PIPE_CONTROL_NOWRITE       (0 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_QWORD   (1 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_DEPTH   (2 << 14)
-#define GEN6_PIPE_CONTROL_WRITE_TIME    (3 << 14)
-#define GEN6_PIPE_CONTROL_DEPTH_STALL   (1 << 13)
-#define GEN6_PIPE_CONTROL_WC_FLUSH      (1 << 12)
-#define GEN6_PIPE_CONTROL_IS_FLUSH      (1 << 11)
-#define GEN6_PIPE_CONTROL_TC_FLUSH      (1 << 10)
-#define GEN6_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
-#define GEN6_PIPE_CONTROL_GLOBAL_GTT    (1 << 2)
-#define GEN6_PIPE_CONTROL_LOCAL_PGTT    (0 << 2)
-#define GEN6_PIPE_CONTROL_DEPTH_CACHE_FLUSH	(1 << 0)
-
-/* 3DPRIMITIVE bits */
-#define GEN6_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
-#define GEN6_3DPRIMITIVE_VERTEX_RANDOM	  (1 << 15)
-/* Primitive types are in gen6_defines.h */
-#define GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT	  10
-
-#define GEN6_SVG_CTL		       0x7400
-
-#define GEN6_SVG_CTL_GS_BA	       (0 << 8)
-#define GEN6_SVG_CTL_SS_BA	       (1 << 8)
-#define GEN6_SVG_CTL_IO_BA	       (2 << 8)
-#define GEN6_SVG_CTL_GS_AUB	       (3 << 8)
-#define GEN6_SVG_CTL_IO_AUB	       (4 << 8)
-#define GEN6_SVG_CTL_SIP		       (5 << 8)
-
-#define GEN6_SVG_RDATA		       0x7404
-#define GEN6_SVG_WORK_CTL	       0x7408
-
-#define GEN6_VF_CTL		       0x7500
-
-#define GEN6_VF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID	   (0 << 8)
-#define GEN6_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG	   (1 << 8)
-#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE   (0 << 4)
-#define GEN6_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX	   (1 << 4)
-#define GEN6_VF_CTL_SKIP_INITIAL_PRIMITIVES	   (1 << 3)
-#define GEN6_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE	   (1 << 2)
-#define GEN6_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE	   (1 << 1)
-#define GEN6_VF_CTL_SNAPSHOT_ENABLE	     	   (1 << 0)
-
-#define GEN6_VF_STRG_VAL		       0x7504
-#define GEN6_VF_STR_VL_OVR	       0x7508
-#define GEN6_VF_VC_OVR		       0x750c
-#define GEN6_VF_STR_PSKIP	       0x7510
-#define GEN6_VF_MAX_PRIM		       0x7514
-#define GEN6_VF_RDATA		       0x7518
-
-#define GEN6_VS_CTL		       0x7600
-#define GEN6_VS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_0	   (0 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VERTEX_1	   (1 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VALID_COUNT	   (2 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER  (3 << 8)
-#define GEN6_VS_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
-#define GEN6_VS_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
-#define GEN6_VS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_VS_STRG_VAL		       0x7604
-#define GEN6_VS_RDATA		       0x7608
-
-#define GEN6_SF_CTL		       0x7b00
-#define GEN6_SF_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID	   (0 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID	   (2 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID	   (4 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT	   (6 << 8)
-#define GEN6_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER  (7 << 8)
-#define GEN6_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE  (1 << 4)
-#define GEN6_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE	   (1 << 3)
-#define GEN6_SF_CTL_SNAPSHOT_ALL_THREADS		   (1 << 2)
-#define GEN6_SF_CTL_THREAD_SNAPSHOT_ENABLE	   (1 << 1)
-#define GEN6_SF_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_SF_STRG_VAL		       0x7b04
-#define GEN6_SF_RDATA		       0x7b18
-
-#define GEN6_WIZ_CTL		       0x7c00
-#define GEN6_WIZ_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT	   16
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER   (0 << 8)
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE     (1 << 8)
-#define GEN6_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE   (2 << 8)
-#define GEN6_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH	      (1 << 6)
-#define GEN6_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS    (1 << 5)
-#define GEN6_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE   (1 << 4)
-#define GEN6_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG	      (1 << 3)
-#define GEN6_WIZ_CTL_SNAPSHOT_ALL_THREADS	      (1 << 2)
-#define GEN6_WIZ_CTL_THREAD_SNAPSHOT_ENABLE	      (1 << 1)
-#define GEN6_WIZ_CTL_SNAPSHOT_ENABLE		      (1 << 0)
-
-#define GEN6_WIZ_STRG_VAL			      0x7c04
-#define GEN6_WIZ_RDATA				      0x7c18
-
-#define GEN6_TS_CTL		       0x7e00
-#define GEN6_TS_CTL_SNAPSHOT_COMPLETE		   (1 << 31)
-#define GEN6_TS_CTL_SNAPSHOT_MESSAGE_ERROR	   (0 << 8)
-#define GEN6_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR   (3 << 8)
-#define GEN6_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS	   (1 << 2)
-#define GEN6_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS  	   (1 << 1)
-#define GEN6_TS_CTL_SNAPSHOT_ENABLE		   (1 << 0)
-
-#define GEN6_TS_STRG_VAL		       0x7e04
-#define GEN6_TS_RDATA		       0x7e08
-
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL                   0x8000
-#endif
-#define GEN6_TD_CTL_MUX_SHIFT	       8
-#define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
-#define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
-#define GEN6_TD_CTL_EXCEPTION_MASK_OVERRIDE	   (1 << 5)
-#define GEN6_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE  (1 << 4)
-#define GEN6_TD_CTL_BREAKPOINT_ENABLE		   (1 << 2)
-#define GEN6_TD_CTL2		       0x8004
-#define GEN6_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
-#define GEN6_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE      (1 << 26)
-#define GEN6_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE	      (1 << 25)
-#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT	      16
-#define GEN6_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE	      (1 << 8)
-#define GEN6_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
-#define GEN6_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE	      (1 << 6)
-#define GEN6_TD_CTL2_SF_EXECUTION_MASK_ENABLE	      (1 << 5)
-#define GEN6_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE     (1 << 4)
-#define GEN6_TD_CTL2_GS_EXECUTION_MASK_ENABLE	      (1 << 3)
-#define GEN6_TD_CTL2_VS_EXECUTION_MASK_ENABLE	      (1 << 0)
-#define GEN6_TD_VF_VS_EMSK	       0x8008
-#define GEN6_TD_GS_EMSK		       0x800c
-#define GEN6_TD_CLIP_EMSK	       0x8010
-#define GEN6_TD_SF_EMSK		       0x8014
-#define GEN6_TD_WIZ_EMSK		       0x8018
-#define GEN6_TD_0_6_EHTRG_VAL	       0x801c
-#define GEN6_TD_0_7_EHTRG_VAL	       0x8020
-#define GEN6_TD_0_6_EHTRG_MSK           0x8024
-#define GEN6_TD_0_7_EHTRG_MSK	       0x8028
-#define GEN6_TD_RDATA		       0x802c
-#define GEN6_TD_TS_EMSK		       0x8030
-
-#define GEN6_EU_CTL		       0x8800
-#define GEN6_EU_CTL_SELECT_SHIFT	       16
-#define GEN6_EU_CTL_DATA_MUX_SHIFT      8
-#define GEN6_EU_ATT_0		       0x8810
-#define GEN6_EU_ATT_1		       0x8814
-#define GEN6_EU_ATT_DATA_0	       0x8820
-#define GEN6_EU_ATT_DATA_1	       0x8824
-#define GEN6_EU_ATT_CLR_0	       0x8830
-#define GEN6_EU_ATT_CLR_1	       0x8834
-#define GEN6_EU_RDATA		       0x8840
-
-/* 3D state:
- */
-#define _3DOP_3DSTATE_PIPELINED       0x0
-#define _3DOP_3DSTATE_NONPIPELINED    0x1
-#define _3DOP_3DCONTROL               0x2
-#define _3DOP_3DPRIMITIVE             0x3
-
-#define _3DSTATE_PIPELINED_POINTERS       0x00
-#define _3DSTATE_BINDING_TABLE_POINTERS   0x01
-#define _3DSTATE_VERTEX_BUFFERS           0x08
-#define _3DSTATE_VERTEX_ELEMENTS          0x09
-#define _3DSTATE_INDEX_BUFFER             0x0A
-#define _3DSTATE_VF_STATISTICS            0x0B
-#define _3DSTATE_DRAWING_RECTANGLE            0x00
-#define _3DSTATE_CONSTANT_COLOR               0x01
-#define _3DSTATE_SAMPLER_PALETTE_LOAD         0x02
-#define _3DSTATE_CHROMA_KEY                   0x04
-#define _3DSTATE_DEPTH_BUFFER                 0x05
-#define _3DSTATE_POLY_STIPPLE_OFFSET          0x06
-#define _3DSTATE_POLY_STIPPLE_PATTERN         0x07
-#define _3DSTATE_LINE_STIPPLE                 0x08
-#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP    0x09
-#define _3DCONTROL    0x00
-#define _3DPRIMITIVE  0x00
-
-#define _3DPRIM_POINTLIST         0x01
-#define _3DPRIM_LINELIST          0x02
-#define _3DPRIM_LINESTRIP         0x03
-#define _3DPRIM_TRILIST           0x04
-#define _3DPRIM_TRISTRIP          0x05
-#define _3DPRIM_TRIFAN            0x06
-#define _3DPRIM_QUADLIST          0x07
-#define _3DPRIM_QUADSTRIP         0x08
-#define _3DPRIM_LINELIST_ADJ      0x09
-#define _3DPRIM_LINESTRIP_ADJ     0x0A
-#define _3DPRIM_TRILIST_ADJ       0x0B
-#define _3DPRIM_TRISTRIP_ADJ      0x0C
-#define _3DPRIM_TRISTRIP_REVERSE  0x0D
-#define _3DPRIM_POLYGON           0x0E
-#define _3DPRIM_RECTLIST          0x0F
-#define _3DPRIM_LINELOOP          0x10
-#define _3DPRIM_POINTLIST_BF      0x11
-#define _3DPRIM_LINESTRIP_CONT    0x12
-#define _3DPRIM_LINESTRIP_BF      0x13
-#define _3DPRIM_LINESTRIP_CONT_BF 0x14
-#define _3DPRIM_TRIFAN_NOSTIPPLE  0x15
-
-#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
-#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     1
-
-#define GEN6_ANISORATIO_2     0 
-#define GEN6_ANISORATIO_4     1 
-#define GEN6_ANISORATIO_6     2 
-#define GEN6_ANISORATIO_8     3 
-#define GEN6_ANISORATIO_10    4 
-#define GEN6_ANISORATIO_12    5 
-#define GEN6_ANISORATIO_14    6 
-#define GEN6_ANISORATIO_16    7
-
-#define GEN6_BLENDFACTOR_ONE                 0x1
-#define GEN6_BLENDFACTOR_SRC_COLOR           0x2
-#define GEN6_BLENDFACTOR_SRC_ALPHA           0x3
-#define GEN6_BLENDFACTOR_DST_ALPHA           0x4
-#define GEN6_BLENDFACTOR_DST_COLOR           0x5
-#define GEN6_BLENDFACTOR_SRC_ALPHA_SATURATE  0x6
-#define GEN6_BLENDFACTOR_CONST_COLOR         0x7
-#define GEN6_BLENDFACTOR_CONST_ALPHA         0x8
-#define GEN6_BLENDFACTOR_SRC1_COLOR          0x9
-#define GEN6_BLENDFACTOR_SRC1_ALPHA          0x0A
-#define GEN6_BLENDFACTOR_ZERO                0x11
-#define GEN6_BLENDFACTOR_INV_SRC_COLOR       0x12
-#define GEN6_BLENDFACTOR_INV_SRC_ALPHA       0x13
-#define GEN6_BLENDFACTOR_INV_DST_ALPHA       0x14
-#define GEN6_BLENDFACTOR_INV_DST_COLOR       0x15
-#define GEN6_BLENDFACTOR_INV_CONST_COLOR     0x17
-#define GEN6_BLENDFACTOR_INV_CONST_ALPHA     0x18
-#define GEN6_BLENDFACTOR_INV_SRC1_COLOR      0x19
-#define GEN6_BLENDFACTOR_INV_SRC1_ALPHA      0x1A
-
-#define GEN6_BLENDFUNCTION_ADD               0
-#define GEN6_BLENDFUNCTION_SUBTRACT          1
-#define GEN6_BLENDFUNCTION_REVERSE_SUBTRACT  2
-#define GEN6_BLENDFUNCTION_MIN               3
-#define GEN6_BLENDFUNCTION_MAX               4
-
-#define GEN6_ALPHATEST_FORMAT_UNORM8         0
-#define GEN6_ALPHATEST_FORMAT_FLOAT32        1
-
-#define GEN6_CHROMAKEY_KILL_ON_ANY_MATCH  0
-#define GEN6_CHROMAKEY_REPLACE_BLACK      1
-
-#define GEN6_CLIP_API_OGL     0
-#define GEN6_CLIP_API_DX      1
-
-#define GEN6_CLIPMODE_NORMAL              0
-#define GEN6_CLIPMODE_CLIP_ALL            1
-#define GEN6_CLIPMODE_CLIP_NON_REJECTED   2
-#define GEN6_CLIPMODE_REJECT_ALL          3
-#define GEN6_CLIPMODE_ACCEPT_ALL          4
-
-#define GEN6_CLIP_NDCSPACE     0
-#define GEN6_CLIP_SCREENSPACE  1
-
-#define GEN6_COMPAREFUNCTION_ALWAYS       0
-#define GEN6_COMPAREFUNCTION_NEVER        1
-#define GEN6_COMPAREFUNCTION_LESS         2
-#define GEN6_COMPAREFUNCTION_EQUAL        3
-#define GEN6_COMPAREFUNCTION_LEQUAL       4
-#define GEN6_COMPAREFUNCTION_GREATER      5
-#define GEN6_COMPAREFUNCTION_NOTEQUAL     6
-#define GEN6_COMPAREFUNCTION_GEQUAL       7
-
-#define GEN6_COVERAGE_PIXELS_HALF     0
-#define GEN6_COVERAGE_PIXELS_1        1
-#define GEN6_COVERAGE_PIXELS_2        2
-#define GEN6_COVERAGE_PIXELS_4        3
-
-#define GEN6_CULLMODE_BOTH        0
-#define GEN6_CULLMODE_NONE        1
-#define GEN6_CULLMODE_FRONT       2
-#define GEN6_CULLMODE_BACK        3
-
-#define GEN6_DEFAULTCOLOR_R8G8B8A8_UNORM      0
-#define GEN6_DEFAULTCOLOR_R32G32B32A32_FLOAT  1
-
-#define GEN6_DEPTHFORMAT_D32_FLOAT_S8X24_UINT     0
-#define GEN6_DEPTHFORMAT_D32_FLOAT                1
-#define GEN6_DEPTHFORMAT_D24_UNORM_S8_UINT        2
-#define GEN6_DEPTHFORMAT_D16_UNORM                5
-
-#define GEN6_FLOATING_POINT_IEEE_754        0
-#define GEN6_FLOATING_POINT_NON_IEEE_754    1
-
-#define GEN6_FRONTWINDING_CW      0
-#define GEN6_FRONTWINDING_CCW     1
-
-#define GEN6_INDEX_BYTE     0
-#define GEN6_INDEX_WORD     1
-#define GEN6_INDEX_DWORD    2
-
-#define GEN6_LOGICOPFUNCTION_CLEAR            0
-#define GEN6_LOGICOPFUNCTION_NOR              1
-#define GEN6_LOGICOPFUNCTION_AND_INVERTED     2
-#define GEN6_LOGICOPFUNCTION_COPY_INVERTED    3
-#define GEN6_LOGICOPFUNCTION_AND_REVERSE      4
-#define GEN6_LOGICOPFUNCTION_INVERT           5
-#define GEN6_LOGICOPFUNCTION_XOR              6
-#define GEN6_LOGICOPFUNCTION_NAND             7
-#define GEN6_LOGICOPFUNCTION_AND              8
-#define GEN6_LOGICOPFUNCTION_EQUIV            9
-#define GEN6_LOGICOPFUNCTION_NOOP             10
-#define GEN6_LOGICOPFUNCTION_OR_INVERTED      11
-#define GEN6_LOGICOPFUNCTION_COPY             12
-#define GEN6_LOGICOPFUNCTION_OR_REVERSE       13
-#define GEN6_LOGICOPFUNCTION_OR               14
-#define GEN6_LOGICOPFUNCTION_SET              15  
-
-#define GEN6_MAPFILTER_NEAREST        0x0 
-#define GEN6_MAPFILTER_LINEAR         0x1 
-#define GEN6_MAPFILTER_ANISOTROPIC    0x2
-
-#define GEN6_MIPFILTER_NONE        0   
-#define GEN6_MIPFILTER_NEAREST     1   
-#define GEN6_MIPFILTER_LINEAR      3
-
-#define GEN6_POLYGON_FRONT_FACING     0
-#define GEN6_POLYGON_BACK_FACING      1
-
-#define GEN6_PREFILTER_ALWAYS     0x0 
-#define GEN6_PREFILTER_NEVER      0x1
-#define GEN6_PREFILTER_LESS       0x2
-#define GEN6_PREFILTER_EQUAL      0x3
-#define GEN6_PREFILTER_LEQUAL     0x4
-#define GEN6_PREFILTER_GREATER    0x5
-#define GEN6_PREFILTER_NOTEQUAL   0x6
-#define GEN6_PREFILTER_GEQUAL     0x7
-
-#define GEN6_PROVOKING_VERTEX_0    0
-#define GEN6_PROVOKING_VERTEX_1    1 
-#define GEN6_PROVOKING_VERTEX_2    2
-
-#define GEN6_RASTRULE_UPPER_LEFT  0    
-#define GEN6_RASTRULE_UPPER_RIGHT 1
-
-#define GEN6_RENDERTARGET_CLAMPRANGE_UNORM    0
-#define GEN6_RENDERTARGET_CLAMPRANGE_SNORM    1
-#define GEN6_RENDERTARGET_CLAMPRANGE_FORMAT   2
-
-#define GEN6_STENCILOP_KEEP               0
-#define GEN6_STENCILOP_ZERO               1
-#define GEN6_STENCILOP_REPLACE            2
-#define GEN6_STENCILOP_INCRSAT            3
-#define GEN6_STENCILOP_DECRSAT            4
-#define GEN6_STENCILOP_INCR               5
-#define GEN6_STENCILOP_DECR               6
-#define GEN6_STENCILOP_INVERT             7
-
-#define GEN6_SURFACE_MIPMAPLAYOUT_BELOW   0
-#define GEN6_SURFACE_MIPMAPLAYOUT_RIGHT   1
-
-#define GEN6_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
-#define GEN6_SURFACEFORMAT_R32G32B32A32_SINT              0x001
-#define GEN6_SURFACEFORMAT_R32G32B32A32_UINT              0x002
-#define GEN6_SURFACEFORMAT_R32G32B32A32_UNORM             0x003
-#define GEN6_SURFACEFORMAT_R32G32B32A32_SNORM             0x004
-#define GEN6_SURFACEFORMAT_R64G64_FLOAT                   0x005
-#define GEN6_SURFACEFORMAT_R32G32B32X32_FLOAT             0x006
-#define GEN6_SURFACEFORMAT_R32G32B32A32_SSCALED           0x007
-#define GEN6_SURFACEFORMAT_R32G32B32A32_USCALED           0x008
-#define GEN6_SURFACEFORMAT_R32G32B32_FLOAT                0x040
-#define GEN6_SURFACEFORMAT_R32G32B32_SINT                 0x041
-#define GEN6_SURFACEFORMAT_R32G32B32_UINT                 0x042
-#define GEN6_SURFACEFORMAT_R32G32B32_UNORM                0x043
-#define GEN6_SURFACEFORMAT_R32G32B32_SNORM                0x044
-#define GEN6_SURFACEFORMAT_R32G32B32_SSCALED              0x045
-#define GEN6_SURFACEFORMAT_R32G32B32_USCALED              0x046
-#define GEN6_SURFACEFORMAT_R16G16B16A16_UNORM             0x080
-#define GEN6_SURFACEFORMAT_R16G16B16A16_SNORM             0x081
-#define GEN6_SURFACEFORMAT_R16G16B16A16_SINT              0x082
-#define GEN6_SURFACEFORMAT_R16G16B16A16_UINT              0x083
-#define GEN6_SURFACEFORMAT_R16G16B16A16_FLOAT             0x084
-#define GEN6_SURFACEFORMAT_R32G32_FLOAT                   0x085
-#define GEN6_SURFACEFORMAT_R32G32_SINT                    0x086
-#define GEN6_SURFACEFORMAT_R32G32_UINT                    0x087
-#define GEN6_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS       0x088
-#define GEN6_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT        0x089
-#define GEN6_SURFACEFORMAT_L32A32_FLOAT                   0x08A
-#define GEN6_SURFACEFORMAT_R32G32_UNORM                   0x08B
-#define GEN6_SURFACEFORMAT_R32G32_SNORM                   0x08C
-#define GEN6_SURFACEFORMAT_R64_FLOAT                      0x08D
-#define GEN6_SURFACEFORMAT_R16G16B16X16_UNORM             0x08E
-#define GEN6_SURFACEFORMAT_R16G16B16X16_FLOAT             0x08F
-#define GEN6_SURFACEFORMAT_A32X32_FLOAT                   0x090
-#define GEN6_SURFACEFORMAT_L32X32_FLOAT                   0x091
-#define GEN6_SURFACEFORMAT_I32X32_FLOAT                   0x092
-#define GEN6_SURFACEFORMAT_R16G16B16A16_SSCALED           0x093
-#define GEN6_SURFACEFORMAT_R16G16B16A16_USCALED           0x094
-#define GEN6_SURFACEFORMAT_R32G32_SSCALED                 0x095
-#define GEN6_SURFACEFORMAT_R32G32_USCALED                 0x096
-#define GEN6_SURFACEFORMAT_B8G8R8A8_UNORM                 0x0C0
-#define GEN6_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB            0x0C1
-#define GEN6_SURFACEFORMAT_R10G10B10A2_UNORM              0x0C2
-#define GEN6_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB         0x0C3
-#define GEN6_SURFACEFORMAT_R10G10B10A2_UINT               0x0C4
-#define GEN6_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM       0x0C5
-#define GEN6_SURFACEFORMAT_R8G8B8A8_UNORM                 0x0C7
-#define GEN6_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB            0x0C8
-#define GEN6_SURFACEFORMAT_R8G8B8A8_SNORM                 0x0C9
-#define GEN6_SURFACEFORMAT_R8G8B8A8_SINT                  0x0CA
-#define GEN6_SURFACEFORMAT_R8G8B8A8_UINT                  0x0CB
-#define GEN6_SURFACEFORMAT_R16G16_UNORM                   0x0CC
-#define GEN6_SURFACEFORMAT_R16G16_SNORM                   0x0CD
-#define GEN6_SURFACEFORMAT_R16G16_SINT                    0x0CE
-#define GEN6_SURFACEFORMAT_R16G16_UINT                    0x0CF
-#define GEN6_SURFACEFORMAT_R16G16_FLOAT                   0x0D0
-#define GEN6_SURFACEFORMAT_B10G10R10A2_UNORM              0x0D1
-#define GEN6_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB         0x0D2
-#define GEN6_SURFACEFORMAT_R11G11B10_FLOAT                0x0D3
-#define GEN6_SURFACEFORMAT_R32_SINT                       0x0D6
-#define GEN6_SURFACEFORMAT_R32_UINT                       0x0D7
-#define GEN6_SURFACEFORMAT_R32_FLOAT                      0x0D8
-#define GEN6_SURFACEFORMAT_R24_UNORM_X8_TYPELESS          0x0D9
-#define GEN6_SURFACEFORMAT_X24_TYPELESS_G8_UINT           0x0DA
-#define GEN6_SURFACEFORMAT_L16A16_UNORM                   0x0DF
-#define GEN6_SURFACEFORMAT_I24X8_UNORM                    0x0E0
-#define GEN6_SURFACEFORMAT_L24X8_UNORM                    0x0E1
-#define GEN6_SURFACEFORMAT_A24X8_UNORM                    0x0E2
-#define GEN6_SURFACEFORMAT_I32_FLOAT                      0x0E3
-#define GEN6_SURFACEFORMAT_L32_FLOAT                      0x0E4
-#define GEN6_SURFACEFORMAT_A32_FLOAT                      0x0E5
-#define GEN6_SURFACEFORMAT_B8G8R8X8_UNORM                 0x0E9
-#define GEN6_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB            0x0EA
-#define GEN6_SURFACEFORMAT_R8G8B8X8_UNORM                 0x0EB
-#define GEN6_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB            0x0EC
-#define GEN6_SURFACEFORMAT_R9G9B9E5_SHAREDEXP             0x0ED
-#define GEN6_SURFACEFORMAT_B10G10R10X2_UNORM              0x0EE
-#define GEN6_SURFACEFORMAT_L16A16_FLOAT                   0x0F0
-#define GEN6_SURFACEFORMAT_R32_UNORM                      0x0F1
-#define GEN6_SURFACEFORMAT_R32_SNORM                      0x0F2
-#define GEN6_SURFACEFORMAT_R10G10B10X2_USCALED            0x0F3
-#define GEN6_SURFACEFORMAT_R8G8B8A8_SSCALED               0x0F4
-#define GEN6_SURFACEFORMAT_R8G8B8A8_USCALED               0x0F5
-#define GEN6_SURFACEFORMAT_R16G16_SSCALED                 0x0F6
-#define GEN6_SURFACEFORMAT_R16G16_USCALED                 0x0F7
-#define GEN6_SURFACEFORMAT_R32_SSCALED                    0x0F8
-#define GEN6_SURFACEFORMAT_R32_USCALED                    0x0F9
-#define GEN6_SURFACEFORMAT_B5G6R5_UNORM                   0x100
-#define GEN6_SURFACEFORMAT_B5G6R5_UNORM_SRGB              0x101
-#define GEN6_SURFACEFORMAT_B5G5R5A1_UNORM                 0x102
-#define GEN6_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB            0x103
-#define GEN6_SURFACEFORMAT_B4G4R4A4_UNORM                 0x104
-#define GEN6_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB            0x105
-#define GEN6_SURFACEFORMAT_R8G8_UNORM                     0x106
-#define GEN6_SURFACEFORMAT_R8G8_SNORM                     0x107
-#define GEN6_SURFACEFORMAT_R8G8_SINT                      0x108
-#define GEN6_SURFACEFORMAT_R8G8_UINT                      0x109
-#define GEN6_SURFACEFORMAT_R16_UNORM                      0x10A
-#define GEN6_SURFACEFORMAT_R16_SNORM                      0x10B
-#define GEN6_SURFACEFORMAT_R16_SINT                       0x10C
-#define GEN6_SURFACEFORMAT_R16_UINT                       0x10D
-#define GEN6_SURFACEFORMAT_R16_FLOAT                      0x10E
-#define GEN6_SURFACEFORMAT_I16_UNORM                      0x111
-#define GEN6_SURFACEFORMAT_L16_UNORM                      0x112
-#define GEN6_SURFACEFORMAT_A16_UNORM                      0x113
-#define GEN6_SURFACEFORMAT_L8A8_UNORM                     0x114
-#define GEN6_SURFACEFORMAT_I16_FLOAT                      0x115
-#define GEN6_SURFACEFORMAT_L16_FLOAT                      0x116
-#define GEN6_SURFACEFORMAT_A16_FLOAT                      0x117
-#define GEN6_SURFACEFORMAT_R5G5_SNORM_B6_UNORM            0x119
-#define GEN6_SURFACEFORMAT_B5G5R5X1_UNORM                 0x11A
-#define GEN6_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB            0x11B
-#define GEN6_SURFACEFORMAT_R8G8_SSCALED                   0x11C
-#define GEN6_SURFACEFORMAT_R8G8_USCALED                   0x11D
-#define GEN6_SURFACEFORMAT_R16_SSCALED                    0x11E
-#define GEN6_SURFACEFORMAT_R16_USCALED                    0x11F
-#define GEN6_SURFACEFORMAT_R8_UNORM                       0x140
-#define GEN6_SURFACEFORMAT_R8_SNORM                       0x141
-#define GEN6_SURFACEFORMAT_R8_SINT                        0x142
-#define GEN6_SURFACEFORMAT_R8_UINT                        0x143
-#define GEN6_SURFACEFORMAT_A8_UNORM                       0x144
-#define GEN6_SURFACEFORMAT_I8_UNORM                       0x145
-#define GEN6_SURFACEFORMAT_L8_UNORM                       0x146
-#define GEN6_SURFACEFORMAT_P4A4_UNORM                     0x147
-#define GEN6_SURFACEFORMAT_A4P4_UNORM                     0x148
-#define GEN6_SURFACEFORMAT_R8_SSCALED                     0x149
-#define GEN6_SURFACEFORMAT_R8_USCALED                     0x14A
-#define GEN6_SURFACEFORMAT_R1_UINT                        0x181
-#define GEN6_SURFACEFORMAT_YCRCB_NORMAL                   0x182
-#define GEN6_SURFACEFORMAT_YCRCB_SWAPUVY                  0x183
-#define GEN6_SURFACEFORMAT_BC1_UNORM                      0x186
-#define GEN6_SURFACEFORMAT_BC2_UNORM                      0x187
-#define GEN6_SURFACEFORMAT_BC3_UNORM                      0x188
-#define GEN6_SURFACEFORMAT_BC4_UNORM                      0x189
-#define GEN6_SURFACEFORMAT_BC5_UNORM                      0x18A
-#define GEN6_SURFACEFORMAT_BC1_UNORM_SRGB                 0x18B
-#define GEN6_SURFACEFORMAT_BC2_UNORM_SRGB                 0x18C
-#define GEN6_SURFACEFORMAT_BC3_UNORM_SRGB                 0x18D
-#define GEN6_SURFACEFORMAT_MONO8                          0x18E
-#define GEN6_SURFACEFORMAT_YCRCB_SWAPUV                   0x18F
-#define GEN6_SURFACEFORMAT_YCRCB_SWAPY                    0x190
-#define GEN6_SURFACEFORMAT_DXT1_RGB                       0x191
-#define GEN6_SURFACEFORMAT_FXT1                           0x192
-#define GEN6_SURFACEFORMAT_R8G8B8_UNORM                   0x193
-#define GEN6_SURFACEFORMAT_R8G8B8_SNORM                   0x194
-#define GEN6_SURFACEFORMAT_R8G8B8_SSCALED                 0x195
-#define GEN6_SURFACEFORMAT_R8G8B8_USCALED                 0x196
-#define GEN6_SURFACEFORMAT_R64G64B64A64_FLOAT             0x197
-#define GEN6_SURFACEFORMAT_R64G64B64_FLOAT                0x198
-#define GEN6_SURFACEFORMAT_BC4_SNORM                      0x199
-#define GEN6_SURFACEFORMAT_BC5_SNORM                      0x19A
-#define GEN6_SURFACEFORMAT_R16G16B16_UNORM                0x19C
-#define GEN6_SURFACEFORMAT_R16G16B16_SNORM                0x19D
-#define GEN6_SURFACEFORMAT_R16G16B16_SSCALED              0x19E
-#define GEN6_SURFACEFORMAT_R16G16B16_USCALED              0x19F
-
-#define GEN6_SURFACERETURNFORMAT_FLOAT32  0
-#define GEN6_SURFACERETURNFORMAT_S1       1
-
-#define GEN6_SURFACE_1D      0
-#define GEN6_SURFACE_2D      1
-#define GEN6_SURFACE_3D      2
-#define GEN6_SURFACE_CUBE    3
-#define GEN6_SURFACE_BUFFER  4
-#define GEN6_SURFACE_NULL    7
-
-#define GEN6_BORDER_COLOR_MODE_DEFAULT	0
-#define GEN6_BORDER_COLOR_MODE_LEGACY	1
-
-#define GEN6_TEXCOORDMODE_WRAP            0
-#define GEN6_TEXCOORDMODE_MIRROR          1
-#define GEN6_TEXCOORDMODE_CLAMP           2
-#define GEN6_TEXCOORDMODE_CUBE            3
-#define GEN6_TEXCOORDMODE_CLAMP_BORDER    4
-#define GEN6_TEXCOORDMODE_MIRROR_ONCE     5
-
-#define GEN6_THREAD_PRIORITY_NORMAL   0
-#define GEN6_THREAD_PRIORITY_HIGH     1
-
-#define GEN6_TILEWALK_XMAJOR                 0
-#define GEN6_TILEWALK_YMAJOR                 1
-
-#define GEN6_VERTEX_SUBPIXEL_PRECISION_8BITS  0
-#define GEN6_VERTEX_SUBPIXEL_PRECISION_4BITS  1
-
-#define GEN6_VERTEXBUFFER_ACCESS_VERTEXDATA     0
-#define GEN6_VERTEXBUFFER_ACCESS_INSTANCEDATA   1
-
-#define GEN6_VFCOMPONENT_NOSTORE      0
-#define GEN6_VFCOMPONENT_STORE_SRC    1
-#define GEN6_VFCOMPONENT_STORE_0      2
-#define GEN6_VFCOMPONENT_STORE_1_FLT  3
-#define GEN6_VFCOMPONENT_STORE_1_INT  4
-#define GEN6_VFCOMPONENT_STORE_VID    5
-#define GEN6_VFCOMPONENT_STORE_IID    6
-#define GEN6_VFCOMPONENT_STORE_PID    7
-
-
-
-/* Execution Unit (EU) defines
- */
-
-#define GEN6_ALIGN_1   0
-#define GEN6_ALIGN_16  1
-
-#define GEN6_ADDRESS_DIRECT                        0
-#define GEN6_ADDRESS_REGISTER_INDIRECT_REGISTER    1
-
-#define GEN6_CHANNEL_X     0
-#define GEN6_CHANNEL_Y     1
-#define GEN6_CHANNEL_Z     2
-#define GEN6_CHANNEL_W     3
-
-#define GEN6_COMPRESSION_NONE          0
-#define GEN6_COMPRESSION_2NDHALF       1
-#define GEN6_COMPRESSION_COMPRESSED    2
-
-#define GEN6_CONDITIONAL_NONE  0
-#define GEN6_CONDITIONAL_Z     1
-#define GEN6_CONDITIONAL_NZ    2
-#define GEN6_CONDITIONAL_EQ    1	/* Z */
-#define GEN6_CONDITIONAL_NEQ   2	/* NZ */
-#define GEN6_CONDITIONAL_G     3
-#define GEN6_CONDITIONAL_GE    4
-#define GEN6_CONDITIONAL_L     5
-#define GEN6_CONDITIONAL_LE    6
-#define GEN6_CONDITIONAL_C     7
-#define GEN6_CONDITIONAL_O     8
-
-#define GEN6_DEBUG_NONE        0
-#define GEN6_DEBUG_BREAKPOINT  1
-
-#define GEN6_DEPENDENCY_NORMAL         0
-#define GEN6_DEPENDENCY_NOTCLEARED     1
-#define GEN6_DEPENDENCY_NOTCHECKED     2
-#define GEN6_DEPENDENCY_DISABLE        3
-
-#define GEN6_EXECUTE_1     0
-#define GEN6_EXECUTE_2     1
-#define GEN6_EXECUTE_4     2
-#define GEN6_EXECUTE_8     3
-#define GEN6_EXECUTE_16    4
-#define GEN6_EXECUTE_32    5
-
-#define GEN6_HORIZONTAL_STRIDE_0   0
-#define GEN6_HORIZONTAL_STRIDE_1   1
-#define GEN6_HORIZONTAL_STRIDE_2   2
-#define GEN6_HORIZONTAL_STRIDE_4   3
-
-#define GEN6_INSTRUCTION_NORMAL    0
-#define GEN6_INSTRUCTION_SATURATE  1
-
-#define GEN6_MASK_ENABLE   0
-#define GEN6_MASK_DISABLE  1
-
-#define GEN6_OPCODE_MOV        1
-#define GEN6_OPCODE_SEL        2
-#define GEN6_OPCODE_NOT        4
-#define GEN6_OPCODE_AND        5
-#define GEN6_OPCODE_OR         6
-#define GEN6_OPCODE_XOR        7
-#define GEN6_OPCODE_SHR        8
-#define GEN6_OPCODE_SHL        9
-#define GEN6_OPCODE_RSR        10
-#define GEN6_OPCODE_RSL        11
-#define GEN6_OPCODE_ASR        12
-#define GEN6_OPCODE_CMP        16
-#define GEN6_OPCODE_JMPI       32
-#define GEN6_OPCODE_IF         34
-#define GEN6_OPCODE_IFF        35
-#define GEN6_OPCODE_ELSE       36
-#define GEN6_OPCODE_ENDIF      37
-#define GEN6_OPCODE_DO         38
-#define GEN6_OPCODE_WHILE      39
-#define GEN6_OPCODE_BREAK      40
-#define GEN6_OPCODE_CONTINUE   41
-#define GEN6_OPCODE_HALT       42
-#define GEN6_OPCODE_MSAVE      44
-#define GEN6_OPCODE_MRESTORE   45
-#define GEN6_OPCODE_PUSH       46
-#define GEN6_OPCODE_POP        47
-#define GEN6_OPCODE_WAIT       48
-#define GEN6_OPCODE_SEND       49
-#define GEN6_OPCODE_ADD        64
-#define GEN6_OPCODE_MUL        65
-#define GEN6_OPCODE_AVG        66
-#define GEN6_OPCODE_FRC        67
-#define GEN6_OPCODE_RNDU       68
-#define GEN6_OPCODE_RNDD       69
-#define GEN6_OPCODE_RNDE       70
-#define GEN6_OPCODE_RNDZ       71
-#define GEN6_OPCODE_MAC        72
-#define GEN6_OPCODE_MACH       73
-#define GEN6_OPCODE_LZD        74
-#define GEN6_OPCODE_SAD2       80
-#define GEN6_OPCODE_SADA2      81
-#define GEN6_OPCODE_DP4        84
-#define GEN6_OPCODE_DPH        85
-#define GEN6_OPCODE_DP3        86
-#define GEN6_OPCODE_DP2        87
-#define GEN6_OPCODE_DPA2       88
-#define GEN6_OPCODE_LINE       89
-#define GEN6_OPCODE_NOP        126
-
-#define GEN6_PREDICATE_NONE             0
-#define GEN6_PREDICATE_NORMAL           1
-#define GEN6_PREDICATE_ALIGN1_ANYV             2
-#define GEN6_PREDICATE_ALIGN1_ALLV             3
-#define GEN6_PREDICATE_ALIGN1_ANY2H            4
-#define GEN6_PREDICATE_ALIGN1_ALL2H            5
-#define GEN6_PREDICATE_ALIGN1_ANY4H            6
-#define GEN6_PREDICATE_ALIGN1_ALL4H            7
-#define GEN6_PREDICATE_ALIGN1_ANY8H            8
-#define GEN6_PREDICATE_ALIGN1_ALL8H            9
-#define GEN6_PREDICATE_ALIGN1_ANY16H           10
-#define GEN6_PREDICATE_ALIGN1_ALL16H           11
-#define GEN6_PREDICATE_ALIGN16_REPLICATE_X     2
-#define GEN6_PREDICATE_ALIGN16_REPLICATE_Y     3
-#define GEN6_PREDICATE_ALIGN16_REPLICATE_Z     4
-#define GEN6_PREDICATE_ALIGN16_REPLICATE_W     5
-#define GEN6_PREDICATE_ALIGN16_ANY4H           6
-#define GEN6_PREDICATE_ALIGN16_ALL4H           7
-
-#define GEN6_ARCHITECTURE_REGISTER_FILE    0
-#define GEN6_GENERAL_REGISTER_FILE         1
-#define GEN6_MESSAGE_REGISTER_FILE         2
-#define GEN6_IMMEDIATE_VALUE               3
-
-#define GEN6_REGISTER_TYPE_UD  0
-#define GEN6_REGISTER_TYPE_D   1
-#define GEN6_REGISTER_TYPE_UW  2
-#define GEN6_REGISTER_TYPE_W   3
-#define GEN6_REGISTER_TYPE_UB  4
-#define GEN6_REGISTER_TYPE_B   5
-#define GEN6_REGISTER_TYPE_VF  5	/* packed float vector, immediates only? */
-#define GEN6_REGISTER_TYPE_HF  6
-#define GEN6_REGISTER_TYPE_V   6	/* packed int vector, immediates only, uword dest only */
-#define GEN6_REGISTER_TYPE_F   7
-
-#define GEN6_ARF_NULL                  0x00
-#define GEN6_ARF_ADDRESS               0x10
-#define GEN6_ARF_ACCUMULATOR           0x20   
-#define GEN6_ARF_FLAG                  0x30
-#define GEN6_ARF_MASK                  0x40
-#define GEN6_ARF_MASK_STACK            0x50
-#define GEN6_ARF_MASK_STACK_DEPTH      0x60
-#define GEN6_ARF_STATE                 0x70
-#define GEN6_ARF_CONTROL               0x80
-#define GEN6_ARF_NOTIFICATION_COUNT    0x90
-#define GEN6_ARF_IP                    0xA0
-
-#define GEN6_AMASK   0
-#define GEN6_IMASK   1
-#define GEN6_LMASK   2
-#define GEN6_CMASK   3
-
-
-
-#define GEN6_THREAD_NORMAL     0
-#define GEN6_THREAD_ATOMIC     1
-#define GEN6_THREAD_SWITCH     2
-
-#define GEN6_VERTICAL_STRIDE_0                 0
-#define GEN6_VERTICAL_STRIDE_1                 1
-#define GEN6_VERTICAL_STRIDE_2                 2
-#define GEN6_VERTICAL_STRIDE_4                 3
-#define GEN6_VERTICAL_STRIDE_8                 4
-#define GEN6_VERTICAL_STRIDE_16                5
-#define GEN6_VERTICAL_STRIDE_32                6
-#define GEN6_VERTICAL_STRIDE_64                7
-#define GEN6_VERTICAL_STRIDE_128               8
-#define GEN6_VERTICAL_STRIDE_256               9
-#define GEN6_VERTICAL_STRIDE_ONE_DIMENSIONAL   0xF
-
-#define GEN6_WIDTH_1       0
-#define GEN6_WIDTH_2       1
-#define GEN6_WIDTH_4       2
-#define GEN6_WIDTH_8       3
-#define GEN6_WIDTH_16      4
-
-#define GEN6_STATELESS_BUFFER_BOUNDARY_1K      0
-#define GEN6_STATELESS_BUFFER_BOUNDARY_2K      1
-#define GEN6_STATELESS_BUFFER_BOUNDARY_4K      2
-#define GEN6_STATELESS_BUFFER_BOUNDARY_8K      3
-#define GEN6_STATELESS_BUFFER_BOUNDARY_16K     4
-#define GEN6_STATELESS_BUFFER_BOUNDARY_32K     5
-#define GEN6_STATELESS_BUFFER_BOUNDARY_64K     6
-#define GEN6_STATELESS_BUFFER_BOUNDARY_128K    7
-#define GEN6_STATELESS_BUFFER_BOUNDARY_256K    8
-#define GEN6_STATELESS_BUFFER_BOUNDARY_512K    9
-#define GEN6_STATELESS_BUFFER_BOUNDARY_1M      10
-#define GEN6_STATELESS_BUFFER_BOUNDARY_2M      11
-
-#define GEN6_POLYGON_FACING_FRONT      0
-#define GEN6_POLYGON_FACING_BACK       1
-
-#define GEN6_MESSAGE_TARGET_NULL               0
-#define GEN6_MESSAGE_TARGET_MATH               1
-#define GEN6_MESSAGE_TARGET_SAMPLER            2
-#define GEN6_MESSAGE_TARGET_GATEWAY            3
-#define GEN6_MESSAGE_TARGET_DATAPORT_READ      4
-#define GEN6_MESSAGE_TARGET_DATAPORT_WRITE     5
-#define GEN6_MESSAGE_TARGET_URB                6
-#define GEN6_MESSAGE_TARGET_THREAD_SPAWNER     7
-
-#define GEN6_SAMPLER_RETURN_FORMAT_FLOAT32     0
-#define GEN6_SAMPLER_RETURN_FORMAT_UINT32      2
-#define GEN6_SAMPLER_RETURN_FORMAT_SINT32      3
-
-#define GEN6_SAMPLER_MESSAGE_SIMD8_SAMPLE              0
-#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE             0
-#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS        0
-#define GEN6_SAMPLER_MESSAGE_SIMD8_KILLPIX             1
-#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD        1
-#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD         1
-#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS  2
-#define GEN6_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS    2
-#define GEN6_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE    0
-#define GEN6_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE     2
-#define GEN6_SAMPLER_MESSAGE_SIMD4X2_RESINFO           2
-#define GEN6_SAMPLER_MESSAGE_SIMD8_RESINFO             2
-#define GEN6_SAMPLER_MESSAGE_SIMD16_RESINFO            2
-#define GEN6_SAMPLER_MESSAGE_SIMD4X2_LD                3
-#define GEN6_SAMPLER_MESSAGE_SIMD8_LD                  3
-#define GEN6_SAMPLER_MESSAGE_SIMD16_LD                 3
-
-#define GEN6_DATAPORT_OWORD_BLOCK_1_OWORDLOW   0
-#define GEN6_DATAPORT_OWORD_BLOCK_1_OWORDHIGH  1
-#define GEN6_DATAPORT_OWORD_BLOCK_2_OWORDS     2
-#define GEN6_DATAPORT_OWORD_BLOCK_4_OWORDS     3
-#define GEN6_DATAPORT_OWORD_BLOCK_8_OWORDS     4
-
-#define GEN6_DATAPORT_OWORD_DUAL_BLOCK_1OWORD     0
-#define GEN6_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS    2
-
-#define GEN6_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS   2
-#define GEN6_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS  3
-
-#define GEN6_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ          0
-#define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     1
-#define GEN6_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ          2
-#define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      3
-
-#define GEN6_DATAPORT_READ_TARGET_DATA_CACHE      0
-#define GEN6_DATAPORT_READ_TARGET_RENDER_CACHE    1
-#define GEN6_DATAPORT_READ_TARGET_SAMPLER_CACHE   2
-
-#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE                0
-#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED     1
-#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01         2
-#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23         3
-#define GEN6_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01       4
-
-#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE                0
-#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE           1
-#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE                2
-#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE            3
-#define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE              4
-#define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE     5
-#define GEN6_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE               7
-
-#define GEN6_MATH_FUNCTION_INV                              1
-#define GEN6_MATH_FUNCTION_LOG                              2
-#define GEN6_MATH_FUNCTION_EXP                              3
-#define GEN6_MATH_FUNCTION_SQRT                             4
-#define GEN6_MATH_FUNCTION_RSQ                              5
-#define GEN6_MATH_FUNCTION_SIN                              6 /* was 7 */
-#define GEN6_MATH_FUNCTION_COS                              7 /* was 8 */
-#define GEN6_MATH_FUNCTION_SINCOS                           8 /* was 6 */
-#define GEN6_MATH_FUNCTION_TAN                              9
-#define GEN6_MATH_FUNCTION_POW                              10
-#define GEN6_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER   11
-#define GEN6_MATH_FUNCTION_INT_DIV_QUOTIENT                 12
-#define GEN6_MATH_FUNCTION_INT_DIV_REMAINDER                13
-
-#define GEN6_MATH_INTEGER_UNSIGNED     0
-#define GEN6_MATH_INTEGER_SIGNED       1
-
-#define GEN6_MATH_PRECISION_FULL        0
-#define GEN6_MATH_PRECISION_PARTIAL     1
-
-#define GEN6_MATH_SATURATE_NONE         0
-#define GEN6_MATH_SATURATE_SATURATE     1
-
-#define GEN6_MATH_DATA_VECTOR  0
-#define GEN6_MATH_DATA_SCALAR  1
-
-#define GEN6_URB_OPCODE_WRITE  0
-
-#define GEN6_URB_SWIZZLE_NONE          0
-#define GEN6_URB_SWIZZLE_INTERLEAVE    1
-#define GEN6_URB_SWIZZLE_TRANSPOSE     2
-
-#define GEN6_SCRATCH_SPACE_SIZE_1K     0
-#define GEN6_SCRATCH_SPACE_SIZE_2K     1
-#define GEN6_SCRATCH_SPACE_SIZE_4K     2
-#define GEN6_SCRATCH_SPACE_SIZE_8K     3
-#define GEN6_SCRATCH_SPACE_SIZE_16K    4
-#define GEN6_SCRATCH_SPACE_SIZE_32K    5
-#define GEN6_SCRATCH_SPACE_SIZE_64K    6
-#define GEN6_SCRATCH_SPACE_SIZE_128K   7
-#define GEN6_SCRATCH_SPACE_SIZE_256K   8
-#define GEN6_SCRATCH_SPACE_SIZE_512K   9
-#define GEN6_SCRATCH_SPACE_SIZE_1M     10
-#define GEN6_SCRATCH_SPACE_SIZE_2M     11
-
-/* The hardware supports two different modes for border color. The
- * default (OpenGL) mode uses floating-point color channels, while the
- * legacy mode uses 4 bytes.
- *
- * More significantly, the legacy mode respects the components of the
- * border color for channels not present in the source, (whereas the
- * default mode will ignore the border color's alpha channel and use
- * alpha==1 for an RGB source, for example).
- *
- * The legacy mode matches the semantics specified by the Render
- * extension.
- */
-struct gen6_sampler_default_border_color {
-   float color[4];
-};
-
-struct gen6_sampler_legacy_border_color {
-   uint8_t color[4];
-};
-
-struct gen6_sampler_state {
-   struct {
-      uint32_t shadow_function:3;
-      uint32_t lod_bias:11;
-      uint32_t min_filter:3;
-      uint32_t mag_filter:3;
-      uint32_t mip_filter:2;
-      uint32_t base_level:5;
-      uint32_t pad:1;
-      uint32_t lod_preclamp:1;
-      uint32_t border_color_mode:1;
-      uint32_t pad0:1;
-      uint32_t disable:1;
-   } ss0;
-
-   struct {
-      uint32_t r_wrap_mode:3;
-      uint32_t t_wrap_mode:3;
-      uint32_t s_wrap_mode:3;
-      uint32_t pad:3;
-      uint32_t max_lod:10;
-      uint32_t min_lod:10;
-   } ss1;
-
-   struct {
-      uint32_t border_color;
-   } ss2;
-
-   struct {
-      uint32_t pad:19;
-      uint32_t max_aniso:3;
-      uint32_t chroma_key_mode:1;
-      uint32_t chroma_key_index:2;
-      uint32_t chroma_key_enable:1;
-      uint32_t monochrome_filter_width:3;
-      uint32_t monochrome_filter_height:3;
-   } ss3;
-};
-
-struct gen6_blend_state {
-	struct {
-		uint32_t dest_blend_factor:5;
-		uint32_t source_blend_factor:5;
-		uint32_t pad3:1;
-		uint32_t blend_func:3;
-		uint32_t pad2:1;
-		uint32_t ia_dest_blend_factor:5;
-		uint32_t ia_source_blend_factor:5;
-		uint32_t pad1:1;
-		uint32_t ia_blend_func:3;
-		uint32_t pad0:1;
-		uint32_t ia_blend_enable:1;
-		uint32_t blend_enable:1;
-	} blend0;
-
-	struct {
-		uint32_t post_blend_clamp_enable:1;
-		uint32_t pre_blend_clamp_enable:1;
-		uint32_t clamp_range:2;
-		uint32_t pad0:4;
-		uint32_t x_dither_offset:2;
-		uint32_t y_dither_offset:2;
-		uint32_t dither_enable:1;
-		uint32_t alpha_test_func:3;
-		uint32_t alpha_test_enable:1;
-		uint32_t pad1:1;
-		uint32_t logic_op_func:4;
-		uint32_t logic_op_enable:1;
-		uint32_t pad2:1;
-		uint32_t write_disable_b:1;
-		uint32_t write_disable_g:1;
-		uint32_t write_disable_r:1;
-		uint32_t write_disable_a:1;
-		uint32_t pad3:1;
-		uint32_t alpha_to_coverage_dither:1;
-		uint32_t alpha_to_one:1;
-		uint32_t alpha_to_coverage:1;
-	} blend1;
-};
-
-struct gen6_color_calc_state {
-	struct {
-		uint32_t alpha_test_format:1;
-		uint32_t pad0:14;
-		uint32_t round_disable:1;
-		uint32_t bf_stencil_ref:8;
-		uint32_t stencil_ref:8;
-	} cc0;
-
-	union {
-		float alpha_ref_f;
-		struct {
-			uint32_t ui:8;
-			uint32_t pad0:24;
-		} alpha_ref_fi;
-	} cc1;
-
-	float constant_r;
-	float constant_g;
-	float constant_b;
-	float constant_a;
-};
-
-struct gen6_depth_stencil_state {
-	struct {
-		uint32_t pad0:3;
-		uint32_t bf_stencil_pass_depth_pass_op:3;
-		uint32_t bf_stencil_pass_depth_fail_op:3;
-		uint32_t bf_stencil_fail_op:3;
-		uint32_t bf_stencil_func:3;
-		uint32_t bf_stencil_enable:1;
-		uint32_t pad1:2;
-		uint32_t stencil_write_enable:1;
-		uint32_t stencil_pass_depth_pass_op:3;
-		uint32_t stencil_pass_depth_fail_op:3;
-		uint32_t stencil_fail_op:3;
-		uint32_t stencil_func:3;
-		uint32_t stencil_enable:1;
-	} ds0;
-
-	struct {
-		uint32_t bf_stencil_write_mask:8;
-		uint32_t bf_stencil_test_mask:8;
-		uint32_t stencil_write_mask:8;
-		uint32_t stencil_test_mask:8;
-	} ds1;
-
-	struct {
-		uint32_t pad0:26;
-		uint32_t depth_write_enable:1;
-		uint32_t depth_test_func:3;
-		uint32_t pad1:1;
-		uint32_t depth_test_enable:1;
-	} ds2;
-};
-
-struct gen6_surface_state {
-	struct {
-		uint32_t cube_pos_z:1;
-		uint32_t cube_neg_z:1;
-		uint32_t cube_pos_y:1;
-		uint32_t cube_neg_y:1;
-		uint32_t cube_pos_x:1;
-		uint32_t cube_neg_x:1;
-		uint32_t pad:3;
-		uint32_t render_cache_read_mode:1;
-		uint32_t mipmap_layout_mode:1;
-		uint32_t vert_line_stride_ofs:1;
-		uint32_t vert_line_stride:1;
-		uint32_t color_blend:1;
-		uint32_t writedisable_blue:1;
-		uint32_t writedisable_green:1;
-		uint32_t writedisable_red:1;
-		uint32_t writedisable_alpha:1;
-		uint32_t surface_format:9;
-		uint32_t data_return_format:1;
-		uint32_t pad0:1;
-		uint32_t surface_type:3;
-	} ss0;
-
-	struct {
-		uint32_t base_addr;
-	} ss1;
-
-	struct {
-		uint32_t render_target_rotation:2;
-		uint32_t mip_count:4;
-		uint32_t width:13;
-		uint32_t height:13;
-	} ss2;
-
-	struct {
-		uint32_t tile_walk:1;
-		uint32_t tiled_surface:1;
-		uint32_t pad:1;
-		uint32_t pitch:18;
-		uint32_t depth:11;
-	} ss3;
-
-	struct {
-		uint32_t pad:19;
-		uint32_t min_array_elt:9;
-		uint32_t min_lod:4;
-	} ss4;
-
-	struct {
-		uint32_t pad:20;
-		uint32_t y_offset:4;
-		uint32_t pad2:1;
-		uint32_t x_offset:7;
-	} ss5;
-};
-
-struct gen6_cc_viewport {
-	float min_depth;
-	float max_depth;
-};
-
-typedef enum {
-	SAMPLER_FILTER_NEAREST = 0,
-	SAMPLER_FILTER_BILINEAR,
-	FILTER_COUNT
-} sampler_filter_t;
-
-typedef enum {
-	SAMPLER_EXTEND_NONE = 0,
-	SAMPLER_EXTEND_REPEAT,
-	SAMPLER_EXTEND_PAD,
-	SAMPLER_EXTEND_REFLECT,
-	EXTEND_COUNT
-} sampler_extend_t;
-
-#endif
-- 
1.7.8.3



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux