/** * \brief Return a attribute list suitable for waffle_config_choose(). * * The funcion deduces the values of WAFFLE_CONTEXT_API, * WAFFLE_CONTEXT_PROFILE, WAFFLE_CONTEXT_MAJOR_VERSION, and * WAFFLE_CONTEXT_MINOR_VERSION from the given context \a flavor and \a * test_config. The \a partial_attrib_list must not contain any of those * attributes. Any attributes in \a partial_attrib_list are added to the * returned attribute list. */ static int32_t* make_config_attrib_list(const struct piglit_gl_test_config *test_config, enum context_flavor flavor, const int32_t partial_attrib_list[]) { int32_t head_attrib_list[64]; int32_t junk; int i; /* Derived class must not provide any context attributes. */ assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_API, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_PROFILE, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_MAJOR_VERSION, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_MINOR_VERSION, &junk) == false); switch (flavor) { case CONTEXT_GL_CORE: assert(test_config->supports_gl_core_version); i = 0; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = WAFFLE_CONTEXT_OPENGL; if (test_config->supports_gl_core_version >= 32) { head_attrib_list[i++] = WAFFLE_CONTEXT_PROFILE; head_attrib_list[i++] = WAFFLE_CONTEXT_CORE_PROFILE; } head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_core_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_core_version % 10; break; case CONTEXT_GL_COMPAT: assert(test_config->supports_gl_compat_version); i = 0; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = WAFFLE_CONTEXT_OPENGL; head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_compat_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_compat_version % 10; break; case CONTEXT_GL_ES: { int32_t waffle_context_api; assert(test_config->supports_gl_es_version); if (test_config->supports_gl_es_version < 40 && test_config->supports_gl_es_version >= 30) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES3; } else if (test_config->supports_gl_es_version >= 20) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES2; } else if (test_config->supports_gl_es_version >= 10) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES1; } else { printf("piglit: error: config attribute " "'supports_gl_es_version' has " "bad value %d\n", test_config->supports_gl_es_version); piglit_report_result(PIGLIT_FAIL); } i = 0; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = waffle_context_api; head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_es_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = test_config->supports_gl_es_version % 10; break; } default: assert(0); break; } if (test_config->require_forward_compatible_context) { head_attrib_list[i++] = WAFFLE_CONTEXT_FORWARD_COMPATIBLE; head_attrib_list[i++] = true; } if (test_config->require_debug_context) { head_attrib_list[i++] = WAFFLE_CONTEXT_DEBUG; head_attrib_list[i++] = true; } head_attrib_list[i++] = 0; return concat_attrib_lists(head_attrib_list, partial_attrib_list); }
/** * \brief Construct human-readable description of the context and an * attribute list suitable for waffle_config_choose(). * * The function deduces the values of WAFFLE_CONTEXT_API, * WAFFLE_CONTEXT_PROFILE, WAFFLE_CONTEXT_MAJOR_VERSION, * WAFFLE_CONTEXT_MINOR_VERSION, WAFFLE_CONTEXT_FORWARD_COMPATIBLE and * WAFFLE_CONTEXT_DEBUG from the given context \a flavor and \a * test_config. At the same time, it produces human-readable description * of the context. At most \a bufsize bytes, including the terminal null, * are written to \a buf. * * The \a partial_attrib_list must not contain any of those * attributes. Any attributes in \a partial_attrib_list are added to the * returned attribute list \a attrib_list. */ static void parse_test_config(const struct piglit_gl_test_config *test_config, enum context_flavor flavor, char buf[], size_t bufsize, const int32_t partial_attrib_list[], int32_t *attrib_list[]) { const char *api_str, *profile_str = "", *fwd_compat_str = "", *debug_str = ""; int32_t major_version, minor_version; int32_t head_attrib_list[64]; int32_t junk; int i; /* Derived class must not provide any context attributes. */ (void)junk; assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_API, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_PROFILE, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_MAJOR_VERSION, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_MINOR_VERSION, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_FORWARD_COMPATIBLE, &junk) == false); assert(waffle_attrib_list_get(partial_attrib_list, WAFFLE_CONTEXT_DEBUG, &junk) == false); switch (flavor) { case CONTEXT_GL_CORE: assert(test_config->supports_gl_core_version); i = 0; api_str = "OpenGL"; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = WAFFLE_CONTEXT_OPENGL; profile_str = "Core "; if (test_config->supports_gl_core_version >= 32) { head_attrib_list[i++] = WAFFLE_CONTEXT_PROFILE; head_attrib_list[i++] = WAFFLE_CONTEXT_CORE_PROFILE; } major_version = test_config->supports_gl_core_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = major_version; minor_version = test_config->supports_gl_core_version % 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = minor_version; break; case CONTEXT_GL_COMPAT: assert(test_config->supports_gl_compat_version); i = 0; api_str = "OpenGL"; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = WAFFLE_CONTEXT_OPENGL; profile_str = "Compatibility "; if (test_config->supports_gl_compat_version >= 32) { head_attrib_list[i++] = WAFFLE_CONTEXT_PROFILE; head_attrib_list[i++] = WAFFLE_CONTEXT_COMPATIBILITY_PROFILE; } major_version = test_config->supports_gl_compat_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = major_version; minor_version = test_config->supports_gl_compat_version % 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = minor_version; break; case CONTEXT_GL_ES: { int32_t waffle_context_api; assert(test_config->supports_gl_es_version); if (test_config->supports_gl_es_version < 40 && test_config->supports_gl_es_version >= 30) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES3; } else if (test_config->supports_gl_es_version >= 20) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES2; } else if (test_config->supports_gl_es_version >= 10) { waffle_context_api = WAFFLE_CONTEXT_OPENGL_ES1; } else { printf("piglit: error: config attribute " "'supports_gl_es_version' has " "bad value %d\n", test_config->supports_gl_es_version); piglit_report_result(PIGLIT_FAIL); } i = 0; api_str = "OpenGL ES"; head_attrib_list[i++] = WAFFLE_CONTEXT_API; head_attrib_list[i++] = waffle_context_api; major_version = test_config->supports_gl_es_version / 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MAJOR_VERSION; head_attrib_list[i++] = major_version; minor_version = test_config->supports_gl_es_version % 10; head_attrib_list[i++] = WAFFLE_CONTEXT_MINOR_VERSION; head_attrib_list[i++] = minor_version; break; } } /* There are no 3.1 core profiles -- the closest is 3.1 context without * ARB_compatibility or a 3.2 core context --, and setting * forward-compatible flag should ensure we don't get a 3.1 context w/ * ARB_compatibility. */ if (test_config->require_forward_compatible_context || (flavor == CONTEXT_GL_CORE && test_config->supports_gl_core_version == 31)) { fwd_compat_str = "Forward-Compatible "; head_attrib_list[i++] = WAFFLE_CONTEXT_FORWARD_COMPATIBLE; head_attrib_list[i++] = true; } if (test_config->require_debug_context) { debug_str = "Debug "; head_attrib_list[i++] = WAFFLE_CONTEXT_DEBUG; head_attrib_list[i++] = true; } head_attrib_list[i++] = 0; if (bufsize != 0) { snprintf(buf, bufsize, "%s %d.%d %s%s%sContext", api_str, major_version, minor_version, fwd_compat_str, profile_str, debug_str); } *attrib_list = concat_attrib_lists(head_attrib_list, partial_attrib_list); }
/** * Return a human-readable description of the context specified by an \a * attrib_list suitable for waffle_config_choose(). At most \a bufsize bytes, * including the terminal null, are written to \a buf. */ static void make_context_description(char buf[], size_t bufsize, const int32_t attrib_list[]) { int32_t api = 0, profile = 0, major_version = 0, minor_version = 0, fwd_compat = 0, debug = 0; const char *api_str = NULL, *profile_str = NULL, *fwd_compat_str = NULL, *debug_str = NULL; if (bufsize == 0) { return; } waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_API, &api); waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_PROFILE, &profile); waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_MAJOR_VERSION, &major_version); waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_MINOR_VERSION, &minor_version); waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_FORWARD_COMPATIBLE, &fwd_compat); waffle_attrib_list_get(attrib_list, WAFFLE_CONTEXT_DEBUG, &debug); switch (api) { case WAFFLE_CONTEXT_OPENGL: api_str = "OpenGL"; break; case WAFFLE_CONTEXT_OPENGL_ES1: case WAFFLE_CONTEXT_OPENGL_ES2: case WAFFLE_CONTEXT_OPENGL_ES3: api_str = "OpenGL ES"; break; default: assert(0); break; } switch (profile) { case WAFFLE_CONTEXT_CORE_PROFILE: profile_str = "Core "; break; case WAFFLE_CONTEXT_COMPATIBILITY_PROFILE: profile_str = "Compatibility "; break; case 0: profile_str = ""; break; default: assert(0); break; } if (fwd_compat) { fwd_compat_str = "Forward-Compatible "; } else { fwd_compat_str = ""; } if (debug) { debug_str = "Debug "; } else { debug_str = ""; } snprintf(buf, bufsize, "%s %d.%d %s%s%sContext", api_str, major_version, minor_version, fwd_compat_str, profile_str, debug_str); }