[virglrenderer-devel] [PATCH 01/16] tests: Check if geometry shaders are available before running tests

Jakob Bornecrantz jakob.bornecrantz at collabora.com
Fri Dec 22 18:57:41 UTC 2017


From: Elie Tournier <elie.tournier at collabora.com>

Signed-off-by: Elie Tournier <elie.tournier at collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob.bornecrantz at collabora.com>
---
 tests/test_virgl_cmd.c |  7 +++++++
 tests/testvirgl.c      | 23 +++++++++++++++++++++++
 tests/testvirgl.h      |  1 +
 3 files changed, 31 insertions(+)

diff --git a/tests/test_virgl_cmd.c b/tests/test_virgl_cmd.c
index b342e85..816e5dc 100644
--- a/tests/test_virgl_cmd.c
+++ b/tests/test_virgl_cmd.c
@@ -497,6 +497,13 @@ START_TEST(virgl_test_render_geom_simple)
     ret = testvirgl_init_ctx_cmdbuf(&ctx);
     ck_assert_int_eq(ret, 0);
 
+    /* Geometry shader are only available since GLSL 150 */
+    uint32_t glsl_level = testvirgl_get_glsl_level_from_caps();
+    if (glsl_level < 150) {
+      testvirgl_fini_ctx_cmdbuf(&ctx);
+      return;
+    }
+
     /* init and create simple 2D resource */
     ret = testvirgl_create_backed_simple_2d_res(&res, 1, tw, th);
     ck_assert_int_eq(ret, 0);
diff --git a/tests/testvirgl.c b/tests/testvirgl.c
index 03b31e0..a7c8043 100644
--- a/tests/testvirgl.c
+++ b/tests/testvirgl.c
@@ -32,6 +32,7 @@
 #include "util/u_format.h"
 #include "testvirgl.h"
 
+#include "virgl_hw.h"
 #include "virglrenderer.h"
 
 void testvirgl_init_simple_1d_resource(struct virgl_renderer_resource_create_args *res, int handle)
@@ -265,3 +266,25 @@ int testvirgl_create_backed_simple_buffer(struct virgl_resource *res,
     virgl_renderer_resource_attach_iov(res->handle, res->iovs, res->niovs);
     return 0;
 }
+
+uint32_t testvirgl_get_glsl_level_from_caps(void)
+{
+  uint32_t max_ver, max_size, glsl_level;
+  void *caps;
+
+  virgl_renderer_get_cap_set(1, &max_ver, &max_size);
+  ck_assert_int_eq(max_ver, 1);
+  ck_assert_int_ne(max_size, 0);
+  ck_assert_int_eq(max_size, sizeof(struct virgl_caps_v1));
+
+  caps = malloc(max_size);
+
+  virgl_renderer_fill_caps(0, 0, caps);
+
+  struct virgl_caps_v1 *v1 = (struct virgl_caps_v1*) caps;
+  glsl_level = v1->glsl_level;
+
+  free(caps);
+
+  return glsl_level;
+}
diff --git a/tests/testvirgl.h b/tests/testvirgl.h
index 64f0a8e..28b15d0 100644
--- a/tests/testvirgl.h
+++ b/tests/testvirgl.h
@@ -77,4 +77,5 @@ int testvirgl_create_backed_simple_2d_res(struct virgl_resource *res,
 int testvirgl_create_backed_simple_buffer(struct virgl_resource *res,
 					  int handle, int size, int bind);
 void testvirgl_destroy_backed_res(struct virgl_resource *res);
+uint32_t testvirgl_get_glsl_level_from_caps(void);
 #endif
-- 
2.11.0



More information about the virglrenderer-devel mailing list