All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm 0/3] tests/etnaviv_2d_test: some test improvements
@ 2020-12-01 20:38 Lubomir Rintel
  2020-12-01 20:38 ` [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Lubomir Rintel
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lubomir Rintel @ 2020-12-01 20:38 UTC (permalink / raw)
  To: dri-devel; +Cc: etnaviv

Hi,

patches chained to this message contains changes I've found useful when
testing whether 2d rendering works well with the etnaviv driver on my
platform. Perhaps they're useful enough for merging upstream.

Thanks
Lubo


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors
  2020-12-01 20:38 [PATCH libdrm 0/3] tests/etnaviv_2d_test: some test improvements Lubomir Rintel
@ 2020-12-01 20:38 ` Lubomir Rintel
  2020-12-09 14:54   ` Christian Gmeiner
  2020-12-01 20:38 ` [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core Lubomir Rintel
  2020-12-01 20:38 ` [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct Lubomir Rintel
  2 siblings, 1 reply; 7+ messages in thread
From: Lubomir Rintel @ 2020-12-01 20:38 UTC (permalink / raw)
  To: dri-devel; +Cc: Lubomir Rintel, etnaviv

Just so that it's obvious what failed and why.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 tests/etnaviv/etnaviv_2d_test.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
index 8dd77b66..eb9dfa59 100644
--- a/tests/etnaviv/etnaviv_2d_test.c
+++ b/tests/etnaviv/etnaviv_2d_test.c
@@ -162,9 +162,16 @@ int main(int argc, char *argv[])
 	drmVersionPtr version;
 	int fd, ret = 0;
 
-	fd = open(argv[1], O_RDWR);
-	if (fd < 0)
+	if (argc < 2) {
+		fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
 		return 1;
+	}
+
+	fd = open(argv[1], O_RDWR);
+	if (fd < 0) {
+		perror(argv[1]);
+		return 1;
+	}
 
 	version = drmGetVersion(fd);
 	if (version) {
@@ -178,6 +185,7 @@ int main(int argc, char *argv[])
 
 	dev = etna_device_new(fd);
 	if (!dev) {
+		perror("etna_device_new");
 		ret = 2;
 		goto out;
 	}
@@ -185,18 +193,21 @@ int main(int argc, char *argv[])
 	/* TODO: we assume that core 0 is a 2D capable one */
 	gpu = etna_gpu_new(dev, 0);
 	if (!gpu) {
+		perror("etna_gpu_new");
 		ret = 3;
 		goto out_device;
 	}
 
 	pipe = etna_pipe_new(gpu, ETNA_PIPE_2D);
 	if (!pipe) {
+		perror("etna_pipe_new");
 		ret = 4;
 		goto out_gpu;
 	}
 
 	bmp = etna_bo_new(dev, bmp_size, ETNA_BO_UNCACHED);
 	if (!bmp) {
+		perror("etna_bo_new");
 		ret = 5;
 		goto out_pipe;
 	}
@@ -204,6 +215,7 @@ int main(int argc, char *argv[])
 
 	stream = etna_cmd_stream_new(pipe, 0x300, NULL, NULL);
 	if (!stream) {
+		perror("etna_cmd_stream_new");
 		ret = 6;
 		goto out_bo;
 	}
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core
  2020-12-01 20:38 [PATCH libdrm 0/3] tests/etnaviv_2d_test: some test improvements Lubomir Rintel
  2020-12-01 20:38 ` [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Lubomir Rintel
@ 2020-12-01 20:38 ` Lubomir Rintel
  2020-12-09 14:56   ` Christian Gmeiner
  2020-12-01 20:38 ` [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct Lubomir Rintel
  2 siblings, 1 reply; 7+ messages in thread
From: Lubomir Rintel @ 2020-12-01 20:38 UTC (permalink / raw)
  To: dri-devel; +Cc: Lubomir Rintel, etnaviv

Run the test on a core capable of 2D rendering instead of hardcoding to
core zero.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 tests/etnaviv/etnaviv_2d_test.c | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
index eb9dfa59..a75a4a89 100644
--- a/tests/etnaviv/etnaviv_2d_test.c
+++ b/tests/etnaviv/etnaviv_2d_test.c
@@ -161,6 +161,8 @@ int main(int argc, char *argv[])
 
 	drmVersionPtr version;
 	int fd, ret = 0;
+	uint64_t feat;
+	int core = 0;
 
 	if (argc < 2) {
 		fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
@@ -190,13 +192,28 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	/* TODO: we assume that core 0 is a 2D capable one */
-	gpu = etna_gpu_new(dev, 0);
-	if (!gpu) {
-		perror("etna_gpu_new");
-		ret = 3;
-		goto out_device;
-	}
+	do {
+		gpu = etna_gpu_new(dev, core);
+		if (!gpu) {
+			perror("etna_gpu_new");
+			ret = 3;
+			goto out_device;
+		}
+
+		if (etna_gpu_get_param(gpu, ETNA_GPU_FEATURES_0, &feat)) {
+			perror("etna_gpu_get_param");
+			ret = 4;
+			goto out_device;
+		}
+
+		if ((feat & (1 << 9)) == 0) {
+			/* GPU not 2D capable. */
+			etna_gpu_del(gpu);
+			gpu = NULL;
+		}
+
+		core++;
+	} while (!gpu);
 
 	pipe = etna_pipe_new(gpu, ETNA_PIPE_2D);
 	if (!pipe) {
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct
  2020-12-01 20:38 [PATCH libdrm 0/3] tests/etnaviv_2d_test: some test improvements Lubomir Rintel
  2020-12-01 20:38 ` [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Lubomir Rintel
  2020-12-01 20:38 ` [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core Lubomir Rintel
@ 2020-12-01 20:38 ` Lubomir Rintel
  2020-12-09 14:58   ` Christian Gmeiner
  2 siblings, 1 reply; 7+ messages in thread
From: Lubomir Rintel @ 2020-12-01 20:38 UTC (permalink / raw)
  To: dri-devel; +Cc: Lubomir Rintel, etnaviv

Instead of always dumping the rendered picture, check whether it matches
the expectations. This makes more sense for automated testing.

Retain the ability to dump the picture instead of checking it when a
file name is given as an argument. This also removes use of a hardcoded
file name in a world writable directory, which is an unsafe thing to
do anyway.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
---
 tests/etnaviv/etnaviv_2d_test.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
index a75a4a89..9fcdae18 100644
--- a/tests/etnaviv/etnaviv_2d_test.c
+++ b/tests/etnaviv/etnaviv_2d_test.c
@@ -147,6 +147,27 @@ static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo *bmp,
 	etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D);
 }
 
+int etna_check_image(uint32_t *p, int width, int height)
+{
+	int i;
+	uint32_t expected;
+
+	for (i = 0; i < width * height; i++) {
+		if (i%8 < 4 && i%(width*8) < width*4 && i%width < 8*16 && i < width*8*16)
+			expected = 0xff40ff40;
+		else
+			expected = 0x00000000;
+
+		if (p[i] != expected) {
+			fprintf(stderr, "Offset %d: expected: 0x%08x, got: 0x%08x\n",
+				i, expected, p[i]);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 int main(int argc, char *argv[])
 {
 	const int width = 256;
@@ -165,7 +186,7 @@ int main(int argc, char *argv[])
 	int core = 0;
 
 	if (argc < 2) {
-		fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
+		fprintf(stderr, "Usage: %s /dev/dri/<device> [<etna.bmp>]\n", argv[0]);
 		return 1;
 	}
 
@@ -242,7 +263,11 @@ int main(int argc, char *argv[])
 
 	etna_cmd_stream_finish(stream);
 
-	bmp_dump32(etna_bo_map(bmp), width, height, false, "/tmp/etna.bmp");
+	if (argc > 2)
+		bmp_dump32(etna_bo_map(bmp), width, height, false, argv[2]);
+
+	if (etna_check_image(etna_bo_map(bmp), width, height))
+		ret = 7;
 
 	etna_cmd_stream_del(stream);
 
-- 
2.28.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors
  2020-12-01 20:38 ` [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Lubomir Rintel
@ 2020-12-09 14:54   ` Christian Gmeiner
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Gmeiner @ 2020-12-09 14:54 UTC (permalink / raw)
  To: Lubomir Rintel; +Cc: The etnaviv authors, DRI mailing list

Am Di., 1. Dez. 2020 um 21:38 Uhr schrieb Lubomir Rintel <lkundrak@v3.sk>:
>
> Just so that it's obvious what failed and why.
>
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  tests/etnaviv/etnaviv_2d_test.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
> index 8dd77b66..eb9dfa59 100644
> --- a/tests/etnaviv/etnaviv_2d_test.c
> +++ b/tests/etnaviv/etnaviv_2d_test.c
> @@ -162,9 +162,16 @@ int main(int argc, char *argv[])
>         drmVersionPtr version;
>         int fd, ret = 0;
>
> -       fd = open(argv[1], O_RDWR);
> -       if (fd < 0)
> +       if (argc < 2) {
> +               fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
>                 return 1;
> +       }
> +
> +       fd = open(argv[1], O_RDWR);
> +       if (fd < 0) {
> +               perror(argv[1]);
> +               return 1;
> +       }
>
>         version = drmGetVersion(fd);
>         if (version) {
> @@ -178,6 +185,7 @@ int main(int argc, char *argv[])
>
>         dev = etna_device_new(fd);
>         if (!dev) {
> +               perror("etna_device_new");
>                 ret = 2;
>                 goto out;
>         }
> @@ -185,18 +193,21 @@ int main(int argc, char *argv[])
>         /* TODO: we assume that core 0 is a 2D capable one */
>         gpu = etna_gpu_new(dev, 0);
>         if (!gpu) {
> +               perror("etna_gpu_new");
>                 ret = 3;
>                 goto out_device;
>         }
>
>         pipe = etna_pipe_new(gpu, ETNA_PIPE_2D);
>         if (!pipe) {
> +               perror("etna_pipe_new");
>                 ret = 4;
>                 goto out_gpu;
>         }
>
>         bmp = etna_bo_new(dev, bmp_size, ETNA_BO_UNCACHED);
>         if (!bmp) {
> +               perror("etna_bo_new");
>                 ret = 5;
>                 goto out_pipe;
>         }
> @@ -204,6 +215,7 @@ int main(int argc, char *argv[])
>
>         stream = etna_cmd_stream_new(pipe, 0x300, NULL, NULL);
>         if (!stream) {
> +               perror("etna_cmd_stream_new");
>                 ret = 6;
>                 goto out_bo;
>         }
> --
> 2.28.0
>
> _______________________________________________
> etnaviv mailing list
> etnaviv@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core
  2020-12-01 20:38 ` [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core Lubomir Rintel
@ 2020-12-09 14:56   ` Christian Gmeiner
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Gmeiner @ 2020-12-09 14:56 UTC (permalink / raw)
  To: Lubomir Rintel; +Cc: The etnaviv authors, DRI mailing list

Am Di., 1. Dez. 2020 um 21:38 Uhr schrieb Lubomir Rintel <lkundrak@v3.sk>:
>
> Run the test on a core capable of 2D rendering instead of hardcoding to
> core zero.
>

Thanks - I should have done this before landing this test :)

> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  tests/etnaviv/etnaviv_2d_test.c | 31 ++++++++++++++++++++++++-------
>  1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
> index eb9dfa59..a75a4a89 100644
> --- a/tests/etnaviv/etnaviv_2d_test.c
> +++ b/tests/etnaviv/etnaviv_2d_test.c
> @@ -161,6 +161,8 @@ int main(int argc, char *argv[])
>
>         drmVersionPtr version;
>         int fd, ret = 0;
> +       uint64_t feat;
> +       int core = 0;
>
>         if (argc < 2) {
>                 fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
> @@ -190,13 +192,28 @@ int main(int argc, char *argv[])
>                 goto out;
>         }
>
> -       /* TODO: we assume that core 0 is a 2D capable one */
> -       gpu = etna_gpu_new(dev, 0);
> -       if (!gpu) {
> -               perror("etna_gpu_new");
> -               ret = 3;
> -               goto out_device;
> -       }
> +       do {
> +               gpu = etna_gpu_new(dev, core);
> +               if (!gpu) {
> +                       perror("etna_gpu_new");
> +                       ret = 3;
> +                       goto out_device;
> +               }
> +
> +               if (etna_gpu_get_param(gpu, ETNA_GPU_FEATURES_0, &feat)) {
> +                       perror("etna_gpu_get_param");
> +                       ret = 4;
> +                       goto out_device;
> +               }
> +
> +               if ((feat & (1 << 9)) == 0) {
> +                       /* GPU not 2D capable. */
> +                       etna_gpu_del(gpu);
> +                       gpu = NULL;
> +               }
> +
> +               core++;
> +       } while (!gpu);
>
>         pipe = etna_pipe_new(gpu, ETNA_PIPE_2D);
>         if (!pipe) {
> --
> 2.28.0
>
> _______________________________________________
> etnaviv mailing list
> etnaviv@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct
  2020-12-01 20:38 ` [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct Lubomir Rintel
@ 2020-12-09 14:58   ` Christian Gmeiner
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Gmeiner @ 2020-12-09 14:58 UTC (permalink / raw)
  To: Lubomir Rintel; +Cc: The etnaviv authors, DRI mailing list

Am Di., 1. Dez. 2020 um 21:38 Uhr schrieb Lubomir Rintel <lkundrak@v3.sk>:
>
> Instead of always dumping the rendered picture, check whether it matches
> the expectations. This makes more sense for automated testing.
>
> Retain the ability to dump the picture instead of checking it when a
> file name is given as an argument. This also removes use of a hardcoded
> file name in a world writable directory, which is an unsafe thing to
> do anyway.
>
> Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  tests/etnaviv/etnaviv_2d_test.c | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/tests/etnaviv/etnaviv_2d_test.c b/tests/etnaviv/etnaviv_2d_test.c
> index a75a4a89..9fcdae18 100644
> --- a/tests/etnaviv/etnaviv_2d_test.c
> +++ b/tests/etnaviv/etnaviv_2d_test.c
> @@ -147,6 +147,27 @@ static void gen_cmd_stream(struct etna_cmd_stream *stream, struct etna_bo *bmp,
>         etna_set_state(stream, VIVS_GL_FLUSH_CACHE, VIVS_GL_FLUSH_CACHE_PE2D);
>  }
>
> +int etna_check_image(uint32_t *p, int width, int height)
> +{
> +       int i;
> +       uint32_t expected;
> +
> +       for (i = 0; i < width * height; i++) {
> +               if (i%8 < 4 && i%(width*8) < width*4 && i%width < 8*16 && i < width*8*16)
> +                       expected = 0xff40ff40;
> +               else
> +                       expected = 0x00000000;
> +
> +               if (p[i] != expected) {
> +                       fprintf(stderr, "Offset %d: expected: 0x%08x, got: 0x%08x\n",
> +                               i, expected, p[i]);
> +                       return -1;
> +               }
> +       }
> +
> +       return 0;
> +}
> +
>  int main(int argc, char *argv[])
>  {
>         const int width = 256;
> @@ -165,7 +186,7 @@ int main(int argc, char *argv[])
>         int core = 0;
>
>         if (argc < 2) {
> -               fprintf(stderr, "Usage: %s /dev/dri/<device>\n", argv[0]);
> +               fprintf(stderr, "Usage: %s /dev/dri/<device> [<etna.bmp>]\n", argv[0]);
>                 return 1;
>         }
>
> @@ -242,7 +263,11 @@ int main(int argc, char *argv[])
>
>         etna_cmd_stream_finish(stream);
>
> -       bmp_dump32(etna_bo_map(bmp), width, height, false, "/tmp/etna.bmp");
> +       if (argc > 2)
> +               bmp_dump32(etna_bo_map(bmp), width, height, false, argv[2]);
> +
> +       if (etna_check_image(etna_bo_map(bmp), width, height))
> +               ret = 7;
>
>         etna_cmd_stream_del(stream);
>
> --
> 2.28.0
>
> _______________________________________________
> etnaviv mailing list
> etnaviv@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/etnaviv



-- 
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-12-09 14:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01 20:38 [PATCH libdrm 0/3] tests/etnaviv_2d_test: some test improvements Lubomir Rintel
2020-12-01 20:38 ` [PATCH libdrm 1/3] tests/etnaviv_2d_test: explain the errors Lubomir Rintel
2020-12-09 14:54   ` Christian Gmeiner
2020-12-01 20:38 ` [PATCH libdrm 2/3] tests/etnaviv_2d_test: pick the 2D core Lubomir Rintel
2020-12-09 14:56   ` Christian Gmeiner
2020-12-01 20:38 ` [PATCH libdrm 3/3] tests/etnaviv_2d_test: check whether the rendering is correct Lubomir Rintel
2020-12-09 14:58   ` Christian Gmeiner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.