[Piglit] [PATCH] arb_query_buffer_object: beef up the test

Alejandro Piñeiro apinheiro at igalia.com
Fri Sep 16 08:44:23 UTC 2016



On 15/09/16 18:02, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
> A bunch of additions to the ARB_query_buffer_object test:
> 
> 1. test different result types (including 64 bit types)
> 2. compare the written result with equality to the result obtained by
>    querying on the CPU
> 3. add an additional mode to catch cache invalidation problems
> 4. additional checks that no values are written when they shouldn't
> 5. proper extension checks for the different query types
> 
> Also, rename the binary for the test to fit the extension-testname pattern.
> ---
>  tests/all.py                                       |   2 +-
>  .../spec/arb_query_buffer_object/CMakeLists.gl.txt |   2 +-
>  tests/spec/arb_query_buffer_object/qbo.c           | 297 +++++++++++++--------
>  3 files changed, 186 insertions(+), 115 deletions(-)
> 
> diff --git a/tests/all.py b/tests/all.py
> index 3961656..3f7c8ad 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4692,21 +4692,21 @@ with profile.group_manager(
>      g(['arb_vertex_attrib_64bit-check-explicit-location'], 'check-explicit-location')
>      g(['arb_vertex_attrib_64bit-getactiveattrib'], 'getactiveattrib')
>      g(['arb_vertex_attrib_64bit-max-vertex-attrib'], 'max-vertex-attrib')
>      for test_type in ('shader', 'api'):
>          g(['arb_vertex_attrib_64bit-overlapping-locations', test_type],
>            run_concurrent=False)
>  
>  with profile.group_manager(
>          PiglitGLTest,
>          grouptools.join('spec', 'arb_query_buffer_object')) as g:
> -    g(['arb_query_buffer_object'], 'qbo')
> +    g(['arb_query_buffer_object-qbo'], 'qbo')
>  
>  with profile.group_manager(
>          PiglitGLTest,
>          grouptools.join('spec', 'ext_framebuffer_blit')) as g:
>      g(['ext_framebuffer_blit-blit-early'], 'blit-early')
>  
>  # Group OES_draw_elements_base_vertex
>  with profile.group_manager(
>          PiglitGLTest,
>          grouptools.join('spec', 'OES_draw_elements_base_vertex')) as g:
> diff --git a/tests/spec/arb_query_buffer_object/CMakeLists.gl.txt b/tests/spec/arb_query_buffer_object/CMakeLists.gl.txt
> index 6381625..9a3d202 100644
> --- a/tests/spec/arb_query_buffer_object/CMakeLists.gl.txt
> +++ b/tests/spec/arb_query_buffer_object/CMakeLists.gl.txt
> @@ -1,13 +1,13 @@
>  include_directories(
>  	${GLEXT_INCLUDE_DIR}
>  	${OPENGL_INCLUDE_PATH}
>  	)
>  
>  link_libraries(
>  	piglitutil_${piglit_target_api}
>  	${OPENGL_gl_LIBRARY}
>  	)
>  
> -piglit_add_executable(qbo qbo.c)
> +piglit_add_executable(arb_query_buffer_object-qbo qbo.c)
>  
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_query_buffer_object/qbo.c b/tests/spec/arb_query_buffer_object/qbo.c
> index c00b534..5eef41c 100644
> --- a/tests/spec/arb_query_buffer_object/qbo.c
> +++ b/tests/spec/arb_query_buffer_object/qbo.c
> @@ -34,101 +34,94 @@
>  #include "piglit-util-gl.h"
>  
>  PIGLIT_GL_TEST_CONFIG_BEGIN
>  	config.supports_gl_compat_version = 32;
>  	config.supports_gl_core_version = 32;
>  	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE |
>  		PIGLIT_GL_VISUAL_DEPTH;
>  
>  PIGLIT_GL_TEST_CONFIG_END
>  
> -#define BUFFER_OFFSET(i) ((GLint *)((unsigned char*)NULL + (i)))
> +#define BUFFER_OFFSET(i) ((void *)(i))

Out of curiosity, this was really needed or it was just clean-up?

>  
>  static const float green[] = {0, 1, 0, 1};
>  
>  static unsigned query;
>  static unsigned qbo;
>  
>  static int prog;
>  static int qbo_prog;
>  static int sync_mode_loc;
> -static int original_count_loc;
>  static int expect_exact_loc;
> -static int expected_count_loc;
> -static bool has_pipeline_stats;
> +static int is_64bit_loc;
> +static int expected_loc;
> +static int expected_hi_loc;
>  
>  enum sync_mode {
>  	QBO_SYNC,
> +	QBO_SYNC_CPU_READ_AFTER_CACHE_TEST,
>  	QBO_ASYNC,
>  	QBO_ASYNC_CPU_READ_BEFORE,
>  	QBO_ASYNC_CPU_READ_AFTER,
>  	NUM_QBO_SYNC_MODES,
>  };
>  
> -static char* sync_mode_names[] = {
> +static const char * const sync_mode_names[] = {
>  	"SYNC",
> +	"SYNC_CPU_READ_AFTER_CACHE_TEST",
>  	"ASYNC",
>  	"ASYNC_CPU_READ_BEFORE",
>  	"ASYNC_CPU_READ_AFTER",
>  };
>  
> +static GLenum query_type;
>  static enum sync_mode sync_mode;
> +static GLenum result_type;
>  
> -static bool
> -is_pipeline_stats_query(GLenum q)
> -{
> -	switch (q) {
> -	case GL_VERTICES_SUBMITTED_ARB:
> -	case GL_PRIMITIVES_SUBMITTED_ARB:
> -	case GL_VERTEX_SHADER_INVOCATIONS_ARB:
> -	case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
> -	case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
> -	case GL_GEOMETRY_SHADER_INVOCATIONS:
> -	case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
> -	case GL_FRAGMENT_SHADER_INVOCATIONS_ARB:
> -	case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
> -	case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
> -	case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
> -		return true;
> -	default:
> -		return false;
> -	}
> -}
> -
> -static GLenum query_types[] = {
> -	GL_ANY_SAMPLES_PASSED,
> -	GL_ANY_SAMPLES_PASSED_CONSERVATIVE,
> -	GL_CLIPPING_INPUT_PRIMITIVES_ARB,
> -	GL_CLIPPING_OUTPUT_PRIMITIVES_ARB,
> -	/* GL_COMPUTE_SHADER_INVOCATIONS_ARB, */
> -	GL_FRAGMENT_SHADER_INVOCATIONS_ARB,
> -	/* GL_GEOMETRY_SHADER_INVOCATIONS, */
> -	/* GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB, */
> -	GL_PRIMITIVES_GENERATED,
> -	GL_PRIMITIVES_SUBMITTED_ARB,
> -	GL_SAMPLES_PASSED_ARB,
> -	/* GL_TESS_CONTROL_SHADER_PATCHES_ARB, */
> -	/* GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB, */
> -	GL_TIMESTAMP,
> -	GL_TIME_ELAPSED,
> -	GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
> -	GL_VERTEX_SHADER_INVOCATIONS_ARB,
> -	GL_VERTICES_SUBMITTED_ARB,
> +struct query_type_desc {
> +	GLenum type;
> +	const char *extensions[2];
>  };
>  
> -static GLenum query_type;
> +/* Note: meaningful test cases (with non-zero values) for the following are
> + * missing:
> + *  - GL_COMPUTE_SHADER_INVOCATIONS_ARB
> + *  - GL_GEOMETRY_SHADER_INVOCATIONS
> + *  - GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB
> + *  - GL_TESS_CONTROL_SHADER_PATCHES_ARB
> + *  - GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB
> + *  - GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
> + */
> +static const struct query_type_desc query_types[] = {
> +	{ GL_ANY_SAMPLES_PASSED,			{ "GL_ARB_occlusion_query2", NULL } },
> +	{ GL_ANY_SAMPLES_PASSED_CONSERVATIVE,		{ "GL_ARB_ES3_compatibility", NULL } },
> +	{ GL_CLIPPING_INPUT_PRIMITIVES_ARB,		{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_CLIPPING_OUTPUT_PRIMITIVES_ARB,		{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_COMPUTE_SHADER_INVOCATIONS_ARB,		{ "GL_ARB_pipeline_statistics_query", "GL_ARB_compute_shader" } },
> +	{ GL_FRAGMENT_SHADER_INVOCATIONS_ARB,		{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_GEOMETRY_SHADER_INVOCATIONS,		{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB,	{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_PRIMITIVES_GENERATED,			{ NULL, } },
> +	{ GL_PRIMITIVES_SUBMITTED_ARB,			{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_SAMPLES_PASSED_ARB,			{ NULL, } },
> +	{ GL_TESS_CONTROL_SHADER_PATCHES_ARB,		{ "GL_ARB_pipeline_statistics_query", "GL_ARB_tessellation_shader" } },
> +	{ GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB,	{ "GL_ARB_pipeline_statistics_query", "GL_ARB_tessellation_shader" } },
> +	{ GL_TIMESTAMP,					{ "GL_ARB_timer_query", NULL } },
> +	{ GL_TIME_ELAPSED,				{ "GL_ARB_timer_query", NULL } },
> +	{ GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,	{ NULL, } },
> +	{ GL_VERTEX_SHADER_INVOCATIONS_ARB,		{ "GL_ARB_pipeline_statistics_query", NULL } },
> +	{ GL_VERTICES_SUBMITTED_ARB,			{ "GL_ARB_pipeline_statistics_query", NULL } },
> +};
>  
>  static void
> -get_query_values(GLenum query_type, uint32_t *original,
> -		 bool *exact, uint32_t *expected)
> +get_query_values(GLenum query_type, bool *exact, uint32_t *expected)
>  {
> -	*original = 0xffffffff;
>  	*exact = true;
>  
>  	switch (query_type) {
>  	case GL_ANY_SAMPLES_PASSED:
>  	case GL_ANY_SAMPLES_PASSED_CONSERVATIVE:
>  		*expected = 1;
>  		break;
>  	case GL_CLIPPING_INPUT_PRIMITIVES_ARB:
>  	case GL_CLIPPING_OUTPUT_PRIMITIVES_ARB:
>  		*exact = false;
> @@ -157,160 +150,214 @@ get_query_values(GLenum query_type, uint32_t *original,
>  	case GL_VERTEX_SHADER_INVOCATIONS_ARB:
>  	case GL_VERTICES_SUBMITTED_ARB:
>  		*exact = false;
>  		*expected = 1;
>  		break;
>  	case GL_COMPUTE_SHADER_INVOCATIONS_ARB:
>  	case GL_GEOMETRY_SHADER_INVOCATIONS:
>  	case GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB:
>  	case GL_TESS_CONTROL_SHADER_PATCHES_ARB:
>  	case GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB:
> +		*expected = 0;
> +		break;
>  	default:
>  		abort();
>  	}
>  }
>  
>  static enum piglit_result
> -cpu_gather_query(bool exact, uint32_t expected)
> +cpu_gather_query(bool exact, uint32_t expected, uint64_t *cpu_result)
>  {
> -	GLint qresult;
> +	*cpu_result = 0;
>  
>  	glBindBuffer(GL_QUERY_BUFFER, 0);
>  
> -	glGetQueryObjectiv(query, GL_QUERY_RESULT, &qresult);
> +	if (result_type == GL_INT)
> +		glGetQueryObjectiv(query, GL_QUERY_RESULT, (GLint*)cpu_result);
> +	else if (result_type == GL_UNSIGNED_INT)
> +		glGetQueryObjectuiv(query, GL_QUERY_RESULT, (GLuint*)cpu_result);
> +	else
> +		glGetQueryObjectui64v(query, GL_QUERY_RESULT, cpu_result);
>  
>  	glBindBuffer(GL_QUERY_BUFFER, qbo);
>  
> -	return (exact ? qresult == expected : qresult >= expected)
> +	return (exact ? *cpu_result == expected : *cpu_result >= expected)
>  		? PIGLIT_PASS : PIGLIT_FAIL;
>  }
>  
>  enum piglit_result
>  run_subtest(void)
>  {
> -	uint32_t original;
>  	bool exact;
>  	uint32_t expected;
> -	uint32_t default_value[2] = { 0u, 0u };
> -	bool is_sync = sync_mode == QBO_SYNC;
> +	uint64_t cpu_result;
> +	bool have_cpu_result = false;
> +	uint32_t default_value[4] = { 0xccccccccu, 0xccccccccu, 0xccccccccu, 0xccccccccu };
> +	bool is_sync =
> +		sync_mode == QBO_SYNC ||
> +		sync_mode == QBO_SYNC_CPU_READ_AFTER_CACHE_TEST;
>  
> -	get_query_values(query_type, &original, &exact, &expected);
> -	default_value[0] = original;
> +	get_query_values(query_type, &exact, &expected);
>  
>  	glClearColor(0.5, 0.5, 0.5, 1.0);
>  	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>  
>  	/* Load default value into buffer */
>  	glBindBuffer(GL_QUERY_BUFFER, qbo);
> -	glBufferData(GL_QUERY_BUFFER, 8, default_value, GL_DYNAMIC_COPY);
> +	glBufferData(GL_QUERY_BUFFER, 16, default_value, GL_DYNAMIC_COPY);
>  
>  	/* Enable query, draw something that should pass */
>  	glEnable(GL_DEPTH_TEST);
>  	glUseProgram(prog);
>  	glGenQueries(1, &query);
>  	if (query_type != GL_TIMESTAMP)
>  		glBeginQuery(query_type, query);
>  	piglit_draw_rect_z(0.5, -1, -1, 2, 2);
>  	if (query_type != GL_TIMESTAMP)
>  		glEndQuery(query_type);
>  	else
>  		glQueryCounter(query, query_type);
>  
> -	if (sync_mode == QBO_ASYNC_CPU_READ_BEFORE &&
> -	    cpu_gather_query(exact, expected))
> -		return PIGLIT_FAIL;
> +	if (sync_mode == QBO_ASYNC_CPU_READ_BEFORE) {
> +		if (cpu_gather_query(exact, expected, &cpu_result))
> +			return PIGLIT_FAIL;
> +		have_cpu_result = true;
> +	}
>  
>  	glBindBuffer(GL_QUERY_BUFFER, qbo);
>  	if (is_sync) {
> -		/* Stuff query result into qbo */
> -		glGetQueryObjectivARB(query, GL_QUERY_RESULT,
> -				      BUFFER_OFFSET(0));
> +		/* Special mode to test against a possible cache invalidation
> +		 * in case the wait-for-result is handled at a different place
> +		 * in the memory hierarchy than actually reading and
> +		 * summarizing the result.
> +		 */
> +		if (sync_mode == QBO_SYNC_CPU_READ_AFTER_CACHE_TEST)
> +			glGetQueryObjectivARB(query, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
> +
> +		if (result_type == GL_INT)
> +			glGetQueryObjectivARB(query, GL_QUERY_RESULT, BUFFER_OFFSET(0));
> +		else if (result_type == GL_UNSIGNED_INT)
> +			glGetQueryObjectuivARB(query, GL_QUERY_RESULT, BUFFER_OFFSET(0));
> +		else
> +			glGetQueryObjectui64v(query, GL_QUERY_RESULT, BUFFER_OFFSET(0));
>  	} else {
> -		/* Stuff query result into qbo */
> -		glGetQueryObjectivARB(query, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
> -		/* Stuff query availability into qbo */
> -		glGetQueryObjectivARB(query, GL_QUERY_RESULT_AVAILABLE, BUFFER_OFFSET(4));
> +		if (result_type == GL_INT) {
> +			glGetQueryObjectivARB(query, GL_QUERY_RESULT_AVAILABLE, BUFFER_OFFSET(8));
> +			glGetQueryObjectivARB(query, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
> +		} else if (result_type == GL_UNSIGNED_INT) {
> +			glGetQueryObjectuivARB(query, GL_QUERY_RESULT_AVAILABLE, BUFFER_OFFSET(8));
> +			glGetQueryObjectuivARB(query, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
> +		} else {
> +			glGetQueryObjectui64v(query, GL_QUERY_RESULT_AVAILABLE, BUFFER_OFFSET(8));
> +			glGetQueryObjectui64v(query, GL_QUERY_RESULT_NO_WAIT, BUFFER_OFFSET(0));
> +		}
>  	}
>  
> -	if (sync_mode == QBO_ASYNC_CPU_READ_AFTER &&
> -	    cpu_gather_query(exact, expected))
> -		return PIGLIT_FAIL;
> +	if (sync_mode == QBO_SYNC_CPU_READ_AFTER_CACHE_TEST ||
> +	    sync_mode == QBO_ASYNC_CPU_READ_AFTER) {
> +		if (cpu_gather_query(exact, expected, &cpu_result))
> +			return PIGLIT_FAIL;
> +		have_cpu_result = true;
> +	}
>  
>  	/* Make it available to shader as uniform buffer 0 */
>  	glBindBufferBase(GL_UNIFORM_BUFFER, 0, qbo);
>  
>  	glUseProgram(qbo_prog);
>  
>  	/* Setup program uniforms */
>  	glUniform1ui(sync_mode_loc, is_sync ? GL_TRUE : GL_FALSE);
> -	glUniform1ui(original_count_loc, original);
> -	glUniform1ui(expect_exact_loc, exact ? GL_TRUE : GL_FALSE);
> -	glUniform1ui(expected_count_loc, expected);
> +	glUniform1ui(expect_exact_loc, have_cpu_result || exact);
> +	glUniform1ui(is_64bit_loc, result_type == GL_UNSIGNED_INT64_ARB);
> +	glUniform1ui(expected_loc, have_cpu_result ? cpu_result : expected);
> +	glUniform1ui(expected_hi_loc, have_cpu_result ? (cpu_result >> 32) : 0);
>  
>  	glDisable(GL_DEPTH_TEST);
>  	/* Draw green if query successful */
>  	piglit_draw_rect(-1, -1, 2, 2);
>  
>  	glDeleteQueries(1, &query);
>  
> -	return piglit_probe_rect_rgba(0, 0, piglit_width,
> -				      piglit_height, green)
> -		? PIGLIT_PASS : PIGLIT_FAIL;
> -}
> +	if (!piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, green)) {
> +		unsigned *ptr = glMapBuffer(GL_QUERY_BUFFER, GL_READ_ONLY);
>  
> -enum piglit_result
> -run_subtest_and_present(void)
> -{
> -	char *subtest_name;
> -	enum piglit_result r = run_subtest();
> -	piglit_present_results();
> -	(void)!asprintf(&subtest_name, "query-%s-%s",
> -			piglit_get_gl_enum_name(query_type),
> -			sync_mode_names[sync_mode]);
> -	piglit_report_subtest_result(r, "%s", subtest_name);
> -	free(subtest_name);
> -	return r;
> +		printf("Expected: %u\n", expected);
> +		if (have_cpu_result)
> +			printf("CPU result: %lu\n", cpu_result);
> +		printf("QBO: %u %u %u %u\n", ptr[0], ptr[1], ptr[2], ptr[3]);
> +		glUnmapBuffer(GL_QUERY_BUFFER);
> +
> +		return PIGLIT_FAIL;
> +	}
> +
> +	return PIGLIT_PASS;
>  }
>  
>  enum piglit_result
>  piglit_display(void)
>  {
> +	static const GLenum result_types[] = {
> +		GL_INT,
> +		GL_UNSIGNED_INT,
> +		GL_UNSIGNED_INT64_ARB
> +	};
>  	enum piglit_result r = PIGLIT_PASS;
> -	enum piglit_result subtest_result;
> -	int qnum;
>  
> -	for (qnum = 0; qnum < ARRAY_SIZE(query_types); qnum++) {
> -		query_type = query_types[qnum];
> +	for (unsigned qnum = 0; qnum < ARRAY_SIZE(query_types); qnum++) {
> +		const struct query_type_desc *desc = &query_types[qnum];
> +		bool supported = true;
> +
> +		query_type = desc->type;
> +
> +		for (unsigned i = 0; i < ARRAY_SIZE(desc->extensions); ++i) {
> +			if (!desc->extensions[i])
> +				break;
> +
> +			if (!piglit_is_extension_supported(desc->extensions[i])) {
> +				supported = false;
> +				break;
> +			}
> +		}
> +
>  		for (sync_mode = QBO_SYNC;
>  		     sync_mode < NUM_QBO_SYNC_MODES;
>  		     sync_mode++) {
> -			if (!has_pipeline_stats &&
> -			    is_pipeline_stats_query(query_type))
> -				continue;
> -			subtest_result = run_subtest_and_present();
> -			r = MAX2(r, subtest_result);
> +			for (unsigned ridx = 0; ridx < ARRAY_SIZE(result_types); ++ridx) {
> +				enum piglit_result subtest_result = PIGLIT_SKIP;
> +
> +				result_type = result_types[ridx];
> +
> +				if (supported) {
> +					subtest_result = run_subtest();
> +					if (subtest_result != PIGLIT_PASS)
> +						r = subtest_result;
> +				}
> +
> +				piglit_report_subtest_result(subtest_result, "query-%s-%s-%s",
> +						piglit_get_gl_enum_name(query_type),
> +						sync_mode_names[sync_mode],
> +						piglit_get_gl_enum_name(result_type));
> +			}
>  		}
>  	}
>  
>  	return r;
>  }
>  
>  void
>  piglit_init(int argc, char **argv)
>  {
>  	char *vsCode;
>  	char *fsCode, *qboFsCode;
>  
>  	piglit_require_extension("GL_ARB_query_buffer_object");
>  	piglit_require_extension("GL_ARB_uniform_buffer_object");
> -	has_pipeline_stats =
> -		piglit_is_extension_supported("GL_ARB_pipeline_statistics_query");
>  
>  	glGenBuffers(1, &qbo);
>  	glBindBuffer(GL_QUERY_BUFFER, qbo);
>  	glBufferData(GL_QUERY_BUFFER, 4, NULL, GL_DYNAMIC_COPY);
>  
>  	vsCode =
>  		"#version 150\n"
>  		"in vec4 pos_in;\n"
>  		"void main() {\n"
>  		"	gl_Position = pos_in;\n"
> @@ -319,37 +366,61 @@ piglit_init(int argc, char **argv)
>  		"#version 150\n"
>  		"out vec4 color;\n"
>  		"void main() {\n"
>  		"	color = vec4(0.0, 0.0, 1.0, 1.0);\n"
>  		"}\n";
>  	qboFsCode =
>  		"#version 150\n"
>  		"#extension GL_ARB_uniform_buffer_object : require\n"
>  		"uniform query {\n"
>  		"	uint result;\n"
> +		"	uint result_hi;\n"
>  		"	uint available;\n"
> +		"	uint available_hi;\n"
>  		"};\n"
>  		"uniform bool sync_mode;\n"
> -		"uniform uint original_count;\n"
>  		"uniform bool expect_exact;\n"
> -		"uniform uint expected_count;\n"
> +		"uniform bool is_64bit;\n"
> +		"uniform uint expected;\n"
> +		"uniform uint expected_hi;\n"
>  		"out vec4 color;\n"
>  		"void main() {\n"
> +		"	uint INIT = uint(0xcccccccc);\n"
>  		"	bool ready = sync_mode || available != 0u;\n"
> -		"	if (!ready && result == original_count) {\n"
> -		"		color = vec4(0.0, 1.0, 0.0, 1.0);\n"
> -		"	} else if (ready &&\n"
> -		"	           (expect_exact ? result == expected_count :\n"
> -		"	                           result >= expected_count)) {\n"
> -		"		color = vec4(0.0, 1.0, 0.0, 1.0);\n"
> +		"	if (!is_64bit && (result_hi != INIT || available_hi != INIT)) {\n"
> +		"		color = vec4(1.0, 0.0, 0.25, 1.0);\n"
> +		"	} else if ((sync_mode && (available != INIT ||\n"
> +		"	                          available_hi != INIT)) ||\n"
> +		"	           (!sync_mode && ((available != 0u && available != 1u) ||\n"
> +		"	                           (is_64bit && available_hi != 0u) ||\n"
> +		"	                           (!is_64bit && available_hi != INIT)))) {\n"
> +		"		color = vec4(1.0, 0.0, 0.5, 1.0);\n"
>  		"	} else {\n"
> -		"		color = vec4(1.0, 0.0, 0.0, 1.0);\n"
> +		"		bool result_ok = false;\n"
> +		"		if (result == expected &&\n"
> +		"		    (!is_64bit || result_hi == expected_hi))\n"
> +		"			result_ok = true;\n"
> +		"		if (!expect_exact &&\n"
> +		"		    ((!is_64bit && result >= expected) ||\n"
> +		"		     (is_64bit && ((result_hi == expected_hi && result >= expected) ||\n"
> +		"		                   (result_hi > expected_hi)))))\n"
> +		"			result_ok = true;\n"
> +		"		if (!ready && result == INIT && result_hi == INIT)\n"
> +		"			result_ok = true;\n"
> +		"		if (result_ok) {\n"
> +		"			color = vec4(0.0, 1.0, 0.0, 1.0);\n"
> +		"		} else if (ready) {\n"
> +		"			color = vec4(1.0, 0.0, 0.0, 1.0);\n"
> +		"		} else {\n"
> +		"			color = vec4(1.0, 0.5, 0.0, 1.0);\n"
> +		"		}\n"
>  		"	}\n"
>  		"}\n";
>  
>  	prog = piglit_build_simple_program(vsCode, fsCode);
>  	qbo_prog = piglit_build_simple_program(vsCode, qboFsCode);
>  	sync_mode_loc = glGetUniformLocation(qbo_prog, "sync_mode");
> -	original_count_loc = glGetUniformLocation(qbo_prog, "original_count");
>  	expect_exact_loc = glGetUniformLocation(qbo_prog, "expect_exact");
> -	expected_count_loc = glGetUniformLocation(qbo_prog, "expected_count");
> +	is_64bit_loc = glGetUniformLocation(qbo_prog, "is_64bit");
> +	expected_loc = glGetUniformLocation(qbo_prog, "expected");
> +	expected_hi_loc = glGetUniformLocation(qbo_prog, "expected_hi");
>  }
> 

Acked-by: Alejandro Piñeiro <apinheiro at igalia.com>

-- 
Alejandro Piñeiro <apinheiro at igalia.com>


More information about the Piglit mailing list