Beispiel #1
0
static void
piglit_framework_fbo_glx_init()
{
	piglit_glx_dpy = piglit_get_glx_display();

	/* Unfortunately in GLX we need a drawable to bind our context
	 * to.  Make an unmapped window.
	 */
	piglit_glx_visinfo = piglit_get_glx_visual(piglit_glx_dpy);

	piglit_glx_context = piglit_get_glx_context(piglit_glx_dpy,
						    piglit_glx_visinfo);

	piglit_glx_window = piglit_get_glx_window_unmapped(piglit_glx_dpy,
							   piglit_glx_visinfo);

	glXMakeCurrent(piglit_glx_dpy, piglit_glx_window, piglit_glx_context);
}
static void *
thread_func(void *arg)
{
	Display *dpy;
	XVisualInfo *visinfo;
	Window win;
	unsigned i;

	dpy = piglit_get_glx_display();
	visinfo = piglit_get_glx_visual(dpy);
	win = piglit_get_glx_window(dpy, visinfo);

	for (i = 0; i < 100; ++i) {
		GLXContext ctx;
		GLuint vert_shader, frag_shader;
		GLuint program;

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

		/* Ok, not nice but should be safe due to all threads working
		 * on the same type of context.
                 */
		pthread_mutex_lock(&mutex);
		piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
		pthread_mutex_unlock(&mutex);

		vert_shader = piglit_compile_shader_text(GL_VERTEX_SHADER, vert_shader_text);
		piglit_check_gl_error(GL_NO_ERROR);

		frag_shader = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag_shader_text);
		piglit_check_gl_error(GL_NO_ERROR);

		program = piglit_link_simple_program(vert_shader, frag_shader);
		piglit_check_gl_error(GL_NO_ERROR);

		glUseProgram(program);
		piglit_check_gl_error(GL_NO_ERROR);

		glXDestroyContext(dpy, ctx);
	}

	return NULL;
}
Beispiel #3
0
int main(int argc, char **argv) {
	Display *display;
	XVisualInfo *visual;
	Window window;
	GLXContext ctx;
	void (*test_func)(Display*, GLXDrawable);

	parse_args(argc, argv, &test_func);

	display = piglit_get_glx_display();
	visual = piglit_get_glx_visual(display);
	window = piglit_get_glx_window(display, visual);
	ctx = piglit_get_glx_context(display, visual);
	glXMakeCurrent(display, window, ctx);

	/* Must initialize static variables of this function. */
	piglit_glx_get_error(display, NULL);

	test_func(display, window);

	return 0;
}
Beispiel #4
0
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);
}
Beispiel #5
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;
}
Beispiel #6
0
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);
}
Beispiel #7
0
void GLX_EXT_import_context_setup_for_child(void)
{
	dpy = piglit_get_glx_display();
	old_handler = XSetErrorHandler(x_error_handler);
}