コード例 #1
0
ファイル: invalid-attribute.c プロジェクト: blaztinn/piglit
int main(int argc, char **argv)
{
	static const int bad_attributes[] = {
		0xffff0000,
		GLX_SAMPLE_BUFFERS
	};
	bool pass = true;
	unsigned i;

	GLX_ARB_create_context_setup();

	for (i = 0; i < ARRAY_SIZE(bad_attributes); i++) {
		pass = try_attribute(bad_attributes[i]) && pass;
	}

	/* The GLX_ARB_create_context spec says:
	 *
	 *     "If GLX_ARB_create_context_profile is not supported, then the
	 *     GLX_CONTEXT_PROFILE_MASK_ARB attribute [is] not defined, and
	 *     specifying the attribute in <attribList> attribute will
	 *     generate BadValue."
	 */
	if (!piglit_is_glx_extension_supported(dpy, "GLX_ARB_create_context_profile")) {
		pass = try_attribute(GLX_CONTEXT_PROFILE_MASK_ARB)
			&& pass;
	}

	GLX_ARB_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
	return 0;
}
コード例 #2
0
ファイル: invalid-profile.c プロジェクト: janesma/piglit
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;
}
コード例 #3
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;
}
コード例 #4
0
int main(int argc, char **argv)
{
	static const int attribs[] = {
		None
	};
	bool pass = true;
	GLXContext ctx;

	GLX_ARB_create_context_setup();

	/* The GLX_ARB_create_context spec says:
	 *
	 *     "<attrib_list> may be NULL or empty (first attribute is None),
	 *     in which case all attributes assume their default values as
	 *     described below.
	 *
	 *     ...
	 *
	 *     The default values for GLX_CONTEXT_MAJOR_VERSION_ARB and
	 *     GLX_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this
	 *     case, implementations will typically return the most recent
	 *     version of OpenGL they support which is backwards compatible
	 *     with OpenGL 1.0 (e.g. 3.0, 3.1 + GL_ARB_compatibility, or 3.2
	 *     compatibility profile)."
	 *
	 * The Linux OpenGL ABI requires at least OpenGL 1.2, so this must
	 * create a context.
	 */
	ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs);
	if (ctx == NULL) {
		fprintf(stderr,	"Unable to create OpenGL context!\n");
		pass = false;
	} else {
		glXDestroyContext(dpy, ctx);
	}

	GLX_ARB_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
	return 0;
}
コード例 #5
0
int main(int argc, char **argv)
{
	static const int invalid_render_types[] = {
		GLX_COLOR_INDEX_BIT,
		GLX_RGBA_BIT,
		GLX_RGBA_FLOAT_BIT_ARB,
		GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT,
		0,
		-1,
		~GLX_RGBA_TYPE,
		~GLX_COLOR_INDEX_TYPE
	};
	bool pass = true;
	unsigned i;

	GLX_ARB_create_context_setup();

	for (i = 0; i < ARRAY_SIZE(invalid_render_types); i++) {
		pass = try_render_type(invalid_render_types[i])
			&& pass;
	}

	if (!piglit_is_glx_extension_supported(dpy, "GLX_ARB_fbconfig_float")) {
		pass = try_render_type(GLX_RGBA_FLOAT_TYPE_ARB)
			&& pass;
	}

	if (!piglit_is_glx_extension_supported(dpy, "GLX_EXT_fbconfig_packed_float")) {
		pass = try_render_type(GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT)
			&& pass;
	}

	GLX_ARB_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
	return 0;
}
コード例 #6
0
ファイル: default-minor-version.c プロジェクト: RAOF/piglit
int main(int argc, char **argv)
{
	static const int attribs[] = {
		GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
		None
	};
	GLXContext ctx;
	const char *version_string;
	int major;
	int minor;

	GLX_ARB_create_context_setup();

	/* The GLX_ARB_create_context spec says:
	 *
	 *     "The default values for GLX_CONTEXT_MAJOR_VERSION_ARB and
	 *     GLX_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this
	 *     case, implementations will typically return the most recent
	 *     version of OpenGL they support which is backwards compatible
	 *     with OpenGL 1.0 (e.g. 3.0, 3.1 + GL_ARB_compatibility, or 3.2
	 *     compatibility profile)."
	 *
	 * Request an OpenGL 2.0 context by explicitly setting the major
	 * version to 2 and leaving the major version at the default value of
	 * 0.  The Linux OpenGL ABI only requires OpenGL 1.2, so this might
	 * fail to create a context.
	 */
	ctx = glXCreateContextAttribsARB(dpy, fbconfig, NULL, True, attribs);
	if (ctx == NULL) {
		printf("Unable to create an OpenGL 2.0 context.\n");
		goto done;
	}

	glXMakeContextCurrent(dpy, glxWin, glxWin, ctx);
	piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);

	version_string = (char *) glGetString(GL_VERSION);

	if (!parse_version_string(version_string, &major, &minor)) {
		fprintf(stderr,
			"Unable to parse GL version string: %s\n",
			version_string);
		piglit_report_result(PIGLIT_FAIL);
	}

	if (major < 2 || (major == 2 && minor < 0)) {
		fprintf(stderr,
			"GL version too low: %s\n"
			"Expected 2.0 or greater.\n",
			version_string);
		piglit_report_result(PIGLIT_FAIL);
	}

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

done:
	GLX_ARB_create_context_teardown();

	piglit_report_result(PIGLIT_PASS);
	return 0;
}
コード例 #7
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;
}