int main(int argc, char **argv)
{
	static const EGLint attribs[] = {
		EGL_NONE
	};
	const char *version_string;
	int major;
	int minor;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES_BIT)) {
		fprintf(stderr, "ES 1 not available.\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	/* The EGL 1.4 spec says:
	 *
	 *     "attrib list may be NULL or empty (first attribute is EGL_NONE),
	 *     in which case all the attributes assume their default values"
	 *
	 * Specify an empty attrib_list and expect to receive an ES 1.x context.
	 */
	ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
	if (ctx == EGL_NO_CONTEXT) {
		fprintf(stderr, "eglCreateContext() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_dispatch_default_init(PIGLIT_DISPATCH_ES1);

	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 != 1 || (minor != 0 && minor != 1)) {
		fprintf(stderr,
			"Unexpected GLES version: %s\n"
			"Expected ES 1.0 or ES 1.1.\n",
			version_string);
		piglit_report_result(PIGLIT_FAIL);
	}

	eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
	eglDestroyContext(egl_dpy, ctx);

	EGL_KHR_create_context_teardown();

	piglit_report_result(PIGLIT_PASS);

	return EXIT_SUCCESS;
}
Example #2
0
int main(int argc, char **argv)
{
    bool pass = true;

    if (!EGL_KHR_create_context_setup(EGL_OPENGL_BIT)) {
        fprintf(stderr, "Desktop GL not available.\n");
        piglit_report_result(PIGLIT_SKIP);
    }
    eglBindAPI(EGL_OPENGL_API);

    pass = try_version(1, 0) && pass;
    pass = try_version(1, 1) && pass;
    pass = try_version(1, 2) && pass;
    pass = try_version(1, 3) && pass;
    pass = try_version(1, 4) && pass;
    pass = try_version(1, 5) && pass;
    pass = try_version(2, 0) && pass;
    pass = try_version(2, 1) && pass;
    pass = try_version(3, 0) && pass;
    pass = try_version(3, 1) && pass;

    EGL_KHR_create_context_teardown();

    piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
    return 0;
}
int main(int argc, char **argv)
{
	EGLint bad_attributes[] = {
		0xffff0000,
		EGL_SAMPLE_BUFFERS
	};
	bool pass = true;
	unsigned i;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_BIT)) {
		fprintf(stderr, "Desktop GL not available.\n");
		piglit_report_result(PIGLIT_SKIP);
	}
	eglBindAPI(EGL_OPENGL_API);

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

	EGL_KHR_create_context_teardown();

	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);

	return EXIT_SUCCESS;
}
Example #4
0
static enum piglit_result
check_opengl_es1(void)
{
	enum piglit_result result = PIGLIT_SKIP;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES_BIT))
		return PIGLIT_SKIP;

	/* Try OpenGL ES1 context versions. */
	fold_results(&result, check_flavor(10, API_GLES1));
	fold_results(&result, check_flavor(11, API_GLES1));
	fold_results(&result, check_flavor(12, API_GLES1));
	fold_results(&result, check_flavor(13, API_GLES1));

	EGL_KHR_create_context_teardown();
	return result;
}
Example #5
0
static enum piglit_result
check_opengl_es3(void)
{
	enum piglit_result result = PIGLIT_SKIP;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES3_BIT_KHR))
		return PIGLIT_SKIP;

	fold_results(&result, check_flavor(30, API_GLES3));
	fold_results(&result, check_flavor(31, API_GLES3));
	fold_results(&result, check_flavor(32, API_GLES3));
	fold_results(&result, check_flavor(33, API_GLES3));
	fold_results(&result, check_flavor(34, API_GLES3));
	fold_results(&result, check_flavor(35, API_GLES3));
	fold_results(&result, check_flavor(36, API_GLES3));
	fold_results(&result, check_flavor(37, API_GLES3));

	EGL_KHR_create_context_teardown();
	return result;
}
Example #6
0
static enum piglit_result
check_opengl_es2(void)
{
	enum piglit_result result = PIGLIT_SKIP;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES2_BIT))
		return PIGLIT_SKIP;

	/* Try OpenGL ES2 context versions. */
	fold_results(&result, check_flavor(20, API_GLES2));
	fold_results(&result, check_flavor(21, API_GLES2));
	fold_results(&result, check_flavor(22, API_GLES2));
	fold_results(&result, check_flavor(23, API_GLES2));
	fold_results(&result, check_flavor(24, API_GLES2));
	fold_results(&result, check_flavor(25, API_GLES2));
	fold_results(&result, check_flavor(26, API_GLES2));
	fold_results(&result, check_flavor(27, API_GLES2));

	EGL_KHR_create_context_teardown();
	return result;
}
Example #7
0
int main(int argc, char **argv)
{
	EGLint attribs[] = {
		EGL_CONTEXT_MAJOR_VERSION_KHR, 1,
		EGL_NONE
	};
	const char *version_string;
	int major;
	int minor;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES_BIT)) {
		attribs[1] = 2;
		if (!EGL_KHR_create_context_setup(EGL_OPENGL_ES2_BIT)) {
			fprintf(stderr, "ES 2 not available.\n");
			piglit_report_result(PIGLIT_SKIP);
		}
	}

	/* The EGL_KHR_create_context spec says:
	 *
	 *     "The default values for EGL_CONTEXT_MAJOR_VERSION_KHR and
	 *     EGL_CONTEXT_MINOR_VERSION_KHR are 1 and 0 respectively."
	 *
	 * Request an OpenGL ES 1.x or 2.0 context by explicitly setting the
	 * major version and leaving the minor version at the default value of
	 * 0.
	 *
	 * The EGLConfig's EGL_RENDERABLE_TYPE and the attribute list's
	 * EGL_CONTEXT_MAJOR_VERSION_KHR have been chosen so that the driver
	 * is required to succeed at context creation.
	 */
	ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
	if (ctx == EGL_NO_CONTEXT) {
		fprintf(stderr, "eglCreateContext() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	if (attribs[1] == 1) {
		/* FINISHME: Use PIGLIT_DISPATCH_ES1 when implemented. */
		piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
	} else if (attribs[1] == 2) {
		piglit_dispatch_default_init(PIGLIT_DISPATCH_ES2);
	}

	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 (!version_is_valid_for_context(attribs[1], major, minor)) {
		fprintf(stderr,
			"Unexpected GLES version: %s\n"
			"Expected ES %s.\n",
			version_string,
			attribs[1] == 1 ? "1.0 or 1.1" : "2.0 or 3.0");
		piglit_report_result(PIGLIT_FAIL);
	}

	eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
	eglDestroyContext(egl_dpy, ctx);

	EGL_KHR_create_context_teardown();

	piglit_report_result(PIGLIT_PASS);

	return EXIT_SUCCESS;
}
Example #8
0
static enum piglit_result
check_opengl(void)
{
	enum piglit_result result = PIGLIT_SKIP;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_BIT))
		return PIGLIT_SKIP;

	/* Try all valid OpenGL compatibility context versions. */
	fold_results(&result, check_flavor(10, API_GL_COMPAT));
	fold_results(&result, check_flavor(11, API_GL_COMPAT));
	fold_results(&result, check_flavor(12, API_GL_COMPAT));
	fold_results(&result, check_flavor(13, API_GL_COMPAT));
	fold_results(&result, check_flavor(14, API_GL_COMPAT));
	fold_results(&result, check_flavor(15, API_GL_COMPAT));
	fold_results(&result, check_flavor(16, API_GL_COMPAT));
	fold_results(&result, check_flavor(17, API_GL_COMPAT));
	fold_results(&result, check_flavor(20, API_GL_COMPAT));
	fold_results(&result, check_flavor(21, API_GL_COMPAT));
	fold_results(&result, check_flavor(22, API_GL_COMPAT));
	fold_results(&result, check_flavor(23, API_GL_COMPAT));
	fold_results(&result, check_flavor(24, API_GL_COMPAT));
	fold_results(&result, check_flavor(25, API_GL_COMPAT));
	fold_results(&result, check_flavor(26, API_GL_COMPAT));
	fold_results(&result, check_flavor(27, API_GL_COMPAT));
	fold_results(&result, check_flavor(30, API_GL_COMPAT));
	fold_results(&result, check_flavor(31, API_GL_COMPAT));
	fold_results(&result, check_flavor(32, API_GL_COMPAT));
	fold_results(&result, check_flavor(33, API_GL_COMPAT));
	fold_results(&result, check_flavor(34, API_GL_COMPAT));
	fold_results(&result, check_flavor(35, API_GL_COMPAT));
	fold_results(&result, check_flavor(36, API_GL_COMPAT));
	fold_results(&result, check_flavor(37, API_GL_COMPAT));
	fold_results(&result, check_flavor(40, API_GL_COMPAT));
	fold_results(&result, check_flavor(41, API_GL_COMPAT));
	fold_results(&result, check_flavor(42, API_GL_COMPAT));
	fold_results(&result, check_flavor(43, API_GL_COMPAT));
	fold_results(&result, check_flavor(44, API_GL_COMPAT));
	fold_results(&result, check_flavor(45, API_GL_COMPAT));
	fold_results(&result, check_flavor(46, API_GL_COMPAT));
	fold_results(&result, check_flavor(47, API_GL_COMPAT));

	/* Try all valid OpenGL core context versions. */
	fold_results(&result, check_flavor(32, API_GL_CORE));
	fold_results(&result, check_flavor(33, API_GL_CORE));
	fold_results(&result, check_flavor(34, API_GL_CORE));
	fold_results(&result, check_flavor(35, API_GL_CORE));
	fold_results(&result, check_flavor(36, API_GL_CORE));
	fold_results(&result, check_flavor(37, API_GL_CORE));
	fold_results(&result, check_flavor(40, API_GL_CORE));
	fold_results(&result, check_flavor(41, API_GL_CORE));
	fold_results(&result, check_flavor(42, API_GL_CORE));
	fold_results(&result, check_flavor(43, API_GL_CORE));
	fold_results(&result, check_flavor(44, API_GL_CORE));
	fold_results(&result, check_flavor(45, API_GL_CORE));
	fold_results(&result, check_flavor(46, API_GL_CORE));
	fold_results(&result, check_flavor(47, API_GL_CORE));

	EGL_KHR_create_context_teardown();
	return result;
}
int main(int argc, char **argv)
{
	EGLint attribs[] = {
		EGL_CONTEXT_MAJOR_VERSION_KHR, 2,
		EGL_NONE
	};
	const char *version_string;
	int major;
	int minor;

	if (!EGL_KHR_create_context_setup(EGL_OPENGL_BIT)) {
		fprintf(stderr, "Desktop GL not available.\n");
		piglit_report_result(PIGLIT_SKIP);
	}
	eglBindAPI(EGL_OPENGL_API);

	/* The EGL_KHR_create_context spec says:
	 *
	 *    "Typically, the implementation will return the most recent
	 *     version of OpenGL it supports which is backwards compatible
	 *     with the requested version."
	 *
	 *     "The default values for EGL_CONTEXT_MAJOR_VERSION_KHR and
	 *     EGL_CONTEXT_MINOR_VERSION_KHR are 1 and 0 respectively."
	 *
	 * 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 = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
	if (ctx == EGL_NO_CONTEXT) {
		fprintf(stderr, "eglCreateContext() failed with "
				"EGL_CONTEXT_MAJOR_VERSION_KHR=%d. skipping "
				"test.\n", attribs[1]);
		piglit_report_result(PIGLIT_SKIP);
	}

	if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	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 && (minor < 0 || minor > 1)) ||
	    (major == 3 && (minor != 0)) ||
	    (major < 2 || major > 3)) {
		fprintf(stderr,
			"Unexpected GL version: %s\n"
			"Expected GL 2.0, 2.1, or 3.0.\n",
			version_string);
		piglit_report_result(PIGLIT_FAIL);
	}

	eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
	eglDestroyContext(egl_dpy, ctx);

	EGL_KHR_create_context_teardown();

	piglit_report_result(PIGLIT_PASS);

	return EXIT_SUCCESS;
}
Example #10
0
static void
try_debug_flag(EGLenum context_api, EGLenum context_bit)
{
	GLint actual_flags = 0;
	piglit_dispatch_api dispatch_api;

	EGLint attribs[64];
	int i = 0;

	if (!EGL_KHR_create_context_setup(context_bit))
		piglit_report_result(PIGLIT_SKIP);

	if (!piglit_egl_bind_api(context_api))
		piglit_report_result(PIGLIT_SKIP);

        attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
        attribs[i++] = EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;

        switch (context_bit) {
        case EGL_OPENGL_BIT:
           break;
        case EGL_OPENGL_ES_BIT:
              attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
              attribs[i++] = 1;
              break;
        case EGL_OPENGL_ES2_BIT:
              attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
              attribs[i++] = 2;
              break;
        case EGL_OPENGL_ES3_BIT_KHR:
           attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
           attribs[i++] = 3;
           break;
        default:
           assert(0);
           break;
        }

        attribs[i++] = EGL_NONE;

	ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
	if (!ctx) {
		if (piglit_check_egl_error(EGL_BAD_MATCH)) {
			piglit_report_result(PIGLIT_SKIP);
		} else {
			piglit_report_result(PIGLIT_FAIL);
		}
	}

	if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
		fprintf(stderr, "eglMakeCurrent() failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	switch (context_bit) {
	case EGL_OPENGL_BIT:
		dispatch_api = PIGLIT_DISPATCH_GL;
		break;
	case EGL_OPENGL_ES_BIT:
		/* Piglit doesn't yet have ES1 dispatch, so just initialize
		 * with ES2 dispatch. This should be safe because the only
		 * GL functions called by this test are glGetString() and
		 * glGetIntegerv().
		 */
		dispatch_api = PIGLIT_DISPATCH_ES2;
		break;
	case EGL_OPENGL_ES2_BIT:
	case EGL_OPENGL_ES3_BIT_KHR:
		dispatch_api = PIGLIT_DISPATCH_ES2;
		break;
	default:
		dispatch_api = 0;
		assert(0);
		break;
	}

	piglit_dispatch_default_init(dispatch_api);

	switch (context_bit) {
	case EGL_OPENGL_BIT:
		if (piglit_get_gl_version() < 31 &&
		    !piglit_is_extension_supported("GL_KHR_debug")) {
			fprintf(stderr, "In OpenGL, either OpenGL 3.1 or "
				"GL_KHR_debug is required to query "
				"GL_CONTEXT_FLAGS\n");
			piglit_report_result(PIGLIT_SKIP);
		}
		break;
	case EGL_OPENGL_ES_BIT:
	case EGL_OPENGL_ES2_BIT:
	case EGL_OPENGL_ES3_BIT_KHR:
		if (!piglit_is_extension_supported("GL_KHR_debug")) {
			fprintf(stderr, "In OpenGL ES, GL_KHR_debug is "
				"required to query GL_CONTEXT_FLAGS\n");
			piglit_report_result(PIGLIT_SKIP);
		}
		break;
	default:
		assert(0);
		break;
	}

	glGetIntegerv(GL_CONTEXT_FLAGS, &actual_flags);

	if (!piglit_check_gl_error(GL_NO_ERROR)) {
		fprintf(stderr, "glGetIntegerv(GL_CONTEXT_FLAGS) failed\n");
		piglit_report_result(PIGLIT_FAIL);
	}

	/* Verify that this is actually a debug context. */
	if (!(actual_flags & GL_CONTEXT_FLAG_DEBUG_BIT)) {
		fprintf(stderr,
			"GL_CONTEXT_FLAGS=0x%x does not contain "
			"GL_CONTEXT_FLAG_DEBUG_BIT=0x%x\n",
			actual_flags, GL_CONTEXT_FLAG_DEBUG_BIT);
		piglit_report_result(PIGLIT_FAIL);
	}

	eglDestroyContext(egl_dpy, ctx);
	EGL_KHR_create_context_teardown();

	piglit_report_result(PIGLIT_PASS);
}