Skip to content

Commit

Permalink
wflinfo: show platform-specific information
Browse files Browse the repository at this point in the history
Add waffle_display_print_info() which calls a new display struct member
function "print_info" to print platform-specific information, such as
glx or egl version and extensions.
Call this new function from wflinfo when the -s flag is given.
Gbm, glx and x11_egl platforms supported so far.
  • Loading branch information
fjhenigman committed Feb 8, 2015
1 parent a074cab commit d0b45bb
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 3 deletions.
3 changes: 3 additions & 0 deletions include/waffle/waffle.h
Expand Up @@ -208,6 +208,9 @@ bool
waffle_display_supports_context_api(struct waffle_display *self,
int32_t context_api);

bool
waffle_display_print_info(struct waffle_display *self, bool verbose);

This comment has been minimized.

Copy link
@versalinyaa

versalinyaa Feb 10, 2015

When adding new entries to the public API, the entry should be guarded with a feature test macro, just like the POSIX and Xopen macros. See man:waffle_feature_test_macros(7).

The sensible choice is to guard this with WAFFLE_API_VERSION >= 0x0106, just like waffle_window_create2().


union waffle_native_display*
waffle_display_get_native(struct waffle_display *self);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/wflinfo.c
Expand Up @@ -1134,7 +1134,7 @@ main(int argc, char **argv)
error_waffle();

if (opts.specific) {
//TODO print platform-specific information
waffle_display_print_info(dpy, opts.verbose);
}

ok = waffle_make_current(dpy, NULL, NULL);
Expand Down
20 changes: 20 additions & 0 deletions src/waffle/api/waffle_display.c
Expand Up @@ -90,6 +90,26 @@ waffle_display_supports_context_api(
context_api);
}

WAFFLE_API bool
waffle_display_print_info(struct waffle_display *self, bool verbose)
{
struct wcore_display *wc_self = wcore_display(self);

const struct api_object *obj_list[] = {
wc_self ? &wc_self->api : NULL,
};

if (!api_check_entry(obj_list, 1))
return false;

if (api_platform->vtbl->display.print_info) {
return api_platform->vtbl->display.print_info(wc_self, verbose);
}

wcore_error(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
return false;
}

WAFFLE_API union waffle_native_display*
waffle_display_get_native(struct waffle_display *self)
{
Expand Down
5 changes: 5 additions & 0 deletions src/waffle/core/wcore_platform.h
Expand Up @@ -77,6 +77,11 @@ struct wcore_platform_vtbl {
struct wcore_display *display,
int32_t context_api);

bool
(*print_info)(
struct wcore_display *display,
bool verbose);

/// May be null.
union waffle_native_display*
(*get_native)(struct wcore_display *display);
Expand Down
27 changes: 25 additions & 2 deletions src/waffle/egl/wegl_display.c
Expand Up @@ -24,6 +24,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <assert.h>
#include <stdio.h>

#include "wcore_error.h"
#include "wcore_platform.h"
Expand Down Expand Up @@ -63,7 +64,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)
Expand All @@ -75,7 +75,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;
Expand Down Expand Up @@ -139,3 +139,26 @@ wegl_display_supports_context_api(struct wcore_display *wc_dpy,

return wc_plat->vtbl->dl_can_open(wc_plat, waffle_dl);
}

bool
wegl_display_print_info(struct wcore_display *wc_dpy,
bool verbose)
{
struct wegl_display *dpy = wegl_display(wc_dpy);
struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);

printf("EGL API version: %d.%d\n",
plat->major, plat->minor);
printf("EGL vendor string: %s\n",
plat->eglQueryString(dpy->egl, EGL_VENDOR));
printf("EGL version string: %s\n",
plat->eglQueryString(dpy->egl, EGL_VERSION));
#ifdef EGL_VERSION_1_2
printf("EGL client APIs: %s\n",
plat->eglQueryString(dpy->egl, EGL_CLIENT_APIS));
#endif
printf("EGL extensions string: %s\n",
plat->eglQueryString(dpy->egl, EGL_EXTENSIONS));

This comment has been minimized.

Copy link
@versalinyaa

versalinyaa Feb 10, 2015

Prefixing the lines with "EGL" looks like the right approach.

return true;
}
4 changes: 4 additions & 0 deletions src/waffle/egl/wegl_display.h
Expand Up @@ -56,3 +56,7 @@ wegl_display_teardown(struct wegl_display *dpy);
bool
wegl_display_supports_context_api(struct wcore_display *wc_dpy,
int32_t waffle_context_api);

