public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tomasz Lis <tomasz.lis@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: bartosz.dunajski@intel.com
Subject: [igt-dev] [PATCH i-g-t v2 1/3] lib: Separated emit part of gpgpu_fill.
Date: Fri,  5 Oct 2018 20:04:34 +0200	[thread overview]
Message-ID: <1538762676-15259-2-git-send-email-tomasz.lis@intel.com> (raw)
In-Reply-To: <1538762676-15259-1-git-send-email-tomasz.lis@intel.com>

From: "Lis, Tomasz" <tomasz.lis@intel.com>

Having emitting and sumbission in one function was restricting
possible use cases of the code. Now it is possible to emit
the gpgpu_fill to a batchbuffer with something already there,
or add more commands after.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>

Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
---
 lib/gpgpu_fill.c        | 59 ++++++++++++++++---------------------------------
 lib/gpgpu_fill.h        |  8 +++----
 lib/intel_batchbuffer.c | 12 +++++-----
 lib/intel_batchbuffer.h |  2 +-
 tests/gem_gpgpu_fill.c  | 19 ++++++++++++----
 5 files changed, 45 insertions(+), 55 deletions(-)

diff --git a/lib/gpgpu_fill.c b/lib/gpgpu_fill.c
index 003f461..654b791 100644
--- a/lib/gpgpu_fill.c
+++ b/lib/gpgpu_fill.c
@@ -117,18 +117,17 @@ static const uint32_t gen11_gpgpu_kernel[][4] = {
 #define GEN7_VFE_STATE_GPGPU_MODE 1
 
 void
-gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen7_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		    const struct igt_buf *dst,
 		    unsigned int x, unsigned int y,
 		    unsigned int width, unsigned int height,
 		    uint8_t color)
 {
 	uint32_t curbe_buffer, interface_descriptor;
-	uint32_t batch_end;
-
-	intel_batchbuffer_flush(batch);
+	uint8_t *prev_ptr;
 
 	/* setup states */
+	prev_ptr = batch->ptr;
 	batch->ptr = &batch->buffer[BATCH_STATE_SPLIT];
 
 	/*
@@ -143,7 +142,7 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 
 	igt_assert(batch->ptr < &batch->buffer[4095]);
 
-	batch->ptr = batch->buffer;
+	batch->ptr = prev_ptr;
 
 	/* GPGPU pipeline */
 	OUT_BATCH(GEN7_PIPELINE_SELECT | PIPELINE_SELECT_GPGPU);
@@ -156,28 +155,21 @@ gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 	gen7_emit_gpgpu_walk(batch, x, y, width, height);
 
-	OUT_BATCH(MI_BATCH_BUFFER_END);
-
-	batch_end = intel_batchbuffer_align(batch, 8);
-	igt_assert(batch_end < BATCH_STATE_SPLIT);
-
-	gen7_render_flush(batch, batch_end);
-	intel_batchbuffer_reset(batch);
+	igt_assert(batch->ptr + 8 < batch->buffer + BATCH_STATE_SPLIT);
 }
 
 void
-gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen8_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		    const struct igt_buf *dst,
 		    unsigned int x, unsigned int y,
 		    unsigned int width, unsigned int height,
 		    uint8_t color)
 {
 	uint32_t curbe_buffer, interface_descriptor;
-	uint32_t batch_end;
-
-	intel_batchbuffer_flush(batch);
+	uint8_t *prev_ptr;
 
 	/* setup states */
+	prev_ptr = batch->ptr;
 	batch->ptr = &batch->buffer[BATCH_STATE_SPLIT];
 
 	/*
@@ -192,7 +184,7 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 
 	igt_assert(batch->ptr < &batch->buffer[4095]);
 
-	batch->ptr = batch->buffer;
+	batch->ptr = prev_ptr;
 
 	/* GPGPU pipeline */
 	OUT_BATCH(GEN7_PIPELINE_SELECT | PIPELINE_SELECT_GPGPU);
@@ -204,17 +196,11 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 	gen8_emit_gpgpu_walk(batch, x, y, width, height);
 
-	OUT_BATCH(MI_BATCH_BUFFER_END);
-
-	batch_end = intel_batchbuffer_align(batch, 8);
-	igt_assert(batch_end < BATCH_STATE_SPLIT);
-
-	gen7_render_flush(batch, batch_end);
-	intel_batchbuffer_reset(batch);
+	igt_assert(batch->ptr + 8 < batch->buffer + BATCH_STATE_SPLIT);
 }
 
 static void
