]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/libdrm.git/blobdiff - intel/intel_decode.c
intel/decode: VERTEX_ELEMENT_STATE, 1 means valid
[glsdk/libdrm.git] / intel / intel_decode.c
index 1519f6af712679a055279f3f71c593d3fb74a1be..74dd530ddd608e802a0b127ff64810e1f155da47 100644 (file)
@@ -138,6 +138,74 @@ instr_out(struct drm_intel_decode *ctx, unsigned int index,
        va_end(va);
 }
 
+static int
+decode_MI_WAIT_FOR_EVENT(struct drm_intel_decode *ctx)
+{
+       const char *cc_wait;
+       int cc_shift = 0;
+       uint32_t data = ctx->data[0];
+
+       if (ctx->gen <= 5)
+               cc_shift = 9;
+       else
+               cc_shift = 16;
+
+       switch ((data >> cc_shift) & 0x1f) {
+       case 1:
+               cc_wait = ", cc wait 1";
+               break;
+       case 2:
+               cc_wait = ", cc wait 2";
+               break;
+       case 3:
+               cc_wait = ", cc wait 3";
+               break;
+       case 4:
+               cc_wait = ", cc wait 4";
+               break;
+       case 5:
+               cc_wait = ", cc wait 4";
+               break;
+       default:
+               cc_wait = "";
+               break;
+       }
+
+       if (ctx->gen <= 5) {
+               instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+                         data & (1<<18)? ", pipe B start vblank wait": "",
+                         data & (1<<17)? ", pipe A start vblank wait": "",
+                         data & (1<<16)? ", overlay flip pending wait": "",
+                         data & (1<<14)? ", pipe B hblank wait": "",
+                         data & (1<<13)? ", pipe A hblank wait": "",
+                         cc_wait,
+                         data & (1<<8)? ", plane C pending flip wait": "",
+                         data & (1<<7)? ", pipe B vblank wait": "",
+                         data & (1<<6)? ", plane B pending flip wait": "",
+                         data & (1<<5)? ", pipe B scan line wait": "",
+                         data & (1<<4)? ", fbc idle wait": "",
+                         data & (1<<3)? ", pipe A vblank wait": "",
+                         data & (1<<2)? ", plane A pending flip wait": "",
+                         data & (1<<1)? ", plane A scan line wait": "");
+       } else {
+               instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n",
+                         data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */
+                         cc_wait,
+                         data & (1<<13)? ", pipe B hblank wait": "",
+                         data & (1<<11)? ", pipe B vblank wait": "",
+                         data & (1<<10)? ", sprite B pending flip wait": "",
+                         data & (1<<9)? ", plane B pending flip wait": "",
+                         data & (1<<8)? ", plane B scan line wait": "",
+                         data & (1<<5)? ", pipe A hblank wait": "",
+                         data & (1<<3)? ", pipe A vblank wait": "",
+                         data & (1<<2)? ", sprite A pending flip wait": "",
+                         data & (1<<1)? ", plane A pending flip wait": "",
+                         data & (1<<0)? ", plane A scan line wait": "");
+       }
+
+       return 1;
+}
+
 static int
 decode_mi(struct drm_intel_decode *ctx)
 {
@@ -151,6 +219,7 @@ decode_mi(struct drm_intel_decode *ctx)
                unsigned int min_len;
                unsigned int max_len;
                const char *name;
+               int (*func)(struct drm_intel_decode *ctx);
        } opcodes_mi[] = {
                { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
                { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
@@ -169,11 +238,11 @@ decode_mi(struct drm_intel_decode *ctx)
                { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
                { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
                { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
-               { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
+               { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT },
                { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
                { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
                { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
-       };
+       }, *opcode_mi = NULL;
 
        /* check instruction length */
        for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
@@ -192,10 +261,14 @@ decode_mi(struct drm_intel_decode *ctx)
                                                opcodes_mi[opcode].max_len);
                                }
                        }
+                       opcode_mi = &opcodes_mi[opcode];
                        break;
                }
        }
 
+       if (opcode_mi && opcode_mi->func)
+               return opcode_mi->func(ctx);
+
        switch ((data[0] & 0x1f800000) >> 23) {
        case 0x0a:
                instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n");
@@ -2577,10 +2650,8 @@ static const char *get_965_element_component(uint32_t data, int component)
        }
 }
 
-static const char *get_965_prim_type(uint32_t data)
+static const char *get_965_prim_type(uint32_t primtype)
 {
-       uint32_t primtype = (data >> 10) & 0x1f;
-
        switch (primtype) {
        case 0x01:
                return "point list";
@@ -2703,6 +2774,344 @@ state_max_out(struct drm_intel_decode *ctx, unsigned int index,
        }
 }
 
+static int
+gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n");
+       instr_out(ctx, 1, "pointer to CC viewport\n");
+
+       return 2;
+}
+
+static int
+gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n");
+       instr_out(ctx, 1, "pointer to SF_CLIP viewport\n");
+
+       return 2;
+}
+
+static int
+gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n");
+       instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n",
+                 ctx->data[1] & ~1,
+                 (ctx->data[1] & 1) ? "changed" : "unchanged");
+
+       return 2;
+}
+
+static int
+gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n");
+       instr_out(ctx, 1,
+                 "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n",
+                 ctx->data[1] & ~1,
+                 (ctx->data[1] & 1) ? "changed" : "unchanged");
+
+       return 2;
+}
+
+static int
+gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n");
+       instr_out(ctx, 1, "pitch %db\n",
+                 (ctx->data[1] & 0x1ffff) + 1);
+       instr_out(ctx, 2, "pointer to HiZ buffer\n");
+
+       return 3;
+}
+
+static int
+gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
+       instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1);
+       instr_out(ctx, 2, "depth stencil change %d\n",
+                 ctx->data[2] & 1);
+       instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1);
+
+       return 4;
+}
+
+static int
+gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
+       instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x "
+                 "(%s)\n",
+                 ctx->data[1] & ~1,
+                 (ctx->data[1] & 1) ? "changed" : "unchanged");
+
+       return 2;
+}
+
+static int
+gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit)
+{
+    int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8;
+    /* the field is # of 512-bit rows - 1, we print bytes */
+    int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1);
+    int nr_entries = ctx->data[1] & 0xffff;
+
+    instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit);
+    instr_out(ctx, 1,
+             "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n",
+             start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size);
+
+    return 2;
+}
+
+static int
+gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_URB_unit(ctx, "VS");
+}
+
+static int
+gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_URB_unit(ctx, "HS");
+}
+
+static int
+gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_URB_unit(ctx, "DS");
+}
+
+static int
+gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_URB_unit(ctx, "GS");
+}
+
+static int
+gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit)
+{
+       int rlen[4];
+
+       rlen[0] = (ctx->data[1] >> 0) & 0xffff;
+       rlen[1] = (ctx->data[1] >> 16) & 0xffff;
+       rlen[2] = (ctx->data[2] >> 0) & 0xffff;
+       rlen[3] = (ctx->data[2] >> 16) & 0xffff;
+
+       instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit);
+       instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]);
+       instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]);
+       instr_out(ctx, 3, "pointer to constbuf 0\n");
+       instr_out(ctx, 4, "pointer to constbuf 1\n");
+       instr_out(ctx, 5, "pointer to constbuf 2\n");
+       instr_out(ctx, 6, "pointer to constbuf 3\n");
+
+       return 7;
+}
+
+static int
+gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_CONSTANT(ctx, "VS");
+}
+
+static int
+gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_CONSTANT(ctx, "GS");
+}
+
+static int
+gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_CONSTANT(ctx, "PS");
+}
+
+static int
+gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_CONSTANT(ctx, "DS");
+}
+
+static int
+gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx)
+{
+       return gen7_3DSTATE_CONSTANT(ctx, "HS");
+}
+
+
+static int
+gen6_3DSTATE_WM(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0, "3DSTATE_WM\n");
+       instr_out(ctx, 1, "kernel start pointer 0\n");
+       instr_out(ctx, 2,
+                 "SPF=%d, VME=%d, Sampler Count %d, "
+                 "Binding table count %d\n",
+                 (ctx->data[2] >> 31) & 1,
+                 (ctx->data[2] >> 30) & 1,
+                 (ctx->data[2] >> 27) & 7,
+                 (ctx->data[2] >> 18) & 0xff);
+       instr_out(ctx, 3, "scratch offset\n");
+       instr_out(ctx, 4,
+                 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
+                 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
+                 (ctx->data[4] & (1 << 30)) != 0,
+                 (ctx->data[4] & (1 << 28)) != 0,
+                 (ctx->data[4] & (1 << 27)) != 0,
+                 (ctx->data[4] >> 16) & 0x7f,
+                 (ctx->data[4] >> 8) & 0x7f,
+                 (ctx->data[4] & 0x7f));
+       instr_out(ctx, 5,
+                 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
+                 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, "
+                 "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n",
+                 ((ctx->data[5] >> 25) & 0x7f) + 1,
+                 (ctx->data[5] & (1 << 22)) != 0,
+                 (ctx->data[5] & (1 << 21)) != 0,
+                 (ctx->data[5] & (1 << 20)) != 0,
+                 (ctx->data[5] & (1 << 19)) != 0,
+                 (ctx->data[5] & (1 << 8)) != 0,
+                 (ctx->data[5] & (1 << 2)) != 0,
+                 (ctx->data[5] & (1 << 1)) != 0,
+                 (ctx->data[5] & (1 << 0)) != 0);
+       instr_out(ctx, 6,
+                 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
+                 "Barycentric interp mode 0x%x, Point raster rule %d, "
+                 "Multisample mode %d, "
+                 "Multisample Dispatch mode %d\n",
+                 (ctx->data[6] >> 20) & 0x3f,
+                 (ctx->data[6] >> 18) & 3,
+                 (ctx->data[6] >> 16) & 3,
+                 (ctx->data[6] >> 10) & 0x3f,
+                 (ctx->data[6] & (1 << 9)) != 0,
+                 (ctx->data[6] >> 1) & 3,
+                 (ctx->data[6] & 1));
+       instr_out(ctx, 7, "kernel start pointer 1\n");
+       instr_out(ctx, 8, "kernel start pointer 2\n");
+
+       return 9;
+}
+
+static int
+gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
+{
+       const char *computed_depth = "";
+       const char *early_depth = "";
+       const char *zw_interp = "";
+
+       switch ((ctx->data[1] >> 23) & 0x3) {
+       case 0:
+               computed_depth = "";
+               break;
+       case 1:
+               computed_depth = "computed depth";
+               break;
+       case 2:
+               computed_depth = "computed depth >=";
+               break;
+       case 3:
+               computed_depth = "computed depth <=";
+               break;
+       }
+
+       switch ((ctx->data[1] >> 21) & 0x3) {
+       case 0:
+               early_depth = "";
+               break;
+       case 1:
+               early_depth = ", EDSC_PSEXEC";
+               break;
+       case 2:
+               early_depth = ", EDSC_PREPS";
+               break;
+       case 3:
+               early_depth = ", BAD EDSC";
+               break;
+       }
+
+       switch ((ctx->data[1] >> 17) & 0x3) {
+       case 0:
+               early_depth = "";
+               break;
+       case 1:
+               early_depth = ", BAD ZW interp";
+               break;
+       case 2:
+               early_depth = ", ZW centroid";
+               break;
+       case 3:
+               early_depth = ", ZW sample";
+               break;
+       }
+
+       instr_out(ctx, 0, "3DSTATE_WM\n");
+       instr_out(ctx, 1, "(%s%s%s%s%s%s)%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+                 (ctx->data[1] & (1 << 11)) ? "PP " : "",
+                 (ctx->data[1] & (1 << 12)) ? "PC " : "",
+                 (ctx->data[1] & (1 << 13)) ? "PS " : "",
+                 (ctx->data[1] & (1 << 14)) ? "NPP " : "",
+                 (ctx->data[1] & (1 << 15)) ? "NPC " : "",
+                 (ctx->data[1] & (1 << 16)) ? "NPS " : "",
+                 (ctx->data[1] & (1 << 30)) ? ", depth clear" : "",
+                 (ctx->data[1] & (1 << 29)) ? "" : ", disabled",
+                 (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "",
+                 (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "",
+                 (ctx->data[1] & (1 << 25)) ? ", kill" : "",
+                 computed_depth,
+                 early_depth,
+                 zw_interp,
+                 (ctx->data[1] & (1 << 20)) ? ", source depth" : "",
+                 (ctx->data[1] & (1 << 19)) ? ", source W" : "",
+                 (ctx->data[1] & (1 << 10)) ? ", coverage" : "",
+                 (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "",
+                 (ctx->data[1] & (1 << 3)) ? ", line stipple" : "",
+                 (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR"
+                 );
+       instr_out(ctx, 2, "MS\n");
+
+       return 3;
+}
+
+static int
+gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
+{
+       instr_out(ctx, 0,
+                 "3DPRIMITIVE: %s %s\n",
+                 get_965_prim_type((ctx->data[0] >> 10) & 0x1f),
+                 (ctx->data[0] & (1 << 15)) ? "random" : "sequential");
+       instr_out(ctx, 1, "vertex count\n");
+       instr_out(ctx, 2, "start vertex\n");
+       instr_out(ctx, 3, "instance count\n");
+       instr_out(ctx, 4, "start instance\n");
+       instr_out(ctx, 5, "index bias\n");
+
+       return 6;
+}
+
+static int
+gen7_3DPRIMITIVE(struct drm_intel_decode *ctx)
+{
+       bool indirect = !!(ctx->data[0] & (1 << 10));
+
+       instr_out(ctx, 0,
+                 "3DPRIMITIVE: %s%s\n",
+                 indirect ? " indirect" : "",
+                 (ctx->data[0] & (1 << 8)) ? " predicated" : "");
+       instr_out(ctx, 1, "%s %s\n",
+                 get_965_prim_type(ctx->data[1] & 0x3f),
+                 (ctx->data[1] & (1 << 8)) ? "random" : "sequential");
+       instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n");
+       instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n");
+       instr_out(ctx, 4, indirect ? "ignored" : "instance count\n");
+       instr_out(ctx, 5, indirect ? "ignored" : "start instance\n");
+       instr_out(ctx, 6, indirect ? "ignored" : "index bias\n");
+
+       return 7;
+}
+
 static int
 decode_3d_965(struct drm_intel_decode *ctx)
 {
@@ -2725,31 +3134,68 @@ decode_3d_965(struct drm_intel_decode *ctx)
                { 0x6000, 0x00ff, 3, 3, "URB_FENCE" },
                { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" },
                { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" },
-               { 0x6101, 0xffff, 6, 6, "STATE_BASE_ADDRESS" },
+               { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" },
                { 0x6102, 0xffff, 2, 2, "STATE_SIP" },
                { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
                { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
                { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" },
                { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
-               { 0x7801, 0x00ff, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
+               { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
                { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
+               { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 },
                { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" },
+               { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" },
+               { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" },
+               { 0x7807, 0x00ff, 4, 4, "3DSTATE_HIER_DEPTH_BUFFER", 6 },
+               { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER },
                { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
                { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
                { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" },
                { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" },
                { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
-               { 0x780e, 0xffff, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
+               { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS },
+               { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS },
                { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" },
                { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" },
                { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" },
                { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" },
-               { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF" },
-               { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM" },
-               { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
-               { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
-               { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
+               { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 },
+               { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 },
+               { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM },
+               { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM },
+               { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 },
+               { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS },
+               { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 },
+               { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS },
+               { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 },
+               { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS },
                { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" },
+               { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS },
+               { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS },
+               { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" },
+               { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" },
+               { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" },
+               { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" },
+               { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" },
+               { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" },
+               { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP },
+               { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC },
+               { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS },
+               { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS },
+               { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" },
+               { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" },
+               { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" },
+               { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" },
+               { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" },
+               { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" },
+               { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" },
+               { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" },
+               { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" },
+               { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" },
+               { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS },
+               { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS },
+               { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS },
+               { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS },
                { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
                { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" },
                { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" },
@@ -2763,8 +3209,16 @@ decode_3d_965(struct drm_intel_decode *ctx)
                { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 },
                { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 },
                { 0x7910, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" },
+               { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" },
+               { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" },
+               { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" },
+               { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" },
+               { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" },
+               { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" },
+               { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
                { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
-               { 0x7b00, 0x00ff, 6, 6, "3DPRIMITIVE" },
+               { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
+               { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
        }, *opcode_3d = NULL;
 
        opcode = (data[0] & 0xffff0000) >> 16;
@@ -2786,6 +3240,13 @@ decode_3d_965(struct drm_intel_decode *ctx)
                        len = 1;
                else
                        len = (data[0] & opcode_3d->len_mask) + 2;
+
+               if (len < opcode_3d->min_len ||
+                   len > opcode_3d->max_len) {
+                       fprintf(out, "Bad length %d in %s, expected %d-%d\n",
+                               len, opcode_3d->name,
+                               opcode_3d->min_len, opcode_3d->max_len);
+               }
        } else {
                len = (data[0] & 0x0000ffff) + 2;
        }
@@ -2838,10 +3299,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
 
                return len;
        case 0x7800:
-               if (len != 7)
-                       fprintf(out,
-                               "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
-
                instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n");
                instr_out(ctx, 1, "VS state\n");
                instr_out(ctx, 2, "GS state\n");
@@ -2876,9 +3333,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
 
                return len;
        case 0x7802:
-               if (len != 4)
-                       fprintf(out,
-                               "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
                instr_out(ctx, 0,
                          "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
                          "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
@@ -2889,8 +3343,10 @@ decode_3d_965(struct drm_intel_decode *ctx)
                instr_out(ctx, 3, "WM sampler state\n");
                return len;
        case 0x7805:
-               if (len != 3)
-                       fprintf(out, "Bad count in 3DSTATE_URB\n");
+               /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */
+               if (ctx->gen == 7)
+                       break;
+
                instr_out(ctx, 0, "3DSTATE_URB\n");
                instr_out(ctx, 1,
                          "VS entries %d, alloc size %d (1024bit row)\n",
@@ -2936,7 +3392,7 @@ decode_3d_965(struct drm_intel_decode *ctx)
                                  "src offset 0x%04x bytes\n",
                                  data[i] >> (IS_GEN6(devid) ? 26 : 27),
                                  data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
-                                 "" : "in", (data[i] >> 16) & 0x1ff,
+                                 "in" : "", (data[i] >> 16) & 0x1ff,
                                  data[i] & 0x07ff);
                        i++;
                        instr_out(ctx, i, "(%s, %s, %s, %s), "
@@ -2951,9 +3407,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x780d:
-               if (len != 4)
-                       fprintf(out,
-                               "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
                instr_out(ctx, 0,
                          "3DSTATE_VIEWPORT_STATE_POINTERS\n");
                instr_out(ctx, 1, "clip\n");
@@ -2962,34 +3415,17 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x780a:
-               if (len != 3)
-                       fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
                instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n");
                instr_out(ctx, 1, "beginning buffer address\n");
                instr_out(ctx, 2, "ending buffer address\n");
                return len;
 
-       case 0x780e:
-               if (len != 4)
-                       fprintf(out,
-                               "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
-               instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n");
-               instr_out(ctx, 1, "blend change %d\n", data[1] & 1);
-               instr_out(ctx, 2, "depth stencil change %d\n",
-                         data[2] & 1);
-               instr_out(ctx, 3, "cc change %d\n", data[3] & 1);
-               return len;
-
        case 0x780f:
-               if (len != 2)
-                       fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
                instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n");
                instr_out(ctx, 1, "scissor rect offset\n");
                return len;
 
        case 0x7810:
-               if (len != 6)
-                       fprintf(out, "Bad count in 3DSTATE_VS\n");
                instr_out(ctx, 0, "3DSTATE_VS\n");
                instr_out(ctx, 1, "kernel pointer\n");
                instr_out(ctx, 2,
@@ -3010,8 +3446,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x7811:
-               if (len != 7)
-                       fprintf(out, "Bad count in 3DSTATE_GS\n");
                instr_out(ctx, 0, "3DSTATE_GS\n");
                instr_out(ctx, 1, "kernel pointer\n");
                instr_out(ctx, 2,
@@ -3037,8 +3471,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x7812:
-               if (len != 4)
-                       fprintf(out, "Bad count in 3DSTATE_CLIP\n");
                instr_out(ctx, 0, "3DSTATE_CLIP\n");
                instr_out(ctx, 1,
                          "UserClip distance cull test mask 0x%x\n",
@@ -3067,8 +3499,9 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x7813:
-               if (len != 20)
-                       fprintf(out, "Bad count in 3DSTATE_SF\n");
+               if (ctx->gen == 7)
+                       break;
+
                instr_out(ctx, 0, "3DSTATE_SF\n");
                instr_out(ctx, 1,
                          "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
@@ -3129,53 +3562,7 @@ decode_3d_965(struct drm_intel_decode *ctx)
 
                return len;
 
-       case 0x7814:
-               if (len != 9)
-                       fprintf(out, "Bad count in 3DSTATE_WM\n");
-               instr_out(ctx, 0, "3DSTATE_WM\n");
-               instr_out(ctx, 1, "kernel start pointer 0\n");
-               instr_out(ctx, 2,
-                         "SPF=%d, VME=%d, Sampler Count %d, "
-                         "Binding table count %d\n", (data[2] >> 31) & 1,
-                         (data[2] >> 30) & 1, (data[2] >> 27) & 7,
-                         (data[2] >> 18) & 0xff);
-               instr_out(ctx, 3, "scratch offset\n");
-               instr_out(ctx, 4,
-                         "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
-                         "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
-                         (data[4] & (1 << 30)) != 0,
-                         (data[4] & (1 << 28)) != 0,
-                         (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
-                         (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
-               instr_out(ctx, 5,
-                         "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
-                         "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
-                         "Dispatch16 %d, Dispatch8 %d\n",
-                         ((data[5] >> 25) & 0x7f) + 1,
-                         (data[5] & (1 << 22)) != 0,
-                         (data[5] & (1 << 21)) != 0,
-                         (data[5] & (1 << 20)) != 0,
-                         (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
-                         (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
-                         (data[5] & (1 << 0)) != 0);
-               instr_out(ctx, 6,
-                         "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
-                         "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
-                         "Multisample Dispatch mode %d\n",
-                         (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
-                         (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
-                         (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
-                         (data[6] & 1));
-               instr_out(ctx, 7, "kernel start pointer 1\n");
-               instr_out(ctx, 8, "kernel start pointer 2\n");
-
-               return len;
-
        case 0x7900:
-               if (len != 4)
-                       fprintf(out,
-                               "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
-
                instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n");
                instr_out(ctx, 1, "top left: %d,%d\n",
                          data[1] & 0xffff, (data[1] >> 16) & 0xffff);
@@ -3187,9 +3574,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                return len;
 
        case 0x7905:
-               if (len < 5 || len > 7)
-                       fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
-
                instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n");
                if (IS_GEN5(devid) || IS_GEN6(devid))
                        instr_out(ctx, 1,
@@ -3322,20 +3706,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                        instr_out(ctx, 3, "immediate dword high\n");
                        return len;
                }
-       case 0x7b00:
-               if (len != 6)
-                       fprintf(out, "Bad count in 3DPRIMITIVE\n");
-
-               instr_out(ctx, 0,
-                         "3DPRIMITIVE: %s %s\n",
-                         get_965_prim_type(data[0]),
-                         (data[0] & (1 << 15)) ? "random" : "sequential");
-               instr_out(ctx, 1, "vertex count\n");
-               instr_out(ctx, 2, "start vertex\n");
-               instr_out(ctx, 3, "instance count\n");
-               instr_out(ctx, 4, "start instance\n");
-               instr_out(ctx, 5, "index bias\n");
-               return len;
        }
 
        if (opcode_3d) {
@@ -3345,11 +3715,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
                        unsigned int i;
 
                        instr_out(ctx, 0, "%s\n", opcode_3d->name);
-                       if (len < opcode_3d->min_len ||
-                           len > opcode_3d->max_len) {
-                               fprintf(out, "Bad count in %s\n",
-                                       opcode_3d->name);
-                       }
 
                        for (i = 1; i < len; i++) {
                                instr_out(ctx, i, "dword %d\n", i);