[waffle] [PATCH 04/12] core: add JSON library
A small library for building JSON strings. Signed-off-by: Frank Henigman --- src/waffle/CMakeLists.txt | 1 + src/waffle/core/json.c| 235 ++ src/waffle/core/json.h| 93 ++ 3 files changed, 329 insertions(+) create mode 100644 src/waffle/core/json.c create mode 100644 src/waffle/core/json.h diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt index dd9fa11..99df29d 100644 --- a/src/waffle/CMakeLists.txt +++ b/src/waffle/CMakeLists.txt @@ -71,6 +71,7 @@ set(waffle_sources api/waffle_gl_misc.c api/waffle_init.c api/waffle_window.c +core/json.c core/wcore_attrib_list.c core/wcore_config_attrs.c core/wcore_display.c diff --git a/src/waffle/core/json.c b/src/waffle/core/json.c new file mode 100644 index 000..75ba35c --- /dev/null +++ b/src/waffle/core/json.c @@ -0,0 +1,235 @@ +// Copyright 2015 Google +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// - Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// - Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include +#include +#include +#include +#include + +#include "json.h" + +#include "wcore_error.h" +#include "wcore_util.h" + +struct json { +char *buf; // json string +size_t size; // amount of memory at 'buf' +char *pos; // end of json string +bool comma; // need a comma before next value +}; + +// Append 's' to json buffer, growing it as needed. +static void +put(struct json *jj, char *s) +{ +if (!jj->buf) +return; + +for (;;) { +if (!(*jj->pos = *s++)) +break; +if (++jj->pos == jj->buf + jj->size) { +size_t z = jj->size * 2; +jj->buf = realloc(jj->buf, z); +if (!jj->buf) +return; +jj->pos = jj->buf + jj->size; +jj->size = z; +} +} +} + +// Format 's' as json and write to 'p' +static char* +string(char *p, const char *s) +{ +*p++ = '"'; +for (;; ++s) { +char e; +switch (*s) { +default: +*p++ = *s; +continue; +case '\0': +*p++ = '"'; +*p = '\0'; +return p; +case '\b': e = 'b'; break; +case '\f': e = 'f'; break; +case '\n': e = 'n'; break; +case '\r': e = 'r'; break; +case '\t': e = 't'; break; +case '"': e = '"'; break; +case '\\': e = '\\'; break; +} +*p++ = '\\'; +*p++ = e; +} +} + +struct json* +json_init() +{ +struct json *jj; +jj = malloc(sizeof(*jj)); +if (jj) { +jj->size = 1; +jj->buf = jj->pos = strdup(""); +if (jj->buf) +jj->comma = false; +} +return jj; +} + +char * +json_destroy(struct json *jj) +{ +char *result = jj->buf; +free(jj); +return result; +} + +char* +json_key(const char *s) +{ +// If each character is escaped, we need double the length, +// plus quotes and " : " and final null. +char *buf = malloc(strlen(s) * 2 + 6); +if (buf) +strcpy(string(buf, s), " : "); +return buf; +} + +char* +json_str(const char *s) +{ +// If each character is escaped, we need double the length, +// plus quotes and final null. +char *buf = malloc(strlen(s) * 2 + 3); +if (buf) +string(buf, s); +return buf; +} + +char* +json_split(const char *s, const char *sep) +{ +char *dup = strdup(s); +if (!dup) +return NULL; + +// The worst case space requirement is for a string of length L=2N+1 +// which has N separators and N+1 1-character items. +// N separators each become 4 characters '", "' for 4N characters. +// If
[waffle] [PATCH 07/12] waffle: support platform-specific information
Add a platform hook so platform-specific information can be included by waffle_display_info_json(). Signed-off-by: Frank Henigman --- src/waffle/api/waffle_display.c | 10 +- src/waffle/core/wcore_platform.h | 4 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/waffle/api/waffle_display.c b/src/waffle/api/waffle_display.c index 7abe2ef..d6988ac 100644 --- a/src/waffle/api/waffle_display.c +++ b/src/waffle/api/waffle_display.c @@ -367,8 +367,16 @@ waffle_display_info_json(struct waffle_display *self, bool platform_too) json_appendv(jj, "{", "generic", "{", ""); add_generic_info(jj, wc_self->current_context); -json_appendv(jj, "}", "}", ""); +json_append(jj, "}"); +if (platform_too) { +json_appendv(jj, "platform", "{", ""); +if (api_platform->vtbl->display.info_json) +api_platform->vtbl->display.info_json(wc_self, jj); +json_append(jj, "}"); +} + +json_append(jj, "}"); return json_destroy(jj); } diff --git a/src/waffle/core/wcore_platform.h b/src/waffle/core/wcore_platform.h index 30d1c6c..9e890c1 100644 --- a/src/waffle/core/wcore_platform.h +++ b/src/waffle/core/wcore_platform.h @@ -30,6 +30,7 @@ #include #include "c99_compat.h" +struct json; struct wcore_config; struct wcore_config_attrs; struct wcore_context; @@ -77,6 +78,9 @@ struct wcore_platform_vtbl { struct wcore_display *display, int32_t context_api); +void +(*info_json)(struct wcore_display *display, struct json *); + /// May be null. union waffle_native_display* (*get_native)(struct wcore_display *display); -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 10/12] egl: implement platform-specific information
Implement the platform hook of waffle_display_info_json() so it can pick up egl-specific information. Signed-off-by: Frank Henigman --- src/waffle/egl/wegl_display.c | 32 ++-- src/waffle/egl/wegl_display.h | 4 src/waffle/egl/wegl_platform.h | 3 +++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/waffle/egl/wegl_display.c b/src/waffle/egl/wegl_display.c index 88fce7a..dcfe934 100644 --- a/src/waffle/egl/wegl_display.c +++ b/src/waffle/egl/wegl_display.c @@ -25,6 +25,8 @@ #include +#include "json.h" + #include "wcore_error.h" #include "wcore_platform.h" @@ -63,7 +65,6 @@ wegl_display_init(struct wegl_display *dpy, { struct wegl_platform *plat = wegl_platform(wc_plat); bool ok; -EGLint major, minor; ok = wcore_display_init(&dpy->wcore, wc_plat); if (!ok) @@ -75,7 +76,7 @@ wegl_display_init(struct wegl_display *dpy, goto fail; } -ok = plat->eglInitialize(dpy->egl, &major, &minor); +ok = plat->eglInitialize(dpy->egl, &plat->major, &plat->minor); if (!ok) { wegl_emit_error(plat, "eglInitialize"); goto fail; @@ -139,3 +140,30 @@ wegl_display_supports_context_api(struct wcore_display *wc_dpy, return wc_plat->vtbl->dl_can_open(wc_plat, waffle_dl); } + +void +wegl_display_info_json(struct wcore_display *wc_dpy, struct json *jj) +{ +struct wegl_display *dpy = wegl_display(wc_dpy); +struct wegl_platform *plat = wegl_platform(dpy->wcore.platform); + +const char *version = plat->eglQueryString(dpy->egl, EGL_VERSION); +const char *vendor = plat->eglQueryString(dpy->egl, EGL_VENDOR); +#ifdef EGL_VERSION_1_2 +const char *apis = plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS); +#endif +const char *ext = plat->eglQueryString(dpy->egl, EGL_EXTENSIONS); + +json_appendv(jj, +"version", "{", +"major", json_num(plat->major), +"minor", json_num(plat->minor), +"string", json_str(version), +"}", +"vendor", json_str(vendor), +#ifdef EGL_VERSION_1_2 +"client_apis", "[", json_split(apis, " "), "]", +#endif +"extensions", "[", json_split(ext, " "), "]", +""); +} diff --git a/src/waffle/egl/wegl_display.h b/src/waffle/egl/wegl_display.h index 43b83ef..20a3de8 100644 --- a/src/waffle/egl/wegl_display.h +++ b/src/waffle/egl/wegl_display.h @@ -32,6 +32,7 @@ #include "wcore_display.h" +struct json; struct wcore_display; struct wegl_display { @@ -56,3 +57,6 @@ wegl_display_teardown(struct wegl_display *dpy); bool wegl_display_supports_context_api(struct wcore_display *wc_dpy, int32_t waffle_context_api); + +void +wegl_display_info_json(struct wcore_display *wc_self, struct json *); diff --git a/src/waffle/egl/wegl_platform.h b/src/waffle/egl/wegl_platform.h index 7ae0490..c171b0a 100644 --- a/src/waffle/egl/wegl_platform.h +++ b/src/waffle/egl/wegl_platform.h @@ -34,6 +34,9 @@ struct wegl_platform { struct wcore_platform wcore; +// EGL version from eglInitialize +EGLint major, minor; + // EGL function pointers void *eglHandle; -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 08/12] wflinfo: add flag for platform-specific info
When given a "-s" flag wflinfo will now also print some platform-specific information. This affects only JSON output, not other formats. Signed-off-by: Frank Henigman --- src/utils/wflinfo.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c index 58f5688..6732274 100644 --- a/src/utils/wflinfo.c +++ b/src/utils/wflinfo.c @@ -80,6 +80,9 @@ static const char *usage_message = "-f, --format\n" "One of: original (default) or json\n" "\n" +"-s, --specific\n" +"Include platform-specific information (json format only).\n" +"\n" "--forward-compatible\n" "Create a forward-compatible context.\n" "\n" @@ -104,6 +107,7 @@ enum { OPT_PROFILE, OPT_FORMAT = 'f', OPT_VERBOSE = 'v', +OPT_SPECIFIC = 's', OPT_DEBUG_CONTEXT, OPT_FORWARD_COMPATIBLE, OPT_HELP = 'h', @@ -116,6 +120,7 @@ static const struct option get_opts[] = { { .name = "profile",.has_arg = required_argument, .val = OPT_PROFILE }, { .name = "format", .has_arg = required_argument, .val = OPT_FORMAT }, { .name = "verbose",.has_arg = no_argument, .val = OPT_VERBOSE }, +{ .name = "specific", .has_arg = no_argument, .val = OPT_SPECIFIC }, { .name = "debug-context", .has_arg = no_argument, .val = OPT_DEBUG_CONTEXT }, { .name = "forward-compatible", .has_arg = no_argument, .val = OPT_FORWARD_COMPATIBLE }, { .name = "help", .has_arg = no_argument, .val = OPT_HELP }, @@ -257,6 +262,8 @@ struct options { bool verbose; +bool specific; + bool context_forward_compatible; bool context_debug; @@ -343,7 +350,7 @@ parse_args(int argc, char *argv[], struct options *opts) opterr = 0; while (loop_get_opt) { -int opt = getopt_long(argc, argv, "a:f:hp:vV:", get_opts, NULL); +int opt = getopt_long(argc, argv, "a:f:hp:svV:", get_opts, NULL); switch (opt) { case -1: loop_get_opt = false; @@ -405,6 +412,9 @@ parse_args(int argc, char *argv[], struct options *opts) case OPT_VERBOSE: opts->verbose = true; break; +case OPT_SPECIFIC: +opts->specific = true; +break; case OPT_FORWARD_COMPATIBLE: opts->context_forward_compatible = true; break; @@ -1146,7 +1156,7 @@ main(int argc, char **argv) break; case FORMAT_JSON: -info = waffle_display_info_json(dpy, false); +info = waffle_display_info_json(dpy, opts.specific); if (info) { printf("%s\n", info); free(info); -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 06/12] wflinfo: add option for JSON output
With "-f json" wflinfo will now print the result of waffle_display_info_json(). Signed-off-by: Frank Henigman --- src/utils/wflinfo.c | 40 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c index 268d4b8..58f5688 100644 --- a/src/utils/wflinfo.c +++ b/src/utils/wflinfo.c @@ -77,6 +77,9 @@ static const char *usage_message = "-v, --verbose\n" "Print more information.\n" "\n" +"-f, --format\n" +"One of: original (default) or json\n" +"\n" "--forward-compatible\n" "Create a forward-compatible context.\n" "\n" @@ -99,6 +102,7 @@ enum { OPT_API = 'a', OPT_VERSION = 'V', OPT_PROFILE, +OPT_FORMAT = 'f', OPT_VERBOSE = 'v', OPT_DEBUG_CONTEXT, OPT_FORWARD_COMPATIBLE, @@ -110,6 +114,7 @@ static const struct option get_opts[] = { { .name = "api",.has_arg = required_argument, .val = OPT_API }, { .name = "version",.has_arg = required_argument, .val = OPT_VERSION }, { .name = "profile",.has_arg = required_argument, .val = OPT_PROFILE }, +{ .name = "format", .has_arg = required_argument, .val = OPT_FORMAT }, { .name = "verbose",.has_arg = no_argument, .val = OPT_VERBOSE }, { .name = "debug-context", .has_arg = no_argument, .val = OPT_DEBUG_CONTEXT }, { .name = "forward-compatible", .has_arg = no_argument, .val = OPT_FORWARD_COMPATIBLE }, @@ -248,6 +253,8 @@ struct options { int context_major; int context_minor; +enum format { FORMAT_ORIGINAL, FORMAT_JSON } format; + bool verbose; bool context_forward_compatible; @@ -330,12 +337,13 @@ parse_args(int argc, char *argv[], struct options *opts) opts->context_profile = WAFFLE_NONE; opts->context_major = WAFFLE_DONT_CARE; opts->context_minor = WAFFLE_DONT_CARE; +opts->format = FORMAT_ORIGINAL; // prevent getopt_long from printing an error message opterr = 0; while (loop_get_opt) { -int opt = getopt_long(argc, argv, "a:hp:vV:", get_opts, NULL); +int opt = getopt_long(argc, argv, "a:f:hp:vV:", get_opts, NULL); switch (opt) { case -1: loop_get_opt = false; @@ -384,6 +392,16 @@ parse_args(int argc, char *argv[], struct options *opts) optarg); } break; +case OPT_FORMAT: +if (strcmp(optarg, "original") == 0) { +opts->format = FORMAT_ORIGINAL; +} else if (strcmp(optarg, "json") == 0) { +opts->format = FORMAT_JSON; +} else { +usage_error_printf("'%s' is not a valid format", + optarg); +} +break; case OPT_VERBOSE: opts->verbose = true; break; @@ -1119,9 +1137,23 @@ main(int argc, char **argv) glGetStringi = waffle_get_proc_address("glGetStringi"); } -ok = print_wflinfo(&opts); -if (!ok) -error_waffle(); +char *info; +switch (opts.format) { +case FORMAT_ORIGINAL: +ok = print_wflinfo(&opts); +if (!ok) +error_waffle(); +break; + +case FORMAT_JSON: +info = waffle_display_info_json(dpy, false); +if (info) { +printf("%s\n", info); +free(info); +} else +error_waffle(); +break; +} ok = waffle_make_current(dpy, NULL, NULL); if (!ok) -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 09/12] glx: implement platform-specific information
Implement the platform hook of waffle_display_info_json() so it can pick up glx-specific information. Signed-off-by: Frank Henigman --- src/waffle/glx/glx_display.c | 41 + src/waffle/glx/glx_display.h | 4 src/waffle/glx/glx_platform.c | 4 src/waffle/glx/glx_platform.h | 3 +++ 4 files changed, 52 insertions(+) diff --git a/src/waffle/glx/glx_display.c b/src/waffle/glx/glx_display.c index 24e967c..6e7cc65 100644 --- a/src/waffle/glx/glx_display.c +++ b/src/waffle/glx/glx_display.c @@ -25,6 +25,8 @@ #include +#include "json.h" + #include "wcore_error.h" #include "linux_platform.h" @@ -134,6 +136,45 @@ glx_display_supports_context_api(struct wcore_display *wc_self, } } +void +glx_display_info_json(struct wcore_display *wc_self, struct json *jj) +{ +struct glx_display *self = glx_display(wc_self); +struct glx_platform *plat = glx_platform(wc_self->platform); +Display *dpy = self->x11.xlib; +int screen = self->x11.screen; + +int major, minor; +if (!plat->glXQueryVersion(dpy, &major, &minor)) { +wcore_errorf(WAFFLE_ERROR_UNKNOWN, "glXQueryVersion failed"); +return json_append(jj, NULL); +} + +const char *svendor = plat->glXQueryServerString(dpy, screen, GLX_VENDOR); +const char *sversion = plat->glXQueryServerString(dpy, screen, GLX_VERSION); +const char *sext = plat->glXQueryServerString(dpy, screen, GLX_EXTENSIONS); +const char *cvendor = plat->glXGetClientString(dpy, GLX_VENDOR); +const char *cversion = plat->glXGetClientString(dpy, GLX_VERSION); +const char *cext = plat->glXGetClientString(dpy, GLX_EXTENSIONS); + +json_appendv(jj, +"version", "{", +"major", json_num(major), +"minor", json_num(minor), +"}", +"server", "{", +"vendor", json_str(svendor), +"version",json_str(sversion), +"extensions", "[", json_split(sext, " "), "]", +"}", +"client", "{", +"vendor", json_str(cvendor), +"version",json_str(cversion), +"extensions", "[", json_split(cext, " "), "]", +"}", +""); +} + union waffle_native_display* glx_display_get_native(struct wcore_display *wc_self) { diff --git a/src/waffle/glx/glx_display.h b/src/waffle/glx/glx_display.h index 4b8f687..00d35ad 100644 --- a/src/waffle/glx/glx_display.h +++ b/src/waffle/glx/glx_display.h @@ -38,6 +38,7 @@ #include "x11_display.h" +struct json; struct wcore_platform; struct glx_display { @@ -66,5 +67,8 @@ bool glx_display_supports_context_api(struct wcore_display *wc_self, int32_t context_api); +void +glx_display_info_json(struct wcore_display *wc_self, struct json *); + union waffle_native_display* glx_display_get_native(struct wcore_display *wc_self); diff --git a/src/waffle/glx/glx_platform.c b/src/waffle/glx/glx_platform.c index 4fb2eed..ea49f09 100644 --- a/src/waffle/glx/glx_platform.c +++ b/src/waffle/glx/glx_platform.c @@ -105,6 +105,9 @@ glx_platform_create(void) RETRIEVE_GLX_SYMBOL(glXMakeCurrent); RETRIEVE_GLX_SYMBOL(glXQueryExtensionsString); +RETRIEVE_GLX_SYMBOL(glXQueryServerString); +RETRIEVE_GLX_SYMBOL(glXQueryVersion); +RETRIEVE_GLX_SYMBOL(glXGetClientString); RETRIEVE_GLX_SYMBOL(glXGetProcAddress); RETRIEVE_GLX_SYMBOL(glXGetVisualFromFBConfig); @@ -186,6 +189,7 @@ static const struct wcore_platform_vtbl glx_platform_vtbl = { .connect = glx_display_connect, .destroy = glx_display_destroy, .supports_context_api = glx_display_supports_context_api, +.info_json = glx_display_info_json, .get_native = glx_display_get_native, }, diff --git a/src/waffle/glx/glx_platform.h b/src/waffle/glx/glx_platform.h index 36ddff6..aefc0ee 100644 --- a/src/waffle/glx/glx_platform.h +++ b/src/waffle/glx/glx_platform.h @@ -47,6 +47,9 @@ struct glx_platform { Bool (*glXMakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx); const char *(*glXQueryExtensionsString)(Display *dpy, int screen); +const char *(*glXQueryServerString)(Display *dpy, int screen, int name); +const char *(*glXQueryVersion)(Display *dpy, int *major, int *minor); +const char *(*glXGetClientString)(Display *dpy, int name); void *(*glXGetProcAddress)(const GLubyte *procname); XVisualInfo *(*glXGetVisualFromFBConfig)(Display *dpy, GLXFBConfig config); -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 01/12] core: store platform type in wcore_platform
Facilitates platform-specific code in core functions, like the forthcoming wflinfo-like function. Signed-off-by: Frank Henigman --- src/waffle/api/waffle_init.c | 32 +--- src/waffle/core/wcore_platform.h | 1 + 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/waffle/api/waffle_init.c b/src/waffle/api/waffle_init.c index 60091d1..3d8d350 100644 --- a/src/waffle/api/waffle_init.c +++ b/src/waffle/api/waffle_init.c @@ -142,43 +142,53 @@ waffle_init_parse_attrib_list( static struct wcore_platform* waffle_init_create_platform(int32_t waffle_platform) { +struct wcore_platform *wc_platform = NULL; + switch (waffle_platform) { #ifdef WAFFLE_HAS_ANDROID case WAFFLE_PLATFORM_ANDROID: -return droid_platform_create(); +wc_platform = droid_platform_create(); +break; #endif #ifdef WAFFLE_HAS_CGL case WAFFLE_PLATFORM_CGL: -return cgl_platform_create(); +wc_platform = cgl_platform_create(); +break; #endif #ifdef WAFFLE_HAS_GLX case WAFFLE_PLATFORM_GLX: -return glx_platform_create(); +wc_platform = glx_platform_create(); +break; #endif #ifdef WAFFLE_HAS_WAYLAND case WAFFLE_PLATFORM_WAYLAND: -return wayland_platform_create(); +wc_platform = wayland_platform_create(); +break; #endif #ifdef WAFFLE_HAS_X11_EGL case WAFFLE_PLATFORM_X11_EGL: -return xegl_platform_create(); +wc_platform = xegl_platform_create(); +break; #endif #ifdef WAFFLE_HAS_GBM case WAFFLE_PLATFORM_GBM: -return wgbm_platform_create(); +wc_platform = wgbm_platform_create(); +break; #endif #ifdef WAFFLE_HAS_WGL case WAFFLE_PLATFORM_WGL: -return wgl_platform_create(); +wc_platform = wgl_platform_create(); +break; #endif #ifdef WAFFLE_HAS_NACL case WAFFLE_PLATFORM_NACL: -return nacl_platform_create(); +wc_platform = nacl_platform_create(); +break; #endif -default: -assert(false); -return NULL; } +assert(wc_platform); +wc_platform->waffle_platform = waffle_platform; +return wc_platform; } WAFFLE_API bool diff --git a/src/waffle/core/wcore_platform.h b/src/waffle/core/wcore_platform.h index 780d07a..30d1c6c 100644 --- a/src/waffle/core/wcore_platform.h +++ b/src/waffle/core/wcore_platform.h @@ -139,6 +139,7 @@ struct wcore_platform_vtbl { struct wcore_platform { const struct wcore_platform_vtbl *vtbl; +int32_t waffle_platform; // WAFFLE_PLATFORM_* enum }; static inline bool -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 12/12] x11_egl: implement platform-specific information
Implement the platform hook of waffle_display_info_json() so it can pick up x11_egl-specific information. So far only egl information is provided, nothing specific to x11. Signed-off-by: Frank Henigman --- src/waffle/xegl/xegl_platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/waffle/xegl/xegl_platform.c b/src/waffle/xegl/xegl_platform.c index e36a41b..2f5e922 100644 --- a/src/waffle/xegl/xegl_platform.c +++ b/src/waffle/xegl/xegl_platform.c @@ -152,6 +152,7 @@ static const struct wcore_platform_vtbl xegl_platform_vtbl = { .connect = xegl_display_connect, .destroy = xegl_display_destroy, .supports_context_api = wegl_display_supports_context_api, +.info_json = wegl_display_info_json, .get_native = xegl_display_get_native, }, -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 11/12] gbm: implement platform-specific information
Implement the platform hook of waffle_display_info_json() so it can pick up gbm-specific information. So far only egl information is provided, nothing specific to gbm. Signed-off-by: Frank Henigman --- src/waffle/gbm/wgbm_platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c index 0fc0352..0d5675a 100644 --- a/src/waffle/gbm/wgbm_platform.c +++ b/src/waffle/gbm/wgbm_platform.c @@ -191,6 +191,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl = { .destroy = wgbm_display_destroy, .supports_context_api = wegl_display_supports_context_api, .get_native = wgbm_display_get_native, +.info_json = wegl_display_info_json, }, .config = { -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 00/12] JSON and platform-specific wflinfo
This patch set does two main things, the second of which could just as well be a separate patch set. 1-6: Move wflinfo functionality into the api, info returned as a json string. 7-12: Extend the functionality to include platform-specific info, such as provided by glxinfo. After 1-6 wflinfo can be gutted to just get json from the api and present it as desired (dump the json, legacy wflinfo format, glxinfo compatibility format, verbose or not). I do not have a patch for that yet. Since another json patch set was recently posted, I'll point out how this one differs... This set moves wflinfo functionality into the api, the other extends the wflinfo program. Both options were discussed on the mailing list in Feb 2015 and the former was favored. This set includes a small library for constructing json strings, with the aim of keeping string building code as clear and simple as possible. It also tries to write one key:value per line to allow grepping in lieu of full json parsing. Finally this set adds additional platform-specific info, though as stated above that could be considered a follow-on. Frank Henigman (12): core: store platform type in wcore_platform core: store context API in wcore_context core: store current context in wcore_display core: add JSON library waffle: add waffle_display_info_json() wflinfo: add option for JSON output waffle: support platform-specific information wflinfo: add flag for platform-specific info glx: implement platform-specific information egl: implement platform-specific information gbm: implement platform-specific information x11_egl: implement platform-specific information include/waffle/waffle.h | 5 + man/waffle_display.3.xml | 19 +++ src/utils/wflinfo.c | 50 ++- src/waffle/CMakeLists.txt| 1 + src/waffle/api/waffle_display.c | 292 ++- src/waffle/api/waffle_gl_misc.c | 11 +- src/waffle/api/waffle_init.c | 32 +++-- src/waffle/core/json.c | 235 +++ src/waffle/core/json.h | 93 + src/waffle/core/wcore_context.h | 2 + src/waffle/core/wcore_display.c | 1 + src/waffle/core/wcore_display.h | 2 + src/waffle/core/wcore_platform.h | 5 + src/waffle/egl/wegl_display.c| 32 - src/waffle/egl/wegl_display.h| 4 + src/waffle/egl/wegl_platform.h | 3 + src/waffle/gbm/wgbm_platform.c | 1 + src/waffle/glx/glx_display.c | 41 ++ src/waffle/glx/glx_display.h | 4 + src/waffle/glx/glx_platform.c| 4 + src/waffle/glx/glx_platform.h| 3 + src/waffle/waffle.def.in | 1 + src/waffle/xegl/xegl_platform.c | 1 + 23 files changed, 820 insertions(+), 22 deletions(-) create mode 100644 src/waffle/core/json.c create mode 100644 src/waffle/core/json.h -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 02/12] core: store context API in wcore_context
Facilitates api-specific code in core functions, like the forthcoming wflinfo-like function. Signed-off-by: Frank Henigman --- src/waffle/core/wcore_context.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/waffle/core/wcore_context.h b/src/waffle/core/wcore_context.h index 3800113..451bbf7 100644 --- a/src/waffle/core/wcore_context.h +++ b/src/waffle/core/wcore_context.h @@ -40,6 +40,7 @@ union waffle_native_context; struct wcore_context { struct api_object api; +int32_t context_api; // WAFFLE_CONTEXT_API enum, e.g. WAFFLE_CONTEXT_OPENGL struct wcore_display *display; }; @@ -61,6 +62,7 @@ wcore_context_init(struct wcore_context *self, assert(config); self->api.display_id = config->display->api.display_id; +self->context_api = config->attrs.context_api; self->display = config->display; return true; -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 05/12] waffle: add waffle_display_info_json()
Duplicate wflinfo functionality in the API, with the difference that the information is returned in JSON form. The function has a parameter for including platform-specific information, but it is ignored for now. Signed-off-by: Frank Henigman --- include/waffle/waffle.h | 5 + man/waffle_display.3.xml| 19 +++ src/waffle/api/waffle_display.c | 284 +++- src/waffle/waffle.def.in| 1 + 4 files changed, 308 insertions(+), 1 deletion(-) diff --git a/include/waffle/waffle.h b/include/waffle/waffle.h index df0218e..1800399 100644 --- a/include/waffle/waffle.h +++ b/include/waffle/waffle.h @@ -214,6 +214,11 @@ bool waffle_display_supports_context_api(struct waffle_display *self, int32_t context_api); +#if WAFFLE_API_VERSION >= 0x0106 +char* +waffle_display_info_json(struct waffle_display *self, bool platform_too); +#endif + union waffle_native_display* waffle_display_get_native(struct waffle_display *self); diff --git a/man/waffle_display.3.xml b/man/waffle_display.3.xml index 9896247..5358472 100644 --- a/man/waffle_display.3.xml +++ b/man/waffle_display.3.xml @@ -24,6 +24,7 @@ waffle_display waffle_display_connect waffle_display_disconnect +waffle_display_info_json waffle_display_supports_context_api waffle_display_get_native class waffle_display @@ -58,6 +59,12 @@ struct waffle_display; +char* waffle_display_info_json +struct waffle_display *self +bool platform_info + + + bool waffle_display_supports_context_api struct waffle_display *self int32_t context_api @@ -129,6 +136,18 @@ struct waffle_display; +waffle_display_info_json() + + +Return a JSON string containing information about the current context on the given display, including Waffle platform and API, GL version/vendor/renderer and extensions. +If platform_info is true, platform-specific information (such as GLX or EGL versions and extensions) will be included as available. +Returns NULL on error. +The string should be deallocated with free3. + + + + + waffle_display_supports_context_api() diff --git a/src/waffle/api/waffle_display.c b/src/waffle/api/waffle_display.c index fa19462..7abe2ef 100644 --- a/src/waffle/api/waffle_display.c +++ b/src/waffle/api/waffle_display.c @@ -23,13 +23,61 @@ // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include +#include + #include "api_priv.h" -#include "wcore_error.h" +#include "json.h" + +#include "wcore_context.h" #include "wcore_display.h" +#include "wcore_error.h" #include "wcore_platform.h" #include "wcore_util.h" +typedef unsigned int GLint; +typedef unsigned int GLenum; +typedef unsigned char GLubyte; + +enum { +// Copied from . +GL_NO_ERROR = 0, + +GL_CONTEXT_FLAGS = 0x821e, +GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT = 0x0001, +GL_CONTEXT_FLAG_DEBUG_BIT = 0x0002, +GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB = 0x0004, + +GL_VENDOR = 0x1F00, +GL_RENDERER= 0x1F01, +GL_VERSION = 0x1F02, +GL_EXTENSIONS = 0x1F03, +GL_NUM_EXTENSIONS = 0x821D, +GL_SHADING_LANGUAGE_VERSION= 0x8B8C, +}; + +#ifndef _WIN32 +#define APIENTRY +#else +#ifndef APIENTRY +#define APIENTRY __stdcall +#endif +#endif + +static GLenum (APIENTRY *glGetError)(void); +static void (APIENTRY *glGetIntegerv)(GLenum pname, GLint *params); +static const GLubyte * (APIENTRY *glGetString)(GLenum name); +static const GLubyte * (APIENTRY *glGetStringi)(GLenum name, GLint i); + +#if defined(__GNUC__) +#define NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define NORETURN __declspec(noreturn) +#else +#define NORETURN +#endif + WAFFLE_API struct waffle_display* waffle_display_connect(const char *name) { @@ -90,6 +138,240 @@ waffle_display_supports_context_api( context_api); } +static int +parse_version(const char *version) +{ +int count, major, minor; + +if (version == NULL) +return 0; + +while (*version != '\0' && !isdigit(*version)) +version++; + +count = sscanf(version, "%d.%d", &major, &minor); +if (count != 2) +return 0; + +if (minor > 9) +return 0; + +return (major * 10) + minor; +} + +static void +add_context_flags(struct json *jj) +{ +static struct { +GLint flag; +char *str; +} flags[] = { +{ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "FORWARD_COMPATIBLE" }, +{ GL_CONTEXT_FLA
[waffle] [PATCH 03/12] core: store current context in wcore_display
For core functions that need to know the current context, like the forthcoming wflinfo-like function. Signed-off-by: Frank Henigman --- src/waffle/api/waffle_gl_misc.c | 11 +++ src/waffle/core/wcore_display.c | 1 + src/waffle/core/wcore_display.h | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/waffle/api/waffle_gl_misc.c b/src/waffle/api/waffle_gl_misc.c index 138974d..4161ce8 100644 --- a/src/waffle/api/waffle_gl_misc.c +++ b/src/waffle/api/waffle_gl_misc.c @@ -94,10 +94,13 @@ waffle_make_current( if (!api_check_entry(obj_list, len)) return false; -return api_platform->vtbl->make_current(api_platform, -wc_dpy, -wc_window, -wc_ctx); +bool ok = api_platform->vtbl->make_current(api_platform, + wc_dpy, + wc_window, + wc_ctx); +if (ok) +wc_dpy->current_context = wc_ctx; +return ok; } WAFFLE_API void* diff --git a/src/waffle/core/wcore_display.c b/src/waffle/core/wcore_display.c index 18262c3..bcaeacb 100644 --- a/src/waffle/core/wcore_display.c +++ b/src/waffle/core/wcore_display.c @@ -52,6 +52,7 @@ wcore_display_init(struct wcore_display *self, mtx_unlock(&mutex); self->platform = platform; +self->current_context = NULL; if (self->api.display_id == 0) { fprintf(stderr, "waffle: error: internal counter wrapped to 0\n"); diff --git a/src/waffle/core/wcore_display.h b/src/waffle/core/wcore_display.h index 6e374e3..1ccff6f 100644 --- a/src/waffle/core/wcore_display.h +++ b/src/waffle/core/wcore_display.h @@ -37,12 +37,14 @@ extern "C" { #endif +struct wcore_context; struct wcore_display; struct wcore_platform; union waffle_native_display; struct wcore_display { struct api_object api; +struct wcore_context *current_context; struct wcore_platform *platform; }; -- 2.6.0.rc2.230.g3dd15c0 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 00/29] Rework the functionality test(s)
Hi all, Recently I had the chance to finish a lenghty series started some months ago. Namely - rework gl_basic_tests and kick waffle_test out the door. It starts with a couple of symbol fixes (maint material afaict), caught while experimenting with Travis-CI. Patch 3 adds a trivial --platform param and wires up the build (make check-func) to generate and use all possible combinations. Patches 06 through 14 add a bunch of macros, which minimise the duplication, and make things substantially easier/shorter add new platform (patch 28, platform gbm). We might want patches 15, 16 and 17 squashed, although I chose to keep the "import latest cmoka", "make sure it builds" and "fix the build warning" (this one is on the cmocka ML), separate to ease review. With patch 18, the existing cmocka user is updated - things build even without it, but we no longer use the deprecated API. With 20, we disable the functionality tests as we cannot convert the whole file at once. Immediatelly after (21) we nuke waffle_test. Patch 22, introduce a handy macro (not perfect due to cmocka API shortage), that makes the "add new platform" a ~10 line diff :-) The remaining patches convert the remaining platforms, one at a time, to top up with a small cleanup. The lot can be found in branch for-upstream/rework-tests over at https://github.com/evelikov/waffle/ TL;DR - update cmocka, and use it over waffle_test. Cut gl_basic_test.c from ~1.2k to 0.9 loc, while adding GBM support and platform selection ;-) No more memory leaks with valgrind-check-func (barring driver ones). NOTE: I'll gladly rework any formatting and macro names. If possible, let's avoid rebase chaos (i.e. if thinking about the test... macros) and do them on top ? Thanks Emil ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 08/29] tests/gl_basic: add test_glXX_fwdcompat() macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 66 ++-- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index a14ce32..9ccf822 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -378,6 +378,15 @@ static void test_gl_basic_gl##waffle_version(void) \ .expect_error=WAFFLE_##error);\ } +#define test_glXX_fwdcompat(waffle_version, error) \ +static void test_gl_basic_gl##waffle_version##_fwdcompat(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .version=waffle_version, \ + .forward_compatible=true, \ + .expect_error=WAFFLE_##error);\ +} + test_XX_rgb(gl, OPENGL, NO_ERROR) test_XX_rgba(gl, OPENGL, NO_ERROR) @@ -389,14 +398,7 @@ test_glXX(14, NO_ERROR) test_glXX(15, NO_ERROR) test_glXX(20, NO_ERROR) test_glXX(21, NO_ERROR) - -TEST(gl_basic, all_gl21_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=21, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} +test_glXX_fwdcompat(21, ERROR_BAD_ATTRIBUTE) // @@ -417,22 +419,9 @@ TEST(gl_basic, all_but_cgl_gl_fwdcompat_bad_attribute) } test_glXX(30, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gl30_fwdcompat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=30, - .forward_compatible=true); -} - +test_glXX_fwdcompat(30, NO_ERROR) test_glXX(31, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gl31_fwdcompat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=31, - .forward_compatible=true); -} +test_glXX_fwdcompat(31, NO_ERROR) TEST(gl_basic, all_but_cgl_gl32_core) { @@ -616,7 +605,9 @@ TEST(gl_basic, cgl_gl_fwdcompat_bad_attribute) } test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX(31, NO_ERROR) +test_glXX_fwdcompat(31, ERROR_UNSUPPORTED_ON_PLATFORM) TEST(gl_basic, cgl_gl32_core) { @@ -734,10 +725,12 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl15); TEST_RUN(gl_basic, gl20); TEST_RUN(gl_basic, gl21); -TEST_RUN2(gl_basic, cgl_gl21_fwdcompat_bad_attribute, all_gl21_fwdcompat_bad_attribute); +TEST_RUN(gl_basic, gl21_fwdcompat); TEST_RUN(gl_basic, gl30); +TEST_RUN(gl_basic, gl30_fwdcompat); TEST_RUN(gl_basic, gl31); +TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, cgl_gl32_core); TEST_RUN(gl_basic, cgl_gl33_core); @@ -779,12 +772,12 @@ testsuite_glx(void) TEST_RUN(gl_basic, gl15); TEST_RUN(gl_basic, gl20); TEST_RUN(gl_basic, gl21); -TEST_RUN2(gl_basic, glx_gl21_fwdcompat_bad_attribute, all_gl21_fwdcompat_bad_attribute); +TEST_RUN(gl_basic, gl21_fwdcompat); TEST_RUN(gl_basic, gl30); -TEST_RUN2(gl_basic, glx_gl30_fwdcompat, all_but_cgl_gl30_fwdcompat); +TEST_RUN(gl_basic, gl30_fwdcompat); TEST_RUN(gl_basic, gl31); -TEST_RUN2(gl_basic, glx_gl31_fwdcompat, all_but_cgl_gl31_fwdcompat); +TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN2(gl_basic, glx_gl32_core, all_but_cgl_gl32_core); TEST_RUN2(gl_basic, glx_gl32_core_fwdcompat, all_but_cgl_gl32_core_fwdcompat); @@ -843,12 +836,12 @@ testsuite_wayland(void) TEST_RUN(gl_basic, gl15); TEST_RUN(gl_basic, gl20); TEST_RUN(gl_basic, gl21); -TEST_RUN2(gl_basic, wayland_gl21_fwdcompat_bad_attribute, all_gl21_fwdcompat_bad_attribute); +TEST_RUN(gl_basic, gl21_fwdcompat); TEST_RUN(gl_basic, gl30); -TEST_RUN2(gl_basic, wayland_gl30_fwdcompat, all_but_cgl_gl30_fwdcompat); +TEST_RUN(gl_basic, gl30_fwdcompat); TEST_RUN(gl_basic, gl31); -TEST_RUN2(gl_basic, wayland_gl31_fwdcompat, all_but_cgl_gl31_fwdcompat); +TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN2(gl_basic, wayland_gl32_core, all_but_cgl_gl32_core); TEST_RUN2(gl_basic, wayland_gl32_core_fwdcompat, all_but_cgl_gl32_core_fwdcompat); @@ -907,12 +900,12 @@ testsuite_x11_egl(void) TEST_RUN(gl_basic, gl15); TEST_RUN(gl_basic, gl20); TEST_RUN(gl_basic, gl21); -TEST_RUN2(gl_basic, x11_egl_gl21_fwdcompat_bad_attribute, all_gl21_fwdcompat_bad_attribute); +TEST_RUN(gl_basic, gl21_fwdcompat); TEST_RUN(gl_basic, gl30); -TEST_RUN2(gl_basic, x11_egl_gl30_fwdcompat, all_but_cgl_gl30_fwdcompat); +TEST_RUN(gl_basic, gl30_fwdcompat); TEST_RUN(gl_basic, gl31); -TEST_RUN2(gl_basic, x11_egl_gl31_fwdcompat, all_but_cgl_gl31_fwdcompat); +TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN2(gl_
[waffle] [PATCH 05/29] tests/gl_basic: use actual/expect arrays for the pixel storage
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 27 --- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index c95ae39..55d078d 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -69,7 +69,8 @@ static const uint8_tGREEN_UB= 0x00; static const uint8_tBLUE_UB = 0xff; static const uint8_tALPHA_UB= 0xff; -static uint8_t pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; +static uint8_t actual_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; +static uint8_t expect_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; #define ASSERT_GL(statement) \ do { \ @@ -136,7 +137,17 @@ static void (APIENTRY *glReadPixels)(GLint x, GLint y, static void testgroup_gl_basic_setup(void) { -memset(pixels, 0, sizeof(pixels)); +for (int y = 0 ; y < WINDOW_HEIGHT; ++y) { +for (int x = 0; x < WINDOW_WIDTH; ++x) { +uint8_t *p = &expect_pixels[4 * (y * WINDOW_WIDTH + x)]; +p[0] = RED_UB; +p[1] = GREEN_UB; +p[2] = BLUE_UB; +p[3] = ALPHA_UB; +} +} + +memset(actual_pixels, 0x99, sizeof(actual_pixels)); } static void @@ -321,21 +332,15 @@ gl_basic_draw__(struct gl_basic_draw_args__ args) ASSERT_GL(glClear(GL_COLOR_BUFFER_BIT)); ASSERT_GL(glReadPixels(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, - pixels)); + actual_pixels)); ASSERT_TRUE(waffle_window_swap_buffers(window)); // Probe color buffer. // // Fail at first failing pixel. If the draw fails, we don't want a terminal // filled with error messages. -for (int y = 0 ; y < WINDOW_HEIGHT; ++y) { -for (int x = 0; x < WINDOW_WIDTH; ++x) { -uint8_t *p = &pixels[4 * (y * WINDOW_WIDTH + x)]; -ASSERT_TRUE(p[0] == RED_UB); -ASSERT_TRUE(p[1] == GREEN_UB); -ASSERT_TRUE(p[2] == BLUE_UB); -ASSERT_TRUE(p[3] == ALPHA_UB); -} +for (i = 0 ; i < sizeof(actual_pixels); ++i) { +ASSERT_TRUE(actual_pixels[i] == expect_pixels[i]); } // Teardown. -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 07/29] tests/gl_basic: add test_glXX() macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 192 +++ 1 file changed, 73 insertions(+), 119 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 03c4a0b..a14ce32 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -370,56 +370,25 @@ static void test_gl_basic_##context_api##_rgba(void) \ .expect_error=WAFFLE_##error);\ } -test_XX_rgb(gl, OPENGL, NO_ERROR) -test_XX_rgba(gl, OPENGL, NO_ERROR) - -TEST(gl_basic, all_gl10) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=10); -} - -TEST(gl_basic, all_gl11) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=11); -} - -TEST(gl_basic, all_gl12) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=12); -} - -TEST(gl_basic, all_gl13) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=13); -} - -TEST(gl_basic, all_gl14) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=14); -} - -TEST(gl_basic, all_gl15) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=15); +#define test_glXX(waffle_version, error)\ +static void test_gl_basic_gl##waffle_version(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .version=waffle_version, \ + .expect_error=WAFFLE_##error);\ } -TEST(gl_basic, all_gl20) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=20); -} +test_XX_rgb(gl, OPENGL, NO_ERROR) +test_XX_rgba(gl, OPENGL, NO_ERROR) -TEST(gl_basic, all_gl21) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=21); -} +test_glXX(10, NO_ERROR) +test_glXX(11, NO_ERROR) +test_glXX(12, NO_ERROR) +test_glXX(13, NO_ERROR) +test_glXX(14, NO_ERROR) +test_glXX(15, NO_ERROR) +test_glXX(20, NO_ERROR) +test_glXX(21, NO_ERROR) TEST(gl_basic, all_gl21_fwdcompat_bad_attribute) { @@ -447,11 +416,7 @@ TEST(gl_basic, all_but_cgl_gl_fwdcompat_bad_attribute) .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); } -TEST(gl_basic, all_but_cgl_gl30) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=30); -} +test_glXX(30, NO_ERROR) TEST(gl_basic, all_but_cgl_gl30_fwdcompat) { @@ -460,11 +425,7 @@ TEST(gl_basic, all_but_cgl_gl30_fwdcompat) .forward_compatible=true); } -TEST(gl_basic, all_but_cgl_gl31) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=31); -} +test_glXX(31, NO_ERROR) TEST(gl_basic, all_but_cgl_gl31_fwdcompat) { @@ -654,18 +615,8 @@ TEST(gl_basic, cgl_gl_fwdcompat_bad_attribute) .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); } -TEST(gl_basic, cgl_gl30) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=30, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl31) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=31); -} +test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX(31, NO_ERROR) TEST(gl_basic, cgl_gl32_core) { @@ -775,17 +726,18 @@ testsuite_cgl(void) TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported); TEST_RUN(gl_basic, cgl_gl_fwdcompat_bad_attribute); -TEST_RUN2(gl_basic, cgl_gl10, all_gl10); -TEST_RUN2(gl_basic, cgl_gl11, all_gl11); -TEST_RUN2(gl_basic, cgl_gl12, all_gl12); -TEST_RUN2(gl_basic, cgl_gl13, all_gl13); -TEST_RUN2(gl_basic, cgl_gl14, all_gl14); -TEST_RUN2(gl_basic, cgl_gl15, all_gl15); -TEST_RUN2(gl_basic, cgl_gl20, all_gl20); -TEST_RUN2(gl_basic, cgl_gl21, all_gl21); +TEST_RUN(gl_basic, gl10); +TEST_RUN(gl_basic, gl11); +TEST_RUN(gl_basic, gl12); +TEST_RUN(gl_basic, gl13); +TEST_RUN(gl_basic, gl14); +TEST_RUN(gl_basic, gl15); +TEST_RUN(gl_basic, gl20); +TEST_RUN(gl_basic, gl21); TEST_RUN2(gl_basic, cgl_gl21_fwdcompat_bad_attribute, all_gl21_fwdcompat_bad_attribute); -TEST_RUN(gl_basic, cgl_gl30); -TEST_RUN(gl_basic, cgl_gl31); + +TEST_RUN(gl_basic, gl30); +TEST_RUN(gl_basic, gl31); TEST_RUN(gl_basic, cgl_gl32_core); TEST_RUN(gl_basic, cgl_gl33_core); @@ -819,19 +771,19 @@ testsuite_glx(void) TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug); TEST_RUN2(gl_basic, glx_gl_fwdcompat_bad_attribute, all_but_cgl_gl_fwdcompat_bad_attribute); -TEST_RUN2(gl_basic, glx_gl10, all_gl10); -TEST_RUN2(gl_basic, glx_gl11, all_gl11); -TEST_RUN2(gl_basic, glx_gl12, all_gl12); -TEST_RUN2(gl_basic, glx_gl13, all_gl13); -TEST_RUN2(gl_basic, glx_gl14, all_gl14); -T
[waffle] [PATCH 03/29] tests/gl_basic: introduce --platform param
From: Emil Velikov This will allow us to selectively run the tests we want, and even run the sets in parallel. Fixes #33: https://github.com/waffle-gl/waffle/issues/33 Signed-off-by: Emil Velikov --- tests/functional/CMakeLists.txt | 51 +-- tests/functional/gl_basic_test.c | 193 --- 2 files changed, 221 insertions(+), 23 deletions(-) diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index f1388b2..91d1273 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -32,19 +32,52 @@ add_executable(gl_basic_test target_link_libraries(gl_basic_test ${waffle_libname} waffle_test +${GETOPT_LIBRARIES} ) -add_custom_target(gl_basic_test_run -COMMAND gl_basic_test -) +# +# Per platform functionality tests +# -add_dependencies(check-func gl_basic_test_run) +function(add_functest platform_name) +add_custom_target(gl_basic_test_${platform_name}_run +COMMAND gl_basic_test --platform ${platform_name} +) +add_dependencies(check-func gl_basic_test_${platform_name}_run) -if(VALGRIND_EXECUTABLE) -add_custom_target(valgrind_gl_basic_test_run -DEPENDS gl_basic_test -COMMAND ${VALGRIND_EXECUTABLE} $ +if(VALGRIND_EXECUTABLE) +add_custom_target(valgrind_gl_basic_test_${platform_name}_run +DEPENDS gl_basic_test +COMMAND ${VALGRIND_EXECUTABLE} $ --platform ${platform_name} ) -add_dependencies(valgrind-check-func valgrind_gl_basic_test_run) +add_dependencies(valgrind-check-func valgrind_gl_basic_test_${platform_name}_run) +endif() +endfunction() + + +if(waffle_on_mac) +add_functest(cgl) +endif() + +if(waffle_on_linux) +if(waffle_has_glx) +add_functest(glx) +endif() + +if(waffle_has_wayland) +add_functest(wayland) +endif() + +if(waffle_has_x11_egl) +add_functest(x11_egl) +endif() + +#if(waffle_has_gbm) +#add_functest(gbm) +#endif() +endif() + +if(waffle_on_windows) +add_functest(wgl) endif() diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 19b0dac..d19b8ae 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -34,9 +34,11 @@ /// 4. Verify the window contents with glReadPixels. /// 5. Tear down all waffle state. +#include // for va_start, va_end #include #include #include +#include #if !defined(_WIN32) #include #else @@ -1086,13 +1088,48 @@ testsuite_wgl(void) } #endif // WAFFLE_HAS_WGL -static void -usage_error(void) + +static const char *usage_message = +"Usage:\n" +"gl_basic_test [Options]\n" +"\n" +"Description:\n" +"Run the basic functionality tests.\n" +"\n" +"Required Parameter:\n" +"-p, --platform\n" +"One of: cgl, glx, wayland, wgl or x11_egl\n" +"\n" +"Options:\n" +"-h, --help\n" +"Print gl_basic_test usage information.\n" +; + +#if defined(__GNUC__) +#define NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define NORETURN __declspec(noreturn) +#else +#define NORETURN +#endif + +static void NORETURN +write_usage_and_exit(FILE *f, int exit_code) { -fprintf(stderr, "gl_basic_test: usage error\n"); -exit(1); +fprintf(f, "%s", usage_message); +exit(exit_code); } +enum { +OPT_PLATFORM = 'p', +OPT_HELP = 'h', +}; + +static const struct option get_opts[] = { +{ .name = "platform", .has_arg = required_argument, .val = OPT_PLATFORM }, +{ .name = "help", .has_arg = no_argument, .val = OPT_HELP }, +}; + #ifdef _WIN32 static DWORD __stdcall worker_thread(LPVOID lpParam) @@ -1199,27 +1236,155 @@ run_testsuite(void (*testsuite)(void)) #endif // _WIN32 +static void NORETURN +usage_error_printf(const char *fmt, ...) +{ +fprintf(stderr, "gl_basic_test usage error: "); + +if (fmt) { +va_list ap; +va_start(ap, fmt); +vfprintf(stderr, fmt, ap); +va_end(ap); +fprintf(stderr, " "); +} + +fprintf(stderr, "(see gl_basic_test --help)\n"); +exit(EXIT_FAILURE); +} + +struct enum_map { +int i; +const char *s; +}; + +static const struct enum_map platform_map[] = { +{WAFFLE_PLATFORM_CGL, "cgl", }, +{WAFFLE_PLATFORM_GLX, "glx" }, +{WAFFLE_PLATFORM_WAYLAND, "wayland" }, +{WAFFLE_PLATFORM_WGL, "wgl" }, +{WAFFLE_PLATFORM_X11_EGL, "x11_egl" }, +{0, 0 }, +}; + +/// @brief Translate string to `enum waffle_enum`. +/// +/// @param self is a list of map items. The last item must be zero-filled. +/// @param result is altered only if @a
[waffle] [PATCH 09/29] tests/gl_basic: add test_glXX_core() test macro
... and use it to minimise the duplication across the file. Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 168 --- 1 file changed, 52 insertions(+), 116 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 9ccf822..f8cf2a1 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -387,6 +387,15 @@ static void test_gl_basic_gl##waffle_version##_fwdcompat(void) \ .expect_error=WAFFLE_##error);\ } +#define test_glXX_core(waffle_version, error) \ +static void test_gl_basic_gl##waffle_version##_core(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .version=waffle_version, \ + .profile=WAFFLE_CONTEXT_CORE_PROFILE, \ + .expect_error=WAFFLE_##error);\ +} + test_XX_rgb(gl, OPENGL, NO_ERROR) test_XX_rgba(gl, OPENGL, NO_ERROR) @@ -423,12 +432,7 @@ test_glXX_fwdcompat(30, NO_ERROR) test_glXX(31, NO_ERROR) test_glXX_fwdcompat(31, NO_ERROR) -TEST(gl_basic, all_but_cgl_gl32_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=32, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} +test_glXX_core(32, NO_ERROR) TEST(gl_basic, all_but_cgl_gl32_core_fwdcompat) { @@ -438,40 +442,11 @@ TEST(gl_basic, all_but_cgl_gl32_core_fwdcompat) .forward_compatible=true); } -TEST(gl_basic, all_but_cgl_gl33_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=33, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl40_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=40, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl41_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=41, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl42_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=42, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl43_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=43, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} +test_glXX_core(33, NO_ERROR) +test_glXX_core(40, NO_ERROR) +test_glXX_core(41, NO_ERROR) +test_glXX_core(42, NO_ERROR) +test_glXX_core(43, NO_ERROR) TEST(gl_basic, all_but_cgl_gl32_compat) { @@ -609,52 +584,12 @@ test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX(31, NO_ERROR) test_glXX_fwdcompat(31, ERROR_UNSUPPORTED_ON_PLATFORM) -TEST(gl_basic, cgl_gl32_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=32, - .profile=WAFFLE_CONTEXT_CORE_PROFILE); -} - -TEST(gl_basic, cgl_gl33_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=33, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl40_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=40, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl41_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=41, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl42_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=42, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl43_core) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=43, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} +test_glXX_core(32, NO_ERROR) +test_glXX_core(33, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_core(40, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_core(41, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_core(42, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_core(43, ERROR_UNSUPPORTED_ON_PLATFORM) TEST(gl_basic, cgl_gl32_compat) { @@ -732,12 +667,12 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl31); TEST_RUN(gl_basic, gl31_fwdcompat); -TEST_RUN(gl_basic, cgl_gl32_core); -TEST_RUN(gl_basic, cgl_gl33_core); -TEST_RUN(gl_basic, cgl_gl40_core); -TEST_RUN(gl_basic, cgl_gl41_core); -TEST_RUN(gl_b
[waffle] [PATCH 06/29] tests/gl_basic: add test_XX_rgb{,a} macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 141 --- 1 file changed, 56 insertions(+), 85 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 55d078d..03c4a0b 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -355,17 +355,24 @@ gl_basic_draw__(struct gl_basic_draw_args__ args) // List of tests common to all platforms. // -TEST(gl_basic, all_gl_rgb) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL); +#define test_XX_rgb(context_api, waffle_api, error) \ +static void test_gl_basic_##context_api##_rgb(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_##waffle_api, \ + .expect_error=WAFFLE_##error);\ } -TEST(gl_basic, all_gl_rgba) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .alpha=true); +#define test_XX_rgba(context_api, waffle_api, error)\ +static void test_gl_basic_##context_api##_rgba(void)\ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_##waffle_api, \ + .alpha=true, \ + .expect_error=WAFFLE_##error);\ } +test_XX_rgb(gl, OPENGL, NO_ERROR) +test_XX_rgba(gl, OPENGL, NO_ERROR) + TEST(gl_basic, all_gl10) { gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, @@ -558,16 +565,8 @@ TEST(gl_basic, all_but_cgl_gl43_compat) .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); } -TEST(gl_basic, all_but_cgl_gles1_rgb) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1); -} - -TEST(gl_basic, all_but_cgl_gles1_rgba) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1, - .alpha=true); -} +test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR) +test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR) TEST(gl_basic, all_but_cgl_gles10) { @@ -590,16 +589,8 @@ TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute) .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); } -TEST(gl_basic, all_but_cgl_gles2_rgb) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2); -} - -TEST(gl_basic, all_but_cgl_gles2_rgba) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2, - .alpha=true); -} +test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR) +test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR) TEST(gl_basic, all_but_cgl_gles20) { @@ -614,16 +605,8 @@ TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute) .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); } -TEST(gl_basic, all_but_cgl_gles3_rgb) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3); -} - -TEST(gl_basic, all_but_cgl_gles3_rgba) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3, - .alpha=true); -} +test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR) +test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR) TEST(gl_basic, all_but_cgl_gles30) { @@ -787,9 +770,8 @@ testsuite_cgl(void) TEST_RUN(gl_basic, cgl_gles1_unsupported); TEST_RUN(gl_basic, cgl_gles2_unsupported); -TEST_RUN2(gl_basic, cgl_gl_rgb, all_gl_rgb); -TEST_RUN2(gl_basic, cgl_gl_rgba, all_gl_rgba); - +TEST_RUN(gl_basic, gl_rgb); +TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported); TEST_RUN(gl_basic, cgl_gl_fwdcompat_bad_attribute); @@ -832,8 +814,8 @@ testsuite_glx(void) { TEST_RUN(gl_basic, glx_init); -TEST_RUN2(gl_basic, glx_gl_rgb, all_gl_rgb); -TEST_RUN2(gl_basic, glx_gl_rgba, all_gl_rgb); +TEST_RUN(gl_basic, gl_rgb); +TEST_RUN(gl_basic, gl_rgba); TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug); TEST_RUN2(gl_basic, glx_gl_fwdcompat_bad_attribute, all_but_cgl_gl_fwdcompat_bad_attribute); @@ -867,23 +849,20 @@ testsuite_glx(void) TEST_RUN2(gl_basic, glx_gl42_compat, all_but_cgl_gl42_compat); TEST_RUN2(gl_basic, glx_gl43_compat, all_but_cgl_gl43_compat); -TEST_RUN2(gl_basic, glx_gles1_rgb, all_but_cgl_gles1_rgb); -TEST_RUN2(gl_basic, glx_gles1_rgba, all_but_cgl_gles1_rgba); +TEST_RUN(gl_basic, gles1_rgb); +TEST_RUN(gl_basic, gles1_rgba); TEST_RUN2(gl_basic, glx_gles1_fwdcompat_bad_attribute, all_but_cgl_gles1_fwdcompat_bad_attribute); - TEST_RUN2(gl_basic, glx_gles10, all_but_cgl_gles10); TEST_RUN2(gl_basic, glx_gles11, all_but_cgl_gles10); -TEST_RUN2(gl_basic, glx_gles2_rgb, all_but_cgl_gles2_rgb); -TEST_RUN2(gl_basic, glx_gles2_rgba, all_but_cgl_gles2_rgba); +TEST_RUN(gl_basic, gles2_rgb); +TEST_RUN(gl_basic, gles2_rgba); TEST_RUN2(gl_basic, glx_gles2_fwdcompat_bad_attribute, all_but_cgl_gles2_fwdcompat_bad_attribute); - TEST_RUN2(gl_basic, glx_gles20, all_but_cgl_gles20); -TEST_RUN2(gl_basic, glx_gles3_rgb, all_but_
[waffle] [PATCH 01/29] wayland: add wl_proxy_create wrapper
libwayland has broken its ABI by replacing wl_proxy_create + wl_proxy_marshal with wfl_wl_proxy_marshal_constructor with commit 853c24e6998(client: Introduce functions to allocate and marshal proxies atomically). Add the wrapper to keep compatibility with wayland 1.3.90 and earlier. Signed-off-by: Emil Velikov --- src/waffle/wayland/wayland_wrapper.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/waffle/wayland/wayland_wrapper.h b/src/waffle/wayland/wayland_wrapper.h index 40a581a..e2c96ca 100644 --- a/src/waffle/wayland/wayland_wrapper.h +++ b/src/waffle/wayland/wayland_wrapper.h @@ -66,6 +66,10 @@ int (*wfl_wl_proxy_add_listener)(struct wl_proxy *proxy, void (**implementation)(void), void *data); +struct wl_proxy * +(*wfl_wl_proxy_create)(struct wl_proxy *factory, + const struct wl_interface *interface); + void (*wfl_wl_proxy_marshal)(struct wl_proxy *p, uint32_t opcode, ...); @@ -90,5 +94,6 @@ struct wl_proxy * #define wl_display_roundtrip (*wfl_wl_display_roundtrip) #define wl_proxy_destroy (*wfl_wl_proxy_destroy) #define wl_proxy_add_listener (*wfl_wl_proxy_add_listener) +#define wl_proxy_create (*wfl_wl_proxy_create) #define wl_proxy_marshal (*wfl_wl_proxy_marshal) #define wl_proxy_marshal_constructor (*wfl_wl_proxy_marshal_constructor) -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 12/29] tests/gl_basic: add test_glesXX() macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 93 1 file changed, 36 insertions(+), 57 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index f753276..10b9c71 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -415,6 +415,14 @@ static void test_gl_basic_gl##waffle_version##_compat(void) \ .expect_error=WAFFLE_##error);\ } +#define test_glesXX(api_version, waffle_version, error) \ +static void test_gl_basic_gles##waffle_version(void)\ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES##api_version, \ + .version=waffle_version, \ + .expect_error=WAFFLE_##error);\ +} + test_XX_rgb(gl, OPENGL, NO_ERROR) test_XX_rgba(gl, OPENGL, NO_ERROR) @@ -468,20 +476,8 @@ test_glXX_compat(43, NO_ERROR) test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR) test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gles10) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1, - .version=10, - .alpha=true); -} - -TEST(gl_basic, all_but_cgl_gles11) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1, - .version=11, - .alpha=true); -} +test_glesXX(1, 10, NO_ERROR) +test_glesXX(1, 11, NO_ERROR) TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute) { @@ -492,12 +488,7 @@ TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute) test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR) test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gles20) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2, - .version=20); -} +test_glesXX(2, 20, NO_ERROR) TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute) { @@ -508,12 +499,7 @@ TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute) test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR) test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gles30) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3, - .version=30); -} +test_glesXX(3, 30, NO_ERROR) TEST(gl_basic, all_but_cgl_gles3_fwdcompat_bad_attribute) { @@ -529,18 +515,6 @@ TEST(gl_basic, cgl_init) gl_basic_init(WAFFLE_PLATFORM_CGL); } -TEST(gl_basic, cgl_gles1_unsupported) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gles2_unsupported) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - TEST(gl_basic, cgl_gl_debug_is_unsupported) { gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, @@ -575,14 +549,14 @@ test_glXX_compat(41, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_compat(42, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_compat(43, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glesXX(1, 10, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glesXX(2, 20, ERROR_UNSUPPORTED_ON_PLATFORM) + static void testsuite_cgl(void) { TEST_RUN(gl_basic, cgl_init); -TEST_RUN(gl_basic, cgl_gles1_unsupported); -TEST_RUN(gl_basic, cgl_gles2_unsupported); - TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported); @@ -617,6 +591,9 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl41_compat); TEST_RUN(gl_basic, gl42_compat); TEST_RUN(gl_basic, gl43_compat); + +TEST_RUN(gl_basic, gles10); +TEST_RUN(gl_basic, gles20); } #endif // WAFFLE_HAS_CGL @@ -668,19 +645,19 @@ testsuite_glx(void) TEST_RUN(gl_basic, gles1_rgb); TEST_RUN(gl_basic, gles1_rgba); +TEST_RUN(gl_basic, gles10); +TEST_RUN(gl_basic, gles11); TEST_RUN2(gl_basic, glx_gles1_fwdcompat_bad_attribute, all_but_cgl_gles1_fwdcompat_bad_attribute); -TEST_RUN2(gl_basic, glx_gles10, all_but_cgl_gles10); -TEST_RUN2(gl_basic, glx_gles11, all_but_cgl_gles10); TEST_RUN(gl_basic, gles2_rgb); TEST_RUN(gl_basic, gles2_rgba); +TEST_RUN(gl_basic, gles20); TEST_RUN2(gl_basic, glx_gles2_fwdcompat_bad_attribute, all_but_cgl_gles2_fwdcompat_bad_attribute); -TEST_RUN2(gl_basic, glx_gles20, all_but_cgl_gles20); TEST_RUN(gl_basic, gles3_rgb); TEST_RUN(gl_basic, gles3_rgba); +TEST_RUN(gl_basic, gles30); TEST_RUN2(gl_basic, glx_gles3_fwdcompat_bad_attribute, all_but_cgl_gles3_fwdcompat_bad_attribute); -TEST_RUN2(gl_basic, glx_gles30, all_but_cgl_gles30); } #endif // WAFFLE_HAS_GLX @@ -732,19 +709,19 @@ testsuite_wayland(void) TEST_RUN(gl_basic, gles1_rgb); TEST_RUN(gl_basic, gles1_rgba); +TEST_RUN(gl_basic, gles10); +TEST_RUN(gl_basic, gles11); TEST_RUN2(gl_basic, wayland_gles1_fwdcompat_bad_attrib
[waffle] [PATCH 13/29] tests/gl_basic: add test_XX_fwdcompat() macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 86 1 file changed, 34 insertions(+), 52 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 10b9c71..5e6b518 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -370,6 +370,14 @@ static void test_gl_basic_##context_api##_rgba(void) \ .expect_error=WAFFLE_##error);\ } +#define test_XX_fwdcompat(context_api, waffle_api, error) \ +static void test_gl_basic_##context_api##_fwdcompat(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_##waffle_api, \ + .forward_compatible=true, \ + .expect_error=WAFFLE_##error);\ +} + #define test_glXX(waffle_version, error)\ static void test_gl_basic_gl##waffle_version(void) \ { \ @@ -441,19 +449,15 @@ test_glXX_fwdcompat(21, ERROR_BAD_ATTRIBUTE) // List of linux (glx, wayland and x11_egl) and windows (wgl) specific tests. // #if defined(WAFFLE_HAS_GLX) || defined(WAFFLE_HAS_WAYLAND) || defined(WAFFLE_HAS_X11_EGL) || defined(WAFFLE_HAS_WGL) + +test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) + TEST(gl_basic, all_but_cgl_gl_debug) { gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, .debug=true); } -TEST(gl_basic, all_but_cgl_gl_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} - test_glXX(30, NO_ERROR) test_glXX_fwdcompat(30, NO_ERROR) test_glXX(31, NO_ERROR) @@ -476,37 +480,19 @@ test_glXX_compat(43, NO_ERROR) test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR) test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR) +test_XX_fwdcompat(gles1, OPENGL_ES1, ERROR_BAD_ATTRIBUTE) test_glesXX(1, 10, NO_ERROR) test_glesXX(1, 11, NO_ERROR) -TEST(gl_basic, all_but_cgl_gles1_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES1, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} - test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR) test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR) +test_XX_fwdcompat(gles2, OPENGL_ES2, ERROR_BAD_ATTRIBUTE) test_glesXX(2, 20, NO_ERROR) -TEST(gl_basic, all_but_cgl_gles2_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES2, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} - test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR) test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR) +test_XX_fwdcompat(gles3, OPENGL_ES3, ERROR_BAD_ATTRIBUTE) test_glesXX(3, 30, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gles3_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL_ES3, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} #endif #ifdef WAFFLE_HAS_CGL @@ -515,6 +501,8 @@ TEST(gl_basic, cgl_init) gl_basic_init(WAFFLE_PLATFORM_CGL); } +test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) + TEST(gl_basic, cgl_gl_debug_is_unsupported) { gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, @@ -522,13 +510,6 @@ TEST(gl_basic, cgl_gl_debug_is_unsupported) .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); } -TEST(gl_basic, cgl_gl_fwdcompat_bad_attribute) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .forward_compatible=true, - .expect_error=WAFFLE_ERROR_BAD_ATTRIBUTE); -} - test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX(31, NO_ERROR) @@ -559,8 +540,8 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); +TEST_RUN(gl_basic, gl_fwdcompat); TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported); -TEST_RUN(gl_basic, cgl_gl_fwdcompat_bad_attribute); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -610,8 +591,8 @@ testsuite_glx(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); +TEST_RUN(gl_basic, gl_fwdcompat); TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug); -TEST_RUN2(gl_basic, glx_gl_fwdcompat_bad_attribute, all_but_cgl_gl_fwdcompat_bad_attribute); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -645,19 +626,19 @@ testsuite_glx(void) TEST_RUN(gl_basic, gles1_rgb); TEST_RUN(gl_basic, gles1_rgba); +TEST_RUN(gl_basic, gles1_fwdcompat); TEST_RUN(gl_basic, gles10); TEST_RUN(gl_basic, gles11); -TEST_RUN2(gl_basic, glx_gles1_fwdcompat_bad_attribute, all_but_cgl_gle
[waffle] [PATCH 11/29] tests/gl_basic: add test_glXX_compat() macro
... and use it to minimise the duplication across the file. Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 170 --- 1 file changed, 52 insertions(+), 118 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index ff1d6a3..f753276 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -406,6 +406,15 @@ static void test_gl_basic_gl##waffle_version##_core_fwdcompat(void) \ .expect_error=WAFFLE_##error);\ } +#define test_glXX_compat(waffle_version, error) \ +static void test_gl_basic_gl##waffle_version##_compat(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .version=waffle_version, \ + .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE,\ + .expect_error=WAFFLE_##error);\ +} + test_XX_rgb(gl, OPENGL, NO_ERROR) test_XX_rgba(gl, OPENGL, NO_ERROR) @@ -450,47 +459,12 @@ test_glXX_core(41, NO_ERROR) test_glXX_core(42, NO_ERROR) test_glXX_core(43, NO_ERROR) -TEST(gl_basic, all_but_cgl_gl32_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=32, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl33_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=33, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl40_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=40, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl41_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=41, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl42_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=42, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} - -TEST(gl_basic, all_but_cgl_gl43_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=43, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); -} +test_glXX_compat(32, NO_ERROR) +test_glXX_compat(33, NO_ERROR) +test_glXX_compat(40, NO_ERROR) +test_glXX_compat(41, NO_ERROR) +test_glXX_compat(42, NO_ERROR) +test_glXX_compat(43, NO_ERROR) test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR) test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR) @@ -594,53 +568,12 @@ test_glXX_core(41, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(42, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(43, ERROR_UNSUPPORTED_ON_PLATFORM) -TEST(gl_basic, cgl_gl32_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=32, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl33_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=33, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl40_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=40, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl41_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=41, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl42_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=42, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} - -TEST(gl_basic, cgl_gl43_compat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=43, - .profile=WAFFLE_CONTEXT_COMPATIBILITY_PROFILE, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} +test_glXX_compat(32, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_compat(33, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_compat(40, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_compat(41, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_compat(42, ERROR_UNSUPPORTED_ON_PLATFORM) +test_glXX_compat(43, ERROR_UNSUPPORTED_ON_PLATFORM) static void testsuite_cgl(void) @@ -678,12 +611,12 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl42_core); TEST_RUN(gl_basic, gl43_core); -TEST_RUN(gl_basic, cgl_gl32_compat); -TEST_
[waffle] [PATCH 04/29] tests/gl_basic: fold ifndef _WIN32 blocks
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index d19b8ae..c95ae39 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -39,17 +39,14 @@ #include #include #include +#include #if !defined(_WIN32) #include +#include #else #include #endif -#include -#if !defined(_WIN32) -#include -#endif - #include "waffle.h" #include "waffle_test/waffle_test.h" -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 14/29] tests/gl_basic: add test_gl_debug() macro
Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 34 -- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 5e6b518..d151d44 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -378,6 +378,14 @@ static void test_gl_basic_##context_api##_fwdcompat(void) \ .expect_error=WAFFLE_##error);\ } +#define test_gl_debug(error)\ +static void test_gl_basic_gl_debug(void)\ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .debug=true, \ + .expect_error=WAFFLE_##error);\ +} + #define test_glXX(waffle_version, error)\ static void test_gl_basic_gl##waffle_version(void) \ { \ @@ -451,12 +459,7 @@ test_glXX_fwdcompat(21, ERROR_BAD_ATTRIBUTE) #if defined(WAFFLE_HAS_GLX) || defined(WAFFLE_HAS_WAYLAND) || defined(WAFFLE_HAS_X11_EGL) || defined(WAFFLE_HAS_WGL) test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) - -TEST(gl_basic, all_but_cgl_gl_debug) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .debug=true); -} +test_gl_debug(NO_ERROR) test_glXX(30, NO_ERROR) test_glXX_fwdcompat(30, NO_ERROR) @@ -502,13 +505,7 @@ TEST(gl_basic, cgl_init) } test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) - -TEST(gl_basic, cgl_gl_debug_is_unsupported) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .debug=true, - .expect_error=WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM); -} +test_gl_debug(ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM) @@ -541,7 +538,7 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, cgl_gl_debug_is_unsupported); +TEST_RUN(gl_basic, gl_debug); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -592,7 +589,7 @@ testsuite_glx(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN2(gl_basic, glx_gl_debug, all_but_cgl_gl_debug); +TEST_RUN(gl_basic, gl_debug); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -656,7 +653,7 @@ testsuite_wayland(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN2(gl_basic, wayland_gl_debug, all_but_cgl_gl_debug); +TEST_RUN(gl_basic, gl_debug); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -720,7 +717,7 @@ testsuite_x11_egl(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN2(gl_basic, x11_egl_gl_debug, all_but_cgl_gl_debug); +TEST_RUN(gl_basic, gl_debug); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -784,7 +781,7 @@ testsuite_wgl(void) TEST_RUN(gl_basic, gl_rgb); TEST_RUN(gl_basic, gl_rgba); TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, all_but_cgl_gl_debug); +TEST_RUN(gl_basic, gl_debug); TEST_RUN(gl_basic, gl10); TEST_RUN(gl_basic, gl11); @@ -842,6 +839,7 @@ testsuite_wgl(void) #undef test_glXX_fwdcompat #undef test_glXX +#undef test_gl_debug #undef test_XX_fwdcompat #undef test_XX_rgba #undef test_XX_rgb -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 16/29] cmocka: fix the build for the new version
XXX: should we squash this with the previous commit ? Signed-off-by: Emil Velikov --- cmake/Modules/WaffleCMocka.cmake | 15 ++- cmake/Modules/WaffleDefineCompilerFlags.cmake | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/WaffleCMocka.cmake b/cmake/Modules/WaffleCMocka.cmake index 9222645..1e11579 100644 --- a/cmake/Modules/WaffleCMocka.cmake +++ b/cmake/Modules/WaffleCMocka.cmake @@ -23,11 +23,24 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/third_party/cmocka") + set(cmocka_source_dir ${CMAKE_SOURCE_DIR}/third_party/cmocka) +set(cmocka_build_dir ${CMAKE_SOURCE_DIR}/third_party/cmocka) + +include(ConfigureChecks) +add_definitions(-DHAVE_CONFIG_H=1) +configure_file( +${cmocka_source_dir}/config.h.cmake +${cmocka_build_dir}/config.h +) list(APPEND CMOCKA_SOURCES ${cmocka_source_dir}/src/cmocka.c ) add_library(cmocka STATIC ${cmocka_source_dir}/src/cmocka.c) -target_include_directories(cmocka PUBLIC ${cmocka_source_dir}/include) +target_include_directories(cmocka PUBLIC +${cmocka_source_dir}/include +${cmocka_build_dir} +) diff --git a/cmake/Modules/WaffleDefineCompilerFlags.cmake b/cmake/Modules/WaffleDefineCompilerFlags.cmake index 679d09c..d39ff45 100644 --- a/cmake/Modules/WaffleDefineCompilerFlags.cmake +++ b/cmake/Modules/WaffleDefineCompilerFlags.cmake @@ -126,7 +126,7 @@ if(waffle_on_linux) add_definitions(-DWAFFLE_HAS_TLS_MODEL_INITIAL_EXEC) endif() -add_definitions(-D_XOPEN_SOURCE=600) +add_definitions(-D_XOPEN_SOURCE=700) endif() if(waffle_has_nacl) -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 20/29] tests/gl_basic: disable tests, convert to cmocka step 1
Use cmocka macros and rework gl_basic_{init,fini}, by keeping track of the state and tearing things down as needed. Nuke the (no longer to be used) run_testsuite(). Signed-off-by: Emil Velikov --- tests/functional/CMakeLists.txt | 2 +- tests/functional/gl_basic_test.c | 336 --- 2 files changed, 140 insertions(+), 198 deletions(-) diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt index 91d1273..026a05f 100644 --- a/tests/functional/CMakeLists.txt +++ b/tests/functional/CMakeLists.txt @@ -31,7 +31,7 @@ add_executable(gl_basic_test target_link_libraries(gl_basic_test ${waffle_libname} -waffle_test +cmocka ${GETOPT_LIBRARIES} ) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index d151d44..75d9c20 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -35,6 +35,7 @@ /// 5. Tear down all waffle state. #include // for va_start, va_end +#include // for cmocka.h ... still an issue, fix upstream ? #include #include #include @@ -47,8 +48,8 @@ #include #endif +#include #include "waffle.h" -#include "waffle_test/waffle_test.h" #include "gl_basic_cocoa.h" @@ -69,22 +70,21 @@ static const uint8_tGREEN_UB= 0x00; static const uint8_tBLUE_UB = 0xff; static const uint8_tALPHA_UB= 0xff; -static uint8_t actual_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; -static uint8_t expect_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; +struct test_state_gl_basic { +bool initialized; +struct waffle_display *dpy; +struct waffle_config *config; +struct waffle_window *window; +struct waffle_context *ctx; + +uint8_t actual_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; +uint8_t expect_pixels[4 * WINDOW_WIDTH * WINDOW_HEIGHT]; +}; #define ASSERT_GL(statement) \ do { \ statement; \ -ASSERT_TRUE(!glGetError()); \ -} while (0) - -/// Use this when @a cond will corrupt future tests. -#define ABORT_IF(cond) \ -do { \ -if (cond) { \ -TEST_ERROR_PRINTF("expect %x; aborting...", #cond); \ -abort(); \ -} \ +assert_false(glGetError()); \ } while (0) typedef unsigned intGLenum; @@ -134,26 +134,36 @@ static void (APIENTRY *glReadPixels)(GLint x, GLint y, GLenum format, GLenum type, GLvoid *pixels ); -static void -testgroup_gl_basic_setup(void) +static int +setup(void **state) { +struct test_state_gl_basic *ts; + +ts = calloc(1, sizeof(*ts)); +if (!ts) +return -1; + for (int y = 0 ; y < WINDOW_HEIGHT; ++y) { for (int x = 0; x < WINDOW_WIDTH; ++x) { -uint8_t *p = &expect_pixels[4 * (y * WINDOW_WIDTH + x)]; +uint8_t *p = &ts->expect_pixels[4 * (y * WINDOW_WIDTH + x)]; p[0] = RED_UB; p[1] = GREEN_UB; p[2] = BLUE_UB; p[3] = ALPHA_UB; } } +// Fill actual_pixels with canaries. +memset(&ts->actual_pixels, 0x99, sizeof(ts->actual_pixels)); -memset(actual_pixels, 0x99, sizeof(actual_pixels)); +*state = ts; +return 0; } -static void -testgroup_gl_basic_teardown(void) +static int +teardown(void **state) { -// empty +free(*state); +return 0; } static int32_t @@ -166,25 +176,65 @@ libgl_from_context_api(int32_t waffle_context_api) case WAFFLE_CONTEXT_OPENGL_ES3: return WAFFLE_DL_OPENGL_ES3; default: -TEST_FAIL(); +assert_true(0); return 0; } } -static void -gl_basic_init(int32_t waffle_platform) +static int +gl_basic_init(void **state, int32_t waffle_platform) { +struct test_state_gl_basic *ts; +int ret; + +ret = setup((void **)&ts); +if (ret) +return -1; + const int32_t init_attrib_list[] = { WAFFLE_PLATFORM, waffle_platform, 0, }; -ASSERT_TRUE(waffle_init(init_attrib_list)); +ts->initialized = waffle_init(init_attrib_list); +if (!ts->initialized) { +// XXX: does cmocka call teardown if setup fails ? +teardown(state); +return -1; +} + +*state = ts; +return 0; } -#define gl_basic_draw(...) \ +static int +gl_basic_fini(void **state) +{ +struct test_state_gl_basic *ts = *state; +bool ret = false; + +// XXX: return immediately on error or attempt to finish the teardown ? +if (ts->dpy) // XXX: keep track if we've had current ctx ? +ret = waffle_make_current(ts->dpy, NULL, NULL); +if (ts->window) +ret = waffle_window_destroy(ts->window); +if (ts->ctx) +ret = waffle_context_destroy(ts->ctx); +if (ts->config) +ret = waffle_config_destroy(ts->config); +if (ts->dpy) +ret = waffle_display_disconnect(ts->dpy); + +if (ts->initialized) +ret = waffle_teardown();
[waffle] [PATCH 10/29] tests/gl_basic: add test_glXX_core_fwdcompat() test macro
... and use it to minimise the duplication across the file. Add the equivalent CGL test while we're here :) Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 31 ++- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index f8cf2a1..ff1d6a3 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -396,6 +396,16 @@ static void test_gl_basic_gl##waffle_version##_core(void) \ .expect_error=WAFFLE_##error);\ } +#define test_glXX_core_fwdcompat(waffle_version, error) \ +static void test_gl_basic_gl##waffle_version##_core_fwdcompat(void) \ +{ \ +gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, \ + .version=waffle_version, \ + .profile=WAFFLE_CONTEXT_CORE_PROFILE, \ + .forward_compatible=true, \ + .expect_error=WAFFLE_##error);\ +} + test_XX_rgb(gl, OPENGL, NO_ERROR) test_XX_rgba(gl, OPENGL, NO_ERROR) @@ -433,15 +443,7 @@ test_glXX(31, NO_ERROR) test_glXX_fwdcompat(31, NO_ERROR) test_glXX_core(32, NO_ERROR) - -TEST(gl_basic, all_but_cgl_gl32_core_fwdcompat) -{ -gl_basic_draw(.api=WAFFLE_CONTEXT_OPENGL, - .version=32, - .profile=WAFFLE_CONTEXT_CORE_PROFILE, - .forward_compatible=true); -} - +test_glXX_core_fwdcompat(32, NO_ERROR) test_glXX_core(33, NO_ERROR) test_glXX_core(40, NO_ERROR) test_glXX_core(41, NO_ERROR) @@ -585,6 +587,7 @@ test_glXX(31, NO_ERROR) test_glXX_fwdcompat(31, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(32, NO_ERROR) +test_glXX_core_fwdcompat(32, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(33, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(40, ERROR_UNSUPPORTED_ON_PLATFORM) test_glXX_core(41, ERROR_UNSUPPORTED_ON_PLATFORM) @@ -668,6 +671,7 @@ testsuite_cgl(void) TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, gl32_core); +TEST_RUN(gl_basic, gl32_core_fwdcompat); TEST_RUN(gl_basic, gl33_core); TEST_RUN(gl_basic, gl40_core); TEST_RUN(gl_basic, gl41_core); @@ -715,7 +719,7 @@ testsuite_glx(void) TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, gl32_core); -TEST_RUN2(gl_basic, glx_gl32_core_fwdcompat, all_but_cgl_gl32_core_fwdcompat); +TEST_RUN(gl_basic, gl32_core_fwdcompat); TEST_RUN(gl_basic, gl33_core); TEST_RUN(gl_basic, gl40_core); TEST_RUN(gl_basic, gl41_core); @@ -779,7 +783,7 @@ testsuite_wayland(void) TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, gl32_core); -TEST_RUN2(gl_basic, wayland_gl32_core_fwdcompat, all_but_cgl_gl32_core_fwdcompat); +TEST_RUN(gl_basic, gl32_core_fwdcompat); TEST_RUN(gl_basic, gl33_core); TEST_RUN(gl_basic, gl40_core); TEST_RUN(gl_basic, gl41_core); @@ -843,7 +847,7 @@ testsuite_x11_egl(void) TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, gl32_core); -TEST_RUN2(gl_basic, x11_egl_gl32_core_fwdcompat, all_but_cgl_gl32_core_fwdcompat); +TEST_RUN(gl_basic, gl32_core_fwdcompat); TEST_RUN(gl_basic, gl33_core); TEST_RUN(gl_basic, gl40_core); TEST_RUN(gl_basic, gl41_core); @@ -907,7 +911,7 @@ testsuite_wgl(void) TEST_RUN(gl_basic, gl31_fwdcompat); TEST_RUN(gl_basic, gl32_core); -TEST_RUN(gl_basic, all_but_cgl_gl32_core_fwdcompat); +TEST_RUN(gl_basic, gl32_core_fwdcompat); TEST_RUN(gl_basic, gl33_core); TEST_RUN(gl_basic, gl40_core); TEST_RUN(gl_basic, gl41_core); @@ -939,6 +943,7 @@ testsuite_wgl(void) } #endif // WAFFLE_HAS_WGL +#undef test_glXX_core_fwdcompat #undef test_glXX_core #undef test_glXX_fwdcompat #undef test_glXX -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 02/29] gbm: don't fetch gbm_bo_* symbols from libgbm
Neither one of these is (or has been) used. Remove them for now and introduce back when needed. Presently this causes run-time issues whenever someone attempts to use an old version of libgbm (mesa circa 9.2) as the gbm_bo_get_fd symbol is missing. Due to the multiple gbm provides and their inconsistent versioning (xxx: check ?) we cannot reliably add a limitation during the configure stage. This commit reverts a hunk of commit 14e3356a01d(gbm: make platform friendlier to derived classes). The latter of which could have kept these as a separate patch :) Cc: Frank Henigman Cc: Chad Versace Signed-off-by: Emil Velikov --- src/waffle/gbm/wgbm_platform.h | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/waffle/gbm/wgbm_platform.h b/src/waffle/gbm/wgbm_platform.h index 1a08183..edcbe95 100644 --- a/src/waffle/gbm/wgbm_platform.h +++ b/src/waffle/gbm/wgbm_platform.h @@ -41,16 +41,7 @@ f(struct gbm_surface *, gbm_surface_create , (struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags)) \ f(void, gbm_surface_destroy , (struct gbm_surface *surface)) \ f(struct gbm_bo * , gbm_surface_lock_front_buffer, (struct gbm_surface *surface)) \ -f(void, gbm_surface_release_buffer , (struct gbm_surface *surface, struct gbm_bo *bo)) \ -f(struct gbm_bo * , gbm_bo_create, (struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t flags)) \ -f(void, gbm_bo_destroy , (struct gbm_bo *bo)) \ -f(int , gbm_bo_get_fd, (struct gbm_bo *bo)) \ -f(uint32_t, gbm_bo_get_width , (struct gbm_bo *bo)) \ -f(uint32_t, gbm_bo_get_height, (struct gbm_bo *bo)) \ -f(uint32_t, gbm_bo_get_stride, (struct gbm_bo *bo)) \ -f(uint32_t, gbm_bo_get_format, (struct gbm_bo *bo)) \ -f(union gbm_bo_handle , gbm_bo_get_handle, (struct gbm_bo *bo)) \ -f(struct gbm_device * , gbm_bo_get_device, (struct gbm_bo *bo)) +f(void, gbm_surface_release_buffer , (struct gbm_surface *surface, struct gbm_bo *bo)) struct linux_platform; -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 17/29] UPSTREAM: cmocka: include strings.h for strcasecmp
Signed-off-by: Emil Velikov --- third_party/cmocka/src/cmocka.c | 4 1 file changed, 4 insertions(+) diff --git a/third_party/cmocka/src/cmocka.c b/third_party/cmocka/src/cmocka.c index fc83b57..2a63f82 100644 --- a/third_party/cmocka/src/cmocka.c +++ b/third_party/cmocka/src/cmocka.c @@ -31,6 +31,10 @@ #include #endif +#ifdef HAVE_STRINGS_H +#include +#endif + #include #include #include -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 18/29] core: convert unittests to new cmocka API
Signed-off-by: Emil Velikov --- src/waffle/core/wcore_attrib_list_unittest.c | 40 +-- src/waffle/core/wcore_config_attrs_unittest.c | 18 src/waffle/core/wcore_error_unittest.c| 26 - 3 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/waffle/core/wcore_attrib_list_unittest.c b/src/waffle/core/wcore_attrib_list_unittest.c index 2eb95f2..727c721 100644 --- a/src/waffle/core/wcore_attrib_list_unittest.c +++ b/src/waffle/core/wcore_attrib_list_unittest.c @@ -228,26 +228,26 @@ test_wcore_attrib_list32_update_missing_key(void **state) { int main(void) { -const UnitTest tests[] = { -unit_test(test_wcore_attrib_list32_get_null), -unit_test(test_wcore_attrib_list32_get_empty), -unit_test(test_wcore_attrib_list32_get_missing_value), -unit_test(test_wcore_attrib_list32_get_trailing_items), - unit_test(test_wcore_attrib_list32_get_value_not_modified_if_not_found), -unit_test(test_wcore_attrib_list32_get_key_is_first), -unit_test(test_wcore_attrib_list32_get_key_is_last), -unit_test(test_wcore_attrib_list32_length_null), -unit_test(test_wcore_attrib_list32_length_is_0), -unit_test(test_wcore_attrib_list32_length_is_1), -unit_test(test_wcore_attrib_list32_length_is_2), -unit_test(test_wcore_attrib_list32_length_is_37), -unit_test(test_wcore_attrib_list32_length_trailing_items), -unit_test(test_wcore_attrib_list32_update_null), -unit_test(test_wcore_attrib_list32_update_empty_list), -unit_test(test_wcore_attrib_list32_update_at_0), -unit_test(test_wcore_attrib_list32_update_at_1), -unit_test(test_wcore_attrib_list32_update_missing_key), +const struct CMUnitTest tests[] = { +cmocka_unit_test(test_wcore_attrib_list32_get_null), +cmocka_unit_test(test_wcore_attrib_list32_get_empty), +cmocka_unit_test(test_wcore_attrib_list32_get_missing_value), +cmocka_unit_test(test_wcore_attrib_list32_get_trailing_items), + cmocka_unit_test(test_wcore_attrib_list32_get_value_not_modified_if_not_found), +cmocka_unit_test(test_wcore_attrib_list32_get_key_is_first), +cmocka_unit_test(test_wcore_attrib_list32_get_key_is_last), +cmocka_unit_test(test_wcore_attrib_list32_length_null), +cmocka_unit_test(test_wcore_attrib_list32_length_is_0), +cmocka_unit_test(test_wcore_attrib_list32_length_is_1), +cmocka_unit_test(test_wcore_attrib_list32_length_is_2), +cmocka_unit_test(test_wcore_attrib_list32_length_is_37), +cmocka_unit_test(test_wcore_attrib_list32_length_trailing_items), +cmocka_unit_test(test_wcore_attrib_list32_update_null), +cmocka_unit_test(test_wcore_attrib_list32_update_empty_list), +cmocka_unit_test(test_wcore_attrib_list32_update_at_0), +cmocka_unit_test(test_wcore_attrib_list32_update_at_1), +cmocka_unit_test(test_wcore_attrib_list32_update_missing_key), }; -return run_tests(tests); +return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/src/waffle/core/wcore_config_attrs_unittest.c b/src/waffle/core/wcore_config_attrs_unittest.c index 501e30f..e6a2af0 100644 --- a/src/waffle/core/wcore_config_attrs_unittest.c +++ b/src/waffle/core/wcore_config_attrs_unittest.c @@ -40,7 +40,7 @@ struct test_state_wcore_config_attrs { struct wcore_config_attrs expect_attrs; }; -static void +static int setup(void **state) { static const struct wcore_config_attrs default_attrs = { // There is no default context api, so arbitrarily choose OpenGL. The @@ -73,18 +73,24 @@ setup(void **state) { wcore_error_reset(); -*state = ts = calloc(1, sizeof(*ts)); +ts = calloc(1, sizeof(*ts)); +if (!ts) +return -1; + +*state = ts; // Fill actual_attrs with canaries. memset(&ts->actual_attrs, 0x99, sizeof(ts->actual_attrs)); // Set expect_attrs to defaults. memcpy(&ts->expect_attrs, &default_attrs, sizeof(ts->expect_attrs)); +return 0; } -static void +static int teardown(void **state) { free(*state); +return 0; } static void @@ -1145,8 +1151,8 @@ test_wcore_config_attrs_debug_gles3(void **state) { int main(void) { -const UnitTest tests[] = { -#define unit_test_make(name) unit_test_setup_teardown(name, setup, teardown) +const struct CMUnitTest tests[] = { +#define unit_test_make(name) cmocka_unit_test_setup_teardown(name, setup, teardown) unit_test_make(test_wcore_config_attrs_null_attrib_list), unit_test_make(test_wcore_config_attrs_empty_attrib_list), @@ -1213,5 +1219,5 @@ main(void) { #undef unit_test_make }; -return run_tests(tests); +return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/src/waffle/core/wcore_error_unittest.c b/src/waffle/core/wcore_error_unittest.c index 0ac
[waffle] [PATCH 27/29] tests/gl_basic: enable cgl
From: Emil Velikov With this patch in place, all the existing tests are fully converted to cmocka. With this in place, one can get a 'clean bill of health' according to valgrind. The odd remaining memory leak(s) are likely due to the driver. Fixes #35: https://github.com/waffle-gl/waffle/issues/35 Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 61 ++-- 1 file changed, 8 insertions(+), 53 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index c32b53b..4e81ece 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -631,58 +631,16 @@ test_XX_fwdcompat(gles3, OPENGL_ES3, ERROR_UNSUPPORTED_ON_PLATFORM) #endif -#if 0 #ifdef WAFFLE_HAS_CGL -TEST(gl_basic, cgl_init) -{ -gl_basic_init(WAFFLE_PLATFORM_CGL); -} -static void -testsuite_cgl(void) -{ -TEST_RUN(gl_basic, cgl_init); - -TEST_RUN(gl_basic, gl_rgb); -TEST_RUN(gl_basic, gl_rgba); -TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, gl_debug); - -TEST_RUN(gl_basic, gl10); -TEST_RUN(gl_basic, gl11); -TEST_RUN(gl_basic, gl12); -TEST_RUN(gl_basic, gl13); -TEST_RUN(gl_basic, gl14); -TEST_RUN(gl_basic, gl15); -TEST_RUN(gl_basic, gl20); -TEST_RUN(gl_basic, gl21); -TEST_RUN(gl_basic, gl21_fwdcompat); - -TEST_RUN(gl_basic, gl30); -TEST_RUN(gl_basic, gl30_fwdcompat); -TEST_RUN(gl_basic, gl31); -TEST_RUN(gl_basic, gl31_fwdcompat); - -TEST_RUN(gl_basic, gl32_core); -TEST_RUN(gl_basic, gl32_core_fwdcompat); -TEST_RUN(gl_basic, gl33_core); -TEST_RUN(gl_basic, gl40_core); -TEST_RUN(gl_basic, gl41_core); -TEST_RUN(gl_basic, gl42_core); -TEST_RUN(gl_basic, gl43_core); - -TEST_RUN(gl_basic, gl32_compat); -TEST_RUN(gl_basic, gl33_compat); -TEST_RUN(gl_basic, gl40_compat); -TEST_RUN(gl_basic, gl41_compat); -TEST_RUN(gl_basic, gl42_compat); -TEST_RUN(gl_basic, gl43_compat); - -TEST_RUN(gl_basic, gles10); -TEST_RUN(gl_basic, gles20); -} +#define unit_test_make(name)\ +cmocka_unit_test_setup_teardown(name, setup_cgl, gl_basic_fini) + +CREATE_TESTSUITE(WAFFLE_PLATFORM_CGL, cgl) + +#undef unit_test_make + #endif // WAFFLE_HAS_CGL -#endif // 0 #ifdef WAFFLE_HAS_GLX @@ -902,13 +860,10 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); switch (platform) { -#if 0 #ifdef WAFFLE_HAS_CGL case WAFFLE_PLATFORM_CGL: -run_testsuite(testsuite_cgl); -break; +return testsuite_cgl(); #endif -#endif // 0 #ifdef WAFFLE_HAS_GLX case WAFFLE_PLATFORM_GLX: return testsuite_glx(); -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 24/29] tests/gl_basic: enable x11_egl
From: Emil Velikov Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 66 1 file changed, 6 insertions(+), 60 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index c4faa11..9a2bfff 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -714,67 +714,14 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_WAYLAND, wayland) #endif // WAFFLE_HAS_WAYLAND #ifdef WAFFLE_HAS_X11_EGL -TEST(gl_basic, x11_egl_init) -{ -gl_basic_init(WAFFLE_PLATFORM_X11_EGL); -} - -static void -testsuite_x11_egl(void) -{ -TEST_RUN(gl_basic, x11_egl_init); - -TEST_RUN(gl_basic, gl_rgb); -TEST_RUN(gl_basic, gl_rgba); -TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, gl_debug); - -TEST_RUN(gl_basic, gl10); -TEST_RUN(gl_basic, gl11); -TEST_RUN(gl_basic, gl12); -TEST_RUN(gl_basic, gl13); -TEST_RUN(gl_basic, gl14); -TEST_RUN(gl_basic, gl15); -TEST_RUN(gl_basic, gl20); -TEST_RUN(gl_basic, gl21); -TEST_RUN(gl_basic, gl21_fwdcompat); - -TEST_RUN(gl_basic, gl30); -TEST_RUN(gl_basic, gl30_fwdcompat); -TEST_RUN(gl_basic, gl31); -TEST_RUN(gl_basic, gl31_fwdcompat); - -TEST_RUN(gl_basic, gl32_core); -TEST_RUN(gl_basic, gl32_core_fwdcompat); -TEST_RUN(gl_basic, gl33_core); -TEST_RUN(gl_basic, gl40_core); -TEST_RUN(gl_basic, gl41_core); -TEST_RUN(gl_basic, gl42_core); -TEST_RUN(gl_basic, gl43_core); -TEST_RUN(gl_basic, gl32_compat); -TEST_RUN(gl_basic, gl33_compat); -TEST_RUN(gl_basic, gl40_compat); -TEST_RUN(gl_basic, gl41_compat); -TEST_RUN(gl_basic, gl42_compat); -TEST_RUN(gl_basic, gl43_compat); +#define unit_test_make(name)\ +cmocka_unit_test_setup_teardown(name, setup_x11_egl, gl_basic_fini) -TEST_RUN(gl_basic, gles1_rgb); -TEST_RUN(gl_basic, gles1_rgba); -TEST_RUN(gl_basic, gles1_fwdcompat); -TEST_RUN(gl_basic, gles10); -TEST_RUN(gl_basic, gles11); +CREATE_TESTSUITE(WAFFLE_PLATFORM_X11_EGL, x11_egl) -TEST_RUN(gl_basic, gles2_rgb); -TEST_RUN(gl_basic, gles2_rgba); -TEST_RUN(gl_basic, gles2_fwdcompat); -TEST_RUN(gl_basic, gles20); +#undef unit_test_make -TEST_RUN(gl_basic, gles3_rgb); -TEST_RUN(gl_basic, gles3_rgba); -TEST_RUN(gl_basic, gles3_fwdcompat); -TEST_RUN(gl_basic, gles30); -} #endif // WAFFLE_HAS_X11_EGL #ifdef WAFFLE_HAS_WGL @@ -1037,12 +984,11 @@ main(int argc, char *argv[]) run_testsuite(testsuite_wgl); break; #endif +#endif // 0 #ifdef WAFFLE_HAS_X11_EGL case WAFFLE_PLATFORM_X11_EGL: -run_testsuite(testsuite_x11_egl); -break; +return testsuite_x11_egl(); #endif -#endif // 0 default: abort(); break; -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 29/29] tests/gl_basic: call waffle_error_get_code() less often
From: Emil Velikov There is no need to (potentially) call the function twice in a roll, as there are no waffle calls inbetween that can trigger a change. Use a switch (as opposed to if-else 'spaghetti'), which has the benefit of slightly improved readability. While we're here, fix the copy/paste in the related comment. Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 10a7af8..02d4712 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -320,15 +320,14 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ args) assert_true(waffle_error_get_code() == expect_error); return; } else if (ts->config == NULL) { -if (waffle_error_get_code() == WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM) { -skip(); -} -else if (waffle_error_get_code() == WAFFLE_ERROR_UNKNOWN) { +switch (waffle_error_get_code()) { +case WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM: +// fall-through +case WAFFLE_ERROR_UNKNOWN: // Assume that the native platform rejected the requested -// context flavor. +// config flavor. skip(); -} -else { +default: assert_true(0); } } @@ -338,15 +337,14 @@ gl_basic_draw__(void **state, struct gl_basic_draw_args__ args) ts->ctx = waffle_context_create(ts->config, NULL); if (ts->ctx == NULL) { -if (waffle_error_get_code() == WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM) { -skip(); -} -else if (waffle_error_get_code() == WAFFLE_ERROR_UNKNOWN) { +switch (waffle_error_get_code()) { +case WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM: +// fall-through +case WAFFLE_ERROR_UNKNOWN: // Assume that the native platform rejected the requested // context flavor. skip(); -} -else { +default: assert_true(0); } } -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 25/29] tests/gl_basic: enable wgl
From: Emil Velikov Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 67 +++- 1 file changed, 5 insertions(+), 62 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 9a2bfff..970f299 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -725,69 +725,15 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_X11_EGL, x11_egl) #endif // WAFFLE_HAS_X11_EGL #ifdef WAFFLE_HAS_WGL -TEST(gl_basic, wgl_init) -{ -gl_basic_init(WAFFLE_PLATFORM_WGL); -} - -static void -testsuite_wgl(void) -{ -TEST_RUN(gl_basic, wgl_init); - -TEST_RUN(gl_basic, gl_rgb); -TEST_RUN(gl_basic, gl_rgba); -TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, gl_debug); - -TEST_RUN(gl_basic, gl10); -TEST_RUN(gl_basic, gl11); -TEST_RUN(gl_basic, gl12); -TEST_RUN(gl_basic, gl13); -TEST_RUN(gl_basic, gl14); -TEST_RUN(gl_basic, gl15); -TEST_RUN(gl_basic, gl20); -TEST_RUN(gl_basic, gl21); -TEST_RUN(gl_basic, gl21_fwdcompat); - -TEST_RUN(gl_basic, gl30); -TEST_RUN(gl_basic, gl30_fwdcompat); -TEST_RUN(gl_basic, gl31); -TEST_RUN(gl_basic, gl31_fwdcompat); - -TEST_RUN(gl_basic, gl32_core); -TEST_RUN(gl_basic, gl32_core_fwdcompat); -TEST_RUN(gl_basic, gl33_core); -TEST_RUN(gl_basic, gl40_core); -TEST_RUN(gl_basic, gl41_core); -TEST_RUN(gl_basic, gl42_core); -TEST_RUN(gl_basic, gl43_core); -TEST_RUN(gl_basic, gl32_compat); -TEST_RUN(gl_basic, gl33_compat); -TEST_RUN(gl_basic, gl40_compat); -TEST_RUN(gl_basic, gl41_compat); -TEST_RUN(gl_basic, gl42_compat); -TEST_RUN(gl_basic, gl43_compat); +#define unit_test_make(name)\ +cmocka_unit_test_setup_teardown(name, setup_wgl, gl_basic_fini) -TEST_RUN(gl_basic, gles1_rgb); -TEST_RUN(gl_basic, gles1_rgba); -TEST_RUN(gl_basic, gles1_fwdcompat); -TEST_RUN(gl_basic, gles10); -TEST_RUN(gl_basic, gles11); +CREATE_TESTSUITE(WAFFLE_PLATFORM_WGL, wgl) -TEST_RUN(gl_basic, gles2_rgb); -TEST_RUN(gl_basic, gles2_rgba); -TEST_RUN(gl_basic, gles2_fwdcompat); -TEST_RUN(gl_basic, gles20); +#undef unit_test_make -TEST_RUN(gl_basic, gles3_rgb); -TEST_RUN(gl_basic, gles3_rgba); -TEST_RUN(gl_basic, gles3_fwdcompat); -TEST_RUN(gl_basic, gles30); -} #endif // WAFFLE_HAS_WGL -#endif // 0 #undef test_glesXX @@ -978,13 +924,10 @@ main(int argc, char *argv[]) case WAFFLE_PLATFORM_WAYLAND: return testsuite_wayland(); #endif -#if 0 #ifdef WAFFLE_HAS_WGL case WAFFLE_PLATFORM_WGL: -run_testsuite(testsuite_wgl); -break; +return testsuite_wgl(); #endif -#endif // 0 #ifdef WAFFLE_HAS_X11_EGL case WAFFLE_PLATFORM_X11_EGL: return testsuite_x11_egl(); -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 28/29] tests/gl_basic: add support for GBM platform
From: Emil Velikov This way we can also run waffle's tests through headless CI ;-) Fixes #34: https://github.com/waffle-gl/waffle/issues/34 Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 21 +++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 4e81ece..10a7af8 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -614,7 +614,8 @@ test_glesXX(3, 30, NO_ERROR) // we have to split the ESx + fwdcompat tests into "CGL and everyone else". // -#if defined(WAFFLE_HAS_GLX) || \ +#if defined(WAFFLE_HAS_GBM) || \ +defined(WAFFLE_HAS_GLX) || \ defined(WAFFLE_HAS_WAYLAND) || \ defined(WAFFLE_HAS_X11_EGL) || \ defined(WAFFLE_HAS_WGL) @@ -642,6 +643,17 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_CGL, cgl) #endif // WAFFLE_HAS_CGL +#ifdef WAFFLE_HAS_GBM + +#define unit_test_make(name)\ +cmocka_unit_test_setup_teardown(name, setup_gbm, gl_basic_fini) + +CREATE_TESTSUITE(WAFFLE_PLATFORM_GBM, gbm) + +#undef unit_test_make + +#endif // WAFFLE_HAS_GBM + #ifdef WAFFLE_HAS_GLX #define unit_test_make(name)\ @@ -708,7 +720,7 @@ static const char *usage_message = "\n" "Required Parameter:\n" "-p, --platform\n" -"One of: cgl, glx, wayland, wgl or x11_egl\n" +"One of: cgl, gbm, glx, wayland, wgl or x11_egl\n" "\n" "Options:\n" "-h, --help\n" @@ -764,6 +776,7 @@ struct enum_map { static const struct enum_map platform_map[] = { {WAFFLE_PLATFORM_CGL, "cgl", }, +{WAFFLE_PLATFORM_GBM, "gbm" }, {WAFFLE_PLATFORM_GLX, "glx" }, {WAFFLE_PLATFORM_WAYLAND, "wayland" }, {WAFFLE_PLATFORM_WGL, "wgl" }, @@ -864,6 +877,10 @@ main(int argc, char *argv[]) case WAFFLE_PLATFORM_CGL: return testsuite_cgl(); #endif +#ifdef WAFFLE_HAS_GBM +case WAFFLE_PLATFORM_GBM: +return testsuite_gbm(); +#endif #ifdef WAFFLE_HAS_GLX case WAFFLE_PLATFORM_GLX: return testsuite_glx(); -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 22/29] tests/gl_basic: setup CREATE_TESTSUITE macro and enable glx
From: Emil Velikov Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 140 ++- 1 file changed, 80 insertions(+), 60 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 75d9c20..283489c 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -483,7 +483,76 @@ static void test_gl_basic_gles##waffle_version(void **state)\ .expect_error=WAFFLE_##error);\ } -#if 0 + +#define CREATE_TESTSUITE(waffle_platform, platform) \ +\ +static int \ +setup_##platform(void **state) \ +{ \ +return gl_basic_init(state, waffle_platform); \ +} \ +\ +static int \ +testsuite_##platform(void) \ +{ \ +const struct CMUnitTest tests[] = { \ +\ +unit_test_make(test_gl_basic_gl_rgb), \ +unit_test_make(test_gl_basic_gl_rgba), \ +unit_test_make(test_gl_basic_gl_fwdcompat), \ +unit_test_make(test_gl_basic_gl_debug), \ +\ +unit_test_make(test_gl_basic_gl10), \ +unit_test_make(test_gl_basic_gl11), \ +unit_test_make(test_gl_basic_gl12), \ +unit_test_make(test_gl_basic_gl13), \ +unit_test_make(test_gl_basic_gl14), \ +unit_test_make(test_gl_basic_gl15), \ +unit_test_make(test_gl_basic_gl20), \ +unit_test_make(test_gl_basic_gl21), \ +unit_test_make(test_gl_basic_gl21_fwdcompat), \ +\ +unit_test_make(test_gl_basic_gl30), \ +unit_test_make(test_gl_basic_gl30_fwdcompat), \ +unit_test_make(test_gl_basic_gl31), \ +unit_test_make(test_gl_basic_gl31_fwdcompat), \ +\ +unit_test_make(test_gl_basic_gl32_core),\ +unit_test_make(test_gl_basic_gl32_core_fwdcompat), \ +unit_test_make(test_gl_basic_gl33_core),\ +unit_test_make(test_gl_basic_gl40_core),\ +unit_test_make(test_gl_basic_gl41_core),\ +unit_test_make(test_gl_basic_gl42_core),\ +unit_test_make(test_gl_basic_gl43_core),\ +\ +unit_test_make(test_gl_basic_gl32_compat), \ +unit_test_make(test_gl_basic_gl33_compat), \ +unit_test_make(test_gl_basic_gl40_compat), \ +unit_test_make(test_gl_basic_gl41_compat), \ +unit_test_make(test_gl_basic_gl42_compat), \ +unit_test_make(test_gl_basic_gl43_compat), \ +\ +unit_test_make(test_gl_basic_gles1_rgb),\ +unit_test_make(test_gl_basic_gles1_rgba), \ +unit_test_make(test_gl_basic_gles1_fwdcompat), \ +unit_test_make(test_gl_basic_gles10), \ +unit_test_make(test_gl_basic_gles11), \ +\ +unit_test_make(test_gl_basic_gles2_rgb),\ +unit_test_make(test_gl_basic_gles2_rgba), \ +unit_test_make(test_gl_basic_gles2_fwdcompat), \ +unit_test_make(test_gl_basic_gles20), \ +\ +unit_
[waffle] [PATCH 23/29] tests/gl_basic: enable wayland
From: Emil Velikov Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 67 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 283489c..c4faa11 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -702,69 +702,15 @@ CREATE_TESTSUITE(WAFFLE_PLATFORM_GLX, glx) #endif // WAFFLE_HAS_GLX -#if 0 #ifdef WAFFLE_HAS_WAYLAND -TEST(gl_basic, wayland_init) -{ -gl_basic_init(WAFFLE_PLATFORM_WAYLAND); -} - -static void -testsuite_wayland(void) -{ -TEST_RUN(gl_basic, wayland_init); - -TEST_RUN(gl_basic, gl_rgb); -TEST_RUN(gl_basic, gl_rgba); -TEST_RUN(gl_basic, gl_fwdcompat); -TEST_RUN(gl_basic, gl_debug); - -TEST_RUN(gl_basic, gl10); -TEST_RUN(gl_basic, gl11); -TEST_RUN(gl_basic, gl12); -TEST_RUN(gl_basic, gl13); -TEST_RUN(gl_basic, gl14); -TEST_RUN(gl_basic, gl15); -TEST_RUN(gl_basic, gl20); -TEST_RUN(gl_basic, gl21); -TEST_RUN(gl_basic, gl21_fwdcompat); -TEST_RUN(gl_basic, gl30); -TEST_RUN(gl_basic, gl30_fwdcompat); -TEST_RUN(gl_basic, gl31); -TEST_RUN(gl_basic, gl31_fwdcompat); - -TEST_RUN(gl_basic, gl32_core); -TEST_RUN(gl_basic, gl32_core_fwdcompat); -TEST_RUN(gl_basic, gl33_core); -TEST_RUN(gl_basic, gl40_core); -TEST_RUN(gl_basic, gl41_core); -TEST_RUN(gl_basic, gl42_core); -TEST_RUN(gl_basic, gl43_core); +#define unit_test_make(name)\ +cmocka_unit_test_setup_teardown(name, setup_wayland, gl_basic_fini) -TEST_RUN(gl_basic, gl32_compat); -TEST_RUN(gl_basic, gl33_compat); -TEST_RUN(gl_basic, gl40_compat); -TEST_RUN(gl_basic, gl41_compat); -TEST_RUN(gl_basic, gl42_compat); -TEST_RUN(gl_basic, gl43_compat); +CREATE_TESTSUITE(WAFFLE_PLATFORM_WAYLAND, wayland) -TEST_RUN(gl_basic, gles1_rgb); -TEST_RUN(gl_basic, gles1_rgba); -TEST_RUN(gl_basic, gles1_fwdcompat); -TEST_RUN(gl_basic, gles10); -TEST_RUN(gl_basic, gles11); - -TEST_RUN(gl_basic, gles2_rgb); -TEST_RUN(gl_basic, gles2_rgba); -TEST_RUN(gl_basic, gles2_fwdcompat); -TEST_RUN(gl_basic, gles20); +#undef unit_test_make -TEST_RUN(gl_basic, gles3_rgb); -TEST_RUN(gl_basic, gles3_rgba); -TEST_RUN(gl_basic, gles3_fwdcompat); -TEST_RUN(gl_basic, gles30); -} #endif // WAFFLE_HAS_WAYLAND #ifdef WAFFLE_HAS_X11_EGL @@ -1081,12 +1027,11 @@ main(int argc, char *argv[]) case WAFFLE_PLATFORM_GLX: return testsuite_glx(); #endif -#if 0 #ifdef WAFFLE_HAS_WAYLAND case WAFFLE_PLATFORM_WAYLAND: -run_testsuite(testsuite_wayland); -break; +return testsuite_wayland(); #endif +#if 0 #ifdef WAFFLE_HAS_WGL case WAFFLE_PLATFORM_WGL: run_testsuite(testsuite_wgl); -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 19/29] core: wcore_error_reset() after calloc()
Signed-off-by: Emil Velikov --- src/waffle/core/wcore_config_attrs_unittest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/waffle/core/wcore_config_attrs_unittest.c b/src/waffle/core/wcore_config_attrs_unittest.c index e6a2af0..14eec01 100644 --- a/src/waffle/core/wcore_config_attrs_unittest.c +++ b/src/waffle/core/wcore_config_attrs_unittest.c @@ -71,14 +71,14 @@ setup(void **state) { struct test_state_wcore_config_attrs *ts; -wcore_error_reset(); - ts = calloc(1, sizeof(*ts)); if (!ts) return -1; *state = ts; +wcore_error_reset(); + // Fill actual_attrs with canaries. memset(&ts->actual_attrs, 0x99, sizeof(ts->actual_attrs)); -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 26/29] tests/gl_basic: reshuffle the cgl tests
From: Emil Velikov During context setup we prioritise as follows 1. expected error (!= NO_ERROR), check it 2. otherwise (if call fails) check for a) UNSUPPORTED_ON_PLATFORM and b) ERROR_UNKNOWN (winsys implementation has rejected the request) and skip the test. If other error is returned, fail the test. Thus, we can fold the CGL specific UNSUPPORTED_ON_PLATFORM tests, where NO_ERROR is expected. Thus all that happens is that some tests change from "pass" to "skip", at the cost of greatly simplifying things ;-) The remaining tests will still need to be separated as any other expected result must be checked explicitly. Add a similar inline comment for posterity. Signed-off-by: Emil Velikov --- tests/functional/gl_basic_test.c | 55 ++-- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/tests/functional/gl_basic_test.c b/tests/functional/gl_basic_test.c index 970f299..c32b53b 100644 --- a/tests/functional/gl_basic_test.c +++ b/tests/functional/gl_basic_test.c @@ -568,9 +568,10 @@ test_glXX_fwdcompat(21, ERROR_BAD_ATTRIBUTE) // -// List of linux (glx, wayland and x11_egl) and windows (wgl) specific tests. +// Most of the following tests will return ERROR_UNSUPPORTED_ON_PLATFORM +// on Apple/CGL, where NO_ERROR is expected. +// This is safe, as the test is skipped when the said error occurs. // -#if defined(WAFFLE_HAS_GLX) || defined(WAFFLE_HAS_WAYLAND) || defined(WAFFLE_HAS_X11_EGL) || defined(WAFFLE_HAS_WGL) test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) test_gl_debug(NO_ERROR) @@ -597,19 +598,37 @@ test_glXX_compat(43, NO_ERROR) test_XX_rgb(gles1, OPENGL_ES1, NO_ERROR) test_XX_rgba(gles1, OPENGL_ES1, NO_ERROR) -test_XX_fwdcompat(gles1, OPENGL_ES1, ERROR_BAD_ATTRIBUTE) test_glesXX(1, 10, NO_ERROR) test_glesXX(1, 11, NO_ERROR) test_XX_rgb(gles2, OPENGL_ES2, NO_ERROR) test_XX_rgba(gles2, OPENGL_ES2, NO_ERROR) -test_XX_fwdcompat(gles2, OPENGL_ES2, ERROR_BAD_ATTRIBUTE) test_glesXX(2, 20, NO_ERROR) test_XX_rgb(gles3, OPENGL_ES3, NO_ERROR) test_XX_rgba(gles3, OPENGL_ES3, NO_ERROR) -test_XX_fwdcompat(gles3, OPENGL_ES3, ERROR_BAD_ATTRIBUTE) test_glesXX(3, 30, NO_ERROR) + +// +// As BAD_ATTRIBUTE takes greater precedence over UNSUPPORTED_ON_PLATFORM, +// we have to split the ESx + fwdcompat tests into "CGL and everyone else". +// + +#if defined(WAFFLE_HAS_GLX) || \ +defined(WAFFLE_HAS_WAYLAND) || \ +defined(WAFFLE_HAS_X11_EGL) || \ +defined(WAFFLE_HAS_WGL) + +test_XX_fwdcompat(gles1, OPENGL_ES1, ERROR_BAD_ATTRIBUTE) +test_XX_fwdcompat(gles2, OPENGL_ES2, ERROR_BAD_ATTRIBUTE) +test_XX_fwdcompat(gles3, OPENGL_ES3, ERROR_BAD_ATTRIBUTE) + +#elif defined(WAFFLE_HAS_CGL) + +test_XX_fwdcompat(gles1, OPENGL_ES1, ERROR_UNSUPPORTED_ON_PLATFORM) +test_XX_fwdcompat(gles2, OPENGL_ES2, ERROR_UNSUPPORTED_ON_PLATFORM) +test_XX_fwdcompat(gles3, OPENGL_ES3, ERROR_UNSUPPORTED_ON_PLATFORM) + #endif #if 0 @@ -619,32 +638,6 @@ TEST(gl_basic, cgl_init) gl_basic_init(WAFFLE_PLATFORM_CGL); } -test_XX_fwdcompat(gl, OPENGL, ERROR_BAD_ATTRIBUTE) -test_gl_debug(ERROR_UNSUPPORTED_ON_PLATFORM) - -test_glXX(30, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_fwdcompat(30, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX(31, NO_ERROR) -test_glXX_fwdcompat(31, ERROR_UNSUPPORTED_ON_PLATFORM) - -test_glXX_core(32, NO_ERROR) -test_glXX_core_fwdcompat(32, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_core(33, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_core(40, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_core(41, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_core(42, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_core(43, ERROR_UNSUPPORTED_ON_PLATFORM) - -test_glXX_compat(32, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_compat(33, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_compat(40, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_compat(41, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_compat(42, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glXX_compat(43, ERROR_UNSUPPORTED_ON_PLATFORM) - -test_glesXX(1, 10, ERROR_UNSUPPORTED_ON_PLATFORM) -test_glesXX(2, 20, ERROR_UNSUPPORTED_ON_PLATFORM) - static void testsuite_cgl(void) { -- 2.6.2 ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
[waffle] [PATCH 21/29] waffle_test: bye bye
No longer used/needed. Signed-off-by: Emil Velikov --- .gitignore | 1 - include/waffle_test/priv/wt_runner.h | 46 include/waffle_test/priv/wt_test.h | 52 - include/waffle_test/waffle_test.h| 76 - src/CMakeLists.txt | 4 - src/waffle_test/CMakeLists.txt | 10 -- src/waffle_test/wt_main.c| 48 src/waffle_test/wt_runner.c | 165 --- src/waffle_test/wt_test.c| 208 --- 9 files changed, 610 deletions(-) delete mode 100644 include/waffle_test/priv/wt_runner.h delete mode 100644 include/waffle_test/priv/wt_test.h delete mode 100644 include/waffle_test/waffle_test.h delete mode 100644 src/waffle_test/CMakeLists.txt delete mode 100644 src/waffle_test/wt_main.c delete mode 100644 src/waffle_test/wt_runner.c delete mode 100644 src/waffle_test/wt_test.c diff --git a/.gitignore b/.gitignore index ee8c0fe..e9e3049 100644 --- a/.gitignore +++ b/.gitignore @@ -46,7 +46,6 @@ Makefile /libcmocka.a /src/waffle/libwaffle_static.a /tests/functional/gl_basic_test -/tests/waffle_test/libwaffle_test.dylib /tests/unittests/waffle-unittest /tests/wcore_attrib_list_unittest /tests/wcore_config_attrs_unittest diff --git a/include/waffle_test/priv/wt_runner.h b/include/waffle_test/priv/wt_runner.h deleted file mode 100644 index 543792d..000 --- a/include/waffle_test/priv/wt_runner.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012 Intel Corporation -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -void -wt_runner_init(void); - -void -wt_runner_finish(void); - -void -wt_runner_run_test( -const char *group, -const char *name, -void (*test)(void), -void (*setup)(void), -void (*teardown)(void)); - -void -wt_runner_print_summary(void); - -void -wt_runner_get_totals(int *pass, int *fail, int *ignore); diff --git a/include/waffle_test/priv/wt_test.h b/include/waffle_test/priv/wt_test.h deleted file mode 100644 index d6c75f5..000 --- a/include/waffle_test/priv/wt_test.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2012 Intel Corporation -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#pragma once - -#include - -enum wt_result { -WT_RESULT_PASS, -WT_RESULT_FAIL, -WT_RESULT_SKIP, -}; - -/// T
Re: [waffle] [PATCH v2 1/4] wflinfo.c: split out flags struct
On 5 January 2016 at 19:46, wrote: > From: Dylan Baker > > This is groundwork for adding a json interface to wflinfo. > > v2: - remove extra return statement (Frank) > - rename flags to context_flags (Chad) > --- > src/utils/wflinfo.c | 33 + > 1 file changed, 17 insertions(+), 16 deletions(-) > > diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c > index 268d4b8..eefb605 100644 > --- a/src/utils/wflinfo.c > +++ b/src/utils/wflinfo.c > @@ -487,23 +487,24 @@ print_extensions(bool use_stringi) > printf("\n"); > } > > +static struct { > +GLint flag; > +char *str; > +} context_flags[] = { One could use a few const qualifiers in here (and yes, it was supposed to be a simple move), if this gets to v3. > +{ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "FORWARD_COMPATIBLE" }, > +{ GL_CONTEXT_FLAG_DEBUG_BIT, "DEBUG" }, > +{ GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "ROBUST_ACCESS" }, > +}; > + > static void > print_context_flags(void) > { > -static struct { > -GLint flag; > -char *str; > -} flags[] = { > -{ GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "FORWARD_COMPATIBLE" }, > -{ GL_CONTEXT_FLAG_DEBUG_BIT, "DEBUG" }, > -{ GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "ROBUST_ACCESS" }, > -}; > -int flag_count = sizeof(flags) / sizeof(flags[0]); > -GLint context_flags = 0; > +int flag_count = sizeof(context_flags) / sizeof(context_flags[0]); > +GLint gl_context_flags = 0; Proposed name (annoyingly) clashes with the existing variable, but neither this or the previous is a deal breaker. -Emil ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v2 3/4] wflinfo.c: split version, renderer, and vendor checks
On 5 January 2016 at 19:46, wrote: > From: Dylan Baker > > Pull these out into helper functions, this change will be used in a > following patch to add a JSON printer. > > Signed-off-by: Dylan Baker > > v2: - change "const char * name" to "const char *name" (Frank) > --- > src/utils/wflinfo.c | 50 -- > 1 file changed, 36 insertions(+), 14 deletions(-) > > diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c > index 4b9..8ee95c6 100644 > --- a/src/utils/wflinfo.c > +++ b/src/utils/wflinfo.c > @@ -460,6 +460,39 @@ parse_version(const char *version) > return (major * 10) + minor; > } > > +static const char * > +get_vendor(void) > +{ > +const char *vendor = (const char *) glGetString(GL_VENDOR); > +if (glGetError() != GL_NO_ERROR || vendor == NULL) { > +vendor = "WFLINFO_GL_ERROR"; > +} > + Wish I caught you before re-spinning things. This and the other two can loose the brackets - those were added due to bugs in MSVC's C99 parser. This comment is another "if things ever get to v3". -Emil ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 02/29] gbm: don't fetch gbm_bo_* symbols from libgbm
On Wed, Jan 6, 2016 at 4:27 PM, Emil Velikov wrote: > Neither one of these is (or has been) used. Remove them for now and > introduce back when needed. > > Presently this causes run-time issues whenever someone attempts to use an > old version of libgbm (mesa circa 9.2) as the gbm_bo_get_fd symbol is > missing. > > Due to the multiple gbm provides and their inconsistent versioning > (xxx: check ?) we cannot reliably add a limitation during the configure > stage. > > This commit reverts a hunk of commit 14e3356a01d(gbm: make platform > friendlier to derived classes). The latter of which could have kept > these as a separate patch :) > > Cc: Frank Henigman > Cc: Chad Versace > Signed-off-by: Emil Velikov > --- > src/waffle/gbm/wgbm_platform.h | 11 +-- > 1 file changed, 1 insertion(+), 10 deletions(-) > > diff --git a/src/waffle/gbm/wgbm_platform.h b/src/waffle/gbm/wgbm_platform.h > index 1a08183..edcbe95 100644 > --- a/src/waffle/gbm/wgbm_platform.h > +++ b/src/waffle/gbm/wgbm_platform.h > @@ -41,16 +41,7 @@ > f(struct gbm_surface *, gbm_surface_create , (struct > gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t > flags)) \ > f(void, gbm_surface_destroy , (struct > gbm_surface *surface)) \ > f(struct gbm_bo * , gbm_surface_lock_front_buffer, (struct > gbm_surface *surface)) \ > -f(void, gbm_surface_release_buffer , (struct > gbm_surface *surface, struct gbm_bo *bo)) \ > -f(struct gbm_bo * , gbm_bo_create, (struct > gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t > flags)) \ > -f(void, gbm_bo_destroy , (struct gbm_bo > *bo)) \ > -f(int , gbm_bo_get_fd, (struct gbm_bo > *bo)) \ > -f(uint32_t, gbm_bo_get_width , (struct gbm_bo > *bo)) \ > -f(uint32_t, gbm_bo_get_height, (struct gbm_bo > *bo)) \ > -f(uint32_t, gbm_bo_get_stride, (struct gbm_bo > *bo)) \ > -f(uint32_t, gbm_bo_get_format, (struct gbm_bo > *bo)) \ > -f(union gbm_bo_handle , gbm_bo_get_handle, (struct gbm_bo > *bo)) \ > -f(struct gbm_device * , gbm_bo_get_device, (struct gbm_bo > *bo)) My surfaceless branch uses these. The branch I've been thinking I'll send to the list "soon" for ages. I'll add in a check for gbm_bo_get_fd and disable surfaceless if not found (though I'm sure it wouldn't work anyway on ancient mesa). In the mean time if you have to remove this stuff go ahead, or maybe just remove gbm_bo_get_fd. Then I won't have to add the others back in. ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH v2 3/4] wflinfo.c: split version, renderer, and vendor checks
On Wed, Jan 6, 2016 at 1:30 PM, Emil Velikov wrote: > On 5 January 2016 at 19:46, wrote: > > From: Dylan Baker > > > > Pull these out into helper functions, this change will be used in a > > following patch to add a JSON printer. > > > > Signed-off-by: Dylan Baker > > > > v2: - change "const char * name" to "const char *name" (Frank) > > --- > > src/utils/wflinfo.c | 50 > -- > > 1 file changed, 36 insertions(+), 14 deletions(-) > > > > diff --git a/src/utils/wflinfo.c b/src/utils/wflinfo.c > > index 4b9..8ee95c6 100644 > > --- a/src/utils/wflinfo.c > > +++ b/src/utils/wflinfo.c > > @@ -460,6 +460,39 @@ parse_version(const char *version) > > return (major * 10) + minor; > > } > > > > +static const char * > > +get_vendor(void) > > +{ > > +const char *vendor = (const char *) glGetString(GL_VENDOR); > > +if (glGetError() != GL_NO_ERROR || vendor == NULL) { > > +vendor = "WFLINFO_GL_ERROR"; > > +} > > + > Wish I caught you before re-spinning things. This and the other two > can loose the brackets - those were added due to bugs in MSVC's C99 > parser. This comment is another "if things ever get to v3". > > -Emil > After learning GO I'm always going to use brackets, because being in a good habit of using brackets prevents an entire class of bugs (like apple's ssl return bug). Unless Chad really objects to having the brackets I prefer them. ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 00/12] JSON and platform-specific wflinfo
Hi Frank, It looks like your series is going to achieve the same result (for my use) as mine did, but yours is probably better. With that in mind I'll be withdrawing mine in favour of yours. Dylan On Wed, Jan 6, 2016 at 11:56 AM, Frank Henigman wrote: > This patch set does two main things, the second of which could just as > well be a separate patch set. > 1-6: Move wflinfo functionality into the api, info returned as a json > string. > 7-12: Extend the functionality to include platform-specific info, such as > provided by glxinfo. > > After 1-6 wflinfo can be gutted to just get json from the api and present > it as desired (dump the json, legacy wflinfo format, glxinfo compatibility > format, verbose or not). I do not have a patch for that yet. > > Since another json patch set was recently posted, I'll point out how > this one differs... > This set moves wflinfo functionality into the api, the other extends > the wflinfo program. Both options were discussed on the mailing list > in Feb 2015 and the former was favored. This set includes a small > library for constructing json strings, with the aim of keeping string > building code as clear and simple as possible. It also tries to write > one key:value per line to allow grepping in lieu of full json parsing. > Finally this set adds additional platform-specific info, though as > stated above that could be considered a follow-on. > > > Frank Henigman (12): > core: store platform type in wcore_platform > core: store context API in wcore_context > core: store current context in wcore_display > core: add JSON library > waffle: add waffle_display_info_json() > wflinfo: add option for JSON output > waffle: support platform-specific information > wflinfo: add flag for platform-specific info > glx: implement platform-specific information > egl: implement platform-specific information > gbm: implement platform-specific information > x11_egl: implement platform-specific information > > include/waffle/waffle.h | 5 + > man/waffle_display.3.xml | 19 +++ > src/utils/wflinfo.c | 50 ++- > src/waffle/CMakeLists.txt| 1 + > src/waffle/api/waffle_display.c | 292 > ++- > src/waffle/api/waffle_gl_misc.c | 11 +- > src/waffle/api/waffle_init.c | 32 +++-- > src/waffle/core/json.c | 235 +++ > src/waffle/core/json.h | 93 + > src/waffle/core/wcore_context.h | 2 + > src/waffle/core/wcore_display.c | 1 + > src/waffle/core/wcore_display.h | 2 + > src/waffle/core/wcore_platform.h | 5 + > src/waffle/egl/wegl_display.c| 32 - > src/waffle/egl/wegl_display.h| 4 + > src/waffle/egl/wegl_platform.h | 3 + > src/waffle/gbm/wgbm_platform.c | 1 + > src/waffle/glx/glx_display.c | 41 ++ > src/waffle/glx/glx_display.h | 4 + > src/waffle/glx/glx_platform.c| 4 + > src/waffle/glx/glx_platform.h| 3 + > src/waffle/waffle.def.in | 1 + > src/waffle/xegl/xegl_platform.c | 1 + > 23 files changed, 820 insertions(+), 22 deletions(-) > create mode 100644 src/waffle/core/json.c > create mode 100644 src/waffle/core/json.h > > -- > 2.6.0.rc2.230.g3dd15c0 > > ___ > waffle mailing list > waffle@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/waffle > ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 00/12] JSON and platform-specific wflinfo
Okay, I have some comments: When I run wflinfo -p gbm -a gl -f json | jsontidy (a small python script I have that formats JSON to be human readable) I get this: { "generic": { "waffle": { "api": "WAFFLE_CONTEXT_OPENGL", "platform": "WAFFLE_PLATFORM_GBM" }, "extensions": [ "GL_3DFX_texture_compression_FXT1", ... (truncated for readability) "GL_SUN_multi_draw_arrays" ], "opengl": { "renderer": "Mesa DRI Intel(R) Haswell Mobile ", "version": "3.0 Mesa 11.1.0", "vendor": "Intel Open Source Technology Center" }, "shading_language_version": "1.30" } } I think the shading_language_version and extensions belong in the opengl dictionary. Other than that the output seems reasonable and quite usable for my purposes. On Wed, Jan 6, 2016 at 3:06 PM, Dylan Baker wrote: > Hi Frank, > > It looks like your series is going to achieve the same result (for my use) > as mine did, but yours is probably better. With that in mind I'll be > withdrawing mine in favour of yours. > > Dylan > > On Wed, Jan 6, 2016 at 11:56 AM, Frank Henigman > wrote: > >> This patch set does two main things, the second of which could just as >> well be a separate patch set. >> 1-6: Move wflinfo functionality into the api, info returned as a json >> string. >> 7-12: Extend the functionality to include platform-specific info, such as >> provided by glxinfo. >> >> After 1-6 wflinfo can be gutted to just get json from the api and present >> it as desired (dump the json, legacy wflinfo format, glxinfo compatibility >> format, verbose or not). I do not have a patch for that yet. >> >> Since another json patch set was recently posted, I'll point out how >> this one differs... >> This set moves wflinfo functionality into the api, the other extends >> the wflinfo program. Both options were discussed on the mailing list >> in Feb 2015 and the former was favored. This set includes a small >> library for constructing json strings, with the aim of keeping string >> building code as clear and simple as possible. It also tries to write >> one key:value per line to allow grepping in lieu of full json parsing. >> Finally this set adds additional platform-specific info, though as >> stated above that could be considered a follow-on. >> >> >> Frank Henigman (12): >> core: store platform type in wcore_platform >> core: store context API in wcore_context >> core: store current context in wcore_display >> core: add JSON library >> waffle: add waffle_display_info_json() >> wflinfo: add option for JSON output >> waffle: support platform-specific information >> wflinfo: add flag for platform-specific info >> glx: implement platform-specific information >> egl: implement platform-specific information >> gbm: implement platform-specific information >> x11_egl: implement platform-specific information >> >> include/waffle/waffle.h | 5 + >> man/waffle_display.3.xml | 19 +++ >> src/utils/wflinfo.c | 50 ++- >> src/waffle/CMakeLists.txt| 1 + >> src/waffle/api/waffle_display.c | 292 >> ++- >> src/waffle/api/waffle_gl_misc.c | 11 +- >> src/waffle/api/waffle_init.c | 32 +++-- >> src/waffle/core/json.c | 235 +++ >> src/waffle/core/json.h | 93 + >> src/waffle/core/wcore_context.h | 2 + >> src/waffle/core/wcore_display.c | 1 + >> src/waffle/core/wcore_display.h | 2 + >> src/waffle/core/wcore_platform.h | 5 + >> src/waffle/egl/wegl_display.c| 32 - >> src/waffle/egl/wegl_display.h| 4 + >> src/waffle/egl/wegl_platform.h | 3 + >> src/waffle/gbm/wgbm_platform.c | 1 + >> src/waffle/glx/glx_display.c | 41 ++ >> src/waffle/glx/glx_display.h | 4 + >> src/waffle/glx/glx_platform.c| 4 + >> src/waffle/glx/glx_platform.h| 3 + >> src/waffle/waffle.def.in | 1 + >> src/waffle/xegl/xegl_platform.c | 1 + >> 23 files changed, 820 insertions(+), 22 deletions(-) >> create mode 100644 src/waffle/core/json.c >> create mode 100644 src/waffle/core/json.h >> >> -- >> 2.6.0.rc2.230.g3dd15c0 >> >> ___ >> waffle mailing list >> waffle@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/waffle >> > > ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 00/12] JSON and platform-specific wflinfo
On Wed, Jan 6, 2016 at 6:43 PM, Dylan Baker wrote: > Okay, I have some comments: > > When I run wflinfo -p gbm -a gl -f json | jsontidy (a small python script I > have that formats JSON to be human readable) > I get this: > { > "generic": { > "waffle": { > "api": "WAFFLE_CONTEXT_OPENGL", > "platform": "WAFFLE_PLATFORM_GBM" > }, > "extensions": [ > "GL_3DFX_texture_compression_FXT1", > ... (truncated for readability) > "GL_SUN_multi_draw_arrays" > ], > "opengl": { > "renderer": "Mesa DRI Intel(R) Haswell Mobile ", > "version": "3.0 Mesa 11.1.0", > "vendor": "Intel Open Source Technology Center" > }, > "shading_language_version": "1.30" > } > } > > I think the shading_language_version and extensions belong in the opengl > dictionary. I didn't give much thought at the time to structure nor key names. Figured there would some debate in any case. (-: Makes sense to put gl extensions in the "opengl" block. How about a glsl block? Seems like there might be other stuff in it some day, and adds consistency to the use of "version" i.e. "glsl" : { "version" : "1.30" } I'm not as sure about putting it inside the opengl block, but not fussy about it either. If there's no dissent I'll do as you suggest. > Other than that the output seems reasonable and quite usable for my > purposes. Once again sorry for not sending mine out sooner. If none of your patch makes it in, hopefully it had some value to you as an exercise. ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle
Re: [waffle] [PATCH 00/12] JSON and platform-specific wflinfo
On Wed, Jan 6, 2016 at 4:12 PM, Frank Henigman wrote: > On Wed, Jan 6, 2016 at 6:43 PM, Dylan Baker > wrote: > > Okay, I have some comments: > > > > When I run wflinfo -p gbm -a gl -f json | jsontidy (a small python > script I > > have that formats JSON to be human readable) > > I get this: > > { > > "generic": { > > "waffle": { > > "api": "WAFFLE_CONTEXT_OPENGL", > > "platform": "WAFFLE_PLATFORM_GBM" > > }, > > "extensions": [ > > "GL_3DFX_texture_compression_FXT1", > > ... (truncated for readability) > > "GL_SUN_multi_draw_arrays" > > ], > > "opengl": { > > "renderer": "Mesa DRI Intel(R) Haswell Mobile ", > > "version": "3.0 Mesa 11.1.0", > > "vendor": "Intel Open Source Technology Center" > > }, > > "shading_language_version": "1.30" > > } > > } > > > > I think the shading_language_version and extensions belong in the opengl > > dictionary. > > I didn't give much thought at the time to structure nor key names. > Figured there > would some debate in any case. (-: > Makes sense to put gl extensions in the "opengl" block. > How about a glsl block? Seems like there might be other stuff in it some > day, > and adds consistency to the use of "version" i.e. > "glsl" : { > "version" : "1.30" > } > I'm not as sure about putting it inside the opengl block, but not > fussy about it either. > If there's no dissent I'll do as you suggest. > Putting it an a "glsl" block sounds better to me. > > > Other than that the output seems reasonable and quite usable for my > > purposes. > > Once again sorry for not sending mine out sooner. If none of your patch > makes > it in, hopefully it had some value to you as an exercise. > It did have that. ___ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle