#include "xdg-shell-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
+#include "weston-direct-display-client-protocol.h"
#include "linux-explicit-synchronization-unstable-v1-client-protocol.h"
#include <EGL/egl.h>
#define OPT_IMMEDIATE (1 << 0) /* create wl_buffer immediately */
#define OPT_IMPLICIT_SYNC (1 << 1) /* force implicit sync */
#define OPT_MANDELBROT (1 << 2) /* render mandelbrot */
+#define OPT_DIRECT_DISPLAY (1 << 3) /* direct-display */
#define BUFFER_FORMAT DRM_FORMAT_XRGB8888
#define MAX_BUFFER_PLANES 4
struct xdg_wm_base *wm_base;
struct zwp_fullscreen_shell_v1 *fshell;
struct zwp_linux_dmabuf_v1 *dmabuf;
+ struct weston_direct_display_v1 *direct_display;
struct zwp_linux_explicit_synchronization_v1 *explicit_sync;
uint64_t *modifiers;
int modifiers_count;
static int
create_dmabuf_buffer(struct display *display, struct buffer *buffer,
- int width, int height)
+ int width, int height, uint32_t opts)
{
/* Y-Invert the buffer image, since we are going to renderer to the
* buffer through a FBO. */
- static const uint32_t flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
+ static uint32_t flags = ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
struct zwp_linux_buffer_params_v1 *params;
int i;
#endif
params = zwp_linux_dmabuf_v1_create_params(display->dmabuf);
+
+ if ((opts & OPT_DIRECT_DISPLAY) && display->direct_display) {
+ weston_direct_display_v1_enable(display->direct_display, params);
+ /* turn off Y_INVERT otherwise linux-dmabuf will reject it and
+ * we need all dmabuf flags turned off */
+ flags &= ~ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT;
+ }
+
for (i = 0; i < buffer->plane_count; ++i) {
zwp_linux_buffer_params_v1_add(params,
buffer->dmabuf_fds[i],
for (i = 0; i < NUM_BUFFERS; ++i) {
ret = create_dmabuf_buffer(display, &window->buffers[i],
- width, height);
+ width, height, opts);
if (ret < 0)
goto error;
d->explicit_sync = wl_registry_bind(
registry, id,
&zwp_linux_explicit_synchronization_v1_interface, 1);
+ } else if (strcmp(interface, "weston_direct_display_v1") == 0) {
+ d->direct_display = wl_registry_bind(registry,
+ id, &weston_direct_display_v1_interface, 1);
}
}
"\n\t\t0 to disable explicit sync, "
"\n\t\t1 to enable explicit sync (default: 1)\n"
"\t'-m,--mandelbrot'"
- "\n\t\trender a mandelbrot set with multiple draw calls\n");
+ "\n\t\trender a mandelbrot set with multiple draw calls\n"
+ "\t'-g,--direct-display'"
+ "\n\t\tenables weston-direct-display extension to attempt direct scan-out\n");
exit(0);
}
{"size", required_argument, 0, 's' },
{"explicit-sync", required_argument, 0, 'e' },
{"mandelbrot", no_argument, 0, 'm' },
+ {"direct-display", no_argument, 0, 'g' },
{"help", no_argument , 0, 'h' },
{0, 0, 0, 0}
};
- while ((c = getopt_long(argc, argv, "hi:d:s:e:m",
+ while ((c = getopt_long(argc, argv, "hi:d:s:e:mg",
long_options, &option_index)) != -1) {
switch (c) {
case 'i':
case 'm':
opts |= OPT_MANDELBROT;
break;
+ case 'g':
+ opts |= OPT_DIRECT_DISPLAY;
+ break;
default:
print_usage_and_exit();
}