[Mesa-dev] [PATCH kmscube 2/2] add MSAA
Rob Clark
robdclark at gmail.com
Mon Jun 18 12:04:18 UTC 2018
Signed-off-by: Rob Clark <robdclark at gmail.com>
---
common.c | 5 +++--
common.h | 12 ++++++------
cube-smooth.c | 4 ++--
cube-tex.c | 4 ++--
cube-video.c | 4 ++--
kmscube.c | 12 +++++++++---
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");
--
2.17.1
More information about the mesa-dev
mailing list