[Piglit] [PATCH 1/2] GLX_OML_sync_control: Add new tests.

Chad Versace chad.versace at linux.intel.com
Fri Sep 28 14:52:54 PDT 2012


On 09/28/2012 11:44 AM, Eric Anholt wrote:
> I was going to go touch this code in Mesa, then I realised that we
> didn't have a single test for it.
> ---
>  tests/all.tests                                    |    6 +
>  tests/spec/CMakeLists.txt                          |    1 +
>  tests/spec/glx_oml_sync_control/CMakeLists.gl.txt  |   30 ++++
>  tests/spec/glx_oml_sync_control/CMakeLists.txt     |    1 +
>  tests/spec/glx_oml_sync_control/common.c           |   88 ++++++++++++
>  tests/spec/glx_oml_sync_control/common.h           |   16 +++
>  .../swapbuffersmsc-divisor-zero.c                  |  144 ++++++++++++++++++++
>  .../glx_oml_sync_control/swapbuffersmsc-return.c   |   92 +++++++++++++
>  tests/spec/glx_oml_sync_control/waitformsc.c       |  103 ++++++++++++++
>  9 files changed, 481 insertions(+)
>  create mode 100644 tests/spec/glx_oml_sync_control/CMakeLists.gl.txt
>  create mode 100644 tests/spec/glx_oml_sync_control/CMakeLists.txt
>  create mode 100644 tests/spec/glx_oml_sync_control/common.c
>  create mode 100644 tests/spec/glx_oml_sync_control/common.h
>  create mode 100644 tests/spec/glx_oml_sync_control/swapbuffersmsc-divisor-zero.c
>  create mode 100644 tests/spec/glx_oml_sync_control/swapbuffersmsc-return.c


> +/** @file swapbuffersmsc-return.c
> + *
> + * Test that glXSwapBuffersMscOML() returns a correct sbc value.
> + *
> + * Catches a bug in the X Server when a swap interval of 0 is used.
> + */

I don't see where we set the drawable's swap interval to 0. Does that happen
elsewhere? Does this test rely on 0 being the default?

> +
> +#include "piglit-util-gl-common.h"
> +#include "piglit-glx-util.h"
> +#include "common.h"
> +
> +int piglit_width = 50, piglit_height = 50;
> +
> +enum piglit_result
> +draw(Display *dpy)
> +{
> +	/* Fill the variables that will be returned as out values with
> +	 * junk to better detect failure there.
> +	 */
> +	int64_t start_ust = 0xd0, start_msc = 0xd0, start_sbc = 0xd0;
> +	int64_t next_sbc;
> +	bool pass = true;
> +	int i;
> +
> +	glXGetSyncValuesOML(dpy, win, &start_ust, &start_msc, &start_sbc);
> +	if (start_sbc != 0) {
> +		fprintf(stderr,
> +			"Initial SBC for the window should be 0, was %lld\n",
> +			(long long)start_sbc);
> +		piglit_report_result(PIGLIT_FAIL);
> +	}
> +	next_sbc = start_sbc + 1;
> +
> +	for (i = 0; i < 3; i++) {
> +		int64_t ret_sbc;
> +
> +		glClearColor(0.0, 1.0, 0.0, 0.0);
> +		glClear(GL_COLOR_BUFFER_BIT);
> +
> +		ret_sbc = glXSwapBuffersMscOML(dpy, win, 0, 1, 0);
> +
> +		if (ret_sbc != next_sbc) {
> +			printf("Frame %d: sbc was %lld, should be %lld\n",
> +			       i,
> +			       (long long)ret_sbc,
> +			       (long long)next_sbc);
> +			pass = false;
> +		}
> +
> +		next_sbc++;
> +	}
> +
> +	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +
> +	/* UNREACHED */
> +	return PIGLIT_FAIL;
> +}
> +
> +int
> +main(int argc, char **argv)
> +{
> +	piglit_oml_sync_control_test_run(draw);
> +
> +	return 0;
> +}



> diff --git a/tests/spec/glx_oml_sync_control/waitformsc.c b/tests/spec/glx_oml_sync_control/waitformsc.c
> new file mode 100644
> index 0000000..3dbf636
> --- /dev/null
> +++ b/tests/spec/glx_oml_sync_control/waitformsc.c
> @@ -0,0 +1,103 @@

> +/** @file waitformsc.c
> + *
> + * Test that glXWaitForMscOML() waits until both it and
> + * glXGetSyncValuesOML() return a an msc that meet the target.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +#include "piglit-glx-util.h"
> +#include "common.h"
> +
> +int piglit_width = 50, piglit_height = 50;
> +
> +enum piglit_result
> +draw(Display *dpy)
> +{
> +	/* Fill the variables that will be returned as out values with
> +	 * junk to better detect failure there.
> +	 */
> +	int64_t start_ust = 0xd0, start_msc = 0xd0, start_sbc = 0xd0;
> +	int64_t wait_ust = 0xd0, wait_msc = 0xd0, wait_sbc = 0xd0;
> +	int64_t current_ust = 0xd0, current_msc = 0xd0, current_sbc = 0xd0;
> +	int64_t target_msc;
> +	int i = 0;
> +
> +	do {
> +		glXGetSyncValuesOML(dpy, win, &start_ust, &start_msc, &start_sbc);
> +
> +		/* Wait for the MSC to be at least equal to target,
> +		 * with no divisor trickery.
> +		 */
> +		target_msc = start_msc + 5;
> +		glXWaitForMscOML(dpy, win, target_msc, 0, 0,
> +				 &wait_ust, &wait_msc, &wait_sbc);
> +
> +		if (i++ >= 5) {

Why allow 5 failures? It looks like we should allow one mishap for wraparound
and then fail the 2nd time.

> +			fprintf(stderr,
> +				"current_msc is returning bad values "
> +				"(%lld, start value was %lld\n",
> +				(long long)start_msc,
> +				(long long)wait_msc);
> +			piglit_report_result(PIGLIT_FAIL);
> +		}
> +	} while (wait_msc < start_msc);
> +
> +	if (wait_msc < target_msc) {
> +		fprintf(stderr,
> +			"glXWaitForMscOML() returned msc of %lld, "
> +			"expected >= %lld\n",
> +			(long long)wait_msc,
> +			(long long)target_msc);
> +	}
> +
> +	glXGetSyncValuesOML(dpy, win,
> +			    &current_ust, &current_msc, &current_sbc);
> +
> +	if (current_msc < target_msc) {
> +		fprintf(stderr,
> +			"glXGetSyncValuesOML() returned msc of %lld, "
> +			"expected >= %lld\n",
> +			(long long)current_msc,
> +			(long long)target_msc);
> +	}
> +
> +	piglit_report_result(PIGLIT_PASS);
> +
> +	/* UNREACHED */
> +	return PIGLIT_FAIL;
> +}
> +
> +int
> +main(int argc, char **argv)
> +{
> +	piglit_oml_sync_control_test_run(draw);
> +
> +	return 0;
> +}
> 



More information about the Piglit mailing list