PIGLIT_GL_TEST_CONFIG_END

void
piglit_init(int argc, char **argv)
{
	/**
	 * Separate queries for four different cases preventing the test from
	 * re-using a query that got possibly activated by the previous attempt.
	 *
	 * generated with maximum
	 * generated with maximum + 1
	 * written with maximum
	 * written with maximum + 1
	 */
	GLuint queries[4];
	GLint max_streams;
	bool pass = true;

	piglit_require_extension("GL_ARB_transform_feedback3");

	glGetIntegerv(GL_MAX_VERTEX_STREAMS, &max_streams);
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("failed to resolve the maximum number of streams\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (max_streams <= 0) {
		printf("invalid maximum number of streams: %d\n", max_streams);
		piglit_report_result(PIGLIT_FAIL);
	}

	glGenQueries(ARRAY_SIZE(queries), queries);

	glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams - 1,
			queries[0]);
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("failed to activate primitives generated query for the "
			"maximum supported stream\n");
		pass = false;
	}

	glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, max_streams, queries[1]);
	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;

	glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
			max_streams - 1, queries[2]);
	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		printf("failed to activate primitives written query for the "
			"maximum supported stream\n");
		pass = false;
	}

	glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
			max_streams, queries[3]);
	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;

	glDeleteQueries(ARRAY_SIZE(queries), queries);

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Ejemplo n.º 2
0
void
piglit_init(int argc, char **argv)
{
	bool pass;
	unsigned primitive_n;
	GLint gs_invocation_n;
	GLuint queries[2*STREAMS];
	GLuint xfb[STREAMS];
	GLuint vao;
	unsigned i;

	piglit_require_extension("GL_ARB_gpu_shader5");
	piglit_require_extension("GL_ARB_transform_feedback3");

	glGetIntegerv(GL_MAX_GEOMETRY_SHADER_INVOCATIONS, &gs_invocation_n);
	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	if (gs_invocation_n <= 0) {
		printf("Maximum amount of geometry shader invocations "
		       "needs to be positive (%u).\n", gs_invocation_n);
		piglit_report_result(PIGLIT_FAIL);
	}

	primitive_n = gs_invocation_n;

	build_and_use_program(gs_invocation_n);

	/* Set up the transform feedback buffers. */
	glGenBuffers(ARRAY_SIZE(xfb), xfb);
	for (i = 0; i < ARRAY_SIZE(xfb); i++) {
		unsigned float_n = primitive_n * stream_float_counts[i];
		glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, i, xfb[i]);
		glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,
			     float_n * sizeof(float), NULL,
			     GL_STREAM_READ);
	}

	/* Test only records using transform feedback. */
	glEnable(GL_RASTERIZER_DISCARD);

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	glGenQueries(ARRAY_SIZE(queries), queries);
	for (i = 0; i < STREAMS; i++) {
		glBeginQueryIndexed(GL_PRIMITIVES_GENERATED, i, queries[i]);
		glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
				    i, queries[STREAMS + i]);
	}

	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);

	/* Draw and record */
	glBeginTransformFeedback(GL_POINTS);
	glDrawArrays(GL_POINTS, 0, 1);
	for (i = 0; i < STREAMS; i++) {
		glEndQueryIndexed(GL_PRIMITIVES_GENERATED, i);
		glEndQueryIndexed(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN,
				  i);
	}
	glEndTransformFeedback();
	glDeleteVertexArrays(1, &vao);

	if (!piglit_check_gl_error(GL_NO_ERROR))
		piglit_report_result(PIGLIT_FAIL);

	pass = probe_buffers(xfb, queries, primitive_n);

	glDeleteBuffers(ARRAY_SIZE(xfb), xfb);
	glDeleteQueries(ARRAY_SIZE(queries), queries);

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Ejemplo n.º 3
0
void Query::beginIndexed(const GLenum target, const GLuint index) const
{
    glBeginQueryIndexed(target, index, id());
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GL40_nglBeginQueryIndexed(JNIEnv *__env, jclass clazz, jint target, jint index, jint id, jlong __functionAddress) {
	glBeginQueryIndexedPROC glBeginQueryIndexed = (glBeginQueryIndexedPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	glBeginQueryIndexed(target, index, id);
}