-__gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+__gen9_emit_gpgpu_fill(struct intel_batchbuffer *batch,
 		      const struct igt_buf *dst,
 		      unsigned int x, unsigned int y,
 		      unsigned int width, unsigned int height,
@@ -222,11 +208,10 @@ __gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		      size_t kernel_size)
 {
 	uint32_t curbe_buffer, interface_descriptor;
-	uint32_t batch_end;
-
-	intel_batchbuffer_flush(batch);
+	uint8_t *prev_ptr;
 
 	/* setup states */
+	prev_ptr = batch->ptr;
 	batch->ptr = &batch->buffer[BATCH_STATE_SPLIT];
 
 	/*
@@ -241,7 +226,7 @@ __gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 
 	igt_assert(batch->ptr < &batch->buffer[4095]);
 
-	batch->ptr = batch->buffer;
+	batch->ptr = prev_ptr;
 
 	/* GPGPU pipeline */
 	OUT_BATCH(GEN7_PIPELINE_SELECT | GEN9_PIPELINE_SELECTION_MASK |
@@ -254,31 +239,25 @@ __gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 	gen8_emit_gpgpu_walk(batch, x, y, width, height);
 
-	OUT_BATCH(MI_BATCH_BUFFER_END);
-
-	batch_end = intel_batchbuffer_align(batch, 8);
-	igt_assert(batch_end < BATCH_STATE_SPLIT);
-
-	gen7_render_flush(batch, batch_end);
-	intel_batchbuffer_reset(batch);
+	igt_assert(batch->ptr + 8 < batch->buffer + BATCH_STATE_SPLIT);
 }
 
-void gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+void gen9_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 			 const struct igt_buf *dst,
 			 unsigned int x, unsigned int y,
 			 unsigned int width, unsigned int height,
 			 uint8_t color)
 {
-	__gen9_gpgpu_fillfunc(batch, dst, x, y, width, height, color,
+	__gen9_emit_gpgpu_fill(batch, dst, x, y, width, height, color,
 			      gen9_gpgpu_kernel, sizeof(gen9_gpgpu_kernel));
 }
 
-void gen11_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+void gen11_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 			  const struct igt_buf *dst,
 			  unsigned int x, unsigned int y,
 			  unsigned int width, unsigned int height,
 			  uint8_t color)
 {
-	__gen9_gpgpu_fillfunc(batch, dst, x, y, width, height, color,
+	__gen9_emit_gpgpu_fill(batch, dst, x, y, width, height, color,
 			      gen11_gpgpu_kernel, sizeof(gen11_gpgpu_kernel));
 }
diff --git a/lib/gpgpu_fill.h b/lib/gpgpu_fill.h
index e405df3..1901b1e 100644
--- a/lib/gpgpu_fill.h
+++ b/lib/gpgpu_fill.h
@@ -30,28 +30,28 @@
 #include "intel_batchbuffer.h"
 
 void
-gen7_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen7_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		    const struct igt_buf *dst,
 		    unsigned int x, unsigned int y,
 		    unsigned int width, unsigned int height,
 		    uint8_t color);
 
 void
-gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen8_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		    const struct igt_buf *dst,
 		    unsigned int x, unsigned int y,
 		    unsigned int width, unsigned int height,
 		    uint8_t color);
 
 void
-gen9_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen9_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		    const struct igt_buf *dst,
 		    unsigned int x, unsigned int y,
 		    unsigned int width, unsigned int height,
 		    uint8_t color);
 
 void
-gen11_gpgpu_fillfunc(struct intel_batchbuffer *batch,
+gen11_emit_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 		     const struct igt_buf *dst,
 		     unsigned int x, unsigned int y,
 		     unsigned int width, unsigned int height,
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 387404f..dc1e6f2 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -871,7 +871,7 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)
 }
 
 /**
- * igt_get_gpgpu_fillfunc:
+ * igt_get_emit_gpgpu_fill:
  * @devid: pci device id
  *
  * Returns:
@@ -879,18 +879,18 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)
  * The platform-specific gpgpu fill function pointer for the device specified
  * with @devid. Will return NULL when no gpgpu fill function is implemented.
  */
-igt_fillfunc_t igt_get_gpgpu_fillfunc(int devid)
+igt_fillfunc_t igt_get_emit_gpgpu_fillfunc(int devid)
 {
 	igt_fillfunc_t fill = NULL;
 
 	if (IS_GEN7(devid))
-		fill = gen7_gpgpu_fillfunc;
+		fill = gen7_emit_gpgpu_fillfunc;
 	else if (IS_BROADWELL(devid))
-		fill = gen8_gpgpu_fillfunc;
+		fill = gen8_emit_gpgpu_fillfunc;
 	else if (IS_GEN9(devid) || IS_GEN10(devid))
-		fill = gen9_gpgpu_fillfunc;
+		fill = gen9_emit_gpgpu_fillfunc;
 	else if (IS_GEN11(devid))
-		fill = gen11_gpgpu_fillfunc;
+		fill = gen11_emit_gpgpu_fillfunc;
 
 	return fill;
 }
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 2dcb09c..21babff 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -321,7 +321,7 @@ typedef void (*igt_fillfunc_t)(struct intel_batchbuffer *batch,
 			       uint8_t color);
 
 igt_fillfunc_t igt_get_media_fillfunc(int devid);
-igt_fillfunc_t igt_get_gpgpu_fillfunc(int devid);
+igt_fillfunc_t igt_get_emit_gpgpu_fillfunc(int devid);
 
 /**
  * igt_media_spinfunc_t:
diff --git a/tests/gem_gpgpu_fill.c b/tests/gem_gpgpu_fill.c
index dfb5816..d79f747 100644
--- a/tests/gem_gpgpu_fill.c
+++ b/tests/gem_gpgpu_fill.c
@@ -44,6 +44,7 @@
 #include <sys/time.h>
 #include "drm.h"
 #include "intel_bufmgr.h"
+#include "gpu_cmds.h"
 
 #define WIDTH 64
 #define HEIGHT 64
@@ -99,7 +100,8 @@ igt_simple_main
 	data_t data = {0, };
 	struct intel_batchbuffer *batch = NULL;
 	struct igt_buf dst;
-	igt_fillfunc_t gpgpu_fill = NULL;
+	igt_fillfunc_t emit_gpgpu_fill = NULL;
+        uint32_t batch_end;
 	int i, j;
 
 	data.drm_fd = drm_open_driver_render(DRIVER_INTEL);
@@ -109,9 +111,9 @@ igt_simple_main
 	data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
 	igt_assert(data.bufmgr);
 
-	gpgpu_fill = igt_get_gpgpu_fillfunc(data.devid);
+	emit_gpgpu_fill = igt_get_emit_gpgpu_fillfunc(data.devid);
 
-	igt_require_f(gpgpu_fill,
+	igt_require_f(emit_gpgpu_fill,
 		      "no gpgpu-fill function\n");
 
 	batch = intel_batchbuffer_alloc(data.bufmgr, data.devid);
@@ -125,10 +127,19 @@ igt_simple_main
 		}
 	}
 
-	gpgpu_fill(batch,
+        intel_batchbuffer_flush(batch);
+
+	emit_gpgpu_fill(batch,
 		   &dst, 0, 0, WIDTH / 2, HEIGHT / 2,
 		   COLOR_4C);
 
+        OUT_BATCH(MI_BATCH_BUFFER_END);
+
+        batch_end = intel_batchbuffer_align(batch, 8);
+
+        gen7_render_flush(batch, batch_end);
+        intel_batchbuffer_reset(batch);
+
 	for (i = 0; i < WIDTH; i++) {
 		for (j = 0; j < HEIGHT; j++) {
 			if (i < WIDTH / 2 && j < HEIGHT / 2)
-- 
2.7.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2018-10-05 18:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 18:04 [igt-dev] [PATCH i-g-t v2 0/3] Data Port Cache Coherency test Tomasz Lis
2018-10-05 18:04 ` Tomasz Lis [this message]
2018-10-24 14:49   ` [igt-dev] [PATCH i-g-t v2 1/3] lib: Separated emit part of gpgpu_fill Kalamarz, Lukasz
2018-10-05 18:04 ` [igt-dev] [PATCH i-g-t v2 2/3] lib: Update surface state to set MOCS and coherency Tomasz Lis
2018-10-05 18:04 ` [igt-dev] [PATCH i-g-t v2 3/3] igt: Add a test for Data Port Coherency Tomasz Lis
2018-10-05 19:59 ` [igt-dev] ✓ Fi.CI.BAT: success for Data Port Cache Coherency test Patchwork
2018-10-06  2:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1538762676-15259-2-git-send-email-tomasz.lis@intel.com \
    --to=tomasz.lis@intel.com \
    --cc=bartosz.dunajski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox