Re: [Piglit] [PATCH] tests/image_load_store/atomic: use piglit subtest framework

2018-11-20 Thread Rafael Antognolli
Awesome, thanks for doing this.

Reviewed-by: Rafael Antognolli 

Also, it fixes the issue I had, but apparently it's not the only test
with that problem. Another test with the same issue:

spec@arb_shader_image_size@builtin

I would guess there are other tests in the same situation, it just
happens that I didn't have a GPU hang with them, and so they didn't
incorrectly report pass when they actually hung.

Thanks anyway.
Rafael

On Mon, Nov 19, 2018 at 03:12:27PM -0800, Dylan Baker wrote:
> cc: Rafael Antognolli 
> ---
>  .../arb_shader_image_load_store/atomicity.c   | 403 +++---
>  1 file changed, 239 insertions(+), 164 deletions(-)
> 
> diff --git a/tests/spec/arb_shader_image_load_store/atomicity.c 
> b/tests/spec/arb_shader_image_load_store/atomicity.c
> index f53dddaa2..88d15d65d 100644
> --- a/tests/spec/arb_shader_image_load_store/atomicity.c
> +++ b/tests/spec/arb_shader_image_load_store/atomicity.c
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright (C) 2014 Intel Corporation
> + * Copyright © 2018 Intel Corporation
>   *
>   * Permission is hereby granted, free of charge, to any person obtaining a
>   * copy of this software and associated documentation files (the "Software"),
> @@ -58,16 +59,7 @@
>  /** Total number of pixels in the window and image. */
>  #define N (W * H)
>  
> -PIGLIT_GL_TEST_CONFIG_BEGIN
> -
> -config.supports_gl_core_version = 32;
> -
> -config.window_width = W;
> -config.window_height = H;
> -config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> -config.khr_no_error_support = PIGLIT_NO_ERRORS;
> -
> -PIGLIT_GL_TEST_CONFIG_END
> +static struct piglit_gl_test_config *piglit_config;
>  
>  static bool
>  init_image(const struct image_info img, uint32_t v)
> @@ -112,56 +104,28 @@ check_image_const(const struct image_info img, unsigned 
> n, uint32_t v)
>   pixels, v, 0, 0, 0);
>  }
>  
> -/**
> - * Test skeleton: Init image to \a init_value, run the provided shader
> - * \a op, check that the first \a check_sz pixels of the image equal
> - * \a check_value and optionally check that the resulting fragment
> - * values on the framebuffer are unique.
> - */
> -static bool
> -run_test(uint32_t init_value, unsigned check_sz, uint32_t check_value,
> - bool check_unique, const char *op)
> -{
> -const struct grid_info grid =
> -grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H);
> -const struct image_info img =
> -image_info(GL_TEXTURE_1D, GL_R32UI, W, H);
> -GLuint prog = generate_program(
> -grid, GL_FRAGMENT_SHADER,
> -concat(image_hunk(img, ""),
> -   hunk("volatile IMAGE_UNIFORM_T img;\n"),
> -   hunk(op), NULL));
> -bool ret = prog &&
> -init_fb(grid) &&
> -init_image(img, init_value) &&
> -set_uniform_int(prog, "img", 0) &&
> -draw_grid(grid, prog) &&
> -check_image_const(img, check_sz, check_value) &&
> -(!check_unique || check_fb_unique(grid));
> -
> -glDeleteProgram(prog);
> -return ret;
> -}
> -
> -void
> -piglit_init(int argc, char **argv)
> +struct testcase
>  {
> -enum piglit_result status = PIGLIT_PASS;
> -
> -piglit_require_extension("GL_ARB_shader_image_load_store");
> -
> + uint32_t init_value;
> + unsigned check_sz;
> + uint32_t check_value;
> + bool check_unique;
> + const char * op;
> +};
> +
> +static struct testcase testdata[] = {
>  /*
>   * If imageAtomicAdd() is atomic the return values obtained
>   * from each call are guaranteed to be unique.
>   */
> -subtest(&status, true,
> -run_test(0, 1, N, true,
> - "GRID_T op(ivec2 idx, GRID_T x) {\n"
> - "   return GRID_T("
> - "  imageAtomicAdd(img, 
> IMAGE_ADDR(ivec2(0)), 1u),"
> - "  0, 0, 1);\n"
> - "}\n"),
> -"imageAtomicAdd");
> + {
> + 0, 1, N, true,
> + "GRID_T op(ivec2 idx, GRID_T x) {\n"
> + "   return GRID_T("
> + "  imageAtomicAdd(img, IMAGE_ADDR(ivec2(0)), 1u),"
> + "  0, 0, 1);\n"
> + "}\n",
> + },
>  
> 

[Piglit] [PATCH v2 5/7] egl-context-preemption: Add a subtest to reuse the same display.

2018-10-29 Thread Rafael Antognolli
Add a subtest that reuses the same EGLDisplay used in the main thread.
This is just another case we can test and see if there's a difference in
the preemption behavior.
---
 tests/egl/egl-context-preemption.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index e9180d4ee..3781f2fcf 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -51,6 +51,7 @@ struct test_data {
int nruns;
EGLDisplay dpy;
EGLContext ctx;
+   const struct test_profile *p;
 };
 
 struct test_profile {
@@ -58,6 +59,7 @@ struct test_profile {
size_t bufsize;
GLenum draw_mode;
GLuint (*shader_setup)(void);
+   bool same_display;
 };
 
 static bool small = false;
@@ -300,8 +302,9 @@ setup_thread_context(struct test_data *d)
bool ok = false;
EGLContext ctx2 = EGL_NO_CONTEXT;
 
-   EGLDisplay dpy;
-   if (init_other_display(&dpy) == PIGLIT_SKIP) {
+   EGLDisplay dpy = d->dpy;
+   if (!d->p->same_display &&
+   init_other_display(&dpy) == PIGLIT_SKIP) {
piglit_loge("failed to get display\n");
result = PIGLIT_FAIL;
return result;
@@ -351,7 +354,9 @@ setup_thread_context(struct test_data *d)
 cleanup:
if (ctx2 != EGL_NO_CONTEXT)
eglDestroyContext(dpy, ctx2);
-   eglTerminate(dpy);
+
+   if (!d->p->same_display)
+   eglTerminate(dpy);
 
return result;
 }
@@ -438,7 +443,8 @@ thread2_create_high_priority_context(void *data)
 
if (d->ctx != EGL_NO_CONTEXT)
eglDestroyContext(d->dpy, d->ctx);
-   eglTerminate(d->dpy);
+   if (!d->p->same_display)
+   eglTerminate(d->dpy);
 
return result;
 }
@@ -479,6 +485,7 @@ test_preemption(void *data)
struct test_data d = {
.main_finished = false,
.nruns = 0,
+   .p = profile,
};
d.dpy = eglGetCurrentDisplay();
 
@@ -626,6 +633,14 @@ static struct test_profile trifan = {
.shader_setup = setup_shaders,
 };
 
+static struct test_profile triangles_same_display = {
+   .vertices = triangle_vertices,
+   .bufsize = sizeof(triangle_vertices),
+   .draw_mode = GL_TRIANGLES,
+   .shader_setup = setup_shaders,
+   .same_display = true,
+};
+
 static const struct piglit_subtest subtests[] = {
{
"triangles",
@@ -639,6 +654,12 @@ static const struct piglit_subtest subtests[] = {
test_preemption,
&trifan,
},
+   {
+   "triangles_same_display",
+   "same_display",
+   test_preemption,
+   &triangles_same_display,
+   },
{0},
 };
 
-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 2/7] egl-context-preemption: Add check for high priority contexts.

2018-10-29 Thread Rafael Antognolli
Check if we can create high priority contexts, otherwise just fail the
test immediately. There's no reason to test for preemption if we can't
create high priority contexts.

v2: Require configless context (Tapani)
---
 tests/egl/egl-context-preemption.c | 58 ++
 1 file changed, 58 insertions(+)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 82a698aa1..5265bccc4 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -58,6 +58,40 @@ struct test_profile {
 static bool small = false;
 static int total_objects = 0;
 
+static EGLint
+check_priority(EGLDisplay dpy, EGLContext ctx, EGLint *expected)
+{
+   EGLint value;
+   EGLBoolean status =
+   eglQueryContext(dpy, ctx, EGL_CONTEXT_PRIORITY_LEVEL_IMG, 
&value);
+
+   if (status == EGL_FALSE) {
+   piglit_loge("eglQueryContext failed\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   if (expected && value != *expected) {
+   piglit_loge("%s fail: priority value 0x%x, expected 0x%x\n",
+   __func__, value, *expected);
+   piglit_loge("Can't create high priority context.\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   return value;
+}
+
+static EGLContext
+create_context(EGLDisplay dpy, EGLint *attr)
+{
+   EGLContext ctx =
+   eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr);
+
+   if (ctx == EGL_NO_CONTEXT) {
+   piglit_loge("could not create EGL context, attr 0x%x\n", 
attr[1]);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   return ctx;
+}
+
 static const char *vs_text =
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
@@ -304,6 +338,27 @@ piglit_display(void)
return result;
 }
 
+static void
+check_high_context_priority_creation(EGLDisplay dpy)
+{
+   EGLint attr[] = {
+   EGL_CONTEXT_PRIORITY_LEVEL_IMG,
+   EGL_CONTEXT_PRIORITY_HIGH_IMG,
+   EGL_NONE
+   };
+   EGLContext ctx = create_context(dpy, attr);
+   if (ctx == EGL_NO_CONTEXT) {
+   piglit_loge("failed to create context");
+   piglit_check_egl_error(EGL_SUCCESS);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   EGLint expected = EGL_CONTEXT_PRIORITY_HIGH_IMG;
+   check_priority(dpy, ctx, &expected);
+
+   eglDestroyContext(dpy, ctx);
+}
+
 void
 piglit_init(int argc, char **argv)
 {
@@ -311,6 +366,9 @@ piglit_init(int argc, char **argv)
 
dpy = eglGetCurrentDisplay();
piglit_require_egl_extension(dpy, "EGL_IMG_context_priority");
+   piglit_require_egl_extension(dpy, "EGL_MESA_configless_context");
+
+   check_high_context_priority_creation(dpy);
 
if (piglit_strip_arg(&argc, argv, "small"))
small = true;
-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 6/7] egl-context-preemption: Check that the rendering was correct.

2018-10-29 Thread Rafael Antognolli
Verify that the rendering done by the high priority thread was also
correct by rendering a reference image at the beginning.
---
 tests/egl/egl-context-preemption.c | 75 +-
 1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 3781f2fcf..64e11e48d 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -52,6 +52,7 @@ struct test_data {
EGLDisplay dpy;
EGLContext ctx;
const struct test_profile *p;
+   float *ref_image;
 };
 
 struct test_profile {
@@ -441,6 +442,16 @@ thread2_create_high_priority_context(void *data)
draw_high_priority(d, program, i);
}
 
+   /* check that the rendering was correct */
+   bool pass = true;
+   for (int i = 0; i < d->nruns; i++) {
+   glBindFramebuffer(GL_READ_FRAMEBUFFER, fbos[i]);
+   pass = pass && piglit_probe_image_rgba(0, 0, hp_width, 
hp_height,
+  d->ref_image);
+   }
+
+   *result = pass ? PIGLIT_PASS : PIGLIT_FAIL;
+
if (d->ctx != EGL_NO_CONTEXT)
eglDestroyContext(d->dpy, d->ctx);
if (!d->p->same_display)
@@ -477,6 +488,39 @@ read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei 
height,
return pixels;
 }
 
+static void*
+thread_create_ref_image(void *data)
+{
+   enum piglit_result *result = malloc(sizeof(*result));
+   struct test_data *d = data;
+
+   *result = setup_thread_context(d);
+   if (*result != PIGLIT_PASS)
+   return result;
+
+   GLuint fbo;
+   GLuint texColorBuffer;
+   setup_render_target(&fbo, &texColorBuffer, 1, hp_width, hp_height);
+
+   glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+   unsigned int program = setup_shaders();
+
+   draw_objects(program, GL_TRIANGLES, triangle_vertices,
+sizeof(triangle_vertices), 1);
+   glFinish();
+
+   d->ref_image = read_pixels_float(0, 0, hp_width, hp_height,
+GL_RGBA, NULL);
+
+   if (d->ctx != EGL_NO_CONTEXT)
+   eglDestroyContext(d->dpy, d->ctx);
+   if (!d->p->same_display)
+   eglTerminate(d->dpy);
+
+   return result;
+}
+
 static enum piglit_result
 test_preemption(void *data)
 {
@@ -489,6 +533,29 @@ test_preemption(void *data)
};
d.dpy = eglGetCurrentDisplay();
 
+   pthread_t thread1;
+   int err = pthread_create(
+   &thread1, NULL,
+   thread_create_ref_image,
+   &d);
+   if (err) {
+   piglit_loge("failed to create ref image thread");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   void *retval = NULL;
+   err = pthread_join(thread1, &retval);
+   if (err) {
+   piglit_loge("failed to join thread %"PRIuMAX, (uintmax_t) 
thread1);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   result = *((enum piglit_result *)retval);
+   if (result != PIGLIT_PASS)
+   goto cleanup;
+
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
 
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
@@ -526,7 +593,7 @@ test_preemption(void *data)
 
/* Start second thread with high priority */
pthread_t thread2;
-   int err = pthread_create(
+   err = pthread_create(
&thread2, NULL,
thread2_create_high_priority_context,
&d);
@@ -552,12 +619,16 @@ test_preemption(void *data)
 
glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
-   err = pthread_join(thread2, NULL);
+   err = pthread_join(thread2, &retval);
if (err) {
piglit_loge("failed to join thread %"PRIuMAX, (uintmax_t) 
thread2);
result = PIGLIT_FAIL;
goto cleanup;
}
+   result = *((enum piglit_result *)retval);
+   if (result != PIGLIT_PASS)
+   goto cleanup;
+
 
/* In this loop we are only looking for the first high priority render
 * that started after the main workload. In theory the first one should
-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 1/7] tests: Add base test for mid-command preemption.

2018-10-29 Thread Rafael Antognolli
This is the base of the test, where we use the main piglit context to
render to the framebuffer. It is supposed to be an artificially slow
draw call, that can be preempted by a higher priority context if needed.
---
 tests/egl/CMakeLists.gl.txt|   2 +
 tests/egl/egl-context-preemption.c | 319 +
 2 files changed, 321 insertions(+)
 create mode 100644 tests/egl/egl-context-preemption.c

diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index 3691c56a9..6de166044 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -35,6 +35,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(egl-invalid-attr pthread)
piglit_add_executable (egl-context-priority egl-context-priority.c)
target_link_libraries(egl-context-priority pthread)
+   piglit_add_executable (egl-context-preemption egl-context-preemption.c)
+   target_link_libraries(egl-context-preemption pthread)
 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 # vim: ft=cmake:
diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
new file mode 100644
index 0..82a698aa1
--- /dev/null
+++ b/tests/egl/egl-context-preemption.c
@@ -0,0 +1,319 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-egl.h"
+#include "piglit-util-gl.h"
+
+#include 
+
+#include 
+
+/**
+ * @file egl-context-preemption.c
+ *
+ * EGL API tests for IMG_context_priority extension:
+ * 
https://www.khronos.org/registry/EGL/extensions/IMG/EGL_IMG_context_priority.txt
+ *
+ * This file tries to test mid-command preemption (between triangles) support
+ * through the IMG_context_priority extension.  Particularly on i965, if a
+ * context is marked with high priority level, then it should preempt lower
+ * priority contexts (when the hardware and kernel supports it).
+ */
+
+#define HIGH_PRIO_RUNS 50
+
+struct test_data {
+   bool main_finished;
+   int64_t main_tstarted, main_tfinished;
+   EGLDisplay dpy;
+};
+
+struct test_profile {
+   GLfloat *vertices;
+   size_t bufsize;
+   GLenum draw_mode;
+   GLuint (*shader_setup)(void);
+};
+
+static bool small = false;
+static int total_objects = 0;
+
+static const char *vs_text =
+   "#version 330 core\n"
+   "layout (location = 0) in vec3 aPos;\n"
+   "uniform int nInstances;\n"
+   "out vec4 color;\n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "int i = gl_InstanceID;\n"
+   "float integer;\n"
+   "float r = 0.0 + (1.0 / nInstances) * i;\n"
+   "modf(r, integer);\n"
+   "r -= integer;\n"
+   "float g = 0.333 + (1.0 / nInstances) * i;\n"
+   "modf(g, integer);\n"
+   "g -= integer;\n"
+   "float b = 0.666 + (1.0 / nInstances) * i;\n"
+   "modf(b, integer);\n"
+   "b -= integer;\n"
+   "color = vec4(r, g, b, 0.8);\n"
+   "float invertz = mod(i, 2) * 2 - 1.0;\n"
+   "\n"
+   "float width = 2.0;\n"
+   "float dx = (2.0 / nInstances) * i - 1;\n"
+   "gl_Position = vec4(aPos.x + dx, aPos.y, i / nInstances, 1.0);\n"
+   "}\n";
+
+
+static const char *fs_text =
+   "#version 330 core\n"
+   "in vec4 color;\n"
+   "out vec4 FragColor;\n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "FragColor = color;\n"
+   "}\n";
+
+static GLuint setup_shaders(void)
+{
+   GLuint prog = piglit_build_simple_program(vs_text, fs_text);
+
+   glUseProgram(prog);
+
+   return prog;
+}
+
+#define MAX_OBJECTS 100
+
+static GLfloat triangle_vertices[] = {
+   -1.0f, -1.0f, 0.0f,
+   0.0f, 1.0f, 0.0f,
+   1.0f, -1.0f, 0.0f,
+};
+
+/* 3 vertices for the first triangle, plus 1 more fore each triangle (4
+ * triangles in total)
+ */
+static GLfloat tr

[Piglit] [PATCH v2 4/7] egl-context-preemption: check that preemption actually happened.

2018-10-29 Thread Rafael Antognolli
After both the main and the high priority threads have finished, check
their render timestamps to try to figure out if preemption has kicked
in.
---
 tests/egl/egl-context-preemption.c | 88 ++
 1 file changed, 88 insertions(+)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 8f0245e49..e9180d4ee 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -263,6 +263,36 @@ init_other_display(EGLDisplay *out_other_dpy)
return result;
 }
 
+/* Return the time difference between t1 and t2, taking into account wrapping
+ * around 'nbits'.
+ *
+ * Note: this function only works if the time difference is up to
+ * 1 << (nbits - 1).
+ */
+static int64_t
+time_diff(int64_t t1, int64_t t2, int nbits)
+{
+   const int64_t max_delta = 1ULL << (nbits - 1);
+   const int64_t bitmask = (1ULL << nbits) - 1;
+   const int64_t diff = t1 - t2;
+   const bool wrapped = llabs(t1 - t2) > max_delta;
+
+   /* First find out which one came first
+*  diff < 0 -- if t1 < t2
+*  diff == 0  -- if t1 == t2
+*  diff > 0 -- if t1 > t2
+*/
+   const int64_t diff_wrap = wrapped ? -diff : diff;
+
+   /* Then calculate the difference between them, taking overflow into
+* account
+*/
+   if (diff_wrap > 0)
+   return (t1 - t2) & bitmask;
+   else
+   return -((t2 - t1) & bitmask);
+}
+
 static enum piglit_result
 setup_thread_context(struct test_data *d)
 {
@@ -510,6 +540,9 @@ test_preemption(void *data)
goto cleanup;
}
 
+   GLint nbits;
+   glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &nbits);
+
glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
err = pthread_join(thread2, NULL);
@@ -519,6 +552,61 @@ test_preemption(void *data)
goto cleanup;
}
 
+   /* In this loop we are only looking for the first high priority render
+* that started after the main workload. In theory the first one should
+* already start after the main, but we run this loop just to confirm
+* that assumption.
+*/
+   int first_run = -1;
+   for (int i = 0; i < d.nruns; i++) {
+   if (time_diff(d.tstarted[i], d.main_tstarted, nbits) > 0) {
+   first_run = i;
+   break;
+   }
+   }
+
+   if (first_run < 0) {
+   piglit_loge("Something went wrong, all high priority workloads"
+   " started before the main workload.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* If mid-command preemption is enabled, the first workload to start
+* after the main workload should finish first.
+*/
+   if (time_diff(d.tfinished[first_run], d.main_tfinished, nbits) >= 0) {
+   piglit_loge("First preemption failed.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   int second_run = first_run + 1;
+   if (second_run >= d.nruns) {
+   piglit_loge("The first run to start after the main draw was"
+   " also the last one, so we can't check the second"
+   " run time.");
+   piglit_loge("First run: %d, second run: %d, nruns: %d",
+   first_run, second_run, d.nruns);
+   result = PIGLIT_WARN;
+   }
+
+   /* On i965, it looks like even if mid-command preemption is not
+* supported/enabled, it might report that the first high priority
+* render finished before the main render. So we check the timing of
+* the second high priority render too, which should also finish
+* earlier than the main render, if mid-command preemption is enabled.
+*/
+   if (time_diff(d.tfinished[second_run], d.main_tfinished, nbits) >= 0) {
+   piglit_loge("Second preemption failed.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* TODO: Calculate the time to run each of the high priority workloads,
+* and print the average latency.
+*/
+
 cleanup:
free(ref_image);
return result;
-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 7/7] tests: Add preemption test to the opengl profile.

2018-10-29 Thread Rafael Antognolli
---
 tests/opengl.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/opengl.py b/tests/opengl.py
index 54cfd04d5..9de15af13 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4455,6 +4455,8 @@ with profile.test_list.group_manager(
   run_concurrent=False)
 g(['egl-invalid-attr'])
 g(['egl-context-priority'])
+g(['egl-context-preemption'], run_concurrent=False)
+g(['egl-context-preemption', 'small'], run_concurrent=False)
 g(['egl-blob-cache'])
 g(['egl-copy-buffers'])
 
-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 3/7] egl-context-preemption: Add a high priority thread/context.

2018-10-29 Thread Rafael Antognolli
Start a new thread right after dispatching the render commands from the
main thread, after glFlush().

This second thread creates a high priority EGL context, and uses it to
render to a frame buffer multiple times. These draw calls are supposed
to finish before the one in the main thread.

v2:
 - skip on high priority failure (Ken)
 - remove useless check (Tapani)
---
 tests/egl/egl-context-preemption.c | 242 -
 1 file changed, 239 insertions(+), 3 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 5265bccc4..8f0245e49 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -41,11 +41,16 @@
  */
 
 #define HIGH_PRIO_RUNS 50
+static const int hp_width = 80, hp_height = 80;
 
 struct test_data {
bool main_finished;
int64_t main_tstarted, main_tfinished;
+   int64_t tstarted[HIGH_PRIO_RUNS];
+   int64_t tfinished[HIGH_PRIO_RUNS];
+   int nruns;
EGLDisplay dpy;
+   EGLContext ctx;
 };
 
 struct test_profile {
@@ -71,10 +76,10 @@ check_priority(EGLDisplay dpy, EGLContext ctx, EGLint 
*expected)
}
 
if (expected && value != *expected) {
-   piglit_loge("%s fail: priority value 0x%x, expected 0x%x\n",
+   piglit_logd("%s fail: priority value 0x%x, expected 0x%x\n",
__func__, value, *expected);
-   piglit_loge("Can't create high priority context.\n");
-   piglit_report_result(PIGLIT_FAIL);
+   piglit_logd("Can't create high priority context.\n");
+   piglit_report_result(PIGLIT_SKIP);
}
return value;
 }
@@ -197,6 +202,217 @@ draw_objects(unsigned int shader_program, GLenum mode, 
GLfloat *vertices,
glDisableVertexAttribArray(0);
 }
 
+static enum piglit_result
+init_display(EGLenum platform, EGLDisplay *out_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay dpy;
+   EGLint egl_major, egl_minor;
+   bool ok;
+
+   dpy = piglit_egl_get_default_display(platform);
+   if (!dpy) {
+   result = PIGLIT_SKIP;
+   goto error;
+   }
+
+   ok = eglInitialize(dpy, &egl_major, &egl_minor);
+   if (!ok) {
+   result = PIGLIT_SKIP;
+   goto error;
+   }
+
+   *out_dpy = dpy;
+   return result;
+
+error:
+   if (dpy) {
+   eglTerminate(dpy);
+   }
+   return result;
+}
+
+static enum piglit_result
+init_other_display(EGLDisplay *out_other_dpy)
+{
+   enum piglit_result result = PIGLIT_SKIP;
+   EGLDisplay other_dpy = 0;
+   int i;
+
+   static const EGLint platforms[] = {
+   EGL_PLATFORM_GBM_MESA,
+   EGL_PLATFORM_SURFACELESS_MESA,
+   EGL_PLATFORM_X11_EXT,
+   EGL_PLATFORM_WAYLAND_EXT,
+   0,
+   };
+
+   for (i = 0; platforms[i] != 0; ++i) {
+   result = init_display(platforms[i], &other_dpy);
+   switch (result) {
+   case PIGLIT_SKIP:
+   break;
+   case PIGLIT_PASS:
+   *out_other_dpy = other_dpy;
+   return PIGLIT_PASS;
+   default:
+   break;
+   }
+   }
+
+   return result;
+}
+
+static enum piglit_result
+setup_thread_context(struct test_data *d)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   bool ok = false;
+   EGLContext ctx2 = EGL_NO_CONTEXT;
+
+   EGLDisplay dpy;
+   if (init_other_display(&dpy) == PIGLIT_SKIP) {
+   piglit_loge("failed to get display\n");
+   result = PIGLIT_FAIL;
+   return result;
+   }
+
+   eglBindAPI(EGL_OPENGL_API);
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("failed to set OpenGL API.\n");
+   result = PIGLIT_FAIL;
+   return result;
+   }
+
+   EGLint attr[] = {
+   EGL_CONTEXT_CLIENT_VERSION, 3,
+   EGL_CONTEXT_MINOR_VERSION_KHR, 3,
+   EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
+   EGL_NONE };
+   ctx2 = eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr);
+   if (ctx2 == EGL_NO_CONTEXT) {
+   piglit_loge("failed to create context");
+   piglit_check_egl_error(EGL_SUCCESS);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx2);
+   if (!ok) {
+   piglit_loge("failed to make context current without surface");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   GLuint VertexArrayID;
+   glGenVertexArrays(1, &VertexArrayID);
+   glBindVertexArray(VertexArrayID);
+
+   glEnable(GL_BLEND);
+   glBlendFunc(GL_SRC_ALPHA, GL_O

[Piglit] [PATCH v2 0/8] Preemption test.

2018-10-29 Thread Rafael Antognolli
Updated version with changes requested by Tapani and Ken included (the
test won't fail if we can't create a high priority context, in case we
lack the right permissions.

This series is also available here:

https://gitlab.freedesktop.org/rantogno/piglit/commits/review/context_preemption_v2

Rafael Antognolli (7):
  tests: Add base test for mid-command preemption.
  egl-context-preemption: Add check for high priority contexts.
  egl-context-preemption: Add a high priority thread/context.
  egl-context-preemption: check that preemption actually happened.
  egl-context-preemption: Add a subtest to reuse the same display.
  egl-context-preemption: Check that the rendering was correct.
  tests: Add preemption test to the opengl profile.

 tests/egl/CMakeLists.gl.txt|   2 +
 tests/egl/egl-context-preemption.c | 793 +
 tests/opengl.py|   2 +
 3 files changed, 797 insertions(+)
 create mode 100644 tests/egl/egl-context-preemption.c

-- 
2.19.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 0/7] New preemption test.

2018-10-09 Thread Rafael Antognolli
On Tue, Oct 09, 2018 at 12:59:00PM +0300, Tapani Pälli wrote:
> Hi Rafael;
> 
> This looks very much along the lines of what thoughts I had when writing
> this test:
> 
> https://patchwork.freedesktop.org/patch/156779/

Oh, I think I missed that, otherwise I would definitely used it as a
starting point.

> I think I may have somewhere a GL_TIMESTAMP version attempt about that one
> :) but your test looks much more complete, thanks for doing this!

No problem :)

From the description of your series, it looks like the tests would
compare how much time was given to each of the contexts, which might
still be a good thing to do too (my test doesn't do any of that). So it
might still be good to get it merged.

Is there any reason why it never landed?

And thanks a lot for the review!

> 
> On 10/4/18 6:35 PM, Rafael Antognolli wrote:
> > This series attempts to test that we get a fine grained preemption
> > level when using the EGL_IMG_context_priority extension. Particularly,
> > if the context priority is set to high in a given context, it should
> > preempt lower priority contexts if they are still executing when the
> > higher priority one is dispatch.
> > 
> > This test attemps to confirm that some preemption actually happened. It
> > does so by first starting a draw call that is supposed to take a long
> > time to finish, due to the size of the render buffer and instanced
> > rendering with a high number of instances. Then it starts a new thread
> > and creates a new, high priority context. This context then dispatch a
> > bunch of draw calls, and expects that the first one to start after the
> > main draw call (using GL_TIMESTAMP for that) should still finish before
> > that one too.
> > 
> > However, checking through the GL_TIMESTAMP is not always guaranteed, and
> > sometimes we get reports that the first high priority draw that started
> > after the medium priority one also finished earlier, even if preemption
> > is not supported. For that, we check the second high priority draw that
> > started after the main one, which apparently will not report finished
> > before the medium priority one.
> > 
> > Even though the method reported above might not be ideal for testing
> > preemption, hopefully this test provides a framework that can be tweaked
> > to test things correctly at some point.
> > 
> > Cc: Kenneth Graunke 
> > 
> > Rafael Antognolli (7):
> >tests: Add base test for mid-command preemption.
> >egl-context-preemption: Add check for high priority contexts.
> >egl-context-preemption: Add a high priority thread/context.
> >egl-context-preemption: check that preemption actually happened.
> >egl-context-preemption: Add a subtest to reuse the same display.
> >egl-context-preemption: Check that the rendering was correct.
> >tests: Add preemption test to the opengl profile.
> > 
> >   tests/egl/CMakeLists.gl.txt|   2 +
> >   tests/egl/egl-context-preemption.c | 799 +
> >   tests/opengl.py|   2 +
> >   3 files changed, 803 insertions(+)
> >   create mode 100644 tests/egl/egl-context-preemption.c
> > 
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 2/7] egl-context-preemption: Add check for high priority contexts.

2018-10-09 Thread Rafael Antognolli
On Tue, Oct 09, 2018 at 01:04:07PM +0300, Tapani Pälli wrote:
> 
> On 10/4/18 6:35 PM, Rafael Antognolli wrote:
> > Check if we can create high priority contexts, otherwise just fail the
> > test immediately. There's no reason to test for preemption if we can't
> > create high priority contexts.
> > ---
> >   tests/egl/egl-context-preemption.c | 57 ++
> >   1 file changed, 57 insertions(+)
> > 
> > diff --git a/tests/egl/egl-context-preemption.c 
> > b/tests/egl/egl-context-preemption.c
> > index 82a698aa1..9d5aa42ee 100644
> > --- a/tests/egl/egl-context-preemption.c
> > +++ b/tests/egl/egl-context-preemption.c
> > @@ -58,6 +58,40 @@ struct test_profile {
> >   static bool small = false;
> >   static int total_objects = 0;
> > +static EGLint
> > +check_priority(EGLDisplay dpy, EGLContext ctx, EGLint *expected)
> > +{
> > +   EGLint value;
> > +   EGLBoolean status =
> > +   eglQueryContext(dpy, ctx, EGL_CONTEXT_PRIORITY_LEVEL_IMG, 
> > &value);
> > +
> > +   if (status == EGL_FALSE) {
> > +   piglit_loge("eglQueryContext failed\n");
> > +   piglit_report_result(PIGLIT_FAIL);
> > +   }
> > +
> > +   if (expected && value != *expected) {
> > +   piglit_loge("%s fail: priority value 0x%x, expected 0x%x\n",
> > +   __func__, value, *expected);
> > +   piglit_loge("Can't create high priority context.\n");
> > +   piglit_report_result(PIGLIT_FAIL);
> > +   }
> > +   return value;
> > +}
> > +
> > +static EGLContext
> > +create_context(EGLDisplay dpy, EGLint *attr)
> > +{
> > +   EGLContext ctx =
> > +   eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr);
> > +
> > +   if (ctx == EGL_NO_CONTEXT) {
> > +   piglit_loge("could not create EGL context, attr 0x%x\n", 
> > attr[1]);
> > +   piglit_report_result(PIGLIT_FAIL);
> > +   }
> > +   return ctx;
> > +}
> > +
> >   static const char *vs_text =
> > "#version 330 core\n"
> > "layout (location = 0) in vec3 aPos;\n"
> > @@ -304,6 +338,27 @@ piglit_display(void)
> > return result;
> >   }
> > +static void
> > +check_high_context_priority_creation(EGLDisplay dpy)
> > +{
> > +   EGLint attr[] = {
> > +   EGL_CONTEXT_PRIORITY_LEVEL_IMG,
> > +   EGL_CONTEXT_PRIORITY_HIGH_IMG,
> > +   EGL_NONE
> > +   };
> > +   EGLContext ctx = create_context(dpy, attr);
> > +   if (ctx == EGL_NO_CONTEXT) {
> > +   piglit_loge("failed to create context");
> > +   piglit_check_egl_error(EGL_SUCCESS);
> > +   piglit_report_result(PIGLIT_FAIL);
> > +   }
> > +
> > +   EGLint expected = EGL_CONTEXT_PRIORITY_HIGH_IMG;
> > +   check_priority(dpy, ctx, &expected);
> > +
> > +   eglDestroyContext(dpy, ctx);
> > +}
> > +
> >   void
> >   piglit_init(int argc, char **argv)
> >   {
> > @@ -312,6 +367,8 @@ piglit_init(int argc, char **argv)
> > dpy = eglGetCurrentDisplay();
> > piglit_require_egl_extension(dpy, "EGL_IMG_context_priority");
> 
> You need
> 
> piglit_require_egl_extension(dpy, "EGL_MESA_configless_context");
> 
> because create_context uses EGL_NO_CONFIG_MESA

Fixing it locally.

> > +   check_high_context_priority_creation(dpy);
> > +
> > if (piglit_strip_arg(&argc, argv, "small"))
> > small = true;
> > 
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 3/7] egl-context-preemption: Add a high priority thread/context.

2018-10-09 Thread Rafael Antognolli
On Tue, Oct 09, 2018 at 01:23:03PM +0300, Tapani Pälli wrote:
> 
> 
> On 10/4/18 6:35 PM, Rafael Antognolli wrote:
> > Start a new thread right after dispatching the render commands from the
> > main thread, after glFlush().
> > 
> > This second thread creates a high priority EGL context, and uses it to
> > render to a frame buffer multiple times. These draw calls are supposed
> > to finish before the one in the main thread.
> > ---
> >   tests/egl/egl-context-preemption.c | 243 +
> >   1 file changed, 243 insertions(+)
> > 
> > diff --git a/tests/egl/egl-context-preemption.c 
> > b/tests/egl/egl-context-preemption.c
> > index 9d5aa42ee..566416312 100644
> > --- a/tests/egl/egl-context-preemption.c
> > +++ b/tests/egl/egl-context-preemption.c
> > @@ -41,11 +41,16 @@
> >*/
> >   #define HIGH_PRIO_RUNS 50
> > +static const int hp_width = 80, hp_height = 80;
> >   struct test_data {
> > bool main_finished;
> > int64_t main_tstarted, main_tfinished;
> > +   int64_t tstarted[HIGH_PRIO_RUNS];
> > +   int64_t tfinished[HIGH_PRIO_RUNS];
> > +   int nruns;
> > EGLDisplay dpy;
> > +   EGLContext ctx;
> >   };
> >   struct test_profile {
> > @@ -197,6 +202,224 @@ draw_objects(unsigned int shader_program, GLenum 
> > mode, GLfloat *vertices,
> > glDisableVertexAttribArray(0);
> >   }
> > +static enum piglit_result
> > +init_display(EGLenum platform, EGLDisplay *out_dpy)
> > +{
> > +   enum piglit_result result = PIGLIT_PASS;
> > +   EGLDisplay dpy;
> > +   EGLint egl_major, egl_minor;
> > +   bool ok;
> > +
> > +   dpy = piglit_egl_get_default_display(platform);
> > +   if (!dpy) {
> > +   result = PIGLIT_SKIP;
> > +   goto error;
> > +   }
> > +
> > +   ok = eglInitialize(dpy, &egl_major, &egl_minor);
> > +   if (!ok) {
> > +   result = PIGLIT_SKIP;
> > +   goto error;
> > +   }
> > +
> > +   if (!piglit_is_egl_extension_supported(dpy, 
> > "EGL_IMG_context_priority")) {
> > +   piglit_loge("display does not support 
> > EGL_IMG_context_priority");
> > +   result = PIGLIT_SKIP;
> > +   goto error;
> 
> This seems unnecessary, we are already skipping the test if extension was
> not supported in piglit_init?

Agreed, I'll remove it. I think it was copy & pasted from another test,
sorry for that.

> > +
> > +   }
> > +
> > +   *out_dpy = dpy;
> > +   return result;
> > +
> > +error:
> > +   if (dpy) {
> > +   eglTerminate(dpy);
> > +   }
> > +   return result;
> > +}
> > +
> > +static enum piglit_result
> > +init_other_display(EGLDisplay *out_other_dpy)
> > +{
> > +   enum piglit_result result = PIGLIT_SKIP;
> > +   EGLDisplay other_dpy = 0;
> > +   int i;
> > +
> > +   static const EGLint platforms[] = {
> > +   EGL_PLATFORM_GBM_MESA,
> > +   EGL_PLATFORM_SURFACELESS_MESA,
> > +   EGL_PLATFORM_X11_EXT,
> > +   EGL_PLATFORM_WAYLAND_EXT,
> > +   0,
> > +   };
> > +
> > +   for (i = 0; platforms[i] != 0; ++i) {
> > +   result = init_display(platforms[i], &other_dpy);
> > +   switch (result) {
> > +   case PIGLIT_SKIP:
> > +   break;
> > +   case PIGLIT_PASS:
> > +   *out_other_dpy = other_dpy;
> > +   return PIGLIT_PASS;
> > +   default:
> > +   break;
> > +   }
> > +   }
> > +
> > +   return result;
> > +}
> > +
> > +static enum piglit_result
> > +setup_thread_context(struct test_data *d)
> > +{
> > +   enum piglit_result result = PIGLIT_PASS;
> > +   bool ok = false;
> > +   EGLContext ctx2 = EGL_NO_CONTEXT;
> > +
> > +   EGLDisplay dpy;
> > +   if (init_other_display(&dpy) == PIGLIT_SKIP) {
> > +   piglit_loge("failed to get display\n");
> > +   result = PIGLIT_FAIL;
> > +   return result;
> > +   }
> > +
> > +   eglBindAPI(EGL_OPENGL_API);
> > +   if (!piglit_check_egl_error(EGL_SUCCESS)) {
> > +   piglit_loge("failed to set OpenGL API.\n");
> > +   result = PIGLIT_FAIL;
> > +   return result;
> > +   }
> > +
> > +   EGLint attr[] = {
> > +   EGL_CONTEXT_CLIENT_VERSION, 3,

Re: [Piglit] [PATCH] quick_shader: Do not exclude tests in sanity profile.

2018-10-05 Thread Rafael Antognolli
On Fri, Oct 05, 2018 at 12:16:53PM -0700, Dylan Baker wrote:
> Quoting Rafael Antognolli (2018-10-05 11:25:24)
> > On Fri, Oct 05, 2018 at 11:11:19AM -0700, Dylan Baker wrote:
> > > Does this change the set of tests in the profile? I think it will since 
> > > we'll
> > > end up calling self.random.random() a different number of times.
> > 
> > That's the idea. Now a test always gets included if it's already in the
> > sanity profile. And self.random.random() won't be called for that test.
> 
> So it's going to change the set of tests we run in CI? That seems like 
> something
> we should run by Clayton before we merge.

Ugh, I see what you mean. Yeah, I'm not sure the change is worth it.

Maybe as an alternative, we could just call random() to that test too,
even though we discard the result. Or maybe just drop the whole patch
altogether...

> > We currently only have one 'vs_in' test in the sanity profile, so this
> > change will only add potentially one new test to the quick_shader
> > profile.
> > 
> > On the other hand, checking if the test is in the sanity profile will be
> > done for every single 'vs_in' test now, so generating the list will be a
> > little slower.
> > 
> > > Quoting Rafael Antognolli (2018-10-03 10:51:28)
> > > > We randomly exclude 80% of the 'arb_vertex_attrib_64bit/execution/vs_in'
> > > > tests, but we want to keep at least the ones present in the sanity
> > > > profile. This makes the 'quick' and 'gpu' profiles a superset of the
> > > > 'sanity' profile.
> > > > ---
> > > >  tests/quick_shader.py | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/tests/quick_shader.py b/tests/quick_shader.py
> > > > index f1bda6545..dd8853cde 100644
> > > > --- a/tests/quick_shader.py
> > > > +++ b/tests/quick_shader.py
> > > > @@ -26,6 +26,7 @@ import random
> > > >  
> > > >  from framework import grouptools
> > > >  from .shader import profile as _profile
> > > > +from .sanity import profile as _sanity
> > > >  
> > > >  __all__ = ['profile']
> > > >  
> > > > @@ -42,6 +43,8 @@ class FilterVsIn(object):
> > > >  
> > > >  def __call__(self, name, _):
> > > >  if 'vs_in' in grouptools.split(name):
> > > > +if name in _sanity.test_list:
> > > > +return True
> > > >  # 20%
> > > >  return self.random.random() <= .2
> > > >  return True
> > > > -- 
> > > > 2.17.1
> > > > 
> > > > ___
> > > > Piglit mailing list
> > > > Piglit@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/piglit
> > 
> > 


___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] quick_shader: Do not exclude tests in sanity profile.

2018-10-05 Thread Rafael Antognolli
On Fri, Oct 05, 2018 at 11:11:19AM -0700, Dylan Baker wrote:
> Does this change the set of tests in the profile? I think it will since we'll
> end up calling self.random.random() a different number of times.

That's the idea. Now a test always gets included if it's already in the
sanity profile. And self.random.random() won't be called for that test.

We currently only have one 'vs_in' test in the sanity profile, so this
change will only add potentially one new test to the quick_shader
profile.

On the other hand, checking if the test is in the sanity profile will be
done for every single 'vs_in' test now, so generating the list will be a
little slower.

> Quoting Rafael Antognolli (2018-10-03 10:51:28)
> > We randomly exclude 80% of the 'arb_vertex_attrib_64bit/execution/vs_in'
> > tests, but we want to keep at least the ones present in the sanity
> > profile. This makes the 'quick' and 'gpu' profiles a superset of the
> > 'sanity' profile.
> > ---
> >  tests/quick_shader.py | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/tests/quick_shader.py b/tests/quick_shader.py
> > index f1bda6545..dd8853cde 100644
> > --- a/tests/quick_shader.py
> > +++ b/tests/quick_shader.py
> > @@ -26,6 +26,7 @@ import random
> >  
> >  from framework import grouptools
> >  from .shader import profile as _profile
> > +from .sanity import profile as _sanity
> >  
> >  __all__ = ['profile']
> >  
> > @@ -42,6 +43,8 @@ class FilterVsIn(object):
> >  
> >  def __call__(self, name, _):
> >  if 'vs_in' in grouptools.split(name):
> > +if name in _sanity.test_list:
> > +return True
> >  # 20%
> >  return self.random.random() <= .2
> >  return True
> > -- 
> > 2.17.1
> > 
> > ___
> > Piglit mailing list
> > Piglit@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/piglit


___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 7/7] tests: Add preemption test to the opengl profile.

2018-10-04 Thread Rafael Antognolli
---
 tests/opengl.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/opengl.py b/tests/opengl.py
index c599eb180..59f3884a4 100644
--- a/tests/opengl.py
+++ b/tests/opengl.py
@@ -4451,6 +4451,8 @@ with profile.test_list.group_manager(
   run_concurrent=False)
 g(['egl-invalid-attr'])
 g(['egl-context-priority'])
+g(['egl-context-preemption'], run_concurrent=False)
+g(['egl-context-preemption', 'small'], run_concurrent=False)
 g(['egl-blob-cache'])
 g(['egl-copy-buffers'])
 
-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 3/7] egl-context-preemption: Add a high priority thread/context.

2018-10-04 Thread Rafael Antognolli
Start a new thread right after dispatching the render commands from the
main thread, after glFlush().

This second thread creates a high priority EGL context, and uses it to
render to a frame buffer multiple times. These draw calls are supposed
to finish before the one in the main thread.
---
 tests/egl/egl-context-preemption.c | 243 +
 1 file changed, 243 insertions(+)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 9d5aa42ee..566416312 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -41,11 +41,16 @@
  */
 
 #define HIGH_PRIO_RUNS 50
+static const int hp_width = 80, hp_height = 80;
 
 struct test_data {
bool main_finished;
int64_t main_tstarted, main_tfinished;
+   int64_t tstarted[HIGH_PRIO_RUNS];
+   int64_t tfinished[HIGH_PRIO_RUNS];
+   int nruns;
EGLDisplay dpy;
+   EGLContext ctx;
 };
 
 struct test_profile {
@@ -197,6 +202,224 @@ draw_objects(unsigned int shader_program, GLenum mode, 
GLfloat *vertices,
glDisableVertexAttribArray(0);
 }
 
+static enum piglit_result
+init_display(EGLenum platform, EGLDisplay *out_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay dpy;
+   EGLint egl_major, egl_minor;
+   bool ok;
+
+   dpy = piglit_egl_get_default_display(platform);
+   if (!dpy) {
+   result = PIGLIT_SKIP;
+   goto error;
+   }
+
+   ok = eglInitialize(dpy, &egl_major, &egl_minor);
+   if (!ok) {
+   result = PIGLIT_SKIP;
+   goto error;
+   }
+
+   if (!piglit_is_egl_extension_supported(dpy, 
"EGL_IMG_context_priority")) {
+   piglit_loge("display does not support 
EGL_IMG_context_priority");
+   result = PIGLIT_SKIP;
+   goto error;
+
+   }
+
+   *out_dpy = dpy;
+   return result;
+
+error:
+   if (dpy) {
+   eglTerminate(dpy);
+   }
+   return result;
+}
+
+static enum piglit_result
+init_other_display(EGLDisplay *out_other_dpy)
+{
+   enum piglit_result result = PIGLIT_SKIP;
+   EGLDisplay other_dpy = 0;
+   int i;
+
+   static const EGLint platforms[] = {
+   EGL_PLATFORM_GBM_MESA,
+   EGL_PLATFORM_SURFACELESS_MESA,
+   EGL_PLATFORM_X11_EXT,
+   EGL_PLATFORM_WAYLAND_EXT,
+   0,
+   };
+
+   for (i = 0; platforms[i] != 0; ++i) {
+   result = init_display(platforms[i], &other_dpy);
+   switch (result) {
+   case PIGLIT_SKIP:
+   break;
+   case PIGLIT_PASS:
+   *out_other_dpy = other_dpy;
+   return PIGLIT_PASS;
+   default:
+   break;
+   }
+   }
+
+   return result;
+}
+
+static enum piglit_result
+setup_thread_context(struct test_data *d)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   bool ok = false;
+   EGLContext ctx2 = EGL_NO_CONTEXT;
+
+   EGLDisplay dpy;
+   if (init_other_display(&dpy) == PIGLIT_SKIP) {
+   piglit_loge("failed to get display\n");
+   result = PIGLIT_FAIL;
+   return result;
+   }
+
+   eglBindAPI(EGL_OPENGL_API);
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("failed to set OpenGL API.\n");
+   result = PIGLIT_FAIL;
+   return result;
+   }
+
+   EGLint attr[] = {
+   EGL_CONTEXT_CLIENT_VERSION, 3,
+   EGL_CONTEXT_MINOR_VERSION_KHR, 3,
+   EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG,
+   EGL_NONE };
+   ctx2 = eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr);
+   if (ctx2 == EGL_NO_CONTEXT) {
+   piglit_loge("failed to create context");
+   piglit_check_egl_error(EGL_SUCCESS);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx2);
+   if (!ok) {
+   piglit_loge("failed to make context current without surface");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   GLuint VertexArrayID;
+   glGenVertexArrays(1, &VertexArrayID);
+   glBindVertexArray(VertexArrayID);
+
+   glEnable(GL_BLEND);
+   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+   glViewport(0, 0, hp_width, hp_height);
+
+   d->ctx = ctx2;
+   d->dpy = dpy;
+
+   return result;
+
+cleanup:
+   if (ctx2 != EGL_NO_CONTEXT)
+   eglDestroyContext(dpy, ctx2);
+   eglTerminate(dpy);
+
+   return result;
+}
+
+/* Allocate and attach textures and FBOs */
+static void
+setup_render_target(GLuint *fbos, GLuint *textures, unsigned n,
+   int width, int height)
+{
+   glGe

[Piglit] [PATCH 5/7] egl-context-preemption: Add a subtest to reuse the same display.

2018-10-04 Thread Rafael Antognolli
Add a subtest that reuses the same EGLDisplay used in the main thread.
This is just another case we can test and see if there's a difference in
the preemption behavior.
---
 tests/egl/egl-context-preemption.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 85f5c8fd5..26ead9d58 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -51,6 +51,7 @@ struct test_data {
int nruns;
EGLDisplay dpy;
EGLContext ctx;
+   const struct test_profile *p;
 };
 
 struct test_profile {
@@ -58,6 +59,7 @@ struct test_profile {
size_t bufsize;
GLenum draw_mode;
GLuint (*shader_setup)(void);
+   bool same_display;
 };
 
 static bool small = false;
@@ -307,8 +309,9 @@ setup_thread_context(struct test_data *d)
bool ok = false;
EGLContext ctx2 = EGL_NO_CONTEXT;
 
-   EGLDisplay dpy;
-   if (init_other_display(&dpy) == PIGLIT_SKIP) {
+   EGLDisplay dpy = d->dpy;
+   if (!d->p->same_display &&
+   init_other_display(&dpy) == PIGLIT_SKIP) {
piglit_loge("failed to get display\n");
result = PIGLIT_FAIL;
return result;
@@ -358,7 +361,9 @@ setup_thread_context(struct test_data *d)
 cleanup:
if (ctx2 != EGL_NO_CONTEXT)
eglDestroyContext(dpy, ctx2);
-   eglTerminate(dpy);
+
+   if (!d->p->same_display)
+   eglTerminate(dpy);
 
return result;
 }
@@ -445,7 +450,8 @@ thread2_create_high_priority_context(void *data)
 
if (d->ctx != EGL_NO_CONTEXT)
eglDestroyContext(d->dpy, d->ctx);
-   eglTerminate(d->dpy);
+   if (!d->p->same_display)
+   eglTerminate(d->dpy);
 
return result;
 }
@@ -486,6 +492,7 @@ test_preemption(void *data)
struct test_data d = {
.main_finished = false,
.nruns = 0,
+   .p = profile,
};
d.dpy = eglGetCurrentDisplay();
 
@@ -633,6 +640,14 @@ static struct test_profile trifan = {
.shader_setup = setup_shaders,
 };
 
+static struct test_profile triangles_same_display = {
+   .vertices = triangle_vertices,
+   .bufsize = sizeof(triangle_vertices),
+   .draw_mode = GL_TRIANGLES,
+   .shader_setup = setup_shaders,
+   .same_display = true,
+};
+
 static const struct piglit_subtest subtests[] = {
{
"triangles",
@@ -646,6 +661,12 @@ static const struct piglit_subtest subtests[] = {
test_preemption,
&trifan,
},
+   {
+   "triangles_same_display",
+   "same_display",
+   test_preemption,
+   &triangles_same_display,
+   },
{0},
 };
 
-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 4/7] egl-context-preemption: check that preemption actually happened.

2018-10-04 Thread Rafael Antognolli
After both the main and the high priority threads have finished, check
their render timestamps to try to figure out if preemption has kicked
in.
---
 tests/egl/egl-context-preemption.c | 88 ++
 1 file changed, 88 insertions(+)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 566416312..85f5c8fd5 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -270,6 +270,36 @@ init_other_display(EGLDisplay *out_other_dpy)
return result;
 }
 
+/* Return the time difference between t1 and t2, taking into account wrapping
+ * around 'nbits'.
+ *
+ * Note: this function only works if the time difference is up to
+ * 1 << (nbits - 1).
+ */
+static int64_t
+time_diff(int64_t t1, int64_t t2, int nbits)
+{
+   const int64_t max_delta = 1ULL << (nbits - 1);
+   const int64_t bitmask = (1ULL << nbits) - 1;
+   const int64_t diff = t1 - t2;
+   const bool wrapped = llabs(t1 - t2) > max_delta;
+
+   /* First find out which one came first
+*  diff < 0 -- if t1 < t2
+*  diff == 0  -- if t1 == t2
+*  diff > 0 -- if t1 > t2
+*/
+   const int64_t diff_wrap = wrapped ? -diff : diff;
+
+   /* Then calculate the difference between them, taking overflow into
+* account
+*/
+   if (diff_wrap > 0)
+   return (t1 - t2) & bitmask;
+   else
+   return -((t2 - t1) & bitmask);
+}
+
 static enum piglit_result
 setup_thread_context(struct test_data *d)
 {
@@ -517,6 +547,9 @@ test_preemption(void *data)
goto cleanup;
}
 
+   GLint nbits;
+   glGetQueryiv(GL_TIMESTAMP, GL_QUERY_COUNTER_BITS, &nbits);
+
glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
err = pthread_join(thread2, NULL);
@@ -526,6 +559,61 @@ test_preemption(void *data)
goto cleanup;
}
 
+   /* In this loop we are only looking for the first high priority render
+* that started after the main workload. In theory the first one should
+* already start after the main, but we run this loop just to confirm
+* that assumption.
+*/
+   int first_run = -1;
+   for (int i = 0; i < d.nruns; i++) {
+   if (time_diff(d.tstarted[i], d.main_tstarted, nbits) > 0) {
+   first_run = i;
+   break;
+   }
+   }
+
+   if (first_run < 0) {
+   piglit_loge("Something went wrong, all high priority workloads"
+   " started before the main workload.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* If mid-command preemption is enabled, the first workload to start
+* after the main workload should finish first.
+*/
+   if (time_diff(d.tfinished[first_run], d.main_tfinished, nbits) >= 0) {
+   piglit_loge("First preemption failed.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   int second_run = first_run + 1;
+   if (second_run >= d.nruns) {
+   piglit_loge("The first run to start after the main draw was"
+   " also the last one, so we can't check the second"
+   " run time.");
+   piglit_loge("First run: %d, second run: %d, nruns: %d",
+   first_run, second_run, d.nruns);
+   result = PIGLIT_WARN;
+   }
+
+   /* On i965, it looks like even if mid-command preemption is not
+* supported/enabled, it might report that the first high priority
+* render finished before the main render. So we check the timing of
+* the second high priority render too, which should also finish
+* earlier than the main render, if mid-command preemption is enabled.
+*/
+   if (time_diff(d.tfinished[second_run], d.main_tfinished, nbits) >= 0) {
+   piglit_loge("Second preemption failed.");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* TODO: Calculate the time to run each of the high priority workloads,
+* and print the average latency.
+*/
+
 cleanup:
free(ref_image);
return result;
-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 6/7] egl-context-preemption: Check that the rendering was correct.

2018-10-04 Thread Rafael Antognolli
Verify that the rendering done by the high priority thread was also
correct by rendering a reference image at the beginning.
---
 tests/egl/egl-context-preemption.c | 75 +-
 1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 26ead9d58..b5be67677 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -52,6 +52,7 @@ struct test_data {
EGLDisplay dpy;
EGLContext ctx;
const struct test_profile *p;
+   float *ref_image;
 };
 
 struct test_profile {
@@ -448,6 +449,16 @@ thread2_create_high_priority_context(void *data)
draw_high_priority(d, program, i);
}
 
+   /* check that the rendering was correct */
+   bool pass = true;
+   for (int i = 0; i < d->nruns; i++) {
+   glBindFramebuffer(GL_READ_FRAMEBUFFER, fbos[i]);
+   pass = pass && piglit_probe_image_rgba(0, 0, hp_width, 
hp_height,
+  d->ref_image);
+   }
+
+   *result = pass ? PIGLIT_PASS : PIGLIT_FAIL;
+
if (d->ctx != EGL_NO_CONTEXT)
eglDestroyContext(d->dpy, d->ctx);
if (!d->p->same_display)
@@ -484,6 +495,39 @@ read_pixels_float(GLint x, GLint y, GLsizei width, GLsizei 
height,
return pixels;
 }
 
+static void*
+thread_create_ref_image(void *data)
+{
+   enum piglit_result *result = malloc(sizeof(*result));
+   struct test_data *d = data;
+
+   *result = setup_thread_context(d);
+   if (*result != PIGLIT_PASS)
+   return result;
+
+   GLuint fbo;
+   GLuint texColorBuffer;
+   setup_render_target(&fbo, &texColorBuffer, 1, hp_width, hp_height);
+
+   glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+   unsigned int program = setup_shaders();
+
+   draw_objects(program, GL_TRIANGLES, triangle_vertices,
+sizeof(triangle_vertices), 1);
+   glFinish();
+
+   d->ref_image = read_pixels_float(0, 0, hp_width, hp_height,
+GL_RGBA, NULL);
+
+   if (d->ctx != EGL_NO_CONTEXT)
+   eglDestroyContext(d->dpy, d->ctx);
+   if (!d->p->same_display)
+   eglTerminate(d->dpy);
+
+   return result;
+}
+
 static enum piglit_result
 test_preemption(void *data)
 {
@@ -496,6 +540,29 @@ test_preemption(void *data)
};
d.dpy = eglGetCurrentDisplay();
 
+   pthread_t thread1;
+   int err = pthread_create(
+   &thread1, NULL,
+   thread_create_ref_image,
+   &d);
+   if (err) {
+   piglit_loge("failed to create ref image thread");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   void *retval = NULL;
+   err = pthread_join(thread1, &retval);
+   if (err) {
+   piglit_loge("failed to join thread %"PRIuMAX, (uintmax_t) 
thread1);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   result = *((enum piglit_result *)retval);
+   if (result != PIGLIT_PASS)
+   goto cleanup;
+
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
 
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
@@ -533,7 +600,7 @@ test_preemption(void *data)
 
/* Start second thread with high priority */
pthread_t thread2;
-   int err = pthread_create(
+   err = pthread_create(
&thread2, NULL,
thread2_create_high_priority_context,
&d);
@@ -559,12 +626,16 @@ test_preemption(void *data)
 
glBindFramebuffer(GL_FRAMEBUFFER, 0);
 
-   err = pthread_join(thread2, NULL);
+   err = pthread_join(thread2, &retval);
if (err) {
piglit_loge("failed to join thread %"PRIuMAX, (uintmax_t) 
thread2);
result = PIGLIT_FAIL;
goto cleanup;
}
+   result = *((enum piglit_result *)retval);
+   if (result != PIGLIT_PASS)
+   goto cleanup;
+
 
/* In this loop we are only looking for the first high priority render
 * that started after the main workload. In theory the first one should
-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/7] tests: Add base test for mid-command preemption.

2018-10-04 Thread Rafael Antognolli
This is the base of the test, where we use the main piglit context to
render to the framebuffer. It is supposed to be an artificially slow
draw call, that can be preempted by a higher priority context if needed.
---
 tests/egl/CMakeLists.gl.txt|   2 +
 tests/egl/egl-context-preemption.c | 319 +
 2 files changed, 321 insertions(+)
 create mode 100644 tests/egl/egl-context-preemption.c

diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt
index 3691c56a9..6de166044 100644
--- a/tests/egl/CMakeLists.gl.txt
+++ b/tests/egl/CMakeLists.gl.txt
@@ -35,6 +35,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(egl-invalid-attr pthread)
piglit_add_executable (egl-context-priority egl-context-priority.c)
target_link_libraries(egl-context-priority pthread)
+   piglit_add_executable (egl-context-preemption egl-context-preemption.c)
+   target_link_libraries(egl-context-preemption pthread)
 ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
 
 # vim: ft=cmake:
diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
new file mode 100644
index 0..82a698aa1
--- /dev/null
+++ b/tests/egl/egl-context-preemption.c
@@ -0,0 +1,319 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-egl.h"
+#include "piglit-util-gl.h"
+
+#include 
+
+#include 
+
+/**
+ * @file egl-context-preemption.c
+ *
+ * EGL API tests for IMG_context_priority extension:
+ * 
https://www.khronos.org/registry/EGL/extensions/IMG/EGL_IMG_context_priority.txt
+ *
+ * This file tries to test mid-command preemption (between triangles) support
+ * through the IMG_context_priority extension.  Particularly on i965, if a
+ * context is marked with high priority level, then it should preempt lower
+ * priority contexts (when the hardware and kernel supports it).
+ */
+
+#define HIGH_PRIO_RUNS 50
+
+struct test_data {
+   bool main_finished;
+   int64_t main_tstarted, main_tfinished;
+   EGLDisplay dpy;
+};
+
+struct test_profile {
+   GLfloat *vertices;
+   size_t bufsize;
+   GLenum draw_mode;
+   GLuint (*shader_setup)(void);
+};
+
+static bool small = false;
+static int total_objects = 0;
+
+static const char *vs_text =
+   "#version 330 core\n"
+   "layout (location = 0) in vec3 aPos;\n"
+   "uniform int nInstances;\n"
+   "out vec4 color;\n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "int i = gl_InstanceID;\n"
+   "float integer;\n"
+   "float r = 0.0 + (1.0 / nInstances) * i;\n"
+   "modf(r, integer);\n"
+   "r -= integer;\n"
+   "float g = 0.333 + (1.0 / nInstances) * i;\n"
+   "modf(g, integer);\n"
+   "g -= integer;\n"
+   "float b = 0.666 + (1.0 / nInstances) * i;\n"
+   "modf(b, integer);\n"
+   "b -= integer;\n"
+   "color = vec4(r, g, b, 0.8);\n"
+   "float invertz = mod(i, 2) * 2 - 1.0;\n"
+   "\n"
+   "float width = 2.0;\n"
+   "float dx = (2.0 / nInstances) * i - 1;\n"
+   "gl_Position = vec4(aPos.x + dx, aPos.y, i / nInstances, 1.0);\n"
+   "}\n";
+
+
+static const char *fs_text =
+   "#version 330 core\n"
+   "in vec4 color;\n"
+   "out vec4 FragColor;\n"
+   "\n"
+   "void main()\n"
+   "{\n"
+   "FragColor = color;\n"
+   "}\n";
+
+static GLuint setup_shaders(void)
+{
+   GLuint prog = piglit_build_simple_program(vs_text, fs_text);
+
+   glUseProgram(prog);
+
+   return prog;
+}
+
+#define MAX_OBJECTS 100
+
+static GLfloat triangle_vertices[] = {
+   -1.0f, -1.0f, 0.0f,
+   0.0f, 1.0f, 0.0f,
+   1.0f, -1.0f, 0.0f,
+};
+
+/* 3 vertices for the first triangle, plus 1 more fore each triangle (4
+ * triangles in total)
+ */
+static GLfloat tr

[Piglit] [PATCH 2/7] egl-context-preemption: Add check for high priority contexts.

2018-10-04 Thread Rafael Antognolli
Check if we can create high priority contexts, otherwise just fail the
test immediately. There's no reason to test for preemption if we can't
create high priority contexts.
---
 tests/egl/egl-context-preemption.c | 57 ++
 1 file changed, 57 insertions(+)

diff --git a/tests/egl/egl-context-preemption.c 
b/tests/egl/egl-context-preemption.c
index 82a698aa1..9d5aa42ee 100644
--- a/tests/egl/egl-context-preemption.c
+++ b/tests/egl/egl-context-preemption.c
@@ -58,6 +58,40 @@ struct test_profile {
 static bool small = false;
 static int total_objects = 0;
 
+static EGLint
+check_priority(EGLDisplay dpy, EGLContext ctx, EGLint *expected)
+{
+   EGLint value;
+   EGLBoolean status =
+   eglQueryContext(dpy, ctx, EGL_CONTEXT_PRIORITY_LEVEL_IMG, 
&value);
+
+   if (status == EGL_FALSE) {
+   piglit_loge("eglQueryContext failed\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   if (expected && value != *expected) {
+   piglit_loge("%s fail: priority value 0x%x, expected 0x%x\n",
+   __func__, value, *expected);
+   piglit_loge("Can't create high priority context.\n");
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   return value;
+}
+
+static EGLContext
+create_context(EGLDisplay dpy, EGLint *attr)
+{
+   EGLContext ctx =
+   eglCreateContext(dpy, EGL_NO_CONFIG_MESA, EGL_NO_CONTEXT, attr);
+
+   if (ctx == EGL_NO_CONTEXT) {
+   piglit_loge("could not create EGL context, attr 0x%x\n", 
attr[1]);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   return ctx;
+}
+
 static const char *vs_text =
"#version 330 core\n"
"layout (location = 0) in vec3 aPos;\n"
@@ -304,6 +338,27 @@ piglit_display(void)
return result;
 }
 
+static void
+check_high_context_priority_creation(EGLDisplay dpy)
+{
+   EGLint attr[] = {
+   EGL_CONTEXT_PRIORITY_LEVEL_IMG,
+   EGL_CONTEXT_PRIORITY_HIGH_IMG,
+   EGL_NONE
+   };
+   EGLContext ctx = create_context(dpy, attr);
+   if (ctx == EGL_NO_CONTEXT) {
+   piglit_loge("failed to create context");
+   piglit_check_egl_error(EGL_SUCCESS);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   EGLint expected = EGL_CONTEXT_PRIORITY_HIGH_IMG;
+   check_priority(dpy, ctx, &expected);
+
+   eglDestroyContext(dpy, ctx);
+}
+
 void
 piglit_init(int argc, char **argv)
 {
@@ -312,6 +367,8 @@ piglit_init(int argc, char **argv)
dpy = eglGetCurrentDisplay();
piglit_require_egl_extension(dpy, "EGL_IMG_context_priority");
 
+   check_high_context_priority_creation(dpy);
+
if (piglit_strip_arg(&argc, argv, "small"))
small = true;
 
-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 0/7] New preemption test.

2018-10-04 Thread Rafael Antognolli
This series attempts to test that we get a fine grained preemption
level when using the EGL_IMG_context_priority extension. Particularly,
if the context priority is set to high in a given context, it should
preempt lower priority contexts if they are still executing when the
higher priority one is dispatch.

This test attemps to confirm that some preemption actually happened. It
does so by first starting a draw call that is supposed to take a long
time to finish, due to the size of the render buffer and instanced
rendering with a high number of instances. Then it starts a new thread
and creates a new, high priority context. This context then dispatch a
bunch of draw calls, and expects that the first one to start after the
main draw call (using GL_TIMESTAMP for that) should still finish before
that one too.

However, checking through the GL_TIMESTAMP is not always guaranteed, and
sometimes we get reports that the first high priority draw that started
after the medium priority one also finished earlier, even if preemption
is not supported. For that, we check the second high priority draw that
started after the main one, which apparently will not report finished
before the medium priority one.

Even though the method reported above might not be ideal for testing
preemption, hopefully this test provides a framework that can be tweaked
to test things correctly at some point.

Cc: Kenneth Graunke 

Rafael Antognolli (7):
  tests: Add base test for mid-command preemption.
  egl-context-preemption: Add check for high priority contexts.
  egl-context-preemption: Add a high priority thread/context.
  egl-context-preemption: check that preemption actually happened.
  egl-context-preemption: Add a subtest to reuse the same display.
  egl-context-preemption: Check that the rendering was correct.
  tests: Add preemption test to the opengl profile.

 tests/egl/CMakeLists.gl.txt|   2 +
 tests/egl/egl-context-preemption.c | 799 +
 tests/opengl.py|   2 +
 3 files changed, 803 insertions(+)
 create mode 100644 tests/egl/egl-context-preemption.c

-- 
2.19.0

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH] quick_shader: Do not exclude tests in sanity profile.

2018-10-03 Thread Rafael Antognolli
We randomly exclude 80% of the 'arb_vertex_attrib_64bit/execution/vs_in'
tests, but we want to keep at least the ones present in the sanity
profile. This makes the 'quick' and 'gpu' profiles a superset of the
'sanity' profile.
---
 tests/quick_shader.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/quick_shader.py b/tests/quick_shader.py
index f1bda6545..dd8853cde 100644
--- a/tests/quick_shader.py
+++ b/tests/quick_shader.py
@@ -26,6 +26,7 @@ import random
 
 from framework import grouptools
 from .shader import profile as _profile
+from .sanity import profile as _sanity
 
 __all__ = ['profile']
 
@@ -42,6 +43,8 @@ class FilterVsIn(object):
 
 def __call__(self, name, _):
 if 'vs_in' in grouptools.split(name):
+if name in _sanity.test_list:
+return True
 # 20%
 return self.random.random() <= .2
 return True
-- 
2.17.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 00/35] Serialize profiles into XML at build time

2018-04-25 Thread Rafael Antognolli
On Mon, Apr 23, 2018 at 10:47:08AM -0700, Dylan Baker wrote:
> I'm planning to just push this Wednesday if no one expresses any more 
> concerns,
> or signals that they want time to test or review this.

I've been running some tests this morning (regular runs, using filters,
testing print-cmd and summary), and it all worked just fine for me. It's
not an in deep testing, but at least I can say it works for my common
use cases. So if you want, feel free to add

Tested-by: Rafael Antognolli 

> Dylan
> 
> Quoting Dylan Baker (2018-04-04 15:26:48)
> > I don't expect everyone I've CC'd to give thorough review (or any
> > review), I've mostly CC'd people who I think would be interested in this
> > work, or who's work flow I might be altered by it.
> > 
> > Piglit has struggled to cope with the growing number of tests that it
> > contains, especially with startup time. Piglit has always calculated
> > tests at runtime, which was not a problem when there were only a few
> > hundred or even thousand tests. Piglit now has roughly 55,000
> > OpenGL/OpenGL ES tests, which is a lot to calculate at start up. It also
> > means that piglit needs to keep a python object for each of those tests
> > in memory, which has sent the resident memory usage soaring. We've also
> > moved to automatic test discovery for glslparser, asmparser, and shader
> > tests, which is very convenient and reduces typing, but further
> > increases the amount of time spent starting up. This has even made
> > features which decrease runtime, like fast skipping, hurt startup
> > performance, making it a less than desirable tradeoff in some cases.
> > Even on a relatively fast machine with an nvme disk 15-20 seconds is not
> > an unheard of startup time. That might be okay to run 55,000 tests, but
> > not if you only need a dozen, such as when bisecting.
> > 
> > This series is my proposal to fix that, mainly by moving much of that
> > cost to build time. This series creates the infrastructure build XML
> > base profiles at build time, which are installed with piglit instead of
> > the python profiles. These profiles are lazily iterated over to ease
> > memory usage, test objects are created as they are run, and python can
> > garbage collect them as soon as they are done running. Along with that
> > any filters applied to profiles (like removing 80% of the vs_in shader
> > tests in quick) are done before the profile is serialized, and all fast
> > skipping information is collected at build time as well, and encoded in
> > the XML. All this means that start times are vastly reduced.
> > 
> > For example:
> > XML profiles
> > quick: 0.5
> > shader: 0.5
> > 
> > master
> > quick: 11.6
> > shader: 7.3
> > 
> > This series also implements some optimizations for running without
> > filters or test-lists, if you add a filter quick would take 2.5
> > seconds, because that is necessary to calculate the total number of
> > tests before starting.
> > 
> > To keep classic profiles like all, quick, quick_cl, gpu, cpu, and
> > llvmpipe working this series adds meta profiles, small XML snippets that
> > list other profiles. These can contain other meta profiles, xml
> > profiles, or python profiles. This means that for most uses cases your
> > existing command line will still work, `./piglit run quick out -c` will
> > still do exactly the same thing as before, just faster.
> > 
> > The XML generated is dumb, there is no encoding of options or logic. An
> > early version of this series did contain logic and options, but the
> > result was pretty terrible. It was very hard to read, and the code to
> > handle it was very complicated. I've chosen not to go down that path.
> > There are drawbacks, some things that relied on run time generation have
> > cannot be handled the same way, among them the "multi shader" concept,
> > where shader_runner consumes a directory of shader_tests at a time. This
> > was previously handled via a --process-isolation=false flag, now its
> > encoded into profiles, "shader_multi" and "quick_shader_multi"; there
> > was also an option to use glslparsertest with ES shaders and
> > ARB_ES_compatibility, that is now "glslparser_arb_compat". I haven't
> > added metaprofiles for these cases, although we certainly could (or you
> > can write your own, the schema is dead simple), so `./piglit run quick
> > out --process-isolation=false` is now `./piglit run quick_gl glslparser
> > quick_shader_multi out`.

[Piglit] [PATCH] cmake: Use WAYLAND_LDFLAGS instead of WAYLAND_LIBRARIES.

2018-03-09 Thread Rafael Antognolli
If the wayland library is found in a prefix, or some non-default place,
WAYLAND_LIBRARIES will not contain -L, only the
-lwayland-client part. If we want the whole set of flags, as returned by
"pkg-config --libs wayland-client", we need to use WAYLAND_LDFLAGS
instead.

Signed-off-by: Rafael Antognolli 
---
 tests/util/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/CMakeLists.txt b/tests/util/CMakeLists.txt
index a9fc33900..0508eb030 100644
--- a/tests/util/CMakeLists.txt
+++ b/tests/util/CMakeLists.txt
@@ -155,7 +155,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif()
 
 if(PIGLIT_HAS_WAYLAND)
-   list(APPEND UTIL_GL_LIBS ${WAYLAND_LIBRARIES})
+   list(APPEND UTIL_GL_LIBS ${WAYLAND_LDFLAGS})
 endif()
 
 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
-- 
2.14.3

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 1/2] framework: Add new formatted summary.

2017-11-17 Thread Rafael Antognolli
Similarly to print-cmd, this option allows one to specify a format
string to output each test in the summary. It can be used to easily
generate a list of only tests that failed, with something like:

./piglit summary formatted -e pass -e skip -e notrun --format {name} \
  results.json.bz2 > ../piglit-summary.txt

This file can then be used as input to piglit run --test-list.

v2: Fix typo and s/testResults/test_results/ (Dylan)

Signed-off-by: Rafael Antognolli 
Reviewed-by: Dylan Baker 
---
 framework/programs/summary.py | 58 ++-
 piglit|  4 +++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index e400d9a76..954a86c48 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/summary.py
@@ -40,6 +40,7 @@ __all__ = [
 'csv',
 'html',
 'feature'
+'formatted'
 ]
 
 
@@ -122,7 +123,7 @@ def console(input_):
 """Combine files in a tests/ directory into a single results file."""
 unparsed = parsers.parse_config(input_)[1]
 
-# Adding the parent is necissary to get the help options
+# Adding the parent is necessary to get the help options
 parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
 
 # Set the -d and -s options as exclusive, since it's silly to call for diff
@@ -200,6 +201,61 @@ def csv(input_):
 else:
 write_results(sys.stdout)
 
+@exceptions.handler
+def formatted(input_):
+# Make a copy of the status text list and add all. This is used as the
+# argument list for -e/--exclude
+statuses = set(str(s) for s in status.ALL)
+
+unparsed = parsers.parse_config(input_)[1]
+
+# Adding the parent is necissary to get the help options
+parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
+parser.add_argument("--format",
+dest="format_string",
+metavar="",
+default="{name} ::: {time} ::: "
+"{returncode} ::: {result}",
+action="store",
+help="A template string that defines the format. "
+ "Replacement tokens are {name}, {time}, "
+ "{returncode} and {result}")
+parser.add_argument("-e", "--exclude-details",
+default=[],
+action="append",
+choices=statuses,
+help="Optionally exclude the listing of tests with "
+ "the status(es) given as arguments. "
+ "May be used multiple times")
+parser.add_argument("-o", "--output",
+metavar="",
+action="store",
+dest="output",
+default="stdout",
+help="Output filename")
+parser.add_argument("test_results",
+metavar="",
+help="JSON results file to be converted")
+args = parser.parse_args(unparsed)
+
+testrun = backends.load(args.test_results)
+
+def write_results(output):
+for name, result in six.iteritems(testrun.tests):
+if result.result in args.exclude_details:
+continue
+output.write((args.format_string + "\n").format(
+name=name,
+time=result.time.total,
+returncode=result.returncode,
+result=result.result))
+
+if args.output != "stdout":
+with open(args.output, 'w') as output:
+write_results(output)
+else:
+write_results(sys.stdout)
+
 
 @exceptions.handler
 def aggregate(input_):
diff --git a/piglit b/piglit
index 6c1d30ae8..0bc753402 100755
--- a/piglit
+++ b/piglit
@@ -149,6 +149,10 @@ def main():
 add_help=False,
 help='generate csv from results')
 csv.set_defaults(func=summary.csv)
+formatted = summary_parser.add_parser('formatted',
+add_help=False,
+help='generate formatted output from 
results')
+formatted.set_defaults(func=summary.formatted)
 aggregate = summary_parser.add_parser('aggregate',
   add_help=False,
   help="Aggregate incomplete piglit 
run.")
-- 
2.13.6

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 2/2] framework: Make csv summary a subset of formatted summary.

2017-11-17 Thread Rafael Antognolli
It's really just about calling the formatted with a csv template.

v2: Use a global for default format string. (Dylan)

Signed-off-by: Rafael Antognolli 
---
 framework/programs/summary.py | 36 +---
 1 file changed, 5 insertions(+), 31 deletions(-)

diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index 954a86c48..c6f616dc8 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/summary.py
@@ -43,6 +43,7 @@ __all__ = [
 'formatted'
 ]
 
+DEFAULT_FMT_STR="{name} ::: {time} ::: {returncode} ::: {result}"
 
 @exceptions.handler
 def html(input_):
@@ -172,37 +173,11 @@ def console(input_):
 
 @exceptions.handler
 def csv(input_):
-unparsed = parsers.parse_config(input_)[1]
-
-# Adding the parent is necissary to get the help options
-parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
-parser.add_argument("-o", "--output",
-metavar="",
-action="store",
-dest="output",
-default="stdout",
-help="Output filename")
-parser.add_argument("testResults",
-metavar="",
-help="JSON results file to be converted")
-args = parser.parse_args(unparsed)
-
-testrun = backends.load(args.testResults)
-
-def write_results(output):
-for name, result in six.iteritems(testrun.tests):
-output.write("{},{},{},{}\n".format(name, result.time.total,
-result.returncode,
-result.result))
-
-if args.output != "stdout":
-with open(args.output, 'w') as output:
-write_results(output)
-else:
-write_results(sys.stdout)
+format_string="{name},{time},{returncode},{result}"
+return formatted(input_, default_format_string=format_string)
 
 @exceptions.handler
-def formatted(input_):
+def formatted(input_, default_format_string=DEFAULT_FMT_STR):
 # Make a copy of the status text list and add all. This is used as the
 # argument list for -e/--exclude
 statuses = set(str(s) for s in status.ALL)
@@ -214,8 +189,7 @@ def formatted(input_):
 parser.add_argument("--format",
 dest="format_string",
 metavar="",
-default="{name} ::: {time} ::: "
-"{returncode} ::: {result}",
+default=default_format_string,
 action="store",
 help="A template string that defines the format. "
  "Replacement tokens are {name}, {time}, "
-- 
2.13.6

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] framework: Make csv summary a subset of formatted summary.

2017-09-29 Thread Rafael Antognolli
It's really just about calling the formatted with a csv template.

Signed-off-by: Rafael Antognolli 
---
 framework/programs/summary.py | 39 ---
 1 file changed, 8 insertions(+), 31 deletions(-)

diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index e21fa5fda..afb3460ce 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/summary.py
@@ -172,50 +172,27 @@ def console(input_):
 
 @exceptions.handler
 def csv(input_):
-unparsed = parsers.parse_config(input_)[1]
-
-# Adding the parent is necissary to get the help options
-parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
-parser.add_argument("-o", "--output",
-metavar="",
-action="store",
-dest="output",
-default="stdout",
-help="Output filename")
-parser.add_argument("testResults",
-metavar="",
-help="JSON results file to be converted")
-args = parser.parse_args(unparsed)
-
-testrun = backends.load(args.testResults)
-
-def write_results(output):
-for name, result in six.iteritems(testrun.tests):
-output.write("{},{},{},{}\n".format(name, result.time.total,
-result.returncode,
-result.result))
-
-if args.output != "stdout":
-with open(args.output, 'w') as output:
-write_results(output)
-else:
-write_results(sys.stdout)
+format_string="{name},{time},{returncode},{result}"
+return formatted(input_, default_format_string=format_string)
 
 @exceptions.handler
-def formatted(input_):
+def formatted(input_, default_format_string=None):
 # Make a copy of the status text list and add all. This is used as the
 # argument list for -e/--exclude
 statuses = set(str(s) for s in status.ALL)
 
 unparsed = parsers.parse_config(input_)[1]
 
+if not default_format_string:
+default_format_string="{name} ::: {time} ::: " \
+  "{returncode} ::: {result}"
+
 # Adding the parent is necissary to get the help options
 parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
 parser.add_argument("--format",
 dest="format_string",
 metavar="",
-default="{name} ::: {time} ::: "
-"{returncode} ::: {result}",
+default=default_format_string,
 action="store",
 help="A template string that defines the format. "
  "Replacement tokens are {name}, {time}, "
-- 
2.13.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 1/2] framework: Add new formatted summary.

2017-09-29 Thread Rafael Antognolli
Similarly to print-cmd, this option allows one to specify a format
string to output each test in the summary. It can be used to easily
generate a list of only tests that failed, with something like:

./piglit summary formatted -e pass -e skip -e notrun --format {name} \
  results.json.bz2 > ../piglit-summary.txt

This file can then be used as input to piglit run --test-list.

Signed-off-by: Rafael Antognolli 
---
 framework/programs/summary.py | 56 +++
 piglit|  4 
 2 files changed, 60 insertions(+)

diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index e400d9a76..e21fa5fda 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/summary.py
@@ -40,6 +40,7 @@ __all__ = [
 'csv',
 'html',
 'feature'
+'formatted'
 ]
 
 
@@ -200,6 +201,61 @@ def csv(input_):
 else:
 write_results(sys.stdout)
 
+@exceptions.handler
+def formatted(input_):
+# Make a copy of the status text list and add all. This is used as the
+# argument list for -e/--exclude
+statuses = set(str(s) for s in status.ALL)
+
+unparsed = parsers.parse_config(input_)[1]
+
+# Adding the parent is necissary to get the help options
+parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
+parser.add_argument("--format",
+dest="format_string",
+metavar="",
+default="{name} ::: {time} ::: "
+"{returncode} ::: {result}",
+action="store",
+help="A template string that defines the format. "
+ "Replacement tokens are {name}, {time}, "
+ "{returncode} and {result}")
+parser.add_argument("-e", "--exclude-details",
+default=[],
+action="append",
+choices=statuses,
+help="Optionally exclude the listing of tests with "
+ "the status(es) given as arguments. "
+ "May be used multiple times")
+parser.add_argument("-o", "--output",
+metavar="",
+action="store",
+dest="output",
+default="stdout",
+help="Output filename")
+parser.add_argument("testResults",
+metavar="",
+help="JSON results file to be converted")
+args = parser.parse_args(unparsed)
+
+testrun = backends.load(args.testResults)
+
+def write_results(output):
+for name, result in six.iteritems(testrun.tests):
+if result.result in args.exclude_details:
+continue
+output.write((args.format_string + "\n").format(
+name=name,
+time=result.time.total,
+returncode=result.returncode,
+result=result.result))
+
+if args.output != "stdout":
+with open(args.output, 'w') as output:
+write_results(output)
+else:
+write_results(sys.stdout)
+
 
 @exceptions.handler
 def aggregate(input_):
diff --git a/piglit b/piglit
index 6c1d30ae8..0bc753402 100755
--- a/piglit
+++ b/piglit
@@ -149,6 +149,10 @@ def main():
 add_help=False,
 help='generate csv from results')
 csv.set_defaults(func=summary.csv)
+formatted = summary_parser.add_parser('formatted',
+add_help=False,
+help='generate formatted output from 
results')
+formatted.set_defaults(func=summary.formatted)
 aggregate = summary_parser.add_parser('aggregate',
   add_help=False,
   help="Aggregate incomplete piglit 
run.")
-- 
2.13.5

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 2/2] arb_transform_feedback_overflow_query-basic: add any_inverted subtest

2017-07-31 Thread Rafael Antognolli
This series is

Reviewed-by: Rafael Antognolli 

On Mon, Jul 31, 2017 at 11:28:36AM +0200, Nicolai Hähnle wrote:
> From: Nicolai Hähnle 
> 
> There is a bug in VI+ with conditional render for any-stream overflow
> that depends on whether the condition is inverted or not.
> ---
>  .../arb_transform_feedback_overflow_query/basic.c| 20 
> 
>  1 file changed, 20 insertions(+)
> 
> diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
> b/tests/spec/arb_transform_feedback_overflow_query/basic.c
> index 72b32fb..9fb3c0c 100644
> --- a/tests/spec/arb_transform_feedback_overflow_query/basic.c
> +++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
> @@ -421,6 +421,20 @@ test_overflow_stream_any(void *test_data)
>  }
>  
>  /**
> + * Overflow on stream 1.
> + * Query for overflow on any stream.
> + * inverted = true, expected overflow: true.
> + */
> +static enum piglit_result
> +test_overflow_stream_any_inverted(void *test_data)
> +{
> + GLuint query_type = GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB;
> + int array_sizes[] = { 6, 5 };
> +
> + return run_subtest(2, array_sizes, 0, query_type, true, true, 
> test_data);
> +}
> +
> +/**
>   * No overflow.
>   * Query for overflow on any stream.
>   * inverted = false, expected overflow: false.
> @@ -528,6 +542,12 @@ const struct piglit_subtest overflow_query_subtests[] = {
>   "conditional_render"
>   },
>   {
> + 
> "arb_transform_feedback_overflow_query-conditional_render_any_inverted",
> + 
> "arb_transform_feedback_overflow_query-conditional_render_any_inverted",
> + test_overflow_stream_any_inverted,
> + "conditional_render"
> + },
> + {
>   
> "arb_transform_feedback_overflow_query-conditional_render_no_overflow",
>   
> "arb_transform_feedback_overflow_query-conditional_render_no_overflow",
>   test_no_overflow_stream_any,
> -- 
> 2.9.3
> 
> ___
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cmake: Check for linux/sync_file.h for egl_khr_fence_sync.

2017-06-29 Thread Rafael Antognolli
On Thu, Jun 29, 2017 at 05:29:06AM +, Vinson Lee wrote:
> Fixes: 2e423dd3f4ca ("egl_khr_fence_sync: Add sw_sync lib.")
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101641
> Signed-off-by: Vinson Lee 
> ---
>  CMakeLists.txt |1 +
>  .../spec/egl_khr_fence_sync/CMakeLists.gles2.txt   |2 ++
>  2 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index 90d056b..a24ddbc 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -470,6 +470,7 @@ check_include_file(sys/resource.h  HAVE_SYS_RESOURCE_H)
>  check_include_file(sys/stat.h  HAVE_SYS_STAT_H)
>  check_include_file(unistd.hHAVE_UNISTD_H)
>  check_include_file(fcntl.h HAVE_FCNTL_H)
> +check_include_file(linux/sync_file.h HAVE_LINUX_SYNC_FILE_H)
>  
>  if(DEFINED PIGLIT_INSTALL_VERSION)
>   set(PIGLIT_INSTALL_VERSION_SUFFIX
> diff --git a/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt 
> b/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
> index c652e4c..550d694 100644
> --- a/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
> +++ b/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
> @@ -4,6 +4,8 @@ if(PIGLIT_HAS_PTHREADS)
>   link_libraries(${CMAKE_THREAD_LIBS_INIT})
>  endif()
>  
> +if(HAVE_LINUX_SYNC_FILE_H)
>  piglit_add_executable(egl_khr_fence_sync egl_khr_fence_sync.c sw_sync.c)
> +endif()
>  
>  # vim: ft=cmake:
> -- 
> 1.7.1
> 

Sorry for this.

Reviewed-by: Rafael Antognolli 
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v3 0/8] Add tests for EGL_ANDROID_native_fence_sync.

2017-06-21 Thread Rafael Antognolli
On Wed, Jun 21, 2017 at 02:36:42PM -0700, Eric Anholt wrote:
> Rafael Antognolli  writes:
> 
> > This time, reuse most of the code from egl_khr_fence_sync test.
> >
> > Cc: Eric Anholt 
> >
> > Rafael Antognolli (8):
> >   egl_khr_fence_sync: Prepare to support android native_sync.
> >   egl_khr_fence_sync: add tests for android fence.
> >   egl_khr_fence_sync: Add sw_sync lib.
> >   egl_khr_fence_sync: Add test to create fence from fd.
> >   egl_khr_fence_sync: Verify eglDupNativeFenceFDANDROID.
> >   egl_khr_fence_sync: Verify that dup() fails on invalid fence.
> >   egl_khr_fence_sync: Test for wait with zero timeout.
> >   egl_khr_fence_sync: Enable android native fences extension test.
> 
> Other than one mid-series mistake I noted, which was already fixed in a
> later commit in the series,
> 
> Reviewed-by: Eric Anholt 

Ouch, it looks like I messed up while rebasing. I'll fix that before merging,
thanks for the review!

Rafael
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 5/8] egl_khr_fence_sync: Verify eglDupNativeFenceFDANDROID.

2017-06-20 Thread Rafael Antognolli
Verify that eglDupNativeFenceFDANDROID() correctly returns a new file
descriptor.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 49 +-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index f6ebc0b..54fee66 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef PIGLIT_HAS_PTHREADS
 #include 
@@ -66,6 +67,7 @@ EGLBoolean (*peglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR 
sync);
 EGLint (*peglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, 
EGLTimeKHR timeout);
 EGLint (*peglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
 EGLBoolean (*peglGetSyncAttribKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint 
attribute, EGLint *value);
+EGLint (*peglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
 
 static const EGLint canary = 0x31415926;
 static EGLDisplay g_dpy = 0;
@@ -1486,6 +1488,44 @@ cleanup:
return result;
 }
 
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_fence(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int sync_fd = canary;
+   struct test_profile *profile = test_data;
+
+   result = test_setup(profile);
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, profile->sync_type, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(%s) failed", profile->sync_str);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   glFlush();
+
+   /* Verify that we can get an fd back from eglDupFenceFD(). */
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, sync);
+   if (sync_fd == -1) {
+   piglit_loge("eglDupNativeFenceFDANDROID() failed"
+   "returned %d but expected >= 0", sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   close(sync_fd);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_android_native_subtests[] = {
{
"eglCreateSyncKHR_default_attributes",
@@ -1532,7 +1572,13 @@ static const struct piglit_subtest 
fence_android_native_subtests[] = {
{
"eglCreateSyncKHR_native_from_fd",
"eglCreateSyncKHR_native_from_fd",
-   test_eglClientWaitSyncKHR_nonzero_timeout,
+   test_eglCreateSyncKHR_native_from_fd,
+   &fence_android_native,
+   },
+   {
+   "eglCreateSyncKHR_native_dup_fence",
+   "eglCreateSyncKHR_native_dup_fence",
+   test_eglCreateSyncKHR_native_dup_fence,
&fence_android_native,
},
{0},
@@ -1591,6 +1637,7 @@ init_egl_extension_funcs(void)
peglClientWaitSyncKHR = (void*) 
eglGetProcAddress("eglClientWaitSyncKHR");
peglWaitSyncKHR = (void*) eglGetProcAddress("eglWaitSyncKHR");
peglGetSyncAttribKHR = (void*) eglGetProcAddress("eglGetSyncAttribKHR");
+   peglDupNativeFenceFDANDROID = (void*) 
eglGetProcAddress("eglDupNativeFenceFDANDROID");
 }
 
 int
-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 0/8] Add tests for EGL_ANDROID_native_fence_sync.

2017-06-20 Thread Rafael Antognolli
This time, reuse most of the code from egl_khr_fence_sync test.

Cc: Eric Anholt 

Rafael Antognolli (8):
  egl_khr_fence_sync: Prepare to support android native_sync.
  egl_khr_fence_sync: add tests for android fence.
  egl_khr_fence_sync: Add sw_sync lib.
  egl_khr_fence_sync: Add test to create fence from fd.
  egl_khr_fence_sync: Verify eglDupNativeFenceFDANDROID.
  egl_khr_fence_sync: Verify that dup() fails on invalid fence.
  egl_khr_fence_sync: Test for wait with zero timeout.
  egl_khr_fence_sync: Enable android native fences extension test.

 tests/all.py   |   6 +
 .../spec/egl_khr_fence_sync/CMakeLists.gles2.txt   |   2 +-
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 538 +++--
 tests/egl/spec/egl_khr_fence_sync/sw_sync.c| 108 +
 tests/egl/spec/egl_khr_fence_sync/sw_sync.h|  47 ++
 5 files changed, 649 insertions(+), 52 deletions(-)
 create mode 100644 tests/egl/spec/egl_khr_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_khr_fence_sync/sw_sync.h

-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 8/8] egl_khr_fence_sync: Enable android native fences extension test.

2017-06-20 Thread Rafael Antognolli
Enable the test on the "all" test profile.

Signed-off-by: Rafael Antognolli 
Cc: Dylan Baker 
---
 tests/all.py | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/all.py b/tests/all.py
index f0a7c05..9ecd8d8 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4646,6 +4646,12 @@ with profile.test_list.group_manager(
 
 with profile.test_list.group_manager(
 PiglitGLTest,
+grouptools.join('spec', 'egl_android_native_fence_sync'),
+exclude_platforms=['glx']) as g:
+g(['egl_khr_fence_sync', 'android_native'])
+
+with profile.test_list.group_manager(
+PiglitGLTest,
 grouptools.join('spec', 'egl_khr_gl_colorspace'),
 exclude_platforms=['glx']) as g:
 g(['egl-gl-colorspace'], 'linear')
-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 1/8] egl_khr_fence_sync: Prepare to support android native_sync.

2017-06-20 Thread Rafael Antognolli
Add a test profile to this test, so we can reuse part of the code later
and test the same features from EGL_ANDROID_native_fence_sync.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 144 +
 1 file changed, 93 insertions(+), 51 deletions(-)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index f92faa6..c96cc14 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -70,8 +70,15 @@ static const EGLint canary = 0x31415926;
 static EGLDisplay g_dpy = 0;
 static EGLContext g_ctx = 0;
 
+struct test_profile {
+   EGLint sync_type;
+   const char *sync_str;
+   const char *extension;
+};
+
 static enum piglit_result
-init_display(EGLenum platform, EGLDisplay *out_dpy)
+init_display(EGLenum platform, EGLDisplay *out_dpy,
+struct test_profile *profile)
 {
enum piglit_result result = PIGLIT_PASS;
EGLDisplay dpy;
@@ -90,8 +97,8 @@ init_display(EGLenum platform, EGLDisplay *out_dpy)
goto error;
}
 
-   if (!piglit_is_egl_extension_supported(dpy, "EGL_KHR_fence_sync")) {
-   piglit_loge("display does not support EGL_KHR_fence_sync");
+   if (!piglit_is_egl_extension_supported(dpy, profile->extension)) {
+   piglit_loge("display does not support %s", profile->extension);
result = PIGLIT_SKIP;
goto error;
 
@@ -252,7 +259,7 @@ test_cleanup(EGLSyncKHR sync, enum piglit_result 
*inout_result)
  * Setup state before each subtest begins.
  */
 static enum piglit_result
-test_setup(void)
+test_setup(struct test_profile *profile)
 {
enum piglit_result result = PIGLIT_PASS;
 
@@ -260,7 +267,7 @@ test_setup(void)
g_dpy = EGL_NO_DISPLAY;
g_ctx = EGL_NO_CONTEXT;
 
-   result = init_display(EGL_NONE, &g_dpy);
+   result = init_display(EGL_NONE, &g_dpy, profile);
if (result != PIGLIT_PASS) {
goto cleanup;
}
@@ -307,15 +314,16 @@ test_eglCreateSyncKHR_default_attributes(void *test_data)
   sync_status = canary,
   sync_condition = canary;
bool ok = false;
+   struct test_profile *profile = test_data;
 
-   result = test_setup();
+   result = test_setup(profile);
if (result != PIGLIT_PASS) {
return result;
}
 
-   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_FENCE_KHR, NULL);
+   sync = peglCreateSyncKHR(g_dpy, profile->sync_type, NULL);
if (sync == EGL_NO_SYNC_KHR) {
-   piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed");
+   piglit_loge("eglCreateSyncKHR(%s) failed", profile->sync_str);
result = PIGLIT_FAIL;
goto cleanup;
}
@@ -330,10 +338,10 @@ test_eglCreateSyncKHR_default_attributes(void *test_data)
  "an error");
result = PIGLIT_FAIL;
}
-   if (sync_type != EGL_SYNC_FENCE_KHR) {
+   if (sync_type != profile->sync_type) {
piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) returned "
- "0x%x but expected EGL_SYNC_FENCE_KHR(0x%x)",
- sync_type, EGL_SYNC_FENCE_KHR);
+ "0x%x but expected %s(0x%x)",
+ sync_type, profile->sync_str, profile->sync_type);
result = PIGLIT_FAIL;
}
 
@@ -386,13 +394,14 @@ test_eglCreateSyncKHR_invalid_display(void *test_data)
 {
enum piglit_result result = PIGLIT_PASS;
EGLSyncKHR sync = 0;
+   struct test_profile *profile = test_data;
 
-   result = test_setup();
+   result = test_setup(profile);
if (result != PIGLIT_PASS) {
return result;
}
 
-   sync = peglCreateSyncKHR(EGL_NO_DISPLAY, EGL_SYNC_FENCE_KHR, NULL);
+   sync = peglCreateSyncKHR(EGL_NO_DISPLAY, profile->sync_type, NULL);
if (sync != EGL_NO_SYNC_KHR) {
piglit_loge("eglCreateSyncKHR(EGL_NO_DISPLAY) succeeded");
result = PIGLIT_FAIL;
@@ -425,13 +434,14 @@ test_eglCreateSyncKHR_invalid_attrib_list(void *test_data)
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE,
};
+   struct test_profile *profile = test_data;
 
-   result = test_setup();
+   result = test_setup(profile);
if (result != PIGLIT_PASS) {
return result;
}
 
-   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_FENCE_KHR, attrib_list);
+   sync = peglCreateSyncKHR(g_dpy, profile->sync_type, attrib_list);
if (sync != EGL_NO_SYNC_KHR) {
piglit_loge("eglCreateSyncKHR() succeeded with invalid &quo

[Piglit] [PATCH v3 4/8] egl_khr_fence_sync: Add test to create fence from fd.

2017-06-20 Thread Rafael Antognolli
Add a test that creates a sync file using sw_sync, and then creates an
EGL fence sync from that sync file. It also verify that the fence sync
EGL_SYNC_CONDITION_KHR is set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID,
and that EGL_SYNC_STATUS_KHR changes to EGL_SIGNALED_KHR once the fence
is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 145 +
 1 file changed, 145 insertions(+)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index d5353f2..f6ebc0b 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -55,6 +55,7 @@
 
 #include "piglit-util-egl.h"
 #include "piglit-util-gl.h"
+#include "sw_sync.h"
 
 /* Extension function pointers.
  *
@@ -1347,6 +1348,144 @@ static struct test_profile fence_android_native = {
.extension = "EGL_ANDROID_native_fence_sync",
 };
 
+static EGLSyncKHR
+test_create_fence_from_fd(int fd)
+{
+   EGLint attrib_list[] = {
+   EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
+   EGL_NONE,
+   };
+
+   return peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
attrib_list);
+}
+
+static enum piglit_result
+test_eglCreateSyncKHR_native_from_fd(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   EGLint sync_type = canary,
+  sync_status = canary,
+  sync_condition = canary;
+   int sync_fd = canary;
+   int timeline = canary;
+   bool ok = false;
+   struct test_profile *profile = test_data;
+
+   result = test_setup(profile);
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(%s) failed", profile->sync_str);
+   result = PIGLIT_FAIL;
+   sw_sync_fence_destroy(sync_fd);
+   goto cleanup_timeline;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_TYPE_KHR, &sync_type);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) emitted "
+   "an error");
+   result = PIGLIT_FAIL;
+   }
+   if (sync_type != profile->sync_type) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) returned "
+   "0x%x but expected %s(0x%x)",
+   sync_type, profile->sync_str, profile->sync_type);
+   result = PIGLIT_FAIL;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_STATUS_KHR, 
&sync_status);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) emitted "
+   "an error");
+   result = PIGLIT_FAIL;
+   }
+   if (sync_status != EGL_UNSIGNALED_KHR) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) "
+   "returned 0x%x but expected "
+   "EGL_UNSIGNALED_KHR(0x%x)",
+   sync_status, EGL_UNSIGNALED_KHR);
+   result = PIGLIT_FAIL;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_CONDITION_KHR, 
&sync_condition);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_CONDITION_KHR) 
failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_CONDITION_KHR) "
+   "emitted an error");
+ 

[Piglit] [PATCH v3 2/8] egl_khr_fence_sync: add tests for android fence.

2017-06-20 Thread Rafael Antognolli
Add a new "profile" for android native fences. It basically reuses some
of the tests that should be common to this and the original
EGL_KHR_fence_sync extension.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 54 ++
 1 file changed, 54 insertions(+)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index c96cc14..d5353f2 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -1341,6 +1341,58 @@ static const struct piglit_subtest fence_sync_subtests[] 
= {
{0},
 };
 
+static struct test_profile fence_android_native = {
+   .sync_type = EGL_SYNC_NATIVE_FENCE_ANDROID,
+   .sync_str = "EGL_SYNC_NATIVE_FENCE_ANDROID",
+   .extension = "EGL_ANDROID_native_fence_sync",
+};
+
+static const struct piglit_subtest fence_android_native_subtests[] = {
+   {
+   "eglCreateSyncKHR_default_attributes",
+   "eglCreateSyncKHR_default_attributes",
+   test_eglCreateSyncKHR_default_attributes,
+   &fence_android_native,
+   },
+   {
+   "eglCreateSyncKHR_invalid_display",
+   "eglCreateSyncKHR_invalid_display",
+   test_eglCreateSyncKHR_invalid_display,
+   &fence_android_native,
+   },
+   {
+   "eglCreateSyncKHR_invalid_attrib_list",
+   "eglCreateSyncKHR_invalid_attrib_list",
+   test_eglCreateSyncKHR_invalid_attrib_list,
+   &fence_android_native,
+   },
+   {
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   test_eglCreateSyncKHR_wrong_display_same_thread,
+   &fence_android_native,
+   },
+   {
+   "eglCreateSyncKHR_no_current_context",
+   "eglCreateSyncKHR_no_current_context",
+   test_eglCreateSyncKHR_no_current_context,
+   &fence_android_native,
+   },
+   {
+   "eglGetSyncAttribKHR_invalid_attrib",
+   "eglGetSyncAttribKHR_invalid_attrib",
+   test_eglGetSyncAttribKHR_invalid_attrib,
+   &fence_android_native,
+   },
+   {
+   "eglClientWaitSyncKHR_nonzero_timeout",
+   "eglClientWaitSyncKHR_nonzero_timeout",
+   test_eglClientWaitSyncKHR_nonzero_timeout,
+   &fence_android_native,
+   },
+   {0},
+};
+
 /**
  * Verify that eglWaitSyncKHR() emits correct error when given an invalid
  * sync object.
@@ -1406,6 +1458,8 @@ main(int argc, char **argv)
 
if (piglit_strip_arg(&argc, argv, "wait_sync"))
subtests = wait_sync_subtests;
+   else if (piglit_strip_arg(&argc, argv, "android_native"))
+   subtests = fence_android_native_subtests;
else
subtests = fence_sync_subtests;
 
-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 7/8] egl_khr_fence_sync: Test for wait with zero timeout.

2017-06-20 Thread Rafael Antognolli
Verify that eglClientWaitSyncKHR() correctly handles zero timeout before
and after the sw sync fence is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 97 ++
 1 file changed, 97 insertions(+)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index 96c0be9..dcd56cf 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -1571,6 +1571,97 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() correctly handles zero timeout before and
+ * after sw_sync_timeline_inc().
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ * If the value of  is zero, then eglClientWaitSyncKHR simply
+ * tests the current status of .
+ *
+ * [...]
+ *
+ * eglClientWaitSyncKHR returns one of three status values describing
+ * the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR
+ * indicates that the specified timeout period expired before 
+ * was signaled. A return value of EGL_CONDITION_SATISFIED_KHR
+ * indicates that  was signaled before the timeout expired, which
+ * includes the case when  was already signaled when
+ * eglClientWaitSyncKHR was called. If an error occurs then an error is
+ * generated and EGL_FALSE is returned.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_zero_timeout(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int wait_status1 = 0, wait_status2 = 0;
+   int sync_fd = canary;
+   int timeline = canary;
+   struct test_profile *profile = test_data;
+
+   result = test_setup(profile);
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(%s) failed", profile->sync_str);
+   result = PIGLIT_FAIL;
+   sw_sync_fence_destroy(sync_fd);
+   goto cleanup_timeline;
+   }
+
+   glFlush();
+
+   wait_status1 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+   sw_sync_timeline_inc(timeline, 1);
+   wait_status2 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+
+   if (wait_status1 != EGL_TIMEOUT_EXPIRED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() before 
sw_sync_timeline_inc:\n"
+   "  Expected status: EGL_TIMEOUT_EXPIRED_KHR 
(0x%x)\n"
+   "  Actual status:  0x%x\n",
+   EGL_TIMEOUT_EXPIRED_KHR, wait_status1);
+   result = PIGLIT_FAIL;
+   }
+   if (wait_status2 != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() after 
sw_sync_timeline_inc:\n"
+   "  Expected status: EGL_CONDITION_SATISFIED_KHR\n"
+   "  Actual status:  0x%x\n", wait_status2);
+   result = PIGLIT_FAIL;
+   }
+
+cleanup_timeline:
+   sw_sync_timeline_destroy(timeline);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_android_native_subtests[] = {
{
"eglCreateSyncKHR_default_attributes",
@@ -1632,6 +1723,12 @@ static const struct piglit_subtest 
fence_android_native_subtests[] = {
test_eglCreateSyncKHR_native_dup_invalid,
&fence_android_native,
},
+   {
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   test_eglClientWaitSyncKHR_native_zero_timeout,
+   &fence_android_native,
+   },
{0},
 };
 
-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v3 3/8] egl_khr_fence_sync: Add sw_sync lib.

2017-06-20 Thread Rafael Antognolli
Add a small library that helps manipulating software fences. They are
useful for testing EGL Android fences, since the latter can be created
out of them.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/CMakeLists.gles2.txt   |   2 +-
 tests/egl/spec/egl_khr_fence_sync/sw_sync.c| 108 +
 tests/egl/spec/egl_khr_fence_sync/sw_sync.h|  47 +
 3 files changed, 156 insertions(+), 1 deletion(-)
 create mode 100644 tests/egl/spec/egl_khr_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_khr_fence_sync/sw_sync.h

diff --git a/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt 
b/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
index d3f2961..c652e4c 100644
--- a/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
+++ b/tests/egl/spec/egl_khr_fence_sync/CMakeLists.gles2.txt
@@ -4,6 +4,6 @@ if(PIGLIT_HAS_PTHREADS)
link_libraries(${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-piglit_add_executable(egl_khr_fence_sync egl_khr_fence_sync.c)
+piglit_add_executable(egl_khr_fence_sync egl_khr_fence_sync.c sw_sync.c)
 
 # vim: ft=cmake:
diff --git a/tests/egl/spec/egl_khr_fence_sync/sw_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/sw_sync.c
new file mode 100644
index 000..8c1d29d
--- /dev/null
+++ b/tests/egl/spec/egl_khr_fence_sync/sw_sync.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2012 Google, Inc
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * Based on the implementation from the Android Open Source Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Robert Foss 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sw_sync.h"
+
+#ifndef SW_SYNC_IOC_INC
+struct sw_sync_create_fence_data {
+   __u32   value;
+   charname[32];
+   __s32   fence;
+};
+
+#define SW_SYNC_IOC_MAGIC  'W'
+#define SW_SYNC_IOC_CREATE_FENCE   _IOWR(SW_SYNC_IOC_MAGIC, 0,\
+   struct 
sw_sync_create_fence_data)
+#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, 
__u32)
+#endif
+
+#define DEVFS_SW_SYNC   "/dev/sw_sync"
+#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync"
+
+bool sw_sync_is_supported(void)
+{
+   if (access(DEVFS_SW_SYNC, R_OK | W_OK) != -1) {
+   return true;
+   } else if (access(DEBUGFS_SW_SYNC, R_OK | W_OK) != -1 ) {
+   return true;
+   }
+
+   return false;
+}
+
+int sw_sync_timeline_create(void)
+{
+   int fd = open(DEVFS_SW_SYNC, O_RDWR);
+
+   if (fd < 0)
+   fd = open(DEBUGFS_SW_SYNC, O_RDWR);
+
+   return fd;
+}
+
+void sw_sync_timeline_destroy(int fd)
+{
+   close(fd);
+}
+
+void sw_sync_fence_destroy(int fd)
+{
+   close(fd);
+}
+
+int sw_sync_fence_create(int fd, int32_t seqno)
+{
+   struct sw_sync_create_fence_data data = {};
+   data.value = seqno;
+
+   if (fd < 0)
+   return -1;
+
+   ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data);
+
+   return data.fence;
+}
+
+void sw_sync_timeline_inc(int fd, uint32_t count)
+{
+   uint32_t arg = count;
+
+   if (fd == 0 || fd == -1)
+   return;
+
+   ioctl(fd, SW_SYNC_IOC_INC, &arg);
+}
diff --git a/tests/egl/spec/egl_khr_fence_sync/sw_sync.h 
b/tests/egl/spec/egl_khr_fence_sync/sw_sync.h
new file mode 100644
index 000..e3ddc4d
--- /dev/null
+++ b/tests/egl/spec/egl_khr_fence_sync/sw_sync.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012 Google, Inc
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * Based on the implementation from the Android Open Source Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restricti

[Piglit] [PATCH v3 6/8] egl_khr_fence_sync: Verify that dup() fails on invalid fence.

2017-06-20 Thread Rafael Antognolli
If  is not a valid sync object for ,
EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
error is generated.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_khr_fence_sync/egl_khr_fence_sync.c   | 51 ++
 1 file changed, 51 insertions(+)

diff --git a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c 
b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
index 54fee66..96c0be9 100644
--- a/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
+++ b/tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c
@@ -1526,6 +1526,51 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglDupNativeFenceFDANDROID emits correct error when given an
+ * invalid sync .
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ * If  is not a valid sync object for ,
+ * EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
+ * error is generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_invalid(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary;
+   EGLint sync_fd = canary;
+
+   result = test_setup(test_data);
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, invalid_sync);
+   if (sync_fd != EGL_NO_NATIVE_FENCE_FD_ANDROID) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() should return "
+   "EGL_NO_NATIVE_FENCE_FD_ANDROID, "
+   "but returned %d", sync_fd);
+   close(sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() "
+   "did not emit EGL_BAD_PARAMETER");
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(EGL_NO_SYNC_KHR, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_android_native_subtests[] = {
{
"eglCreateSyncKHR_default_attributes",
@@ -1581,6 +1626,12 @@ static const struct piglit_subtest 
fence_android_native_subtests[] = {
test_eglCreateSyncKHR_native_dup_fence,
&fence_android_native,
},
+   {
+   "eglCreateSyncKHR_native_dup_invalid",
+   "eglCreateSyncKHR_native_dup_invalid",
+   test_eglCreateSyncKHR_native_dup_invalid,
+   &fence_android_native,
+   },
{0},
 };
 
-- 
2.9.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2 00/12] egl_android_native_fence_sync tests.

2017-06-16 Thread Rafael Antognolli
On Fri, Jun 16, 2017 at 04:50:20PM -0700, Dylan Baker wrote:
> I don't see any tests added to tests/all.py, is that intentional?

No, this was the first series I did for piglit, so I didn't even know about
it. But it was in my todo list (somewhere) to add it on a next version.

> Quoting Rafael Antognolli (2016-11-07 15:05:02)
> > Updated version of these tests.
> > 
> > This series is also available at:
> > 
> > https://github.com/rantogno/piglit/tree/review/fences-v02
> > 
> > v2:
> > - split sw_sync lib into its own patch
> > - remove sync_wait and sync_merge from sw_sync lib
> > - do not destroy sync fd after creating EGL sync out of it.
> > 
> > Rafael Antognolli (12):
> >   egl_android_native_fence_sync: Initial test for native fences.
> >   egl_android_native_fence_sync: Add sw_sync lib.
> >   egl_android_native_fence_sync: Add test to create fence from fd.
> >   egl_android_native_fence_sync: Verify eglDupNativeFenceFDANDROID.
> >   egl_android_native_fence_sync: Create fence from invalid display.
> >   egl_android_native_fence_sync: Create fence from other display.
> >   egl_android_native_fence_sync: Create fence with invalid attributes.
> >   egl_android_native_fence_sync: Create fence without current context.
> >   egl_android_native_fence_sync: Try to get invalid attribute.
> >   egl_android_native_fence_sync: Test for wait with zero timeout.
> >   egl_android_native_fence_sync: Test nonzero timeout.
> >   egl_android_native_fence_sync: Verify that dup() fails on invalid
> > fence.
> > 
> >  tests/egl/spec/CMakeLists.txt  |1 +
> >  .../CMakeLists.gles2.txt   |9 +
> >  .../egl_android_native_fence_sync/CMakeLists.txt   |1 +
> >  .../egl_android_native_fence_sync.c| 1068 
> > 
> >  .../spec/egl_android_native_fence_sync/sw_sync.c   |  211 
> >  .../spec/egl_android_native_fence_sync/sw_sync.h   |   50 +
> >  6 files changed, 1340 insertions(+)
> >  create mode 100644 
> > tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
> >  create mode 100644 
> > tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
> >  create mode 100644 
> > tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
> >  create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
> >  create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h
> > 
> > -- 
> > 2.7.4
> > 
> > ___
> > Piglit mailing list
> > Piglit@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/piglit


___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH v2 02/12] egl_android_native_fence_sync: Add sw_sync lib.

2017-06-16 Thread Rafael Antognolli
On Fri, Jun 16, 2017 at 11:59:31AM -0700, Eric Anholt wrote:
> Rafael Antognolli  writes:
> 
> > Add a small library that helps manipulating software fences. They are
> > useful for testing EGL Android fences, since the latter can be created
> > out of them.
> >
> > Signed-off-by: Rafael Antognolli 
> > ---
> >  .../spec/egl_android_native_fence_sync/sw_sync.c   | 211 
> > +
> >  .../spec/egl_android_native_fence_sync/sw_sync.h   |  50 +
> >  2 files changed, 261 insertions(+)
> >  create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
> >  create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h
> >
> > diff --git a/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c 
> > b/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
> > new file mode 100644
> > index 000..4e8117f
> > --- /dev/null
> > +++ b/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
> > @@ -0,0 +1,211 @@
> > +/*
> > + * Copyright 2012 Google, Inc
> > + * Copyright © 2016 Collabora, Ltd.
> > + *
> > + * Based on the implementation from the Android Open Source Project
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the 
> > "Software"),
> > + * to deal in the Software without restriction, including without 
> > limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the 
> > next
> > + * paragraph) shall be included in all copies or substantial portions of 
> > the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
> > OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
> > OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> > DEALINGS
> > + * IN THE SOFTWARE.
> > + *
> > + * Authors:
> > + *Robert Foss 
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include "sw_sync.h"
> > +
> > +#ifndef SW_SYNC_IOC_INC
> > +struct sw_sync_create_fence_data {
> > +   __u32   value;
> > +   charname[32];
> > +   __s32   fence;
> > +};
> > +
> > +#define SW_SYNC_IOC_MAGIC  'W'
> > +#define SW_SYNC_IOC_CREATE_FENCE   _IOWR(SW_SYNC_IOC_MAGIC, 0,\
> > +   struct 
> > sw_sync_create_fence_data)
> > +#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, 
> > __u32)
> > +#endif
> > +
> > +#define DEVFS_SW_SYNC   "/dev/sw_sync"
> > +#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync"
> > +
> > +bool sw_sync_is_supported(void)
> > +{
> > +   if(access(DEVFS_SW_SYNC, R_OK | W_OK) != -1) {
> > +   return true;
> 
> space after "if"
> 
> > +   } else if (access(DEBUGFS_SW_SYNC, R_OK | W_OK) != -1 ) {
> > +   return true;
> > +   }
> > +
> > +   return false;
> > +}
> > +
> > +int sw_sync_fd_is_valid(int fd)
> > +{
> > +   int status;
> > +
> > +   if (fd < 0)
> > +   return 0;
> > +
> > +   status = fcntl(fd, F_GETFD, 0);
> > +   return status >= 0;
> > +}
> 
> Do we need to F_GETFD?  Couldn't all callers of this just "if (fd < 0)"?
> 
> > +
> > +static
> > +void sw_sync_fd_close(int fd)
> > +{
> > +   if (!sw_sync_fd_is_valid(fd))
> > +   return;
> > +
> > +   close(fd);
> 
> Is there a reason to call is_valid() before close()?  I think you could
> drop this entire function and just close(fd) from
> sw_sync_timeline_destroy() and fence_destroy().
> 
> > +}
> > +
> > +int sw_sync_timeline_create(void)
> > +{
> > +   int fd = open(DEVFS_SW_SYNC, O_RDWR);
&g

Re: [Piglit] [PATCH v2 06/12] egl_android_native_fence_sync: Create fence from other display.

2017-06-16 Thread Rafael Antognolli
On Fri, Jun 16, 2017 at 12:29:46PM -0700, Eric Anholt wrote:
> Rafael Antognolli  writes:
> 
> > Verify that EGL_NO_SYNC_KHR is returned and EGL_BAD_MATCH error is
> > generated.
> >
> > Signed-off-by: Rafael Antognolli 
> > ---
> >  .../egl_android_native_fence_sync.c| 98 
> > +-
> >  1 file changed, 97 insertions(+), 1 deletion(-)
> >
> > diff --git 
> > a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
> >  
> > b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
> > index eb01014..721bc44 100644
> > --- 
> > a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
> > +++ 
> > b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
> > @@ -515,7 +515,7 @@ cleanup:
> >   * Verify that eglCreateSyncKHR emits correct error when given an invalid
> >   * display.
> >   *
> > - * From the EGL_KHR_fence_sync spec:
> > + * From the EGL_ANDROID_native_fence_sync spec:
> 
> The citation appears in both specs.  Let's pick one and use it in the
> commit adding the citation, rather than changing it here.
> 
> >   *
> >   * If  is not the name of a valid, initialized EGLDisplay,
> >   * EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
> > @@ -546,6 +546,97 @@ test_eglCreateSyncKHR_native_invalid_display(void 
> > *test_data)
> > return result;
> >  }
> >  
> > +static enum piglit_result
> > +init_other_display(EGLDisplay *out_other_dpy, EGLDisplay orig_dpy)
> > +{
> > +   enum piglit_result result = PIGLIT_PASS;
> > +   EGLDisplay other_dpy = 0;
> > +   int i;
> > +
> > +   static const EGLint platforms[] = {
> > +   EGL_PLATFORM_X11_EXT,
> > +   EGL_PLATFORM_WAYLAND_EXT,
> > +   EGL_PLATFORM_GBM_MESA,
> > +   0,
> > +   };
> > +
> > +   for (i = 0; platforms[i] != 0; ++i) {
> > +   result = init_display(platforms[i], &other_dpy);
> > +   switch (result) {
> > +   case PIGLIT_SKIP:
> > +   break;
> > +   case PIGLIT_PASS:
> > +   if (other_dpy && other_dpy != orig_dpy) {
> > +   *out_other_dpy = other_dpy;
> > +   return PIGLIT_PASS;
> > +   } else {
> > +   result = PIGLIT_SKIP;
> > +   break;
> > +   }
> > +   default:
> > +   break;
> 
> Switch cases should be at the same indentation level as the switch
> itself.
> 
> Actually, since this code looks like it's from
> tests/egl/spec/egl_khr_fence_sync/egl_khr_fence_sync.c, could you just
> move its init_other_display() function to a helper in
> tests/util/piglit-util-egl.c?

If I move it to piglit-util-egl.c, then I'll need to move init_display() as
well. However, that one is checking for the sync extension, which is quite
specific to these two tests, so it's probably not a good idea to move it
there. And if we did, it would probably make sense to also move
init_context(). But I'm not sure these functions belong there...

> I do wonder if it would be possible to share more of our test code
> between these two tests.  Seems messy, though.

I think one idea would be to put the native fence tests inside
egl_khr_fence_sync.c, so we could reuse a lot of these functions, and test
functionality both for native and non-native fences. What do you think?

Anyway, thank you for the reviews!

> > +   }
> > +   }
> > +
> > +   return result;
> > +}
> > +
> > +/**
> > + * Verify that eglCreateSyncKHR() emits correct error when given a display 
> > that
> > + * does not match the display of the bound context.
> > + *
> > + * From the EGL_KHR_fence_sync spec:
> > + *
> > + * * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
> > + *   no context is current for the bound API (i.e., eglGetCurrentContext
> > + *   returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
> > + *   EGL_BAD_MATCH error is generated.
> 
> This citation seems to be in EGL_ANDROID_native_fence_sync, not KHR.
> Also, I think this is the wrong block of spec text -- you want the one
> about "does not match the EGLDisplay of the currently bound context". I
> was going to suggest gutting almost all of the test, given the 

[Piglit] [PATCH v5 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-15 Thread Rafael Antognolli
Add tests to verify that GL_ERROR_VALUE is returned with an invalid
index is used to begin, end or get a current query.

v2:
- Add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- Skip test if some extensions are not present (Ilia Mirkin)
v4:
- Revert to using piglit_require_extension (Ilia Mirkin)
v5:
- allow to run concurrently (Dylan Baker)
- do not specify name (Dylan Baker)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   1 +
 .../CMakeLists.gl.txt  |   1 +
 .../arb_transform_feedback_overflow_query/errors.c | 269 +
 3 files changed, 271 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/errors.c

diff --git a/tests/all.py b/tests/all.py
index 229b22a..7157262 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3679,6 +3679,7 @@ with profile.test_list.group_manager(
 PiglitGLTest,
 grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
 g(['arb_transform_feedback_overflow_query-basic'])
+g(['arb_transform_feedback_overflow_query-errors'])
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
index d75418f..f8adc3a 100644
--- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -9,4 +9,5 @@ link_libraries (
 )
 
 piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+piglit_add_executable (arb_transform_feedback_overflow_query-errors errors.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
b/tests/spec/arb_transform_feedback_overflow_query/errors.c
new file mode 100644
index 000..148b660
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_begin_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLuint query;
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB, 1, query);
+
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is PRIMITIVES_GENERATED,
+ * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, or
+ * TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, and  is not in the range
+ * zero to the value of MAX_VERTEX_STREAMS minus one.
+ */
+static enum piglit_result
+test_begin_index_invalid(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLint max_stream;
+   GLuint query;
+
+   glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_stream);
+   if (!piglit_check_gl_error(GL_NO_ERROR)) {
+   printf("failed to resolve the 

[Piglit] [PATCH v5 1/2] Add arb_transform_feedback_overflow_query tests.

2016-12-15 Thread Rafael Antognolli
Add tests that verify that the xfb overflow query correctly detects
overflow on streams 0 and 1. Also add tests that check its interaction
with glBeginConditionalRender, and with ARB_query_buffer_object.

v2:
- add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- skip some tests when GL_ARB_transform_feedback3 or
GL_ARB_gpu_shader5 are not present, and add specific tests for those
cases (Ilia Mirkin)
v5:
- allow to run concurrently (Dylan Baker)
- do not specify name (Dylan Baker)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   5 +
 tests/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gl.txt  |  12 +
 .../CMakeLists.txt |   1 +
 .../arb_transform_feedback_overflow_query/basic.c  | 591 +
 5 files changed, 610 insertions(+)
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/basic.c

diff --git a/tests/all.py b/tests/all.py
index 03cf0c8..229b22a 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3677,6 +3677,11 @@ with profile.test_list.group_manager(
 
 with profile.test_list.group_manager(
 PiglitGLTest,
+grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
+g(['arb_transform_feedback_overflow_query-basic'])
+
+with profile.test_list.group_manager(
+PiglitGLTest,
 grouptools.join('spec', 'arb_uniform_buffer_object')) as g:
 g(['arb_uniform_buffer_object-bindbuffer-general-point'],
   'bindbuffer-general-point')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..6115c5a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory (arb_texture_view)
 add_subdirectory (arb_timer_query)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (arb_transform_feedback3)
+add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_depth_bounds_test)
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
new file mode 100644
index 000..d75418f
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
b/tests/spec/arb_transform_feedback_overflow_query/basic.c
new file mode 100644
index 000..25c3355
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file basic.c
+ *
+ * This test verifies the basic functionality of
+ * ARB_transform_feedback_overflow_query: that it detects overflow for specific
+ * streams, and on any stream too if re

Re: [Piglit] [PATCH v3 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-15 Thread Rafael Antognolli
On Thu, Dec 15, 2016 at 10:58:10AM -0800, Dylan Baker wrote:
> Quoting Rafael Antognolli (2016-12-13 14:51:14)
> > Add tests to verify that GL_ERROR_VALUE is returned if an invalid
> > index is used to begin, end or get a current query.
> > 
> > v2:
> > - Add test to all.py (Ilia Mirkin)
> > - Add check for ARB_transform_feedback_overflow_query extension
> > v3:
> > - Skip test if some extensions are not present (Ilia Mirkin)
> > 
> > Signed-off-by: Rafael Antognolli 
> > ---
> >  tests/all.py   |   2 +
> >  .../CMakeLists.gl.txt  |   1 +
> >  .../arb_transform_feedback_overflow_query/errors.c | 279 
> > +
> >  3 files changed, 282 insertions(+)
> >  create mode 100644 
> > tests/spec/arb_transform_feedback_overflow_query/errors.c
> > 
> > diff --git a/tests/all.py b/tests/all.py
> > index 888f25f..dbfe225 100644
> > --- a/tests/all.py
> > +++ b/tests/all.py
> > @@ -3680,6 +3680,8 @@ with profile.test_list.group_manager(
> >  grouptools.join('spec', 'arb_transform_feedback_overflow_query')) 
> > as g:
> >  g(['arb_transform_feedback_overflow_query-basic'],
> >'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
> > +g(['arb_transform_feedback_overflow_query-errors'],
> > +  'arb_transform_feedback_overflow_query-errors', run_concurrent=False)
> 
> See my comment on the previous patch here too.

Hmm... makes sense, I just saw how it is used in other places. I can fix
that.

> Also, I just noticed that you're setting run_concurrent to False, is there a
> particular reason that these tests need to be run serially? Generally only 
> tests
> that do front buffer rendering or have CPU/GPU synchronization requirements 
> need
> to be set to run_concurrent.

No front buffer rendering, but I'm not sure about CPU/GPU
synchronization. I mean, when we try to get the result from a query on
the CPU, it does wait for the GPU, but I'm not sure that's what you are
talking about.

I was mainly copying & pasting from
arb_transform_feedback3-query_with_invalid_index, which does much less
stuff that the overflow_query does, and it still uses
run_concurrent=False. It just does some queries with invalid
parameters. Is that also not needed?

Thanks,
Rafael
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v4 1/2] Add arb_transform_feedback_overflow_query tests.

2016-12-13 Thread Rafael Antognolli
Add tests that verify that the xfb overflow query correctly detects
overflow on streams 0 and 1. Also add tests that check its interaction
with glBeginConditionalRender, and with ARB_query_buffer_object.

v2:
- add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- skip some tests when GL_ARB_transform_feedback3 or
GL_ARB_gpu_shader5 are not present, and add specific tests for those
cases (Ilia Mirkin)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   6 +
 tests/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gl.txt  |  12 +
 .../CMakeLists.txt |   1 +
 .../arb_transform_feedback_overflow_query/basic.c  | 591 +
 5 files changed, 611 insertions(+)
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/basic.c

diff --git a/tests/all.py b/tests/all.py
index 03cf0c8..888f25f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3677,6 +3677,12 @@ with profile.test_list.group_manager(
 
 with profile.test_list.group_manager(
 PiglitGLTest,
+grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
+g(['arb_transform_feedback_overflow_query-basic'],
+  'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+
+with profile.test_list.group_manager(
+PiglitGLTest,
 grouptools.join('spec', 'arb_uniform_buffer_object')) as g:
 g(['arb_uniform_buffer_object-bindbuffer-general-point'],
   'bindbuffer-general-point')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..6115c5a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory (arb_texture_view)
 add_subdirectory (arb_timer_query)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (arb_transform_feedback3)
+add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_depth_bounds_test)
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
new file mode 100644
index 000..d75418f
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
b/tests/spec/arb_transform_feedback_overflow_query/basic.c
new file mode 100644
index 000..25c3355
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file basic.c
+ *
+ * This test verifies the basic functionality of
+ * ARB_transform_feedback_overflow_query: that it detects overflow for specific
+ * streams, and on any stream too if requeste

[Piglit] [PATCH v4 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-13 Thread Rafael Antognolli
Add tests to verify that GL_ERROR_VALUE is returned with an invalid
index is used to begin, end or get a current query.

v2:
- Add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- Skip test if some extensions are not present (Ilia Mirkin)
v4:
- Revert to using piglit_require_extension (Ilia Mirkin)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   2 +
 .../CMakeLists.gl.txt  |   1 +
 .../arb_transform_feedback_overflow_query/errors.c | 269 +
 3 files changed, 272 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/errors.c

diff --git a/tests/all.py b/tests/all.py
index 888f25f..dbfe225 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3680,6 +3680,8 @@ with profile.test_list.group_manager(
 grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
 g(['arb_transform_feedback_overflow_query-basic'],
   'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+g(['arb_transform_feedback_overflow_query-errors'],
+  'arb_transform_feedback_overflow_query-errors', run_concurrent=False)
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
index d75418f..f8adc3a 100644
--- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -9,4 +9,5 @@ link_libraries (
 )
 
 piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+piglit_add_executable (arb_transform_feedback_overflow_query-errors errors.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
b/tests/spec/arb_transform_feedback_overflow_query/errors.c
new file mode 100644
index 000..148b660
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_begin_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLuint query;
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB, 1, query);
+
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is PRIMITIVES_GENERATED,
+ * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, or
+ * TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, and  is not in the range
+ * zero to the value of MAX_VERTEX_STREAMS minus one.
+ */
+static enum piglit_result
+test_begin_index_invalid(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLint max_stream;
+   GLuint query;
+
+   glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_stream);
+   if (!piglit_ch

Re: [Piglit] [PATCH v3 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-13 Thread Rafael Antognolli
On Tue, Dec 13, 2016 at 05:53:58PM -0500, Ilia Mirkin wrote:
> On Tue, Dec 13, 2016 at 5:51 PM, Rafael Antognolli
>  wrote:
> > Add tests to verify that GL_ERROR_VALUE is returned if an invalid
> > index is used to begin, end or get a current query.
> >
> > v2:
> > - Add test to all.py (Ilia Mirkin)
> > - Add check for ARB_transform_feedback_overflow_query extension
> > v3:
> > - Skip test if some extensions are not present (Ilia Mirkin)
> >
> > Signed-off-by: Rafael Antognolli 
> > ---
> >  tests/all.py   |   2 +
> >  .../CMakeLists.gl.txt  |   1 +
> >  .../arb_transform_feedback_overflow_query/errors.c | 279 
> > +
> >  3 files changed, 282 insertions(+)
> >  create mode 100644 
> > tests/spec/arb_transform_feedback_overflow_query/errors.c
> >
> > diff --git a/tests/all.py b/tests/all.py
> > index 888f25f..dbfe225 100644
> > --- a/tests/all.py
> > +++ b/tests/all.py
> > @@ -3680,6 +3680,8 @@ with profile.test_list.group_manager(
> >  grouptools.join('spec', 'arb_transform_feedback_overflow_query')) 
> > as g:
> >  g(['arb_transform_feedback_overflow_query-basic'],
> >'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
> > +g(['arb_transform_feedback_overflow_query-errors'],
> > +  'arb_transform_feedback_overflow_query-errors', run_concurrent=False)
> >
> >  with profile.test_list.group_manager(
> >  PiglitGLTest,
> > diff --git 
> > a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
> > b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
> > index d75418f..f8adc3a 100644
> > --- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
> > +++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
> > @@ -9,4 +9,5 @@ link_libraries (
> >  )
> >
> >  piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
> > +piglit_add_executable (arb_transform_feedback_overflow_query-errors 
> > errors.c)
> >  # vim: ft=cmake:
> > diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
> > b/tests/spec/arb_transform_feedback_overflow_query/errors.c
> > new file mode 100644
> > index 000..8b8a703
> > --- /dev/null
> > +++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
> > @@ -0,0 +1,279 @@
> > +/*
> > + * Copyright (c) 2016 Intel Corporation
> > + *
> > + * Permission is hereby granted, free of charge, to any person obtaining a
> > + * copy of this software and associated documentation files (the 
> > "Software"),
> > + * to deal in the Software without restriction, including without 
> > limitation
> > + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> > + * and/or sell copies of the Software, and to permit persons to whom the
> > + * Software is furnished to do so, subject to the following conditions:
> > + *
> > + * The above copyright notice and this permission notice (including the 
> > next
> > + * paragraph) shall be included in all copies or substantial portions of 
> > the
> > + * Software.
> > + *
> > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
> > OR
> > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
> > OTHER
> > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> > DEALINGS
> > + * IN THE SOFTWARE.
> > + */
> > +
> > +#include "piglit-util-gl.h"
> > +
> > +PIGLIT_GL_TEST_CONFIG_BEGIN
> > +
> > +   config.supports_gl_compat_version = 32;
> > +   config.supports_gl_core_version = 32;
> > +
> > +PIGLIT_GL_TEST_CONFIG_END
> > +
> > +/**
> > + * Verify that glBeginQueryIndexed emits correct error when an invalid 
> > index is
> > + * used.
> > + *
> > + * From the ARB_transform_feedback_overflow_query spec:
> > + * An INVALID_VALUE error is generated if  is SAMPLES_PASSED 
> > ...
> > + * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
> > + * zero.
> > + */
&

[Piglit] [PATCH v3 1/2] Add arb_transform_feedback_overflow_query tests.

2016-12-13 Thread Rafael Antognolli
Add tests that verify that the xfb overflow query correctly detects
overflow on streams 0 and 1. Also add tests that check its interaction
with glBeginConditionalRender, and with ARB_query_buffer_object.

v2:
- add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- skip some tests when GL_ARB_transform_feedback3 or
GL_ARB_gpu_shader5 are not present, and add specific tests for those
cases (Ilia Mirkin)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   6 +
 tests/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gl.txt  |  12 +
 .../CMakeLists.txt |   1 +
 .../arb_transform_feedback_overflow_query/basic.c  | 591 +
 5 files changed, 611 insertions(+)
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/basic.c

diff --git a/tests/all.py b/tests/all.py
index 03cf0c8..888f25f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3677,6 +3677,12 @@ with profile.test_list.group_manager(
 
 with profile.test_list.group_manager(
 PiglitGLTest,
+grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
+g(['arb_transform_feedback_overflow_query-basic'],
+  'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+
+with profile.test_list.group_manager(
+PiglitGLTest,
 grouptools.join('spec', 'arb_uniform_buffer_object')) as g:
 g(['arb_uniform_buffer_object-bindbuffer-general-point'],
   'bindbuffer-general-point')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..6115c5a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory (arb_texture_view)
 add_subdirectory (arb_timer_query)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (arb_transform_feedback3)
+add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_depth_bounds_test)
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
new file mode 100644
index 000..d75418f
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
b/tests/spec/arb_transform_feedback_overflow_query/basic.c
new file mode 100644
index 000..25c3355
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
@@ -0,0 +1,591 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file basic.c
+ *
+ * This test verifies the basic functionality of
+ * ARB_transform_feedback_overflow_query: that it detects overflow for specific
+ * streams, and on any stream too if requeste

[Piglit] [PATCH v3 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-13 Thread Rafael Antognolli
Add tests to verify that GL_ERROR_VALUE is returned if an invalid
index is used to begin, end or get a current query.

v2:
- Add test to all.py (Ilia Mirkin)
- Add check for ARB_transform_feedback_overflow_query extension
v3:
- Skip test if some extensions are not present (Ilia Mirkin)

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   2 +
 .../CMakeLists.gl.txt  |   1 +
 .../arb_transform_feedback_overflow_query/errors.c | 279 +
 3 files changed, 282 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/errors.c

diff --git a/tests/all.py b/tests/all.py
index 888f25f..dbfe225 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3680,6 +3680,8 @@ with profile.test_list.group_manager(
 grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
 g(['arb_transform_feedback_overflow_query-basic'],
   'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+g(['arb_transform_feedback_overflow_query-errors'],
+  'arb_transform_feedback_overflow_query-errors', run_concurrent=False)
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
index d75418f..f8adc3a 100644
--- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -9,4 +9,5 @@ link_libraries (
 )
 
 piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+piglit_add_executable (arb_transform_feedback_overflow_query-errors errors.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
b/tests/spec/arb_transform_feedback_overflow_query/errors.c
new file mode 100644
index 000..8b8a703
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_begin_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLuint query;
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB, 1, query);
+
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is PRIMITIVES_GENERATED,
+ * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, or
+ * TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, and  is not in the range
+ * zero to the value of MAX_VERTEX_STREAMS minus one.
+ */
+static enum piglit_result
+test_begin_index_invalid(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLint max_stream;
+   GLuint query;
+
+   glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_stream);
+   if (!piglit_check_gl_error(GL_NO_ERROR)) {
+   printf("failed to resolv

[Piglit] [PATCH 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-08 Thread Rafael Antognolli
Add tests to verify that GL_ERROR_VALUE is returned with an invalid
index is used to begin, end or get a current query.

v2:
Add test to all.py (Ilia Mirkin)
Add check for ARB_transform_feedback_overflow_query extension

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   2 +
 .../CMakeLists.gl.txt  |   1 +
 .../arb_transform_feedback_overflow_query/errors.c | 269 +
 3 files changed, 272 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/errors.c

diff --git a/tests/all.py b/tests/all.py
index 888f25f..dbfe225 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3680,6 +3680,8 @@ with profile.test_list.group_manager(
 grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
 g(['arb_transform_feedback_overflow_query-basic'],
   'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+g(['arb_transform_feedback_overflow_query-errors'],
+  'arb_transform_feedback_overflow_query-errors', run_concurrent=False)
 
 with profile.test_list.group_manager(
 PiglitGLTest,
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
index d75418f..f8adc3a 100644
--- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -9,4 +9,5 @@ link_libraries (
 )
 
 piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+piglit_add_executable (arb_transform_feedback_overflow_query-errors errors.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
b/tests/spec/arb_transform_feedback_overflow_query/errors.c
new file mode 100644
index 000..148b660
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_begin_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLuint query;
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB, 1, query);
+
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is PRIMITIVES_GENERATED,
+ * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, or
+ * TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, and  is not in the range
+ * zero to the value of MAX_VERTEX_STREAMS minus one.
+ */
+static enum piglit_result
+test_begin_index_invalid(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLint max_stream;
+   GLuint query;
+
+   glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_stream);
+   if (!piglit_check_gl_error(GL_NO_ERROR)) {
+   printf("failed to resolve the maximum number of streams\n");
+   pass = PIGLIT_FA

[Piglit] [PATCH 1/2] Add arb_transform_feedback_overflow_query tests.

2016-12-08 Thread Rafael Antognolli
Add tests that verify that the xfb overflow query correctly detects
overflow on streams 0 and 1. Also add tests that check its interaction
with glBeginConditionalRender, and with ARB_query_buffer_object.

v2:
add test to all.py (Ilia Mirkin)
Add check for ARB_transform_feedback_overflow_query extension

Signed-off-by: Rafael Antognolli 
---
 tests/all.py   |   6 +
 tests/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gl.txt  |  12 +
 .../CMakeLists.txt |   1 +
 .../arb_transform_feedback_overflow_query/basic.c  | 487 +
 5 files changed, 507 insertions(+)
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/basic.c

diff --git a/tests/all.py b/tests/all.py
index 03cf0c8..888f25f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3677,6 +3677,12 @@ with profile.test_list.group_manager(
 
 with profile.test_list.group_manager(
 PiglitGLTest,
+grouptools.join('spec', 'arb_transform_feedback_overflow_query')) as g:
+g(['arb_transform_feedback_overflow_query-basic'],
+  'arb_transform_feedback_overflow_query-basic', run_concurrent=False)
+
+with profile.test_list.group_manager(
+PiglitGLTest,
 grouptools.join('spec', 'arb_uniform_buffer_object')) as g:
 g(['arb_uniform_buffer_object-bindbuffer-general-point'],
   'bindbuffer-general-point')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..6115c5a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory (arb_texture_view)
 add_subdirectory (arb_timer_query)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (arb_transform_feedback3)
+add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_depth_bounds_test)
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
new file mode 100644
index 000..d75418f
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
b/tests/spec/arb_transform_feedback_overflow_query/basic.c
new file mode 100644
index 000..34c2399
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
@@ -0,0 +1,487 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file basic.c
+ *
+ * This test verifies the basic functionality of
+ * ARB_transform_feedback_overflow_query: that it detects overflow for specific
+ * streams, and on any stream too if requested. It does so by causing overflow
+ * first on stream 0, and then on stream 1.
+ */
+
+#define BUFFER_OFFSET(i) ((void *)((char *)NULL + i))
+
+PIGLIT_GL_TE

[Piglit] [PATCH 1/2] Add arb_transform_feedback_overflow_query tests.

2016-12-07 Thread Rafael Antognolli
Add tests that verify that the xfb overflow query correctly detects
overflow on streams 0 and 1. Also add tests that check its interaction
with glBeginConditionalRender, and with ARB_query_buffer_object.

Signed-off-by: Rafael Antognolli 
---
 tests/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gl.txt  |  12 +
 .../CMakeLists.txt |   1 +
 .../arb_transform_feedback_overflow_query/basic.c  | 486 +
 4 files changed, 500 insertions(+)
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
 create mode 100644 
tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/basic.c

diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 4ac1a53..6115c5a 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -74,6 +74,7 @@ add_subdirectory (arb_texture_view)
 add_subdirectory (arb_timer_query)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (arb_transform_feedback3)
+add_subdirectory (arb_transform_feedback_overflow_query)
 add_subdirectory (arb_viewport_array)
 add_subdirectory (ati_envmap_bumpmap)
 add_subdirectory (ext_depth_bounds_test)
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
new file mode 100644
index 000..d75418f
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+   ${GLEXT_INCLUDE_DIR}
+   ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+   piglitutil_${piglit_target_api}
+   ${OPENGL_gl_LIBRARY}
+)
+
+piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+# vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_transform_feedback_overflow_query/basic.c 
b/tests/spec/arb_transform_feedback_overflow_query/basic.c
new file mode 100644
index 000..12add9d
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/basic.c
@@ -0,0 +1,486 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+/**
+ * @file basic.c
+ *
+ * This test verifies the basic functionality of
+ * ARB_transform_feedback_overflow_query: that it detects overflow for specific
+ * streams, and on any stream too if requested. It does so by causing overflow
+ * first on stream 0, and then on stream 1.
+ */
+
+#define BUFFER_OFFSET(i) ((void *)((char *)NULL + i))
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static const char vs_pass_thru_text[] =
+   "#version 150\n"
+   "void main() {\n"
+   "  gl_Position = vec4(gl_VertexID);\n"
+   "}\n";
+
+static const char gs_overflow_0[] =
+   "#version 150\n"
+   "#extension GL_ARB_gpu_shader5 : enable\n"
+   "layout(points) in;\n"
+   "layout(points, max_vertices = 4) out;\n"
+   "layout(stream = 0) out vec2 stream0_out;\n"
+   "layout(stream = 1) out vec2 stream1_out;\n"
+   "void main() {\n"
+   "  gl_Position = gl_in[0].gl_Position;\n"
+
+   "  stream0_out = vec2(gl_Position[0], gl_Position[1]);\n"
+   "  EmitStreamVertex(0);\n"
+   &q

[Piglit] [PATCH 2/2] arb_transform_feedback_overflow_query: add error tests.

2016-12-07 Thread Rafael Antognolli
Add tests to verify that GL_ERROR_VALUE is returned with an invalid
index is used to begin, end or get a current query.

Signed-off-by: Rafael Antognolli 
---
 .../CMakeLists.gl.txt  |   1 +
 .../arb_transform_feedback_overflow_query/errors.c | 268 +
 2 files changed, 269 insertions(+)
 create mode 100644 tests/spec/arb_transform_feedback_overflow_query/errors.c

diff --git a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt 
b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
index d75418f..f8adc3a 100644
--- a/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
+++ b/tests/spec/arb_transform_feedback_overflow_query/CMakeLists.gl.txt
@@ -9,4 +9,5 @@ link_libraries (
 )
 
 piglit_add_executable (arb_transform_feedback_overflow_query-basic basic.c)
+piglit_add_executable (arb_transform_feedback_overflow_query-errors errors.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_transform_feedback_overflow_query/errors.c 
b/tests/spec/arb_transform_feedback_overflow_query/errors.c
new file mode 100644
index 000..8cdf324
--- /dev/null
+++ b/tests/spec/arb_transform_feedback_overflow_query/errors.c
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+   config.supports_gl_compat_version = 32;
+   config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_begin_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLuint query;
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB, 1, query);
+
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glBeginQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is PRIMITIVES_GENERATED,
+ * TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, or
+ * TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, and  is not in the range
+ * zero to the value of MAX_VERTEX_STREAMS minus one.
+ */
+static enum piglit_result
+test_begin_index_invalid(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+   GLint max_stream;
+   GLuint query;
+
+   glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_stream);
+   if (!piglit_check_gl_error(GL_NO_ERROR)) {
+   printf("failed to resolve the maximum number of streams\n");
+   pass = PIGLIT_FAIL;
+   goto err_del_query;
+   }
+
+   glGenQueries(1, &query);
+   glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, 
max_stream, query);
+   if (!piglit_check_gl_error(GL_INVALID_VALUE))
+   pass = PIGLIT_FAIL;
+
+err_del_query:
+   glDeleteQueries(1, &query);
+
+   return pass;
+}
+
+/**
+ * Verify that glEndQueryIndexed emits correct error when an invalid index is
+ * used.
+ *
+ * From the ARB_transform_feedback_overflow_query spec:
+ * An INVALID_VALUE error is generated if  is SAMPLES_PASSED, ...
+ * TIME_ELAPSED, or TRANSFORM_FEEDBACK_OVERFLOW_ARB, and  is not
+ * zero.
+ */
+static enum piglit_result
+test_end_index_non_zero(void *test_data)
+{
+   enum piglit_result pass = PIGLIT_PASS;
+
+   glEndQuery

[Piglit] [PATCH v2 12/12] egl_android_native_fence_sync: Verify that dup() fails on invalid fence.

2016-11-07 Thread Rafael Antognolli
If  is not a valid sync object for ,
EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
error is generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 49 ++
 1 file changed, 49 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index eea4f0e..05f6b20 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -512,6 +512,50 @@ cleanup:
 }
 
 /**
+ * Verify that eglDupNativeFenceFDANDROID emits correct error when given an
+ * invalid sync .
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ * If  is not a valid sync object for ,
+ * EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
+ * error is generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_invalid(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary;
+   EGLint sync_fd = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, invalid_sync);
+   if (sync_fd != EGL_NO_NATIVE_FENCE_FD_ANDROID) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() should return "
+   "EGL_NO_NATIVE_FENCE_FD_ANDROID, "
+   "but returned %d", sync_fd);
+   close(sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() "
+   "did not emit EGL_BAD_PARAMETER");
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(EGL_NO_SYNC_KHR, &result);
+   return result;
+}
+
+/**
  * Verify that eglCreateSyncKHR emits correct error when given an invalid
  * display.
  *
@@ -942,6 +986,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
test_eglCreateSyncKHR_native_dup_fence,
},
{
+   "eglCreateSyncKHR_native_dup_invalid",
+   "eglCreateSyncKHR_native_dup_invalid",
+   test_eglCreateSyncKHR_native_dup_invalid,
+   },
+   {
"eglCreateSyncKHR_invalid_display",
"eglCreateSyncKHR_invalid_display",
test_eglCreateSyncKHR_native_invalid_display,
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 03/12] egl_android_native_fence_sync: Add test to create fence from fd.

2016-11-07 Thread Rafael Antognolli
Add a test that creates a sync file using sw_sync, and then creates an
EGL fence sync from that sync file. It also verify that the fence sync
EGL_SYNC_CONDITION_KHR is set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID,
and that EGL_SYNC_STATUS_KHR changes to EGL_SIGNALED_KHR once the fence
is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../CMakeLists.gles2.txt   |   2 +-
 .../egl_android_native_fence_sync.c| 134 -
 2 files changed, 134 insertions(+), 2 deletions(-)

diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
index 0d85ce9..5492a39 100644
--- a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
@@ -4,6 +4,6 @@ if(PIGLIT_HAS_PTHREADS)
link_libraries(${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c)
+piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c sw_sync.c)
 
 # vim: ft=cmake:
diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 8d8f04d..b32e26a 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -34,6 +34,7 @@
 
 #include "piglit-util-egl.h"
 #include "piglit-util-gl.h"
+#include "sw_sync.h"
 
 /* Extension function pointers.
  *
@@ -333,10 +334,141 @@ cleanup:
return result;
 }
 
+static EGLSyncKHR
+test_create_fence_from_fd(int fd)
+{
+   EGLint attrib_list[] = {
+   EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
+   EGL_NONE,
+   };
+
+   return peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
attrib_list);
+}
+
 static enum piglit_result
 test_eglCreateSyncKHR_native_from_fd(void *test_data)
 {
-   return PIGLIT_PASS;
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   EGLint sync_type = canary,
+  sync_status = canary,
+  sync_condition = canary;
+   int sync_fd = canary;
+   int timeline = canary;
+   bool ok = false;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   sw_sync_fence_destroy(sync_fd);
+   goto cleanup_timeline;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_TYPE_KHR, &sync_type);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) emitted "
+   "an error");
+   result = PIGLIT_FAIL;
+   }
+   if (sync_type != EGL_SYNC_NATIVE_FENCE_ANDROID) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) returned "
+   "0x%x but expected 
EGL_SYNC_NATIVE_FENCE_ANDROID(0x%x)",
+   sync_type, EGL_SYNC_NATIVE_FENCE_ANDROID);
+   result = PIGLIT_FAIL;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_STATUS_KHR, 
&sync_status);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) emitted "
+   "an error");
+   result = PIGLIT_FAIL;
+   }
+   if (sync_status != EGL_UNSIGNALED_KHR) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) "
+   "

[Piglit] [PATCH v2 08/12] egl_android_native_fence_sync: Create fence without current context.

2016-11-07 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_MATCH error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 43 ++
 1 file changed, 43 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 59f005b..67d9dfb 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -678,6 +678,44 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when no context is current.
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ *  If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and no
+ *  context is current for the bound API (i.e., eglGetCurrentContext
+ *  returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ *  EGL_BAD_MATCH error is generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_no_current_context(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+   eglMakeCurrent(g_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() succeeded when no context was "
+   "current");
+   peglDestroySyncKHR(g_dpy, sync);
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -709,6 +747,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_wrong_display_same_thread",
test_eglCreateSyncKHR_native_wrong_display_same_thread,
},
+   {
+   "eglCreateSyncKHR_native_no_current_context",
+   "eglCreateSyncKHR_native_no_current_context",
+   test_eglCreateSyncKHR_native_no_current_context,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 02/12] egl_android_native_fence_sync: Add sw_sync lib.

2016-11-07 Thread Rafael Antognolli
Add a small library that helps manipulating software fences. They are
useful for testing EGL Android fences, since the latter can be created
out of them.

Signed-off-by: Rafael Antognolli 
---
 .../spec/egl_android_native_fence_sync/sw_sync.c   | 211 +
 .../spec/egl_android_native_fence_sync/sw_sync.h   |  50 +
 2 files changed, 261 insertions(+)
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h

diff --git a/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
new file mode 100644
index 000..4e8117f
--- /dev/null
+++ b/tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
@@ -0,0 +1,211 @@
+/*
+ * Copyright 2012 Google, Inc
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * Based on the implementation from the Android Open Source Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Robert Foss 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "sw_sync.h"
+
+#ifndef SW_SYNC_IOC_INC
+struct sw_sync_create_fence_data {
+   __u32   value;
+   charname[32];
+   __s32   fence;
+};
+
+#define SW_SYNC_IOC_MAGIC  'W'
+#define SW_SYNC_IOC_CREATE_FENCE   _IOWR(SW_SYNC_IOC_MAGIC, 0,\
+   struct 
sw_sync_create_fence_data)
+#define SW_SYNC_IOC_INC_IOW(SW_SYNC_IOC_MAGIC, 1, 
__u32)
+#endif
+
+#define DEVFS_SW_SYNC   "/dev/sw_sync"
+#define DEBUGFS_SW_SYNC "/sys/kernel/debug/sync/sw_sync"
+
+bool sw_sync_is_supported(void)
+{
+   if(access(DEVFS_SW_SYNC, R_OK | W_OK) != -1) {
+   return true;
+   } else if (access(DEBUGFS_SW_SYNC, R_OK | W_OK) != -1 ) {
+   return true;
+   }
+
+   return false;
+}
+
+int sw_sync_fd_is_valid(int fd)
+{
+   int status;
+
+   if (fd < 0)
+   return 0;
+
+   status = fcntl(fd, F_GETFD, 0);
+   return status >= 0;
+}
+
+static
+void sw_sync_fd_close(int fd)
+{
+   if (!sw_sync_fd_is_valid(fd))
+   return;
+
+   close(fd);
+}
+
+int sw_sync_timeline_create(void)
+{
+   int fd = open(DEVFS_SW_SYNC, O_RDWR);
+
+   if (!sw_sync_fd_is_valid(fd))
+   fd = open(DEBUGFS_SW_SYNC, O_RDWR);
+
+   return fd;
+}
+
+void sw_sync_timeline_destroy(int fd)
+{
+   return sw_sync_fd_close(fd);
+}
+
+void sw_sync_fence_destroy(int fd)
+{
+   return sw_sync_fd_close(fd);
+}
+
+int sw_sync_fence_create(int fd, int32_t seqno)
+{
+   struct sw_sync_create_fence_data data = {};
+   data.value = seqno;
+
+   if (fd >= 0) {
+   ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data);
+   return data.fence;
+   } else {
+   ioctl(fd, SW_SYNC_IOC_CREATE_FENCE, &data);
+   return -1;
+   }
+}
+
+void sw_sync_timeline_inc(int fd, uint32_t count)
+{
+   uint32_t arg = count;
+
+   if (fd == 0 || fd == -1)
+   return;
+
+   ioctl(fd, SW_SYNC_IOC_INC, &arg);
+}
+
+static struct sync_file_info *sync_file_info(int fd)
+{
+   struct sync_file_info *info;
+   struct sync_fence_info *fence_info;
+   int err, num_fences;
+
+   info = calloc(1, sizeof(*info));
+   if (info == NULL)
+   return NULL;
+
+   err = ioctl(fd, SYNC_IOC_FILE_INFO, info);
+   if (err < 0) {
+   free(info);
+   return NULL;
+   }
+
+   num_fences = info->num_fences;
+
+   if (num_fences) {
+   info->flags = 0;
+   info->num_fences = num_fences;
+
+   fence_info = calloc(num_fences, sizeof(*fence_info));
+

[Piglit] [PATCH v2 10/12] egl_android_native_fence_sync: Test for wait with zero timeout.

2016-11-07 Thread Rafael Antognolli
Verify that eglClientWaitSyncKHR() correctly handles zero timeout before
and after the sw sync fence is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 95 ++
 1 file changed, 95 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index b1739a9..f31b213 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -786,6 +786,96 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() correctly handles zero timeout before and
+ * after glFinish().
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ * If the value of  is zero, then eglClientWaitSyncKHR simply
+ * tests the current status of .
+ *
+ * [...]
+ *
+ * eglClientWaitSyncKHR returns one of three status values describing
+ * the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR
+ * indicates that the specified timeout period expired before 
+ * was signaled. A return value of EGL_CONDITION_SATISFIED_KHR
+ * indicates that  was signaled before the timeout expired, which
+ * includes the case when  was already signaled when
+ * eglClientWaitSyncKHR was called. If an error occurs then an error is
+ * generated and EGL_FALSE is returned.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_zero_timeout(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int wait_status1 = 0, wait_status2 = 0;
+   int sync_fd = canary;
+   int timeline = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   sw_sync_fence_destroy(sync_fd);
+   goto cleanup_timeline;
+   }
+
+   glFlush();
+
+   wait_status1 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+   sw_sync_timeline_inc(timeline, 1);
+   wait_status2 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+
+   if (wait_status1 != EGL_TIMEOUT_EXPIRED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() before glFinish:\n"
+   "  Expected status: EGL_TIMEOUT_EXPIRED_KHR 
(0x%x)\n"
+   "  Actual status:  0x%x\n",
+   EGL_TIMEOUT_EXPIRED_KHR, wait_status1);
+   result = PIGLIT_FAIL;
+   }
+   if (wait_status2 != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() after glFinish:\n"
+   "  Expected status: EGL_CONDITION_SATISFIED_KHR\n"
+   "  Actual status:  0x%x\n", wait_status2);
+   result = PIGLIT_FAIL;
+   }
+
+cleanup_timeline:
+   sw_sync_timeline_destroy(timeline);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -827,6 +917,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglGetSyncAttribKHR_native_invalid_attrib",
test_eglGetSyncAttribKHR_native_invalid_attrib,
},
+   {
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   test_eglClientWaitSyncKHR_native_zero_timeout,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 04/12] egl_android_native_fence_sync: Verify eglDupNativeFenceFDANDROID.

2016-11-07 Thread Rafael Antognolli
Verify that eglDupNativeFenceFDANDROID() correctly returns a new file
descriptor.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 45 ++
 1 file changed, 45 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index b32e26a..194e9d5 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -471,6 +471,46 @@ cleanup:
return result;
 }
 
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_fence(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int sync_fd = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   glFlush();
+
+   if (result == PIGLIT_FAIL)
+   goto cleanup;
+
+   /* Verify that we can get an fd back from eglDupFenceFD(). */
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, sync);
+   if (sync_fd == -1) {
+   piglit_loge("eglDupNativeFenceFDANDROID() failed"
+   "returned %d but expected >= 0", sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   close(sync_fd);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -482,6 +522,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_from_fd",
test_eglCreateSyncKHR_native_from_fd,
},
+   {
+   "eglCreateSyncKHR_native_dup_fence",
+   "eglCreateSyncKHR_native_dup_fence",
+   test_eglCreateSyncKHR_native_dup_fence,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 05/12] egl_android_native_fence_sync: Create fence from invalid display.

2016-11-07 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 40 ++
 1 file changed, 40 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 194e9d5..eb01014 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -511,6 +511,41 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when given an invalid
+ * display.
+ *
+ * From the EGL_KHR_fence_sync spec:
+ *
+ * If  is not the name of a valid, initialized EGLDisplay,
+ * EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
+ * generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_invalid_display(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(EGL_NO_DISPLAY, EGL_SYNC_NATIVE_FENCE_ANDROID, 
NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_NO_DISPLAY) succeeded");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_DISPLAY)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -527,6 +562,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_dup_fence",
test_eglCreateSyncKHR_native_dup_fence,
},
+   {
+   "eglCreateSyncKHR_invalid_display",
+   "eglCreateSyncKHR_invalid_display",
+   test_eglCreateSyncKHR_native_invalid_display,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 01/12] egl_android_native_fence_sync: Initial test for native fences.

2016-11-07 Thread Rafael Antognolli
Add a test for EGL_ANDROID_native_fence_sync, and check that we can
create a fence sync using attribute EGL_SYNC_NATIVE_FENCE_FD_ANDROID set
to EGL_NO_NATIVE_FENCE_FD_ANDROID. Check that the several attributes are
the correct default ones.

Signed-off-by: Rafael Antognolli 
---
 tests/egl/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gles2.txt   |   9 +
 .../egl_android_native_fence_sync/CMakeLists.txt   |   1 +
 .../egl_android_native_fence_sync.c| 393 +
 4 files changed, 404 insertions(+)
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c

diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt
index d916f7a..1a66b23 100644
--- a/tests/egl/spec/CMakeLists.txt
+++ b/tests/egl/spec/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_subdirectory (egl-1.4)
+add_subdirectory (egl_android_native_fence_sync)
 add_subdirectory (egl_ext_client_extensions)
 add_subdirectory (egl_ext_device_query)
 add_subdirectory (egl_ext_device_enumeration)
diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
new file mode 100644
index 000..0d85ce9
--- /dev/null
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
@@ -0,0 +1,9 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+if(PIGLIT_HAS_PTHREADS)
+   link_libraries(${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c)
+
+# vim: ft=cmake:
diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
new file mode 100644
index 000..8d8f04d
--- /dev/null
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -0,0 +1,393 @@
+/*
+ * Copyright 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file Tests for EGL_ANDROID_native_fence_sync.
+ *
+ * This file attempts to exhaustively test the EGL_ANDROID_native_fence_sync
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "piglit-util-egl.h"
+#include "piglit-util-gl.h"
+
+/* Extension function pointers.
+ *
+ * Use prefix 'pegl' (piglit egl) instead of 'egl' to avoid collisions with
+ * prototypes in eglext.h. */
+EGLSyncKHR (*peglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint 
*attrib_list);
+EGLBoolean (*peglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync);
+EGLint (*peglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, 
EGLTimeKHR timeout);
+EGLint (*peglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+EGLint (*peglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
+EGLBoolean (*peglGetSyncAttribKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint 
attribute, EGLint *value);
+
+static const EGLint canary = 0x31415926;
+static EGLDisplay g_dpy = 0;
+static EGLContext g_ctx = 0;
+
+static enum piglit_result
+init_display(EGLenum platform, EGLDisplay *out_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay dpy;
+   EGLint egl_major, egl_minor;
+   bool ok;
+
+   dpy = piglit_egl_get_default_display(platform);
+   if (!dpy) {
+   result = PIG

[Piglit] [PATCH v2 11/12] egl_android_native_fence_sync: Test nonzero timeout.

2016-11-07 Thread Rafael Antognolli
Verify that eglClientWaitSyncKHR() correctly handles nonzero timeout
before and after glFinish().

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 54 ++
 1 file changed, 54 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index f31b213..eea4f0e 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -876,6 +876,55 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() accepts nonzero timeout values, including
+ * EGL_FOREVER_KHR.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_nonzero_timeout(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   EGLint wait_status = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* There exist no pending GL commands, so the sync status should be
+* EGL_CONDITION_SATISFIED_KHR.
+*/
+   wait_status = peglClientWaitSyncKHR(g_dpy, sync, 0, 0.5e9);
+   if (wait_status != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR(timeout=0.5sec)\n"
+   "  Expected status 
EGL_CONDITION_SATISFIED_KHR(0x%x)\n"
+   "  Actual status 0x%x\n",
+   EGL_CONDITION_SATISFIED_KHR, wait_status);
+   result = PIGLIT_FAIL;
+   }
+
+   wait_status = peglClientWaitSyncKHR(g_dpy, sync, 0, EGL_FOREVER_KHR);
+   if (wait_status != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR(timeout=forever)\n"
+   "  Expected status 
EGL_CONDITION_SATISFIED_KHR(0x%x)\n"
+   "  Actual status 0x%x\n",
+   EGL_CONDITION_SATISFIED_KHR, wait_status);
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -922,6 +971,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglClientWaitSyncKHR_native_zero_timeout",
test_eglClientWaitSyncKHR_native_zero_timeout,
},
+   {
+   "eglClientWaitSyncKHR_native_nonzero_timeout",
+   "eglClientWaitSyncKHR_native_nonzero_timeout",
+   test_eglClientWaitSyncKHR_native_nonzero_timeout,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 09/12] egl_android_native_fence_sync: Try to get invalid attribute.

2016-11-07 Thread Rafael Antognolli
Verify that the correct error is returned if an invalid attribute is
requested.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 75 ++
 1 file changed, 75 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 67d9dfb..b1739a9 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -716,6 +716,76 @@ test_eglCreateSyncKHR_native_no_current_context(void 
*test_data)
return result;
 }
 
+/**
+ * Verify that eglGetSyncAttribKHR emits the correct error when querying an
+ * unrecognized attribute of a fence sync.
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ *[eglGetSyncAttribKHR] is used to query attributes of the sync object
+ *. Legal values for  depend on the type of sync object,
+ *as shown in table
+ *3.cc. [...]
+ *
+ *Attribute  DescriptionSupported Sync Objects
+ *-  -----
+ *EGL_SYNC_TYPE_KHR  Type of the sync objectAll
+ *EGL_SYNC_STATUS_KHRStatus of the sync object  All
+ *EGL_SYNC_CONDITION_KHR Signaling conditionEGL_SYNC_FENCE_KHR only
+ *
+ *Table 3.cc  Attributes Accepted by eglGetSyncAttribKHR Command
+ *
+ *[...]
+ *
+ ** If  is not one of the attributes in table 3.cc,
+ *  EGL_FALSE is returned and an EGL_BAD_ATTRIBUTE error is
+ *  generated.
+ *
+ *[...]
+ *
+ *If any error occurs, <*value> is not modified.
+ */
+static enum piglit_result
+test_eglGetSyncAttribKHR_native_invalid_attrib(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   bool ok = false;
+   EGLSyncKHR sync = 0;
+   EGLint attrib_value = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_BUFFER_PRESERVED,
+ &attrib_value);
+   if (ok) {
+   piglit_loge("eglGetSyncAttribKHR(attrib=EGL_BUFFER_PRESERVED) "
+   "incorrectly succeeded");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) {
+   piglit_loge("eglGetSyncAttribKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+   if (attrib_value != canary) {
+   piglit_loge("eglGetSynAttribKHR modified out parameter 
");
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -752,6 +822,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_no_current_context",
test_eglCreateSyncKHR_native_no_current_context,
},
+   {
+   "eglGetSyncAttribKHR_native_invalid_attrib",
+   "eglGetSyncAttribKHR_native_invalid_attrib",
+   test_eglGetSyncAttribKHR_native_invalid_attrib,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 06/12] egl_android_native_fence_sync: Create fence from other display.

2016-11-07 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and EGL_BAD_MATCH error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 98 +-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index eb01014..721bc44 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -515,7 +515,7 @@ cleanup:
  * Verify that eglCreateSyncKHR emits correct error when given an invalid
  * display.
  *
- * From the EGL_KHR_fence_sync spec:
+ * From the EGL_ANDROID_native_fence_sync spec:
  *
  * If  is not the name of a valid, initialized EGLDisplay,
  * EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
@@ -546,6 +546,97 @@ test_eglCreateSyncKHR_native_invalid_display(void 
*test_data)
return result;
 }
 
+static enum piglit_result
+init_other_display(EGLDisplay *out_other_dpy, EGLDisplay orig_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay other_dpy = 0;
+   int i;
+
+   static const EGLint platforms[] = {
+   EGL_PLATFORM_X11_EXT,
+   EGL_PLATFORM_WAYLAND_EXT,
+   EGL_PLATFORM_GBM_MESA,
+   0,
+   };
+
+   for (i = 0; platforms[i] != 0; ++i) {
+   result = init_display(platforms[i], &other_dpy);
+   switch (result) {
+   case PIGLIT_SKIP:
+   break;
+   case PIGLIT_PASS:
+   if (other_dpy && other_dpy != orig_dpy) {
+   *out_other_dpy = other_dpy;
+   return PIGLIT_PASS;
+   } else {
+   result = PIGLIT_SKIP;
+   break;
+   }
+   default:
+   break;
+   }
+   }
+
+   return result;
+}
+
+/**
+ * Verify that eglCreateSyncKHR() emits correct error when given a display that
+ * does not match the display of the bound context.
+ *
+ * From the EGL_KHR_fence_sync spec:
+ *
+ * * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
+ *   no context is current for the bound API (i.e., eglGetCurrentContext
+ *   returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ *   EGL_BAD_MATCH error is generated.
+ *
+ * This test verifies a simple case for the above error. It binds a context and
+ * display to the main thread, creates a second display on the same threads but
+ * does not bind it, then gives the second display to eglCreateSyncKHR().
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_wrong_display_same_thread(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay wrong_dpy = 0;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   piglit_logi("create second EGLDisplay");
+   result = init_other_display(&wrong_dpy, g_dpy);
+   if (result != PIGLIT_PASS) {
+   goto cleanup;
+   }
+
+   piglit_require_egl_extension(wrong_dpy, "EGL_KHR_fence_sync");
+
+   piglit_logi("try to create sync with second display");
+   sync = peglCreateSyncKHR(wrong_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() incorrectly succeeded");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+cleanup:
+   if (wrong_dpy) {
+   eglTerminate(wrong_dpy);
+   }
+   test_cleanup(EGL_NO_SYNC_KHR, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -567,6 +658,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_invalid_display",
test_eglCreateSyncKHR_native_invalid_display,
},
+   {
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   test_eglCreateSyncKHR_native_wrong_display_same_thread,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 00/12] egl_android_native_fence_sync tests.

2016-11-07 Thread Rafael Antognolli
Updated version of these tests.

This series is also available at:

https://github.com/rantogno/piglit/tree/review/fences-v02

v2:
- split sw_sync lib into its own patch
- remove sync_wait and sync_merge from sw_sync lib
- do not destroy sync fd after creating EGL sync out of it.

Rafael Antognolli (12):
  egl_android_native_fence_sync: Initial test for native fences.
  egl_android_native_fence_sync: Add sw_sync lib.
  egl_android_native_fence_sync: Add test to create fence from fd.
  egl_android_native_fence_sync: Verify eglDupNativeFenceFDANDROID.
  egl_android_native_fence_sync: Create fence from invalid display.
  egl_android_native_fence_sync: Create fence from other display.
  egl_android_native_fence_sync: Create fence with invalid attributes.
  egl_android_native_fence_sync: Create fence without current context.
  egl_android_native_fence_sync: Try to get invalid attribute.
  egl_android_native_fence_sync: Test for wait with zero timeout.
  egl_android_native_fence_sync: Test nonzero timeout.
  egl_android_native_fence_sync: Verify that dup() fails on invalid
fence.

 tests/egl/spec/CMakeLists.txt  |1 +
 .../CMakeLists.gles2.txt   |9 +
 .../egl_android_native_fence_sync/CMakeLists.txt   |1 +
 .../egl_android_native_fence_sync.c| 1068 
 .../spec/egl_android_native_fence_sync/sw_sync.c   |  211 
 .../spec/egl_android_native_fence_sync/sw_sync.h   |   50 +
 6 files changed, 1340 insertions(+)
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h

-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH v2 07/12] egl_android_native_fence_sync: Create fence with invalid attributes.

2016-11-07 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error
is generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 54 --
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 721bc44..59f005b 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -546,6 +546,47 @@ test_eglCreateSyncKHR_native_invalid_display(void 
*test_data)
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when given an invalid
+ * attribute list.
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ * If  is EGL_SYNC_NATIVE_FENCE_ANDROID and  contains
+ * an attribute other than EGL_SYNC_NATIVE_FENCE_FD_ANDROID,
+ * EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
+ * generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_invalid_attrib_list(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   const EGLint attrib_list[] = {
+   EGL_CONTEXT_CLIENT_VERSION, 2,
+   EGL_NONE,
+   };
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
attrib_list);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() succeeded with invalid "
+   "attrib list");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static enum piglit_result
 init_other_display(EGLDisplay *out_other_dpy, EGLDisplay orig_dpy)
 {
@@ -587,10 +628,10 @@ init_other_display(EGLDisplay *out_other_dpy, EGLDisplay 
orig_dpy)
  *
  * From the EGL_KHR_fence_sync spec:
  *
- * * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
- *   no context is current for the bound API (i.e., eglGetCurrentContext
- *   returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
- *   EGL_BAD_MATCH error is generated.
+ * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and no
+ * context is current for the bound API (i.e., eglGetCurrentContext
+ * returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ * EGL_BAD_MATCH error is generated.
  *
  * This test verifies a simple case for the above error. It binds a context and
  * display to the main thread, creates a second display on the same threads but
@@ -659,6 +700,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
test_eglCreateSyncKHR_native_invalid_display,
},
{
+   "eglCreateSyncKHR_native_invalid_attrib_list",
+   "eglCreateSyncKHR_native_invalid_attrib_list",
+   test_eglCreateSyncKHR_native_invalid_attrib_list,
+   },
+   {
"eglCreateSyncKHR_wrong_display_same_thread",
"eglCreateSyncKHR_wrong_display_same_thread",
test_eglCreateSyncKHR_native_wrong_display_same_thread,
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 03/11] egl_android_native_fence_sync: Verify eglDupNativeFenceFDANDROID.

2016-10-27 Thread Rafael Antognolli
Verify that eglDupNativeFenceFDANDROID() correctly returns a new file
descriptor.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 45 ++
 1 file changed, 45 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index c65eb24..31ccb11 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -473,6 +473,46 @@ cleanup:
return result;
 }
 
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_fence(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int sync_fd = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   glFlush();
+
+   if (result == PIGLIT_FAIL)
+   goto cleanup;
+
+   /* Verify that we can get an fd back from eglDupFenceFD(). */
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, sync);
+   if (sync_fd == -1) {
+   piglit_loge("eglDupNativeFenceFDANDROID() failed"
+   "returned %d but expected >= 0", sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   close(sync_fd);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -484,6 +524,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_from_fd",
test_eglCreateSyncKHR_native_from_fd,
},
+   {
+   "eglCreateSyncKHR_native_dup_fence",
+   "eglCreateSyncKHR_native_dup_fence",
+   test_eglCreateSyncKHR_native_dup_fence,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 07/11] egl_android_native_fence_sync: Create fence without current context.

2016-10-27 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_MATCH error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 43 ++
 1 file changed, 43 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index eb5042b..7547f56 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -680,6 +680,44 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when no context is current.
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ *  If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and no
+ *  context is current for the bound API (i.e., eglGetCurrentContext
+ *  returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ *  EGL_BAD_MATCH error is generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_no_current_context(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+   eglMakeCurrent(g_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() succeeded when no context was "
+   "current");
+   peglDestroySyncKHR(g_dpy, sync);
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -711,6 +749,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_wrong_display_same_thread",
test_eglCreateSyncKHR_native_wrong_display_same_thread,
},
+   {
+   "eglCreateSyncKHR_native_no_current_context",
+   "eglCreateSyncKHR_native_no_current_context",
+   test_eglCreateSyncKHR_native_no_current_context,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 05/11] egl_android_native_fence_sync: Create fence from other display.

2016-10-27 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and EGL_BAD_MATCH error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 98 +-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 52ea6ad..6305c44 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -517,7 +517,7 @@ cleanup:
  * Verify that eglCreateSyncKHR emits correct error when given an invalid
  * display.
  *
- * From the EGL_KHR_fence_sync spec:
+ * From the EGL_ANDROID_native_fence_sync spec:
  *
  * If  is not the name of a valid, initialized EGLDisplay,
  * EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
@@ -548,6 +548,97 @@ test_eglCreateSyncKHR_native_invalid_display(void 
*test_data)
return result;
 }
 
+static enum piglit_result
+init_other_display(EGLDisplay *out_other_dpy, EGLDisplay orig_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay other_dpy = 0;
+   int i;
+
+   static const EGLint platforms[] = {
+   EGL_PLATFORM_X11_EXT,
+   EGL_PLATFORM_WAYLAND_EXT,
+   EGL_PLATFORM_GBM_MESA,
+   0,
+   };
+
+   for (i = 0; platforms[i] != 0; ++i) {
+   result = init_display(platforms[i], &other_dpy);
+   switch (result) {
+   case PIGLIT_SKIP:
+   break;
+   case PIGLIT_PASS:
+   if (other_dpy && other_dpy != orig_dpy) {
+   *out_other_dpy = other_dpy;
+   return PIGLIT_PASS;
+   } else {
+   result = PIGLIT_SKIP;
+   break;
+   }
+   default:
+   break;
+   }
+   }
+
+   return result;
+}
+
+/**
+ * Verify that eglCreateSyncKHR() emits correct error when given a display that
+ * does not match the display of the bound context.
+ *
+ * From the EGL_KHR_fence_sync spec:
+ *
+ * * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
+ *   no context is current for the bound API (i.e., eglGetCurrentContext
+ *   returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ *   EGL_BAD_MATCH error is generated.
+ *
+ * This test verifies a simple case for the above error. It binds a context and
+ * display to the main thread, creates a second display on the same threads but
+ * does not bind it, then gives the second display to eglCreateSyncKHR().
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_wrong_display_same_thread(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay wrong_dpy = 0;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   piglit_logi("create second EGLDisplay");
+   result = init_other_display(&wrong_dpy, g_dpy);
+   if (result != PIGLIT_PASS) {
+   goto cleanup;
+   }
+
+   piglit_require_egl_extension(wrong_dpy, "EGL_KHR_fence_sync");
+
+   piglit_logi("try to create sync with second display");
+   sync = peglCreateSyncKHR(wrong_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() incorrectly succeeded");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_MATCH)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+cleanup:
+   if (wrong_dpy) {
+   eglTerminate(wrong_dpy);
+   }
+   test_cleanup(EGL_NO_SYNC_KHR, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -569,6 +660,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_invalid_display",
test_eglCreateSyncKHR_native_invalid_display,
},
+   {
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   "eglCreateSyncKHR_wrong_display_same_thread",
+   test_eglCreateSyncKHR_native_wrong_display_same_thread,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 08/11] egl_android_native_fence_sync: Try to get invalid attribute.

2016-10-27 Thread Rafael Antognolli
Verify that the correct error is returned if an invalid attribute is
requested.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 75 ++
 1 file changed, 75 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 7547f56..9f3ad51 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -718,6 +718,76 @@ test_eglCreateSyncKHR_native_no_current_context(void 
*test_data)
return result;
 }
 
+/**
+ * Verify that eglGetSyncAttribKHR emits the correct error when querying an
+ * unrecognized attribute of a fence sync.
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ *[eglGetSyncAttribKHR] is used to query attributes of the sync object
+ *. Legal values for  depend on the type of sync object,
+ *as shown in table
+ *3.cc. [...]
+ *
+ *Attribute  DescriptionSupported Sync Objects
+ *-  -----
+ *EGL_SYNC_TYPE_KHR  Type of the sync objectAll
+ *EGL_SYNC_STATUS_KHRStatus of the sync object  All
+ *EGL_SYNC_CONDITION_KHR Signaling conditionEGL_SYNC_FENCE_KHR only
+ *
+ *Table 3.cc  Attributes Accepted by eglGetSyncAttribKHR Command
+ *
+ *[...]
+ *
+ ** If  is not one of the attributes in table 3.cc,
+ *  EGL_FALSE is returned and an EGL_BAD_ATTRIBUTE error is
+ *  generated.
+ *
+ *[...]
+ *
+ *If any error occurs, <*value> is not modified.
+ */
+static enum piglit_result
+test_eglGetSyncAttribKHR_native_invalid_attrib(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   bool ok = false;
+   EGLSyncKHR sync = 0;
+   EGLint attrib_value = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_BUFFER_PRESERVED,
+ &attrib_value);
+   if (ok) {
+   piglit_loge("eglGetSyncAttribKHR(attrib=EGL_BUFFER_PRESERVED) "
+   "incorrectly succeeded");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) {
+   piglit_loge("eglGetSyncAttribKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+   if (attrib_value != canary) {
+   piglit_loge("eglGetSynAttribKHR modified out parameter 
");
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -754,6 +824,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_no_current_context",
test_eglCreateSyncKHR_native_no_current_context,
},
+   {
+   "eglGetSyncAttribKHR_native_invalid_attrib",
+   "eglGetSyncAttribKHR_native_invalid_attrib",
+   test_eglGetSyncAttribKHR_native_invalid_attrib,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 10/11] egl_android_native_fence_sync: Test nonzero timeout.

2016-10-27 Thread Rafael Antognolli
Verify that eglClientWaitSyncKHR() correctly handles nonzero timeout
before and after glFinish().

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 54 ++
 1 file changed, 54 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 1047f41..0af9e75 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -880,6 +880,55 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() accepts nonzero timeout values, including
+ * EGL_FOREVER_KHR.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_nonzero_timeout(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   EGLint wait_status = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, NULL);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_FENCE_KHR) failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   /* There exist no pending GL commands, so the sync status should be
+* EGL_CONDITION_SATISFIED_KHR.
+*/
+   wait_status = peglClientWaitSyncKHR(g_dpy, sync, 0, 0.5e9);
+   if (wait_status != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR(timeout=0.5sec)\n"
+   "  Expected status 
EGL_CONDITION_SATISFIED_KHR(0x%x)\n"
+   "  Actual status 0x%x\n",
+   EGL_CONDITION_SATISFIED_KHR, wait_status);
+   result = PIGLIT_FAIL;
+   }
+
+   wait_status = peglClientWaitSyncKHR(g_dpy, sync, 0, EGL_FOREVER_KHR);
+   if (wait_status != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR(timeout=forever)\n"
+   "  Expected status 
EGL_CONDITION_SATISFIED_KHR(0x%x)\n"
+   "  Actual status 0x%x\n",
+   EGL_CONDITION_SATISFIED_KHR, wait_status);
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -926,6 +975,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglClientWaitSyncKHR_native_zero_timeout",
test_eglClientWaitSyncKHR_native_zero_timeout,
},
+   {
+   "eglClientWaitSyncKHR_native_nonzero_timeout",
+   "eglClientWaitSyncKHR_native_nonzero_timeout",
+   test_eglClientWaitSyncKHR_native_nonzero_timeout,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 00/11] egl_android_native_fence_sync tests.

2016-10-27 Thread Rafael Antognolli
Now with more coverage for the native fence sync API.

Notice that the last commit adds a test that is making piglit crash for now.

Rafael Antognolli (11):
  egl_android_native_fence_sync: Initial test for native fences.
  egl_android_native_fence_sync: Add test to create fence from fd.
  egl_android_native_fence_sync: Verify eglDupNativeFenceFDANDROID.
  egl_android_native_fence_sync: Create fence from invalid display.
  egl_android_native_fence_sync: Create fence from other display.
  egl_android_native_fence_sync: Create fence with invalid attributes.
  egl_android_native_fence_sync: Create fence without current context.
  egl_android_native_fence_sync: Try to get invalid attribute.
  egl_android_native_fence_sync: Test for wait with zero timeout.
  egl_android_native_fence_sync: Test nonzero timeout.
  egl_android_native_fence_sync: Verify that dup() fails on invalid
fence.

 tests/egl/spec/CMakeLists.txt  |1 +
 .../CMakeLists.gles2.txt   |9 +
 .../egl_android_native_fence_sync/CMakeLists.txt   |1 +
 .../egl_android_native_fence_sync.c| 1072 
 .../spec/egl_android_native_fence_sync/sw_sync.c   |  240 +
 .../spec/egl_android_native_fence_sync/sw_sync.h   |   52 +
 6 files changed, 1375 insertions(+)
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h

-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 09/11] egl_android_native_fence_sync: Test for wait with zero timeout.

2016-10-27 Thread Rafael Antognolli
Verify that eglClientWaitSyncKHR() correctly handles zero timeout before
and after the sw sync fence is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 97 ++
 1 file changed, 97 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 9f3ad51..1047f41 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -788,6 +788,98 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() correctly handles zero timeout before and
+ * after glFinish().
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ * If the value of  is zero, then eglClientWaitSyncKHR simply
+ * tests the current status of .
+ *
+ * [...]
+ *
+ * eglClientWaitSyncKHR returns one of three status values describing
+ * the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR
+ * indicates that the specified timeout period expired before 
+ * was signaled. A return value of EGL_CONDITION_SATISFIED_KHR
+ * indicates that  was signaled before the timeout expired, which
+ * includes the case when  was already signaled when
+ * eglClientWaitSyncKHR was called. If an error occurs then an error is
+ * generated and EGL_FALSE is returned.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_zero_timeout(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   int wait_status1 = 0, wait_status2 = 0;
+   int sync_fd = canary;
+   int timeline = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_sw_fence;
+   }
+
+   glFlush();
+
+   wait_status1 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+   sw_sync_timeline_inc(timeline, 1);
+   wait_status2 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+
+   if (wait_status1 != EGL_TIMEOUT_EXPIRED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() before glFinish:\n"
+   "  Expected status: EGL_TIMEOUT_EXPIRED_KHR 
(0x%x)\n"
+   "  Actual status:  0x%x\n",
+   EGL_TIMEOUT_EXPIRED_KHR, wait_status1);
+   result = PIGLIT_FAIL;
+   }
+   if (wait_status2 != EGL_CONDITION_SATISFIED_KHR) {
+   piglit_loge("eglClientWaitSyncKHR() after glFinish:\n"
+   "  Expected status: EGL_CONDITION_SATISFIED_KHR\n"
+   "  Actual status:  0x%x\n", wait_status2);
+   result = PIGLIT_FAIL;
+   }
+
+cleanup_sw_fence:
+   sw_sync_fence_destroy(sync_fd);
+
+cleanup_timeline:
+   sw_sync_timeline_destroy(timeline);
+
+cleanup:
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -829,6 +921,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglGetSyncAttribKHR_native_invalid_attrib",
test_eglGetSyncAttribKHR_native_invalid_attrib,
},
+   {
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   "eglClientWaitSyncKHR_native_zero_timeout",
+   test_eglClientWaitSyncKHR_native_zero_timeout,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 04/11] egl_android_native_fence_sync: Create fence from invalid display.

2016-10-27 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 40 ++
 1 file changed, 40 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 31ccb11..52ea6ad 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -513,6 +513,41 @@ cleanup:
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when given an invalid
+ * display.
+ *
+ * From the EGL_KHR_fence_sync spec:
+ *
+ * If  is not the name of a valid, initialized EGLDisplay,
+ * EGL_NO_SYNC_KHR is returned and an EGL_BAD_DISPLAY error is
+ * generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_invalid_display(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(EGL_NO_DISPLAY, EGL_SYNC_NATIVE_FENCE_ANDROID, 
NULL);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_NO_DISPLAY) succeeded");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_DISPLAY)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
{
"eglCreateSyncKHR_native_no_fence",
@@ -529,6 +564,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
"eglCreateSyncKHR_native_dup_fence",
test_eglCreateSyncKHR_native_dup_fence,
},
+   {
+   "eglCreateSyncKHR_invalid_display",
+   "eglCreateSyncKHR_invalid_display",
+   test_eglCreateSyncKHR_native_invalid_display,
+   },
{0},
 };
 
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 11/11] egl_android_native_fence_sync: Verify that dup() fails on invalid fence.

2016-10-27 Thread Rafael Antognolli
If  is not a valid sync object for ,
EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
error is generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 49 ++
 1 file changed, 49 insertions(+)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 0af9e75..806421f 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -514,6 +514,50 @@ cleanup:
 }
 
 /**
+ * Verify that eglDupNativeFenceFDANDROID emits correct error when given an
+ * invalid sync .
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ * If  is not a valid sync object for ,
+ * EGL_NO_NATIVE_FENCE_FD_ANDROID is returned and an EGL_BAD_PARAMETER
+ * error is generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_dup_invalid(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR invalid_sync = (EGLSyncKHR) &canary;
+   EGLint sync_fd = canary;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync_fd = peglDupNativeFenceFDANDROID(g_dpy, invalid_sync);
+   if (sync_fd != EGL_NO_NATIVE_FENCE_FD_ANDROID) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() should return "
+   "EGL_NO_NATIVE_FENCE_FD_ANDROID, "
+   "but returned %d", sync_fd);
+   close(sync_fd);
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_PARAMETER)) {
+   piglit_loge("Given an invalid sync object, "
+   "eglDupNativeFenceFDANDROID() "
+   "did not emit EGL_BAD_PARAMETER");
+   result = PIGLIT_FAIL;
+   }
+
+cleanup:
+   test_cleanup(EGL_NO_SYNC_KHR, &result);
+   return result;
+}
+
+/**
  * Verify that eglCreateSyncKHR emits correct error when given an invalid
  * display.
  *
@@ -946,6 +990,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
test_eglCreateSyncKHR_native_dup_fence,
},
{
+   "eglCreateSyncKHR_native_dup_invalid",
+   "eglCreateSyncKHR_native_dup_invalid",
+   test_eglCreateSyncKHR_native_dup_invalid,
+   },
+   {
"eglCreateSyncKHR_invalid_display",
"eglCreateSyncKHR_invalid_display",
test_eglCreateSyncKHR_native_invalid_display,
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 06/11] egl_android_native_fence_sync: Create fence with invalid attributes.

2016-10-27 Thread Rafael Antognolli
Verify that EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error
is generated.

Signed-off-by: Rafael Antognolli 
---
 .../egl_android_native_fence_sync.c| 54 --
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 6305c44..eb5042b 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -548,6 +548,47 @@ test_eglCreateSyncKHR_native_invalid_display(void 
*test_data)
return result;
 }
 
+/**
+ * Verify that eglCreateSyncKHR emits correct error when given an invalid
+ * attribute list.
+ *
+ * From the EGL_ANDROID_native_fence_sync spec:
+ *
+ * If  is EGL_SYNC_NATIVE_FENCE_ANDROID and  contains
+ * an attribute other than EGL_SYNC_NATIVE_FENCE_FD_ANDROID,
+ * EGL_NO_SYNC_KHR is returned and an EGL_BAD_ATTRIBUTE error is
+ * generated.
+ */
+static enum piglit_result
+test_eglCreateSyncKHR_native_invalid_attrib_list(void *test_data)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   const EGLint attrib_list[] = {
+   EGL_CONTEXT_CLIENT_VERSION, 2,
+   EGL_NONE,
+   };
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   sync = peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
attrib_list);
+   if (sync != EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR() succeeded with invalid "
+   "attrib list");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_BAD_ATTRIBUTE)) {
+   piglit_loge("eglCreateSyncKHR emitted wrong error");
+   result = PIGLIT_FAIL;
+   }
+
+   test_cleanup(sync, &result);
+   return result;
+}
+
 static enum piglit_result
 init_other_display(EGLDisplay *out_other_dpy, EGLDisplay orig_dpy)
 {
@@ -589,10 +630,10 @@ init_other_display(EGLDisplay *out_other_dpy, EGLDisplay 
orig_dpy)
  *
  * From the EGL_KHR_fence_sync spec:
  *
- * * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and
- *   no context is current for the bound API (i.e., eglGetCurrentContext
- *   returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
- *   EGL_BAD_MATCH error is generated.
+ * If  is EGL_SYNC_FENCE_KHR or EGL_SYNC_NATIVE_FENCE_ANDROID and no
+ * context is current for the bound API (i.e., eglGetCurrentContext
+ * returns EGL_NO_CONTEXT), EGL_NO_SYNC_KHR is returned and an
+ * EGL_BAD_MATCH error is generated.
  *
  * This test verifies a simple case for the above error. It binds a context and
  * display to the main thread, creates a second display on the same threads but
@@ -661,6 +702,11 @@ static const struct piglit_subtest fence_sync_subtests[] = 
{
test_eglCreateSyncKHR_native_invalid_display,
},
{
+   "eglCreateSyncKHR_native_invalid_attrib_list",
+   "eglCreateSyncKHR_native_invalid_attrib_list",
+   test_eglCreateSyncKHR_native_invalid_attrib_list,
+   },
+   {
"eglCreateSyncKHR_wrong_display_same_thread",
"eglCreateSyncKHR_wrong_display_same_thread",
test_eglCreateSyncKHR_native_wrong_display_same_thread,
-- 
2.7.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 01/11] egl_android_native_fence_sync: Initial test for native fences.

2016-10-27 Thread Rafael Antognolli
Add a test for EGL_ANDROID_native_fence_sync, and check that we can
create a fence sync using attribute EGL_SYNC_NATIVE_FENCE_FD_ANDROID set
to EGL_NO_NATIVE_FENCE_FD_ANDROID. Check that the several attributes are
the correct default ones.

Signed-off-by: Rafael Antognolli 
---
 tests/egl/spec/CMakeLists.txt  |   1 +
 .../CMakeLists.gles2.txt   |   9 +
 .../egl_android_native_fence_sync/CMakeLists.txt   |   1 +
 .../egl_android_native_fence_sync.c| 393 +
 4 files changed, 404 insertions(+)
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
 create mode 100644 
tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c

diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt
index d916f7a..1a66b23 100644
--- a/tests/egl/spec/CMakeLists.txt
+++ b/tests/egl/spec/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_subdirectory (egl-1.4)
+add_subdirectory (egl_android_native_fence_sync)
 add_subdirectory (egl_ext_client_extensions)
 add_subdirectory (egl_ext_device_query)
 add_subdirectory (egl_ext_device_enumeration)
diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
new file mode 100644
index 000..0d85ce9
--- /dev/null
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
@@ -0,0 +1,9 @@
+link_libraries(piglitutil_${piglit_target_api})
+
+if(PIGLIT_HAS_PTHREADS)
+   link_libraries(${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c)
+
+# vim: ft=cmake:
diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
new file mode 100644
index 000..144a306
--- /dev/null
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
new file mode 100644
index 000..8d8f04d
--- /dev/null
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -0,0 +1,393 @@
+/*
+ * Copyright 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * \file Tests for EGL_ANDROID_native_fence_sync.
+ *
+ * This file attempts to exhaustively test the EGL_ANDROID_native_fence_sync
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "piglit-util-egl.h"
+#include "piglit-util-gl.h"
+
+/* Extension function pointers.
+ *
+ * Use prefix 'pegl' (piglit egl) instead of 'egl' to avoid collisions with
+ * prototypes in eglext.h. */
+EGLSyncKHR (*peglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint 
*attrib_list);
+EGLBoolean (*peglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync);
+EGLint (*peglClientWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, 
EGLTimeKHR timeout);
+EGLint (*peglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);
+EGLint (*peglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
+EGLBoolean (*peglGetSyncAttribKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint 
attribute, EGLint *value);
+
+static const EGLint canary = 0x31415926;
+static EGLDisplay g_dpy = 0;
+static EGLContext g_ctx = 0;
+
+static enum piglit_result
+init_display(EGLenum platform, EGLDisplay *out_dpy)
+{
+   enum piglit_result result = PIGLIT_PASS;
+   EGLDisplay dpy;
+   EGLint egl_major, egl_minor;
+   bool ok;
+
+   dpy = piglit_egl_get_default_display(platform);
+   if (!dpy) {
+   result = PIG

[Piglit] [PATCH 02/11] egl_android_native_fence_sync: Add test to create fence from fd.

2016-10-27 Thread Rafael Antognolli
Add a test that creates a sync file using sw_sync, and then creates an
EGL fence sync from that sync file. It also verify that the fence sync
EGL_SYNC_CONDITION_KHR is set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID,
and that EGL_SYNC_STATUS_KHR changes to EGL_SIGNALED_KHR once the fence
is signaled.

Signed-off-by: Rafael Antognolli 
---
 .../CMakeLists.gles2.txt   |   2 +-
 .../egl_android_native_fence_sync.c| 136 +++-
 .../spec/egl_android_native_fence_sync/sw_sync.c   | 240 +
 .../spec/egl_android_native_fence_sync/sw_sync.h   |  52 +
 4 files changed, 428 insertions(+), 2 deletions(-)
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.c
 create mode 100644 tests/egl/spec/egl_android_native_fence_sync/sw_sync.h

diff --git a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt 
b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
index 0d85ce9..5492a39 100644
--- a/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
+++ b/tests/egl/spec/egl_android_native_fence_sync/CMakeLists.gles2.txt
@@ -4,6 +4,6 @@ if(PIGLIT_HAS_PTHREADS)
link_libraries(${CMAKE_THREAD_LIBS_INIT})
 endif()
 
-piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c)
+piglit_add_executable(egl_android_native_fence_sync 
egl_android_native_fence_sync.c sw_sync.c)
 
 # vim: ft=cmake:
diff --git 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 8d8f04d..c65eb24 100644
--- 
a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ 
b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -34,6 +34,7 @@
 
 #include "piglit-util-egl.h"
 #include "piglit-util-gl.h"
+#include "sw_sync.h"
 
 /* Extension function pointers.
  *
@@ -333,10 +334,143 @@ cleanup:
return result;
 }
 
+static EGLSyncKHR
+test_create_fence_from_fd(int fd)
+{
+   EGLint attrib_list[] = {
+   EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd,
+   EGL_NONE,
+   };
+
+   return peglCreateSyncKHR(g_dpy, EGL_SYNC_NATIVE_FENCE_ANDROID, 
attrib_list);
+}
+
 static enum piglit_result
 test_eglCreateSyncKHR_native_from_fd(void *test_data)
 {
-   return PIGLIT_PASS;
+   enum piglit_result result = PIGLIT_PASS;
+   EGLSyncKHR sync = 0;
+   EGLint sync_type = canary,
+  sync_status = canary,
+  sync_condition = canary;
+   int sync_fd = canary;
+   int timeline = canary;
+   bool ok = false;
+
+   result = test_setup();
+   if (result != PIGLIT_PASS) {
+   return result;
+   }
+
+   if (!sw_sync_is_supported()) {
+   result = PIGLIT_SKIP;
+   goto cleanup;
+   }
+
+   /* Create timeline and sw_sync */
+   timeline = sw_sync_timeline_create();
+   if (timeline < 0) {
+   piglit_loge("sw_sync_timeline_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup;
+   }
+
+   sync_fd = sw_sync_fence_create(timeline, 1);
+   if (sync_fd < 0) {
+   piglit_loge("sw_sync_fence_create() failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_timeline;
+   }
+
+   sync = test_create_fence_from_fd(sync_fd);
+   if (sync == EGL_NO_SYNC_KHR) {
+   piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) 
failed");
+   result = PIGLIT_FAIL;
+   goto cleanup_sw_fence;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_TYPE_KHR, &sync_type);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) emitted "
+   "an error");
+   result = PIGLIT_FAIL;
+   }
+   if (sync_type != EGL_SYNC_NATIVE_FENCE_ANDROID) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_TYPE_KHR) returned "
+   "0x%x but expected 
EGL_SYNC_NATIVE_FENCE_ANDROID(0x%x)",
+   sync_type, EGL_SYNC_NATIVE_FENCE_ANDROID);
+   result = PIGLIT_FAIL;
+   }
+
+   ok = peglGetSyncAttribKHR(g_dpy, sync, EGL_SYNC_STATUS_KHR, 
&sync_status);
+   if (!ok) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) failed");
+   result = PIGLIT_FAIL;
+   }
+   if (!piglit_check_egl_error(EGL_SUCCESS)) {
+   piglit_loge("eglGetSyncAttribKHR(EGL_SYNC_STATUS_KHR) emitted "
+

Re: [Piglit] [RFC 0/2] egl_android_native_fence_sync tests.

2016-10-27 Thread Rafael Antognolli
On Wed, Oct 26, 2016 at 12:20:52PM -0700, Chad Versace wrote:
> On Tue 25 Oct 2016, Rob Clark wrote:
> > On Tue, Oct 25, 2016 at 5:19 PM, Rafael Antognolli
> >  wrote:

> > >  2) The spec mentions that if a fence sync object is created with
> > >  attribute EGL_SYNC_NATIVE_FENCE_FD_ANDROID set to
> > >  EGL_NO_NATIVE_FENCE_FD_ANDROID, "the next Flush() operation performed
> > >  by the current client API causes a new native fence object to be
> > >  created, and the EGL_SYNC_NATIVE_FENCE_ANDROID attribute of the EGL
> > >  native fence object is set to a file descriptor that refers to the new
> > >  native fence object." I'm not sure I fully understand this statement,
> > >  so I have no idea how to test it.
> > 
> > basically, before glFlush() or eglSwapBuffers() (or perhaps some other
> > calls that are expected to trigger a flush?) eglDupNativeFenceFD() can
> > return -1, but after it should return a valid fence.
> 
> The two modes of using EGL_ANDROID_native_fence_sync correspond
> to an "in" fence and an "out" fence.
> 
> If you give a valid sync fd to eglCreateSync, then the next flush will
> submit the fd as an "in" fence along with the submitted batch buffer. The 
> kernel
> will schedule the work to begin after the in-fence signals.
> 
> If you give fd == -1 to eglCreateSync, then the next flush, when it
> submits the batch buffer to i915, will tell the EXECBUFFER2 ioctl
> to return an "out" fence fd. The out-fence will signal when the batch
> buffer completes execution.

OK, I got the idea of in and out fences but now it's clearer to me how
it interacts with flush. Thank you guys for the detailed explanation.

BTW, I've added more tests here:

https://github.com/rantogno/piglit/tree/fences

I'm still working on them so I didn't submit them to avoid keep flooding
the list, since I'm probably going to change them tomorrow. But most of
the things that I wanted to test are already there, in case you guys
want to check.

Cheers,
Rafael
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [RFC 0/2] egl_android_native_fence_sync tests.

2016-10-26 Thread Rafael Antognolli
On Tue, Oct 25, 2016 at 07:29:16PM -0400, Rob Clark wrote:
> On Tue, Oct 25, 2016 at 5:19 PM, Rafael Antognolli
>  wrote:
> > Hi,
> >
> > I finally got to work on these piglit tests (took longer than I
> > expected). But here is an initial version, and I would like to know if
> > I'm going on the right direction. Particularly I would like to know
> > whether adding the sw_sync lib code that I copied mostly as is from
> > intel-gpu-tools is acceptable/desirable. Also in order to use the
> > sw_sync, one needs to be root on a regular linux distro.
> >
> > I'm still going to add all the tests for trying to create fences from
> > invalid EGLDisplay, and things like that, but I should send those soon.
> >
> > Additionally, I also have a couple questions:
> >
> >  1) I don't see anywhere in the spec mentioning about creating a sync
> >  fence from an invalid fd (or an fd that is not a sync file), but should
> >  I test for it anyway? It looks like an error to me.
> 
> hmm, interesting.. from a practical standpoint, I'm not sure there is
> any good way to discover a bogus fence fd until we do submit/execbuf
> ioctl.  Which means it wouldn't be discovered until you did something
> that triggered a flush.
> 
> I guess on one hand, it is something easy for a user with fd
> refcnt'ing issues to mess up.  On the other hand, for non-debug
> scenario's we wouldn't want to introduce extra overhead..

OK, got your point.

> I wonder if there is some way we could add an ioctl on the fence fd to
> return "are you a valid fence fd" without conflicting with ioctls on
> unrelated fd's?

I don't know, but I could take a look at that if it's really needed (and
assuming nobody does it first). For now I'll just assume it's not
necessary.

Thanks,
Rafael
___
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit