Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Katarzyna Dec <katarzyna.dec@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 2/4] lib: Remove duplications in gpu_fill library
Date: Mon,  9 Apr 2018 16:34:47 +0200	[thread overview]
Message-ID: <20180409143449.13845-3-katarzyna.dec@intel.com> (raw)
In-Reply-To: <20180409143449.13845-1-katarzyna.dec@intel.com>

After moving all functions needed for gpgpu and media fill testing
there is a lot of duplications which can be removed:
  Library media_fill_gen8 and media_fill_gen8lp for CHT was removed,
media state flush for !CHT was added to gen7_emit_media_objects.
  Many gen8 functions were replaced with gen7 version with devid
parameter (gen7_fill_curbe_load, gen7_emit_interface_descriptor,
gen7_fill_binding_table, gen7_emit_media_objects). Unified fill kernel
function so it is applicable to all gens and both media and gpgpu
(merged gen7_fill_media_kernel and gen8_fill_media_kernel).
  Duplicated constants like GEN8_MEDIA_VFE_STATE, GEN8_MEDIA_CURBE_LOAD,
GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD, GEN8_MEDIA_OBJECT were
replaced by GEN7 version. However this constants were not removed
from gen8_media.h library, because they are used by other tests
for Gen8+. More refactoring in this gen*_media.h libraries is needed.

It seems that further unification of *_fillfunc functions will
introduce more confusion in understanding what the tests are doing
and what were changes between Gens.

v2: Moved some reduntant changes from Move gpgpu/media fill to gpu_fill...
to this patch. Applied comments from review.

Signed-off-by: Katarzyna Dec <katarzyna.dec@intel.com>
Cc: Lukasz Kalamarz <lukasz.kalamarz@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 lib/Makefile.sources    |   1 -
 lib/gpgpu_fill.c        |   2 +-
 lib/gpu_fill.c          | 130 +++++++-----------------------------------------
 lib/gpu_fill.h          |  27 +---------
 lib/intel_batchbuffer.c |   4 +-
 lib/media_fill.h        |   7 ---
 lib/media_fill_gen8.c   |   6 +--
 lib/media_fill_gen8lp.c |  87 --------------------------------
 lib/media_fill_gen9.c   |   6 +--
 lib/meson.build         |   1 -
 10 files changed, 26 insertions(+), 245 deletions(-)
 delete mode 100644 lib/media_fill_gen8lp.c

diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 45e65dd7..9c0150c1 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -58,7 +58,6 @@ lib_source_list =	 	\
 	media_fill.h            \
 	media_fill_gen7.c       \
 	media_fill_gen8.c       \
-	media_fill_gen8lp.c     \
 	media_fill_gen9.c       \
 	media_spin.h		\
 	media_spin.c		\
diff --git a/lib/gpgpu_fill.c b/lib/gpgpu_fill.c
index f2765fd6..579ce78d 100644
--- a/lib/gpgpu_fill.c
+++ b/lib/gpgpu_fill.c
@@ -180,7 +180,7 @@ gen8_gpgpu_fillfunc(struct intel_batchbuffer *batch,
 	gen8_emit_state_base_address(batch);
 	gen8_emit_vfe_state_gpgpu(batch);
 	gen7_emit_curbe_load(batch, curbe_buffer);
-	gen8_emit_interface_descriptor_load(batch, interface_descriptor);
+	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 	gen8_emit_gpgpu_walk(batch, x, y, width, height);
 
 	OUT_BATCH(MI_BATCH_BUFFER_END);
diff --git a/lib/gpu_fill.c b/lib/gpu_fill.c
index 172c6db6..f86e3414 100644
--- a/lib/gpu_fill.c
+++ b/lib/gpu_fill.c
@@ -118,26 +118,18 @@ gen7_fill_binding_table(struct intel_batchbuffer *batch,
 
 	binding_table = batch_alloc(batch, 32, 64);
 	offset = batch_offset(batch, binding_table);
-	binding_table[0] = gen7_fill_surface_state(batch, dst,
+	if (IS_GEN7(batch->devid))
+		binding_table[0] = gen7_fill_surface_state(batch, dst,
 						GEN7_SURFACEFORMAT_R8_UNORM, 1);
+	else
+		binding_table[0] = gen8_fill_surface_state(batch, dst,
+						GEN8_SURFACEFORMAT_R8_UNORM, 1);
 
 	return offset;
 }
 
 uint32_t
-gen7_fill_media_kernel(struct intel_batchbuffer *batch,
-		const uint32_t kernel[][4],
-		size_t size)
-{
-	uint32_t offset;
-
-	offset = batch_copy(batch, kernel, size, 64);
-
-	return offset;
-}
-
-uint32_t
-gen8_fill_media_kernel(struct intel_batchbuffer *batch,
+gen7_fill_kernel(struct intel_batchbuffer *batch,
 		const uint32_t kernel[][4],
 		size_t size)
 {
@@ -157,7 +149,7 @@ gen7_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *
 	uint32_t binding_table_offset, kernel_offset;
 
 	binding_table_offset = gen7_fill_binding_table(batch, dst);
-	kernel_offset = gen7_fill_media_kernel(batch, kernel, size);
+	kernel_offset = gen7_fill_kernel(batch, kernel, size);
 
 	idd = batch_alloc(batch, sizeof(*idd), 64);
 	offset = batch_offset(batch, idd);
@@ -272,7 +264,10 @@ gen7_emit_interface_descriptor_load(struct intel_batchbuffer *batch, uint32_t in
 	OUT_BATCH(GEN7_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2));
 	OUT_BATCH(0);
 	/* interface descriptor data length */
-	OUT_BATCH(sizeof(struct gen7_interface_descriptor_data));
+	if (IS_GEN7(batch->devid))
+		OUT_BATCH(sizeof(struct gen7_interface_descriptor_data));
+	else
+		OUT_BATCH(sizeof(struct gen8_interface_descriptor_data));
 	/* interface descriptor address, is relative to the dynamics base address */
 	OUT_BATCH(interface_descriptor);
 }
@@ -302,6 +297,8 @@ gen7_emit_media_objects(struct intel_batchbuffer *batch,
 			/* inline data (xoffset, yoffset) */
 			OUT_BATCH(x + i * 16);
 			OUT_BATCH(y + j * 16);
+			if (AT_LEAST_GEN(batch->devid, 8) && !IS_CHERRYVIEW(batch->devid))
+				gen8_emit_media_state_flush(batch);
 		}
 	}
 }
@@ -441,21 +438,6 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch,
 	return offset;
 }
 
-uint32_t
-gen8_fill_binding_table(struct intel_batchbuffer *batch,
-			struct igt_buf *dst)
-{
-	uint32_t *binding_table, offset;
-
-	binding_table = batch_alloc(batch, 32, 64);
-	offset = batch_offset(batch, binding_table);
-
-	binding_table[0] = gen8_fill_surface_state(batch, dst,
-						GEN8_SURFACEFORMAT_R8_UNORM, 1);
-
-	return offset;
-}
-
 uint32_t
 gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *dst,  const uint32_t kernel[][4], size_t size)
 {
@@ -463,8 +445,8 @@ gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *
 	uint32_t offset;
 	uint32_t binding_table_offset, kernel_offset;
 
-	binding_table_offset = gen8_fill_binding_table(batch, dst);
-	kernel_offset = gen8_fill_media_kernel(batch, kernel, size);
+	binding_table_offset = gen7_fill_binding_table(batch, dst);
+	kernel_offset = gen7_fill_kernel(batch, kernel, size);
 
 	idd = batch_alloc(batch, sizeof(*idd), 64);
 	offset = batch_offset(batch, idd);
@@ -525,7 +507,7 @@ gen8_emit_state_base_address(struct intel_batchbuffer *batch)
 void
 gen8_emit_vfe_state(struct intel_batchbuffer *batch)
 {
-	OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2));
+	OUT_BATCH(GEN7_MEDIA_VFE_STATE | (9 - 2));
 
 	/* scratch buffer */
 	OUT_BATCH(0);
@@ -550,7 +532,7 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch)
 void
 gen8_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch)
 {
-	OUT_BATCH(GEN8_MEDIA_VFE_STATE | (9 - 2));
+	OUT_BATCH(GEN7_MEDIA_VFE_STATE | (9 - 2));
 
 	/* scratch buffer */
 	OUT_BATCH(0);
@@ -570,28 +552,6 @@ gen8_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch)
 	OUT_BATCH(0);
 }
 