bool
wegl_display_print_info(struct wcore_display *wc_self,
bool verbose);
3 changes: 3 additions & 0 deletions src/waffle/egl/wegl_platform.h
Expand Up @@ -33,6 +33,9 @@
struct wegl_platform {
struct wcore_platform wcore;

// EGL version from eglInitialize
EGLint major, minor;

// EGL function pointers
void *eglHandle;

Expand Down
1 change: 1 addition & 0 deletions src/waffle/gbm/wgbm_platform.c
Expand Up @@ -179,6 +179,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,
.print_info = wegl_display_print_info,
},

.config = {
Expand Down
32 changes: 32 additions & 0 deletions src/waffle/glx/glx_display.c
Expand Up @@ -23,6 +23,7 @@
// 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 <stdio.h>
#include <stdlib.h>

#include "wcore_error.h"
Expand Down Expand Up @@ -141,6 +142,37 @@ glx_display_supports_context_api(struct wcore_display *wc_self,
}
}

bool
glx_display_print_info(struct wcore_display *wc_self,
bool verbose)
{
struct glx_display *self = glx_display(wc_self);
struct glx_platform *plat = glx_platform(wc_self->platform);

int major, minor;
if (!plat->glXQueryVersion(self->x11.xlib, &major, &minor)) {
return false;
}

printf("server glx vendor string: %s\n",
plat->glXQueryServerString(self->x11.xlib, self->x11.screen, GLX_VENDOR));

This comment has been minimized.

Copy link
@versalinyaa

versalinyaa Feb 10, 2015

Every line should be prefixed with an all-caps "GLX", like "GLX server vendor string". After the prefix, I have no preference how you capitalize the rest of the line.

printf("server glx version string: %s\n",
plat->glXQueryServerString(self->x11.xlib, self->x11.screen, GLX_VERSION));
printf("server glx extensions: %s\n",
plat->glXQueryServerString(self->x11.xlib, self->x11.screen, GLX_EXTENSIONS));
printf("client glx vendor string: %s\n",
plat->glXGetClientString(self->x11.xlib, GLX_VENDOR));
printf("client glx version string: %s\n",
plat->glXGetClientString(self->x11.xlib, GLX_VERSION));
printf("client glx extensions: %s\n",
plat->glXGetClientString(self->x11.xlib, GLX_EXTENSIONS));
printf("GLX version: %d.%d\n", major, minor);

This comment has been minimized.

Copy link
@versalinyaa

versalinyaa Feb 10, 2015

Should be "GLX server version".

printf("GLX extensions: %s\n",
plat->glXQueryExtensionsString(self->x11.xlib, self->x11.screen));

return true;
}

union waffle_native_display*
glx_display_get_native(struct wcore_display *wc_self)
{
Expand Down
4 changes: 4 additions & 0 deletions src/waffle/glx/glx_display.h
Expand Up @@ -66,5 +66,9 @@ bool
glx_display_supports_context_api(struct wcore_display *wc_self,
int32_t context_api);

bool
glx_display_print_info(struct wcore_display *wc_self,
bool verbose);

union waffle_native_display*
glx_display_get_native(struct wcore_display *wc_self);
4 changes: 4 additions & 0 deletions src/waffle/glx/glx_platform.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
.print_info = glx_display_print_info,
.get_native = glx_display_get_native,
},

Expand Down
3 changes: 3 additions & 0 deletions src/waffle/glx/glx_platform.h
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/waffle/xegl/xegl_platform.c
Expand Up @@ -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,
.print_info = wegl_display_print_info,
.get_native = xegl_display_get_native,
},

Expand Down

0 comments on commit d0b45bb

Please sign in to comment.