From: TheoH <[email protected]> We've observed hangs on some drivers in these calls, which make it harder to run the rest of the Piglit test suite.
Signed-off-by: Theo Hill <[email protected]> Signed-off-by: Jamey Sharp <[email protected]> --- .../glx_oml_sync_control/swapbuffersmsc-divisor-zero.c | 14 ++++++++++++-- tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c | 13 +++++++++++-- tests/spec/glx_oml_sync_control/timing.c | 12 ++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/spec/glx_oml_sync_control/swapbuffersmsc-divisor-zero.c b/tests/spec/glx_oml_sync_control/swapbuffersmsc-divisor-zero.c index d83905c..fa6db1c 100644 --- a/tests/spec/glx_oml_sync_control/swapbuffersmsc-divisor-zero.c +++ b/tests/spec/glx_oml_sync_control/swapbuffersmsc-divisor-zero.c @@ -46,8 +46,18 @@ draw(Display *dpy) int64_t start_ust = 0xd0, start_msc = 0xd0, start_sbc = 0xd0; int64_t swapped_ust = 0xd0, swapped_msc = 0xd0, swapped_sbc = 0xd0; int64_t current_ust = 0xd0, current_msc = 0xd0, current_sbc = 0xd0; - int64_t target_msc, outstanding_sbc; + int64_t target_msc, outstanding_sbc, msc_delta = 5; bool already_wrapped = false; + int32_t rate_num, rate_den; + double timeout; + + if (!glXGetMscRateOML(dpy, win, &rate_num, &rate_den)) { + timeout = 1.0 / 10; /* Assume MSC rate is at least 10Hz */ + } else { + timeout = (double) rate_den / rate_num; + } + piglit_set_timeout(timeout * msc_delta * 2, PIGLIT_FAIL); /* Safety factor 2 */ + glXGetSyncValuesOML(dpy, win, &start_ust, &start_msc, &start_sbc); if (start_sbc != 0) { @@ -63,7 +73,7 @@ wrap: glClear(GL_COLOR_BUFFER_BIT); /* Queue a swap for 5 frames from when we started. */ - target_msc = start_msc + 5; + target_msc = start_msc + msc_delta; glXSwapBuffersMscOML(dpy, win, target_msc, 0, 0); outstanding_sbc++; diff --git a/tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c b/tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c index a37fc9a..74d5873 100644 --- a/tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c +++ b/tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c @@ -49,7 +49,16 @@ draw(Display *dpy) int64_t start_ust = 0xd0, start_msc = 0xd0, start_sbc = 0xd0; int64_t next_sbc; bool pass = true; - int i; + int i, loops = 3; + int32_t rate_num, rate_den; + double timeout; + + if (!glXGetMscRateOML(dpy, win, &rate_num, &rate_den)) { + timeout = 1.0 / 10; /* Assume MSC rate is at least 10Hz */ + } else { + timeout = (double)rate_den / rate_num; + } + piglit_set_timeout(timeout * loops * 2, PIGLIT_FAIL); /* Safety factor 2 */ if (swap_interval != -1) { #if defined(GLX_MESA_swap_control) @@ -81,7 +90,7 @@ draw(Display *dpy) } next_sbc = start_sbc + 1; - for (i = 0; i < 3; i++) { + for (i = 0; i < loops; i++) { int64_t ret_sbc; glClearColor(0.0, 1.0, 0.0, 0.0); diff --git a/tests/spec/glx_oml_sync_control/timing.c b/tests/spec/glx_oml_sync_control/timing.c index decb352..e81beef 100644 --- a/tests/spec/glx_oml_sync_control/timing.c +++ b/tests/spec/glx_oml_sync_control/timing.c @@ -57,6 +57,11 @@ static double get_stddev(struct stats *stats) { return sqrt(stats->M2 / (stats->n - 1)); } +static double max(double a, double b) +{ + return a > b ? a : b; +} + static enum piglit_result draw(Display *dpy) { @@ -67,6 +72,7 @@ draw(Display *dpy) double expected_msc_wallclock_duration = 0.0; int32_t rate_num, rate_den; unsigned int i; + double timeout; if (!glXGetSyncValuesOML(dpy, win, &last_ust, &last_msc, &last_sbc)) { fprintf(stderr, "Initial glXGetSyncValuesOML failed\n"); @@ -80,10 +86,16 @@ draw(Display *dpy) if (!glXGetMscRateOML(dpy, win, &rate_num, &rate_den)) { fprintf(stderr, "glXGetMscRateOML failed, can't test MSC duration\n"); + timeout = 1.0 / 10; /* Assume MSC rate is at least 10Hz */ } else { expected_msc_wallclock_duration = 1e6 * rate_den / rate_num; + timeout = expected_msc_wallclock_duration / 1e6; } + timeout *= loops * max(1, max(target_msc_delta, divisor)); + piglit_set_timeout(timeout * 2, PIGLIT_FAIL); /* Safety factor 2 */ + + for (i = 0; i < loops; i++) { int64_t swapped_ust = 0xd0, swapped_msc = 0xd0, swapped_sbc = 0xd0; int64_t new_ust = 0xd0, new_msc = 0xd0, new_sbc = 0xd0, new_timestamp; -- 1.8.5.3 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