-void
-gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t curbe_buffer)
-{
-	OUT_BATCH(GEN8_MEDIA_CURBE_LOAD | (4 - 2));
-	OUT_BATCH(0);
-	/* curbe total data length */
-	OUT_BATCH(64);
-	/* curbe data start address, is relative to the dynamics base address */
-	OUT_BATCH(curbe_buffer);
-}
-
-void
-gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch, uint32_t interface_descriptor)
-{
-	OUT_BATCH(GEN8_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2));
-	OUT_BATCH(0);
-	/* interface descriptor data length */
-	OUT_BATCH(sizeof(struct gen8_interface_descriptor_data));
-	/* interface descriptor address, is relative to the dynamics base address */
-	OUT_BATCH(interface_descriptor);
-}
-
 void
 gen8_emit_media_state_flush(struct intel_batchbuffer *batch)
 {
@@ -599,63 +559,7 @@ gen8_emit_media_state_flush(struct intel_batchbuffer *batch)
 	OUT_BATCH(0);
 }
 
-void
-gen8_emit_media_objects(struct intel_batchbuffer *batch,
-			unsigned x, unsigned y,
-			unsigned width, unsigned height)
-{
-	int i, j;
-
-	for (i = 0; i < width / 16; i++) {
-		for (j = 0; j < height / 16; j++) {
-			OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2));
-
-			/* interface descriptor offset */
-			OUT_BATCH(0);
-
-			/* without indirect data */
-			OUT_BATCH(0);
-			OUT_BATCH(0);
-
-			/* scoreboard */
-			OUT_BATCH(0);
-			OUT_BATCH(0);
-
-			/* inline data (xoffset, yoffset) */
-			OUT_BATCH(x + i * 16);
-			OUT_BATCH(y + j * 16);
-			gen8_emit_media_state_flush(batch);
-		}
-	}
-}
-void
-gen8lp_emit_media_objects(struct intel_batchbuffer *batch,
-			unsigned x, unsigned y,
-			unsigned width, unsigned height)
-{
-	int i, j;
-
-	for (i = 0; i < width / 16; i++) {
-		for (j = 0; j < height / 16; j++) {
-			OUT_BATCH(GEN8_MEDIA_OBJECT | (8 - 2));
-
-			/* interface descriptor offset */
-			OUT_BATCH(0);
-
-			/* without indirect data */
-			OUT_BATCH(0);
-			OUT_BATCH(0);
-
-			/* scoreboard */
-			OUT_BATCH(0);
-			OUT_BATCH(0);
 
-			/* inline data (xoffset, yoffset) */
-			OUT_BATCH(x + i * 16);
-			OUT_BATCH(y + j * 16);
-		}
-	}
-}
 void
 gen8_emit_gpgpu_walk(struct intel_batchbuffer *batch,
 		     unsigned x, unsigned y,
diff --git a/lib/gpu_fill.h b/lib/gpu_fill.h
index 973513b0..9200fe4f 100644
--- a/lib/gpu_fill.h
+++ b/lib/gpu_fill.h
@@ -43,12 +43,7 @@ gen7_fill_binding_table(struct intel_batchbuffer *batch,
 			struct igt_buf *dst);
 
 uint32_t
-gen7_fill_media_kernel(struct intel_batchbuffer *batch,
-		const uint32_t kernel[][4],
-		size_t size);
-
-uint32_t
-gen8_fill_media_kernel(struct intel_batchbuffer *batch,
+gen7_fill_kernel(struct intel_batchbuffer *batch,
 		const uint32_t kernel[][4],
 		size_t size);
 
@@ -94,10 +89,6 @@ gen8_fill_surface_state(struct intel_batchbuffer *batch,
 			uint32_t format,
 			int is_dst);
 
-uint32_t
-gen8_fill_binding_table(struct intel_batchbuffer *batch,
-			struct igt_buf *dst);
-
 uint32_t
 gen8_fill_interface_descriptor(struct intel_batchbuffer *batch, struct igt_buf *dst,  const uint32_t kernel[][4], size_t size);
 
@@ -110,25 +101,9 @@ gen8_emit_vfe_state(struct intel_batchbuffer *batch);
 void
 gen8_emit_vfe_state_gpgpu(struct intel_batchbuffer *batch);
 
-void
-gen8_emit_curbe_load(struct intel_batchbuffer *batch, uint32_t curbe_buffer);
-
-void
-gen8_emit_interface_descriptor_load(struct intel_batchbuffer *batch, uint32_t interface_descriptor);
-
 void
 gen8_emit_media_state_flush(struct intel_batchbuffer *batch);
 
-void
-gen8_emit_media_objects(struct intel_batchbuffer *batch,
-			unsigned x, unsigned y,
-			unsigned width, unsigned height);
-
-void
-gen8lp_emit_media_objects(struct intel_batchbuffer *batch,
-			unsigned x, unsigned y,
-			unsigned width, unsigned height);
-
 void
 gen8_emit_gpgpu_walk(struct intel_batchbuffer *batch,
 		     unsigned x, unsigned y,
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 7c04ccf3..10d4dce8 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -796,12 +796,10 @@ igt_fillfunc_t igt_get_media_fillfunc(int devid)
 
 	if (IS_GEN9(devid))
 		fill = gen9_media_fillfunc;
-	else if (IS_BROADWELL(devid))
+	else if (IS_GEN8(devid))
 		fill = gen8_media_fillfunc;
 	else if (IS_GEN7(devid))
 		fill = gen7_media_fillfunc;
-	else if (IS_CHERRYVIEW(devid))
-		fill = gen8lp_media_fillfunc;
 
 	return fill;
 }
diff --git a/lib/media_fill.h b/lib/media_fill.h
index 226489cb..161af8cf 100644
--- a/lib/media_fill.h
+++ b/lib/media_fill.h
@@ -18,13 +18,6 @@ gen7_media_fillfunc(struct intel_batchbuffer *batch,
                 unsigned width, unsigned height,
                 uint8_t color);
 
-void
-gen8lp_media_fillfunc(struct intel_batchbuffer *batch,
-		struct igt_buf *dst,
-		unsigned x, unsigned y,
-		unsigned width, unsigned height,
-		uint8_t color);
-
 void
 gen9_media_fillfunc(struct intel_batchbuffer *batch,
                 struct igt_buf *dst,
diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c
index 4270997e..e398c8ea 100644
--- a/lib/media_fill_gen8.c
+++ b/lib/media_fill_gen8.c
@@ -73,11 +73,11 @@ gen8_media_fillfunc(struct intel_batchbuffer *batch,
 
 	gen8_emit_vfe_state(batch);
 
-	gen8_emit_curbe_load(batch, curbe_buffer);
+	gen7_emit_curbe_load(batch, curbe_buffer);
 
-	gen8_emit_interface_descriptor_load(batch, interface_descriptor);
+	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 
-	gen8_emit_media_objects(batch, x, y, width, height);
+	gen7_emit_media_objects(batch, x, y, width, height);
 
 	OUT_BATCH(MI_BATCH_BUFFER_END);
 
diff --git a/lib/media_fill_gen8lp.c b/lib/media_fill_gen8lp.c
deleted file mode 100644
index dcc11982..00000000
--- a/lib/media_fill_gen8lp.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <intel_bufmgr.h>
-#include <i915_drm.h>
-
-#include "media_fill.h"
-#include "gen8_media.h"
-#include "intel_reg.h"
-#include "drmtest.h"
-#include "gpu_fill.h"
-#include <assert.h>
-
-
-static const uint32_t media_kernel[][4] = {
-	{ 0x00400001, 0x20202288, 0x00000020, 0x00000000 },
-	{ 0x00600001, 0x20800208, 0x008d0000, 0x00000000 },
-	{ 0x00200001, 0x20800208, 0x00450040, 0x00000000 },
-	{ 0x00000001, 0x20880608, 0x00000000, 0x000f000f },
-	{ 0x00800001, 0x20a00208, 0x00000020, 0x00000000 },
-	{ 0x00800001, 0x20e00208, 0x00000020, 0x00000000 },
-	{ 0x00800001, 0x21200208, 0x00000020, 0x00000000 },
-	{ 0x00800001, 0x21600208, 0x00000020, 0x00000000 },
-	{ 0x0c800031, 0x24000a40, 0x0e000080, 0x120a8000 },
-	{ 0x00600001, 0x2e000208, 0x008d0000, 0x00000000 },
-	{ 0x07800031, 0x20000a40, 0x0e000e00, 0x82000010 },
-};
-
-/*
- * This sets up the media pipeline,
- *
- * +---------------+ <---- 4096
- * |       ^       |
- * |       |       |
- * |    various    |
- * |      state    |
- * |       |       |
- * |_______|_______| <---- 2048 + ?
- * |       ^       |
- * |       |       |
- * |   batch       |
- * |    commands   |
- * |       |       |
- * |       |       |
- * +---------------+ <---- 0 + ?
- *
- */
-
-#define BATCH_STATE_SPLIT 2048
-
-void
-gen8lp_media_fillfunc(struct intel_batchbuffer *batch,
-		struct igt_buf *dst,
-		unsigned x, unsigned y,
-		unsigned width, unsigned height,
-		uint8_t color)
-{
-	uint32_t curbe_buffer, interface_descriptor;
-	uint32_t batch_end;
-
-	intel_batchbuffer_flush(batch);
-
-	/* setup states */
-	batch->ptr = &batch->buffer[BATCH_STATE_SPLIT];
-
-	curbe_buffer = gen8_fill_curbe_buffer_data(batch, color);
-	interface_descriptor = gen8_fill_interface_descriptor(batch, dst, media_kernel, sizeof(media_kernel));
-	igt_assert(batch->ptr < &batch->buffer[4095]);
-
-	/* media pipeline */
-	batch->ptr = batch->buffer;
-	OUT_BATCH(GEN8_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
-	gen8_emit_state_base_address(batch);
-
-	gen8_emit_vfe_state(batch);
-
-	gen8_emit_curbe_load(batch, curbe_buffer);
-
-	gen8_emit_interface_descriptor_load(batch, interface_descriptor);
-
-	gen8lp_emit_media_objects(batch, x, y, width, height);
-
-	OUT_BATCH(MI_BATCH_BUFFER_END);
-
-	batch_end = batch_align(batch, 8);
-	igt_assert(batch_end < BATCH_STATE_SPLIT);
-
-	gen8_render_flush(batch, batch_end);
-	intel_batchbuffer_reset(batch);
-}
diff --git a/lib/media_fill_gen9.c b/lib/media_fill_gen9.c
index 6accdbe4..a492466a 100644
--- a/lib/media_fill_gen9.c
+++ b/lib/media_fill_gen9.c
@@ -75,11 +75,11 @@ gen9_media_fillfunc(struct intel_batchbuffer *batch,
 
 	gen8_emit_vfe_state(batch);
 
-	gen8_emit_curbe_load(batch, curbe_buffer);
+	gen7_emit_curbe_load(batch, curbe_buffer);
 
-	gen8_emit_interface_descriptor_load(batch, interface_descriptor);
+	gen7_emit_interface_descriptor_load(batch, interface_descriptor);
 
-	gen8_emit_media_objects(batch, x, y, width, height);
+	gen7_emit_media_objects(batch, x, y, width, height);
 
 	OUT_BATCH(GEN8_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA |
 			GEN9_FORCE_MEDIA_AWAKE_DISABLE |
diff --git a/lib/meson.build b/lib/meson.build
index 385e08b9..5f2567fb 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -26,7 +26,6 @@ lib_sources = [
 	'ioctl_wrappers.c',
 	'media_fill_gen7.c',
 	'media_fill_gen8.c',
-	'media_fill_gen8lp.c',
 	'media_fill_gen9.c',
 	'media_spin.c',
 	'gpgpu_fill.c',
-- 
2.14.3

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

  parent reply	other threads:[~2018-04-09 14:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 14:34 [igt-dev] [PATCH i-g-t v3 0/4] Refactoring of *_fill libraries Katarzyna Dec
2018-04-09 14:34 ` [igt-dev] [PATCH i-g-t v3 1/4] lib: Move common gpgpu/media fill functions to gpu_fill library Katarzyna Dec
2018-04-09 14:34 ` Katarzyna Dec [this message]
2018-04-09 14:34 ` [igt-dev] [PATCH i-g-t v3 3/4] lib/gpgpu_fill: Add missing configuration parameters for gpgpu_fill Katarzyna Dec
2018-04-09 14:34 ` [igt-dev] [PATCH i-g-t v3 4/4] lib: Adjust refactored gpu_fill library to our coding style Katarzyna Dec
2018-04-09 15:04 ` [igt-dev] ✗ Fi.CI.BAT: failure for Refactoring of *_fill libraries (rev2) 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=20180409143449.13845-3-katarzyna.dec@intel.com \
    --to=katarzyna.dec@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