summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2018-06-17 09:59:38 -0400
committerRob Clark <robdclark@gmail.com>2018-06-19 09:43:09 -0400
commit9dcce71e603616ee7a54707e932f962cdf8fb20a (patch)
tree874382698c6e736e9d7bde3af3dd8ef028b38e64
parent063ce5c732598b3855775e59b59d9ddffe4ddb24 (diff)
add MSAA
Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
-rw-r--r--common.c5
-rw-r--r--common.h12
-rw-r--r--cube-smooth.c4
-rw-r--r--cube-tex.c4
-rw-r--r--cube-video.c4
-rw-r--r--kmscube.c12
6 files changed, 24 insertions, 17 deletions
diff --git a/common.c b/common.c
index 931fc06..d6d8d27 100644
--- a/common.c
+++ b/common.c
@@ -161,7 +161,7 @@ out:
return true;
}
-int init_egl(struct egl *egl, const struct gbm *gbm)
+int init_egl(struct egl *egl, const struct gbm *gbm, int samples)
{
EGLint major, minor;
@@ -170,13 +170,14 @@ int init_egl(struct egl *egl, const struct gbm *gbm)
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;
diff --git a/common.h b/common.h
index 898010d..cff2c33 100644
--- a/common.h
+++ b/common.h
@@ -118,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);
@@ -130,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
@@ -140,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;
}
diff --git a/cube-smooth.c b/cube-smooth.c
index f29face..483c2ae 100644
--- a/cube-smooth.c
+++ b/cube-smooth.c
@@ -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;
diff --git a/cube-tex.c b/cube-tex.c
index 7353de4..09f18e3 100644
--- a/cube-tex.c
+++ b/cube-tex.c
@@ -569,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;
diff --git a/cube-video.c b/cube-video.c
index 03bfb80..8cb8f24 100644
--- a/cube-video.c
+++ b/cube-video.c
@@ -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;
diff --git a/kmscube.c b/kmscube.c
index 87a4205..6275109 100644
--- a/kmscube.c
+++ b/kmscube.c
@@ -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);
}
@@ -77,6 +79,7 @@ int main(int argc, char *argv[])
const char *video = NULL;
enum mode mode = SMOOTH;
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");