Skip to contentSkip to conversation

Generate raw batches for unit testing the decoder

PATCH New Damien Lespiau 1 participant 4 messages Dec 13, 2013 – Dec 16, 2013

lore
Share & tools
lore
#0 lore raw

libdrm has a way to unit-test the CS decoder: test_decode can decode a raw batch and compare it to a reference output.

However, one still needs to genarate the raw, binary, batches to feed to test_decode. This couple of patches do exactly that.

Signature · 1 line
Damien
#1 lore raw

PATCH 1/2 tests: Add a helper to generate raw batches

These batches can be used to test the CS parser in libdrm. Let's start by generating a MI_FLUSH_DW command that flushes a DWord (as opposed to a QWord).

---
 tests/.gitignore              |   1 +
 tests/Makefile.sources        |   1 +
 tests/generate_test_batches.c | 109 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)
 create mode 100644 tests/generate_test_batches.c
tests/.gitignore +1 -0
index 8a00364..f6e2cf8 100644
@@ -97,6 +97,7 @@ gen3_render_linear_blits
 gen3_render_mixed_blits
 gen3_render_tiledx_blits
 gen3_render_tiledy_blits
+generate_test_batches
 igt_fork_helper
 igt_list_only
 igt_no_exit
tests/Makefile.sources +1 -0
index e286a7c..493fa4e 100644
@@ -1,6 +1,7 @@
 noinst_PROGRAMS = \
 	gem_stress \
 	ddi_compute_wrpll \
+	generate_test_batches \
 	$(TESTS_progs) \
 	$(TESTS_progs_M) \
 	$(HANG) \
tests/generate_test_batches.c new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 generate_test_batches: Add a MI_LOAD_REGISTER_IMM test batch

In reply to Damien Lespiau
---
 tests/generate_test_batches.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
tests/generate_test_batches.c +20 -0
index 997ce37..41f883d 100644
@@ -87,6 +87,25 @@ static void emit_mi_flush_dw(struct intel_batchbuffer *batch)
 	batch_finish(batch, "gen8-2d-mi-flush-dw-len-4.batch");
 }
 
+#define MI_LOAD_REGISTER_IMM	(0x22<<23)
+
+/*
+ * Make sure we correctly print out addresses when the address field only
+ * specificies a number of bits (eg. 22:3). The value to decode is then:
+ *   val << 3
+ * and not just the raw field value.
+ */
+static void emit_mi_load_register_imm(struct intel_batchbuffer *batch)
+{
+	batch_start(batch);
+
+	OUT_BATCH(MI_LOAD_REGISTER_IMM | (3-2));
+	OUT_BATCH(0x0000227c);
+	OUT_BATCH(0);
+
+	batch_finish(batch, "gen8-3d-partial-addresses.batch");
+}
+
 static struct gen_batches {
 	int drm_fd;
 	uint32_t devid;
@@ -106,4 +125,5 @@ int main(int argc, char **argv)
 	igt_assert(batch);
 
 	emit_mi_flush_dw(batch);
+	emit_mi_load_register_imm(batch);
 }
Signature · 1 line
1.8.3.1
#3 lore raw
In reply to Damien Lespiau
Quoted 5 lines · Damien Lespiau

libdrm has a way to unit-test the CS decoder: test_decode can decode a raw batch and compare it to a reference output.

However, one still needs to genarate the raw, binary, batches to feed to test_decode. This couple of patches do exactly that.

Chris noted that it's weird to have those in igt to test code in libdrm. While this is true, I didn't want to create yet another copy of the command definitions we'd have to synchronize by hand (lacking a better solution).

I don't mind keeping them in a branch, so let's just discard those.

Signature · 1 line
Damien