Commit 64518c32 authored by Guido Günther's avatar Guido Günther

Merge branch 'upstream/latest' into debian/sid

parents 79eae504 9dcce71e
......@@ -33,41 +33,36 @@
static struct gbm gbm;
#ifdef HAVE_GBM_MODIFIERS
static int
get_modifiers(uint64_t **mods)
{
/* Assumed LINEAR is supported everywhere */
static uint64_t modifiers[] = {DRM_FORMAT_MOD_LINEAR};
*mods = modifiers;
return 1;
}
#endif
WEAK struct gbm_surface *
gbm_surface_create_with_modifiers(struct gbm_device *gbm,
uint32_t width, uint32_t height,
uint32_t format,
const uint64_t *modifiers,
const unsigned int count);
const struct gbm * init_gbm(int drm_fd, int w, int h, uint64_t modifier)
{
gbm.dev = gbm_create_device(drm_fd);
gbm.format = GBM_FORMAT_XRGB8888;
gbm.surface = NULL;
if (gbm_surface_create_with_modifiers) {
gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
gbm.format,
&modifier, 1);
#ifndef HAVE_GBM_MODIFIERS
if (modifier != DRM_FORMAT_MOD_INVALID) {
fprintf(stderr, "Modifiers requested but support isn't available\n");
return NULL;
}
gbm.surface = gbm_surface_create(gbm.dev, w, h,
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
#else
uint64_t *mods;
int count;
if (modifier != DRM_FORMAT_MOD_INVALID) {
count = 1;
mods = &modifier;
} else {
count = get_modifiers(&mods);
if (!gbm.surface) {
if (modifier != DRM_FORMAT_MOD_LINEAR) {
fprintf(stderr, "Modifiers requested but support isn't available\n");
return NULL;
}
gbm.surface = gbm_surface_create(gbm.dev, w, h,
gbm.format,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
}
gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
GBM_FORMAT_XRGB8888, mods, count);
#endif
if (!gbm.surface) {
printf("failed to create gbm surface\n");
......@@ -100,22 +95,89 @@ static bool has_ext(const char *extension_list, const char *ext)
}
}
int init_egl(struct egl *egl, const struct gbm *gbm)
static int
match_config_to_visual(EGLDisplay egl_display,
EGLint visual_id,
EGLConfig *configs,
int count)
{
EGLint major, minor, n;
int i;
for (i = 0; i < count; ++i) {
EGLint id;
if (!eglGetConfigAttrib(egl_display,
configs[i], EGL_NATIVE_VISUAL_ID,
&id))
continue;
if (id == visual_id)
return i;
}
return -1;
}
static bool
egl_choose_config(EGLDisplay egl_display, const EGLint *attribs,
EGLint visual_id, EGLConfig *config_out)
{
EGLint count = 0;
EGLint matched = 0;
EGLConfig *configs;
int config_index = -1;
if (!eglGetConfigs(egl_display, NULL, 0, &count) || count < 1) {
printf("No EGL configs to choose from.\n");
return false;
}
configs = malloc(count * sizeof *configs);
if (!configs)
return false;
if (!eglChooseConfig(egl_display, attribs, configs,
count, &matched) || !matched) {
printf("No EGL configs with appropriate attributes.\n");
goto out;
}
if (!visual_id)
config_index = 0;
if (config_index == -1)
config_index = match_config_to_visual(egl_display,
visual_id,
configs,
matched);
if (config_index != -1)
*config_out = configs[config_index];
out:
free(configs);
if (config_index == -1)
return false;
return true;
}
int init_egl(struct egl *egl, const struct gbm *gbm, int samples)
{
EGLint major, minor;
static const EGLint context_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
static const EGLint config_attribs[] = {
const EGLint config_attribs[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1,
EGL_ALPHA_SIZE, 0,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL_SAMPLES, samples,
EGL_NONE
};
const char *egl_exts_client, *egl_exts_dpy, *gl_exts;
......@@ -158,6 +220,9 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
get_proc_dpy(EGL_KHR_fence_sync, eglClientWaitSyncKHR);
get_proc_dpy(EGL_ANDROID_native_fence_sync, eglDupNativeFenceFDANDROID);
egl->modifiers_supported = has_ext(egl_exts_dpy,
"EGL_EXT_image_dma_buf_import_modifiers");
printf("Using display %p with EGL version %d.%d\n",
egl->display, major, minor);
......@@ -174,8 +239,9 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
return -1;
}
if (!eglChooseConfig(egl->display, config_attribs, &egl->config, 1, &n) || n != 1) {
printf("failed to choose config: %d\n", n);
if (!egl_choose_config(egl->display, config_attribs, gbm->format,
&egl->config)) {
printf("failed to choose config\n");
return -1;
}
......
......@@ -31,6 +31,7 @@
#include <gbm.h>
#include <drm_fourcc.h>
#include <stdbool.h>
#ifndef DRM_FORMAT_MOD_LINEAR
#define DRM_FORMAT_MOD_LINEAR 0
......@@ -57,9 +58,28 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy,
#endif
#endif /* EGL_EXT_platform_base */
#define WEAK __attribute__((weak))
/* Define tokens from EGL_EXT_image_dma_buf_import_modifiers */
#ifndef EGL_EXT_image_dma_buf_import_modifiers
#define EGL_EXT_image_dma_buf_import_modifiers 1
#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440
#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441
#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442
#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443
#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444
#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445
#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446
#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447
#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448
#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449
#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A
#endif
struct gbm {
struct gbm_device *dev;
struct gbm_surface *surface;
uint32_t format;
int width, height;
};
......@@ -82,6 +102,8 @@ struct egl {
PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR;
PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID;
bool modifiers_supported;
void (*draw)(unsigned i);
};
......@@ -96,7 +118,7 @@ static inline int __egl_check(void *ptr, const char *name)
#define egl_check(egl, name) __egl_check((egl)->name, #name)
int init_egl(struct egl *egl, const struct gbm *gbm);
int init_egl(struct egl *egl, const struct gbm *gbm, int samples);
int create_program(const char *vs_src, const char *fs_src);
int link_program(unsigned program);
......@@ -108,8 +130,8 @@ enum mode {
VIDEO, /* video textured cube */
};
const struct egl * init_cube_smooth(const struct gbm *gbm);
const struct egl * init_cube_tex(const struct gbm *gbm, enum mode mode);
const struct egl * init_cube_smooth(const struct gbm *gbm, int samples);
const struct egl * init_cube_tex(const struct gbm *gbm, enum mode mode, int samples);
#ifdef HAVE_GST
......@@ -118,13 +140,13 @@ struct decoder * video_init(const struct egl *egl, const struct gbm *gbm, const
EGLImage video_frame(struct decoder *dec);
void video_deinit(struct decoder *dec);
const struct egl * init_cube_video(const struct gbm *gbm, const char *video);
const struct egl * init_cube_video(const struct gbm *gbm, const char *video, int samples);
#else
static inline const struct egl *
init_cube_video(const struct gbm *gbm, const char *video)
init_cube_video(const struct gbm *gbm, const char *video, int samples)
{
(void)gbm; (void)video;
(void)gbm; (void)video; (void)samples;
printf("no GStreamer support!\n");
return NULL;
}
......
......@@ -49,21 +49,5 @@ if test "x$HAVE_GST" = "xyes"; then
fi
AM_CONDITIONAL(ENABLE_GST, [test "x$HAVE_GST" = "xyes"])
AC_CHECK_LIB([gbm], [gbm_bo_get_modifier], [gbm_modifiers=yes], [])
AC_ARG_ENABLE([gbm-modifiers],
[AS_HELP_STRING([--enable-gbm-modifiers],
[enable using GBM modifiers @<:@default=auto@:>@])],
[enable_gbm_modifiers="$enableval"],
[enable_gbm_modifiers=auto])
if test "x$enable_gbm_modifiers" = xyes -a "x$gbm_modifiers" != xyes; then
AC_MSG_ERROR([Cannot find gbm modifier supported mesa])
fi
if test "x$enable_gbm_modifiers" = xyes; then
AC_DEFINE(HAVE_GBM_MODIFIERS, 1, [Define if you can use GBM properties.])
fi
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
......@@ -218,11 +218,11 @@ static void draw_cube_smooth(unsigned i)
glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);
}
const struct egl * init_cube_smooth(const struct gbm *gbm)
const struct egl * init_cube_smooth(const struct gbm *gbm, int samples)
{
int ret;
ret = init_egl(&gl.egl, gbm);
ret = init_egl(&gl.egl, gbm, samples);
if (ret)
return NULL;
......
......@@ -29,6 +29,7 @@
#include "common.h"
#include "esUtil.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
struct {
struct egl egl;
......@@ -213,7 +214,10 @@ static const char *fragment_shader_source_2img =
static const uint32_t texw = 512, texh = 512;
static int get_fd_rgba(uint32_t *pstride)
WEAK uint64_t
gbm_bo_get_modifier(struct gbm_bo *bo);
static int get_fd_rgba(uint32_t *pstride, uint64_t *modifier)
{
struct gbm_bo *bo;
void *map_data = NULL;
......@@ -235,6 +239,11 @@ static int get_fd_rgba(uint32_t *pstride)
fd = gbm_bo_get_fd(bo);
if (gbm_bo_get_modifier)
*modifier = gbm_bo_get_modifier(bo);
else
*modifier = DRM_FORMAT_MOD_LINEAR;
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
......@@ -243,7 +252,7 @@ static int get_fd_rgba(uint32_t *pstride)
return fd;
}
static int get_fd_y(uint32_t *pstride)
static int get_fd_y(uint32_t *pstride, uint64_t *modifier)
{
struct gbm_bo *bo;
void *map_data = NULL;
......@@ -265,6 +274,11 @@ static int get_fd_y(uint32_t *pstride)
fd = gbm_bo_get_fd(bo);
if (gbm_bo_get_modifier)
*modifier = gbm_bo_get_modifier(bo);
else
*modifier = DRM_FORMAT_MOD_LINEAR;
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
......@@ -273,7 +287,7 @@ static int get_fd_y(uint32_t *pstride)
return fd;
}
static int get_fd_uv(uint32_t *pstride)
static int get_fd_uv(uint32_t *pstride, uint64_t *modifier)
{
struct gbm_bo *bo;
void *map_data = NULL;
......@@ -295,6 +309,11 @@ static int get_fd_uv(uint32_t *pstride)
fd = gbm_bo_get_fd(bo);
if (gbm_bo_get_modifier)
*modifier = gbm_bo_get_modifier(bo);
else
*modifier = DRM_FORMAT_MOD_LINEAR;
/* we have the fd now, no longer need the bo: */
gbm_bo_destroy(bo);
......@@ -306,16 +325,28 @@ static int get_fd_uv(uint32_t *pstride)
static int init_tex_rgba(void)
{
uint32_t stride;
int fd = get_fd_rgba(&stride);
const EGLint attr[] = {
uint64_t modifier;
int fd = get_fd_rgba(&stride, &modifier);
EGLint attr[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ABGR8888,
EGL_DMA_BUF_PLANE0_FD_EXT, fd,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride,
EGL_NONE, EGL_NONE, /* modifier lo */
EGL_NONE, EGL_NONE, /* modifier hi */
EGL_NONE
};
if (egl->modifiers_supported &&
modifier != DRM_FORMAT_MOD_INVALID) {
unsigned size = ARRAY_SIZE(attr);
attr[size - 5] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
attr[size - 4] = modifier & 0xFFFFFFFF;
attr[size - 3] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
attr[size - 2] = modifier >> 32;
}
EGLImage img;
glGenTextures(1, gl.tex);
......@@ -339,26 +370,48 @@ static int init_tex_rgba(void)
static int init_tex_nv12_2img(void)
{
uint32_t stride_y, stride_uv;
int fd_y = get_fd_y(&stride_y);
int fd_uv = get_fd_uv(&stride_uv);
const EGLint attr_y[] = {
uint64_t modifier_y, modifier_uv;
int fd_y = get_fd_y(&stride_y, &modifier_y);
int fd_uv = get_fd_uv(&stride_uv, &modifier_uv);
EGLint attr_y[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_R8,
EGL_DMA_BUF_PLANE0_FD_EXT, fd_y,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride_y,
EGL_NONE, EGL_NONE, /* modifier lo */
EGL_NONE, EGL_NONE, /* modifier hi */
EGL_NONE
};
const EGLint attr_uv[] = {
EGLint attr_uv[] = {
EGL_WIDTH, texw/2,
EGL_HEIGHT, texh/2,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_GR88,
EGL_DMA_BUF_PLANE0_FD_EXT, fd_uv,
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE0_PITCH_EXT, stride_uv,
EGL_NONE, EGL_NONE, /* modifier lo */
EGL_NONE, EGL_NONE, /* modifier hi */
EGL_NONE
};
if (egl->modifiers_supported &&
modifier_y != DRM_FORMAT_MOD_INVALID &&
modifier_uv != DRM_FORMAT_MOD_INVALID) {
unsigned size = ARRAY_SIZE(attr_y);
attr_y[size - 5] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
attr_y[size - 4] = modifier_y & 0xFFFFFFFF;
attr_y[size - 3] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
attr_y[size - 2] = modifier_y >> 32;
size = ARRAY_SIZE(attr_uv);
attr_uv[size - 5] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
attr_uv[size - 4] = modifier_uv & 0xFFFFFFFF;
attr_uv[size - 3] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
attr_uv[size - 2] = modifier_uv >> 32;
}
EGLImage img_y, img_uv;
glGenTextures(2, gl.tex);
......@@ -397,9 +450,10 @@ static int init_tex_nv12_2img(void)
static int init_tex_nv12_1img(void)
{
uint32_t stride_y, stride_uv;
int fd_y = get_fd_y(&stride_y);
int fd_uv = get_fd_uv(&stride_uv);
const EGLint attr[] = {
uint64_t modifier_y, modifier_uv;
int fd_y = get_fd_y(&stride_y, &modifier_y);
int fd_uv = get_fd_uv(&stride_uv, &modifier_uv);
EGLint attr[] = {
EGL_WIDTH, texw,
EGL_HEIGHT, texh,
EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_NV12,
......@@ -409,10 +463,28 @@ static int init_tex_nv12_1img(void)
EGL_DMA_BUF_PLANE1_FD_EXT, fd_uv,
EGL_DMA_BUF_PLANE1_OFFSET_EXT, 0,
EGL_DMA_BUF_PLANE1_PITCH_EXT, stride_uv,
EGL_NONE, EGL_NONE, /* modifier lo */
EGL_NONE, EGL_NONE, /* modifier hi */
EGL_NONE, EGL_NONE, /* modifier lo */
EGL_NONE, EGL_NONE, /* modifier hi */
EGL_NONE
};
EGLImage img;
if (egl->modifiers_supported &&
modifier_y != DRM_FORMAT_MOD_INVALID &&
modifier_uv != DRM_FORMAT_MOD_INVALID) {
unsigned size = ARRAY_SIZE(attr);
attr[size - 9] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT;
attr[size - 8] = modifier_y & 0xFFFFFFFF;
attr[size - 7] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT;
attr[size - 6] = modifier_y >> 32;
attr[size - 5] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT;
attr[size - 4] = modifier_uv & 0xFFFFFFFF;
attr[size - 3] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT;
attr[size - 2] = modifier_uv >> 32;
}
glGenTextures(1, gl.tex);
img = egl->eglCreateImageKHR(egl->display, EGL_NO_CONTEXT,
......@@ -497,13 +569,13 @@ static void draw_cube_tex(unsigned i)
glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);
}
const struct egl * init_cube_tex(const struct gbm *gbm, enum mode mode)
const struct egl * init_cube_tex(const struct gbm *gbm, enum mode mode, int samples)
{
const char *fragment_shader_source = (mode == NV12_2IMG) ?
fragment_shader_source_2img : fragment_shader_source_1img;
int ret;
ret = init_egl(&gl.egl, gbm);
ret = init_egl(&gl.egl, gbm, samples);
if (ret)
return NULL;
......
......@@ -301,12 +301,12 @@ static void draw_cube_video(unsigned i)
gl.last_fence = egl->eglCreateSyncKHR(egl->display, EGL_SYNC_FENCE_KHR, NULL);
}
const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames)
const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames, int samples)
{
char *fnames, *s;
int ret, i = 0;
ret = init_egl(&gl.egl, gbm);
ret = init_egl(&gl.egl, gbm, samples);
if (ret)
return NULL;
......
......@@ -31,6 +31,18 @@
#include "common.h"
#include "drm-common.h"
WEAK uint64_t
gbm_bo_get_modifier(struct gbm_bo *bo);
WEAK int
gbm_bo_get_plane_count(struct gbm_bo *bo);
WEAK uint32_t
gbm_bo_get_stride_for_plane(struct gbm_bo *bo, int plane);
WEAK uint32_t
gbm_bo_get_offset(struct gbm_bo *bo, int plane);
static void
drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
{
......@@ -47,7 +59,7 @@ struct drm_fb * drm_fb_get_from_bo(struct gbm_bo *bo)
{
int drm_fd = gbm_device_get_fd(gbm_bo_get_device(bo));
struct drm_fb *fb = gbm_bo_get_user_data(bo);
uint32_t width, height,
uint32_t width, height, format,
strides[4] = {0}, handles[4] = {0},
offsets[4] = {0}, flags = 0;
int ret = -1;
......@@ -60,27 +72,31 @@ struct drm_fb * drm_fb_get_from_bo(struct gbm_bo *bo)
width = gbm_bo_get_width(bo);
height = gbm_bo_get_height(bo);
format = gbm_bo_get_format(bo);
if (gbm_bo_get_modifier && gbm_bo_get_plane_count &&
gbm_bo_get_stride_for_plane && gbm_bo_get_offset) {
uint64_t modifiers[4] = {0};
modifiers[0] = gbm_bo_get_modifier(bo);
const int num_planes = gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; i++) {
strides[i] = gbm_bo_get_stride_for_plane(bo, i);
handles[i] = gbm_bo_get_handle(bo).u32;
offsets[i] = gbm_bo_get_offset(bo, i);
modifiers[i] = modifiers[0];
}
#ifdef HAVE_GBM_MODIFIERS
uint64_t modifiers[4] = {0};
modifiers[0] = gbm_bo_get_modifier(bo);
const int num_planes = gbm_bo_get_plane_count(bo);
for (int i = 0; i < num_planes; i++) {
strides[i] = gbm_bo_get_stride_for_plane(bo, i);
handles[i] = gbm_bo_get_handle(bo).u32;
offsets[i] = gbm_bo_get_offset(bo, i);
modifiers[i] = modifiers[0];
}
if (modifiers[0]) {
flags = DRM_MODE_FB_MODIFIERS;
printf("Using modifier %" PRIx64 "\n", modifiers[0]);
}
if (modifiers[0]) {
flags = DRM_MODE_FB_MODIFIERS;
printf("Using modifier %" PRIx64 "\n", modifiers[0]);
ret = drmModeAddFB2WithModifiers(drm_fd, width, height,
format, handles, strides, offsets,
modifiers, &fb->fb_id, flags);
}
ret = drmModeAddFB2WithModifiers(drm_fd, width, height,
DRM_FORMAT_XRGB8888, handles, strides, offsets,
modifiers, &fb->fb_id, flags);
#endif
if (ret) {
if (flags)
fprintf(stderr, "Modifiers failed!\n");
......@@ -88,7 +104,7 @@ struct drm_fb * drm_fb_get_from_bo(struct gbm_bo *bo)
memcpy(handles, (uint32_t [4]){gbm_bo_get_handle(bo).u32,0,0,0}, 16);
memcpy(strides, (uint32_t [4]){gbm_bo_get_stride(bo),0,0,0}, 16);
memset(offsets, 0, 16);
ret = drmModeAddFB2(drm_fd, width, height, DRM_FORMAT_XRGB8888,
ret = drmModeAddFB2(drm_fd, width, height, format,
handles, strides, offsets, &fb->fb_id, 0);
}
......
......@@ -53,10 +53,6 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl)
uint32_t i = 0;
int ret;
FD_ZERO(&fds);
FD_SET(0, &fds);
FD_SET(drm.fd, &fds);
eglSwapBuffers(egl->display, egl->surface);
bo = gbm_surface_lock_front_buffer(gbm->surface);
fb = drm_fb_get_from_bo(bo);
......@@ -100,6 +96,10 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl)
}
while (waiting_for_flip) {
FD_ZERO(&fds);
FD_SET(0, &fds);
FD_SET(drm.fd, &fds);
ret = select(drm.fd + 1, &fds, NULL, NULL, NULL);
if (ret < 0) {
printf("select err: %s\n", strerror(errno));
......@@ -109,7 +109,7 @@ static int legacy_run(const struct gbm *gbm, const struct egl *egl)
return -1;
} else if (FD_ISSET(0, &fds)) {
printf("user interrupted!\n");
break;
return 0;
}
drmHandleEvent(drm.fd, &evctx);
}
......
......@@ -50,6 +50,7 @@ static const struct option longopts[] = {
{"device", required_argument, 0, 'D'},
{"mode", required_argument, 0, 'M'},
{"modifier", required_argument, 0, 'm'},
{"samples", required_argument, 0, 's'},
{"video", required_argument, 0, 'V'},
{0, 0, 0, 0}
};
......@@ -67,6 +68,7 @@ static void usage(const char *name)
" nv12-2img - yuv textured (color conversion in shader)\n"
" nv12-1img - yuv textured (single nv12 texture)\n"
" -m, --modifier=MODIFIER hardcode the selected modifier\n"
" -s, --samples=N use MSAA\n"
" -V, --video=FILE video textured cube\n",
name);
}
......@@ -76,7 +78,8 @@ int main(int argc, char *argv[])
const char *device = "/dev/dri/card0";
const char *video = NULL;
enum mode mode = SMOOTH;
uint64_t modifier = DRM_FORMAT_MOD_INVALID;
uint64_t modifier = DRM_FORMAT_MOD_LINEAR;
int samples = 0;
int atomic = 0;
int opt;
......@@ -111,6 +114,9 @@ int main(int argc, char *argv[])
case 'm':
modifier = strtoull(optarg, NULL, 0);
break;
case 's':
samples = strtoul(optarg, NULL, 0);
break;
case 'V':
mode = VIDEO;
video = optarg;
......@@ -138,11 +144,11 @@ int main(int argc, char *argv[])
}
if (mode == SMOOTH)
egl = init_cube_smooth(gbm);
egl = init_cube_smooth(gbm, samples);
else if (mode == VIDEO)
egl = init_cube_video(gbm, video);
egl = init_cube_video(gbm, video, samples);
else
egl = init_cube_tex(gbm, mode);
egl = init_cube_tex(gbm, mode, samples);
if (!egl) {
printf("failed to initialize EGL\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment