Exemplo n.º 1
0
int
main(int argc, char **argv)
{
	int i, samples = 0;

	for(i = 1; i < argc; ++i) {
		if (!strcmp(argv[i], "-auto"))
			piglit_automatic = 1;
		else if (!strncmp(argv[i], "-samples=", 9)) {
			samples = atoi(argv[i]+9);
		}
		else
			fprintf(stderr, "Unknown option: %s\n", argv[i]);
	}

	dpy = XOpenDisplay(NULL);
	if (dpy == NULL) {
		fprintf(stderr, "couldn't open display\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_require_glx_extension(dpy, "GLX_MESA_copy_sub_buffer");
	CopySubBuffer = (PFNGLXCOPYSUBBUFFERMESAPROC)
	    glXGetProcAddressARB((GLubyte *)"glXCopySubBufferMESA");

	visinfo = get_glx_visual(dpy, samples);
	win_one = piglit_get_glx_window(dpy, visinfo);

	XMapWindow(dpy, win_one);

	piglit_glx_event_loop(dpy, draw);

	return 0;
}
Exemplo n.º 2
0
void
piglit_oml_sync_control_test_run(bool fullscreen, enum piglit_result (*draw)(Display *dpy))
{
	Display *dpy;
	GLXContext ctx;

	dpy = XOpenDisplay(NULL);
	if (dpy == NULL) {
		fprintf(stderr, "couldn't open display\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_require_glx_extension(dpy, "GLX_OML_sync_control");
	piglit_glx_get_all_proc_addresses(procs, ARRAY_SIZE(procs));

	visinfo = piglit_get_glx_visual(dpy);
	if (fullscreen)
		win = piglit_get_glx_window_fullscreen(dpy, visinfo);
	else
		win = piglit_get_glx_window(dpy, visinfo);
	ctx = piglit_get_glx_context(dpy, visinfo);
	glXMakeCurrent(dpy, win, ctx);

	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);

	XMapWindow(dpy, win);

	piglit_glx_event_loop(dpy, draw);
}
enum piglit_result
draw(Display *dpy)
{
	GLboolean pass = GL_TRUE;
	float green[] = {0.0, 1.0, 0.0, 1.0};
	float blue[] = {0.0, 0.0, 1.0, 1.0};
	float gray[] = {0.5, 0.5, 0.5, 1.0};
	pthread_t thread1, thread2;
	void *retval;
	int ret;
	int x1 = 10, x2 = 30;

	ctx = piglit_get_glx_context(dpy, visinfo);
	glXMakeCurrent(dpy, win, ctx);
	glewInit();

	piglit_require_glx_extension(dpy, "MESA_multithread_makecurrent");

	/* Clear background to gray */
	glClearColor(0.5, 0.5, 0.5, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	pthread_mutex_init(&mutex, NULL);

	/* Now, spawn some threads that do some drawing, both with this
	 * context
	 */
	pthread_create(&thread1, NULL, thread1_func, &x1);
	pthread_create(&thread2, NULL, thread2_func, &x2);

	ret = pthread_join(thread1, &retval);
	assert(ret == 0);
	ret = pthread_join(thread2, &retval);
	assert(ret == 0);

	pthread_mutex_destroy(&mutex);

	glColor4f(0.0, 1.0, 0.0, 0.0);
	piglit_draw_rect(50, 10, 10, 10);

	pass &= piglit_probe_rect_rgba( 0, 10, 10, 10, gray);
	pass &= piglit_probe_rect_rgba(10, 10, 10, 10, green);
	pass &= piglit_probe_rect_rgba(20, 10, 10, 10, gray);
	pass &= piglit_probe_rect_rgba(30, 10, 10, 10, blue);
	pass &= piglit_probe_rect_rgba(40, 10, 10, 10, gray);
	pass &= piglit_probe_rect_rgba(50, 10, 10, 10, green);
	pass &= piglit_probe_rect_rgba(60, 10, 10, 10, gray);

	pass &= piglit_probe_rect_rgba(0, 0, piglit_width, 10, gray);
	pass &= piglit_probe_rect_rgba(0, 20, piglit_width, 10, gray);

	glXSwapBuffers(dpy, win);

	glXMakeCurrent(dpy, None, None);
	glXDestroyContext(dpy, ctx);

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    bool pass = true;
    uint32_t i;

    GLX_ARB_create_context_setup();
    piglit_require_glx_extension(dpy, "GLX_ARB_create_context_profile");

    /* The GLX_ARB_create_context_profile spec says:
     *
     *     "* If attribute GLX_CONTEXT_PROFILE_MASK_ARB has no bits set;
     *        has any bits set other than GLX_CONTEXT_CORE_PROFILE_BIT_ARB
     *        and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; has more than
     *        one of these bits set...then GLXBadProfileARB is generated."
     */
    pass = try_profile(0)
           && pass;

    pass = try_profile(GLX_CONTEXT_CORE_PROFILE_BIT_ARB
                       | GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB)
           && pass;

    /* This loop will need to be modified as new profiles are defined by
     * the GLX spec.  The conditional code below for
     * GLX_EXT_create_context_es2_profile is an example of how this should
     * be handled.
     */
    for (i = 0x00000008; i != 0; i <<= 1) {
        pass = try_profile(i)
               && pass;
    }

    if (!piglit_is_glx_extension_supported(dpy, "GLX_EXT_create_context_es2_profile")) {
        pass = try_profile(GLX_CONTEXT_ES2_PROFILE_BIT_EXT)
               && pass;
    }

    GLX_ARB_create_context_teardown();

    piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
    return 0;
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	bool pass = true;

	GLX_ARB_create_context_setup();
	piglit_require_glx_extension(dpy, "GLX_ARB_create_context_robustness");

	/* The GLX_ARB_create_context_robustness spec says:
	 *
	 *     "If the GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB bit is set in
	 *     GLX_CONTEXT_FLAGS_ARB, then a context supporting <robust buffer
	 *     access> will be created. Robust buffer access is defined in the
	 *     GL_ARB_robustness extension specification, and the resulting
	 *     context must also support either the GL_ARB_robustness
	 *     extension, or a version of OpenGL incorporating equivalent
	 *     functionality."
	 *
	 * It also says:
	 *
	 *     "The attribute name GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
	 *     specifies the <reset notification behavior> of the rendering
	 *     context. Reset notification behavior is defined in the
	 *     GL_ARB_robustness extension specification, and the resulting
	 *     context must also support either the GL_ARB_robustness
	 *     extension, or a version of OpenGL incorporating equivalent
	 *     functionality."
	 */
	pass = try_context(GLX_NO_RESET_NOTIFICATION_ARB,
			   GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
		&& pass;
	pass = try_context(GLX_LOSE_CONTEXT_ON_RESET_ARB,
			   0)
		&& pass;
	pass = try_context(GLX_LOSE_CONTEXT_ON_RESET_ARB,
			   GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
		&& pass;

	GLX_ARB_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
	return 0;
}
Exemplo n.º 6
0
Arquivo: common.c Projeto: RAOF/piglit
void
GLX_ARB_create_context_setup(void)
{
	dpy = piglit_get_glx_display();

	piglit_require_glx_version(dpy, 1, 4);
	piglit_require_glx_extension(dpy, "GLX_ARB_create_context");

	__piglit_glXCreateContextAttribsARB =
		(PFNGLXCREATECONTEXTATTRIBSARBPROC)
		glXGetProcAddress((const GLubyte *)
				  "glXCreateContextAttribsARB");
	assert(__piglit_glXCreateContextAttribsARB != NULL);

	visinfo = piglit_get_glx_visual(dpy);
	fbconfig = piglit_glx_get_fbconfig_for_visinfo(dpy, visinfo);

	win = piglit_get_glx_window_unmapped(dpy, visinfo);
	glxWin = glXCreateWindow(dpy, fbconfig, win, NULL);

	piglit_glx_get_error(dpy, NULL);
	old_handler = XSetErrorHandler(x_error_handler);
}
Exemplo n.º 7
0
int
main(int argc, char **argv)
{
	int i;

	for(i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-auto"))
			piglit_automatic = 1;
		else
			fprintf(stderr, "Unknown option: %s\n", argv[i]);
	}

	dpy = piglit_get_glx_display();
	piglit_require_glx_extension(dpy, "GLX_EXT_buffer_age");
	visinfo = piglit_get_glx_visual(dpy);
	window = piglit_get_glx_window(dpy, visinfo);

	XMapWindow(dpy, window);

	piglit_glx_event_loop(dpy, draw);

	return 0;
}
Exemplo n.º 8
0
int main(int argc, char**argv)
{
	XVisualInfo *visinfo;
	GLXContext ctx;
	int i;

	for(i = 1; i < argc; ++i) {
		if (!strcmp(argv[i], "-auto"))
			piglit_automatic = 1;
		else
			fprintf(stderr, "Unknown option: %s\n", argv[i]);
	}

	dpy = XOpenDisplay(NULL);
	if (dpy == NULL) {
		fprintf(stderr, "couldn't open display\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	visinfo = piglit_get_glx_visual(dpy);
	ctx = piglit_get_glx_context(dpy, visinfo);
	win = piglit_get_glx_window(dpy, visinfo);
	XFree(visinfo);

	glXMakeCurrent(dpy, win, ctx);

	glewInit();

	if (piglit_automatic)
		piglit_glx_set_no_input();

	XMapWindow(dpy, win);

	piglit_require_glx_extension(dpy, "GLX_EXT_texture_from_pixmap");
	if (!piglit_is_extension_supported("GL_ARB_texture_env_combine")) {
		fprintf(stderr, "Test requires GL_ARB_texture_env_combine\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	pglXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)
		glXGetProcAddress((GLubyte *)"glXBindTexImageEXT");
	pglXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)
		glXGetProcAddress((GLubyte *)"glXReleaseTexImageEXT");
	if (pglXBindTexImageEXT == NULL || pglXReleaseTexImageEXT == NULL) {
		fprintf(stderr, "Couldn't get TFP functions\n");
		piglit_report_result(PIGLIT_FAIL);
		exit(1);
	}

	init();

	if (!piglit_automatic) {
		printf("Left rectangle (RGB) should be green on the top and\n"
		       "red on the bottom.  The right rectangle (RGBA) should\n"
		       "be the same, but darker on the right half.\n");
		printf("Press Escape to quit\n");
	}

	piglit_glx_event_loop(dpy, draw);

	return 0;
}
Exemplo n.º 9
0
Arquivo: common.c Projeto: RAOF/piglit
void GLX_EXT_import_context_setup(void)
{
	const char *const names[] = {
		"glXGetCurrentDisplayEXT",
		"glXQueryContextInfoEXT",
		"glXGetContextIDEXT",
		"glXImportContextEXT",
		"glXFreeContextEXT"
	};

	__GLXextFuncPtr *procedures[ARRAY_SIZE(names)] = {
		(__GLXextFuncPtr *) & __piglit_glXGetCurrentDisplayEXT,
		(__GLXextFuncPtr *) & __piglit_glXQueryContextInfoEXT,
		(__GLXextFuncPtr *) & __piglit_glXGetContextIDEXT,
		(__GLXextFuncPtr *) & __piglit_glXImportContextEXT,
		(__GLXextFuncPtr *) & __piglit_glXFreeContextEXT
	};

	const char *vendor;

	dpy = piglit_get_glx_display();

	/* NVIDIA incorrectly only list the extension in the client
	 * extenstions list.  If the extension is available for applications
	 * to use, it is supposed to be included in the list returned by
	 * glXQueryExtensionsString.
	 *
	 * The glXImportContextEXT manual page is somewhat clear on this
	 * topic:
	 *
	 *     "If _glxextstring(EXT_import_context) is included in the string
	 *     returned by glXQueryExtensionsString, when called with argument
	 *     GLX_EXTENSIONS, extension EXT_import_context is supported."
	 *
	 * The text is a little weird because the only parameters to
	 * glXQueryExtensionsString are the display and the screen.
	 */
	vendor = glXGetClientString(dpy, GLX_VENDOR);
	if (strcmp("NVIDIA Corporation", vendor) == 0) {
		const char *const client_extensions =
			glXGetClientString(dpy, GLX_EXTENSIONS);

		if (!piglit_is_extension_in_string(client_extensions,
						   "GLX_EXT_import_context")) {
			fprintf(stderr,
				"Test requires GLX_EXT_import_context.\n");
			piglit_report_result(PIGLIT_SKIP);
		}
	} else {
		piglit_require_glx_extension(dpy, "GLX_EXT_import_context");
	}

	piglit_glx_get_all_proc_addresses(procedures, names, ARRAY_SIZE(names));

	visinfo = piglit_get_glx_visual(dpy);

	directCtx = glXCreateContext(dpy, visinfo, NULL, True);
	if (directCtx == NULL) {
		fprintf(stderr,
			"Could not create initial direct-rendering context.\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (!glXIsDirect(dpy, directCtx)) {
		glXDestroyContext(dpy, directCtx);
		directCtx = NULL;
	}

	indirectCtx = glXCreateContext(dpy, visinfo, NULL, False);
	if (indirectCtx == NULL) {
		fprintf(stderr,
			"Could not create initial indirect-rendering "
			"context.\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_glx_get_error(dpy, NULL);
	old_handler = XSetErrorHandler(x_error_handler);
}
Exemplo n.º 10
0
int main(int argc, char **argv)
{
	static const int attribs[] = {
		GLX_CONTEXT_MAJOR_VERSION_ARB,
		2,
		GLX_CONTEXT_MINOR_VERSION_ARB,
		0,
		GLX_CONTEXT_PROFILE_MASK_ARB,
		GLX_CONTEXT_ES2_PROFILE_BIT_EXT,
		None
	};

	bool pass = true;
	GLXContext ctx;

	GLX_ARB_create_context_setup();
	piglit_require_glx_extension(dpy, "GLX_ARB_create_context_profile");
	piglit_require_glx_extension(dpy, "GLX_EXT_create_context_es2_profile");

	/* The GLX_EXT_create_context_es2_profile doesn't say anything about
	 * indirect-rendering contexts for ES2.  However, there is no protocol
	 * defined, so it seems impossible that this could ever work.
	 */
	ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, False, attribs);
	XSync(dpy, 0);

	if (ctx != NULL) {
		PFNGLGETSHADERPRECISIONFORMATPROC func;
		GLint r[] = { ~0, ~0 };
		GLint p = ~0;

		/* Try to call an ES2 function that does not exist in desktop
		 * OpenGL or have GLX protocol defined.  If this works, then
		 * we'll assume the implementation is using some magic
		 * protocol for ES2.  If it doesn't work, then the test fails.
		 */
		func = (PFNGLGETSHADERPRECISIONFORMATPROC)
			glXGetProcAddress((const GLubyte *)
					  "glGetShaderPrecisionFormat");
		if (func == NULL) {
			fprintf(stderr,
				"Indirect rendering OpenGL ES 2.0 context was "
				"created, but could not get\n"
				"function address for "
				"glGetShaderPrecisionFormat.\n");
			pass = false;
			goto done;
		}

		if (!glXMakeCurrent(dpy, glxWin, ctx)) {
			fprintf(stderr,
				"Indirect rendering OpenGL ES 2.0 "
				"context was created, but\n"
				"it could not be made current.\n");
			pass = false;
			goto done;
		}

		(*func)(GL_VERTEX_SHADER, GL_MEDIUM_FLOAT, r, &p);
		if (r[0] < 14 || r[1] < 14 || p < 10) {
			fprintf(stderr,
				"Indirect rendering OpenGL ES 2.0 "
				"context was created, but\n"
				"glGetShaderPrecisionFormat produced "
				"incorrect results.\n");
			pass = false;
		}
	} else {
		/* The GLX_ARB_create_context_profile spec says:
		 *
		 *     "* If <config> does not support compatible OpenGL
		 *        contexts providing the requested API major and minor
		 *        version, forward-compatible flag, and debug context
		 *        flag, GLXBadFBConfig is generated."
		 */
		if (!validate_glx_error_code(Success, GLXBadFBConfig))
			pass = false;
	}

done:
	if (ctx != NULL) {
		glXMakeCurrent(dpy, None, NULL);
		glXDestroyContext(dpy, ctx);
	}

	GLX_ARB_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
	return 0;
}