Skip to contentSkip to conversation

intel: Move the gen4-6 3DPRIMITIVE handling out of the switch statement.

PATCH New Eric Anholt 1 participant 2 messages Mar 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 intel: Move the gen4-6 3DPRIMITIVE handling out of the switch statement.

---
 intel/intel_decode.c |   32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)
intel/intel_decode.c +17 -15
index 2ea8f67..af621d4 100644
@@ -3005,6 +3005,22 @@ gen7_3DSTATE_WM(struct drm_intel_decode *ctx)
 }
 
 static int
+gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
+{
+	instr_out(ctx, 0,
+		  "3DPRIMITIVE: %s %s\n",
+		  get_965_prim_type(ctx->data[0]),
+		  (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
 decode_3d_965(struct drm_intel_decode *ctx)
 {
 	uint32_t opcode;
@@ -3105,7 +3121,7 @@ decode_3d_965(struct drm_intel_decode *ctx)
 		{ 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" },
 		{ 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" },
 		{ 0x7b00, 0x00ff, 7, 7, "3DPRIMITIVE", 7 },
-		{ 0x7b00, 0x00ff, 6, 6, "3DPRIMITIVE" },
+		{ 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
 	}, *opcode_3d = NULL;
 
 	opcode = (data[0] & 0xffff0000) >> 16;
@@ -3593,20 +3609,6 @@ decode_3d_965(struct drm_intel_decode *ctx)
 			instr_out(ctx, 3, "immediate dword high\n");
 			return len;
 		}
-	case 0x7b00:
-		if (ctx->gen == 7)
-			break;
-
-		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) {
Signature · 1 line
1.7.9.1
#1 lore raw

PATCH 2/2 intel: Add per-dword decode of gen7 3DPRIMITIVE.

---
 intel/intel_decode.c              |   29 ++++++++++++++++++++++++-----
 intel/tests/gen7-3d.batch-ref.txt |   14 +++++++-------
 2 files changed, 31 insertions(+), 12 deletions(-)
intel/intel_decode.c +24 -5
index af621d4..df9b704 100644
@@ -2577,10 +2577,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";
@@ -3009,7 +3007,7 @@ gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
 {
 	instr_out(ctx, 0,
 		  "3DPRIMITIVE: %s %s\n",
-		  get_965_prim_type(ctx->data[0]),
+		  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");
@@ -3021,6 +3019,27 @@ gen4_3DPRIMITIVE(struct drm_intel_decode *ctx)
 }
 
 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)
 {
 	uint32_t opcode;
@@ -3120,7 +3139,7 @@ decode_3d_965(struct drm_intel_decode *ctx)
 		{ 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, 7, 7, "3DPRIMITIVE", 7 },
+		{ 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE },
 		{ 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE },
 	}, *opcode_3d = NULL;
 
intel/tests/gen7-3d.batch-ref.txt +7 -7
index 1488ca5..be3c85e 100644
@@ -202,11 +202,11 @@
 0x12300324:      0x11230000:    (X, Y, 0.0, 1.0), dst offset 0x00 bytes
 0x12300328:      0x02400008:    buffer 0: invalid, type 0x0040, src offset 0x0008 bytes
 0x1230032c:      0x11130000:    (X, Y, Z, 1.0), dst offset 0x00 bytes
-0x12300330:      0x7b000005: 3DPRIMITIVE
-0x12300334:      0x00000007:    dword 1
-0x12300338:      0x00000004:    dword 2
-0x1230033c:      0x00000000:    dword 3
-0x12300340:      0x00000001:    dword 4
-0x12300344:      0x00000000:    dword 5
-0x12300348:      0x00000000:    dword 6
+0x12300330:      0x7b000005: 3DPRIMITIVE: 
+0x12300334:      0x00000007:    quad list sequential
+0x12300338:      0x00000004:    vertex count
+0x1230033c:      0x00000000:    start vertex
+0x12300340:      0x00000001:    instance count
+0x12300344:      0x00000000:    start instance
+0x12300348:      0x00000000:    index bias
 0x1230034c:      0x05000000: MI_BATCH_BUFFER_END
Signature · 1 line
1.7.9.1