Commit 9dcce71e authored by Rob Clark's avatar Rob Clark

add MSAA

Signed-off-by: 's avatarRob Clark <robdclark@gmail.com>
Reviewed-by: 's avatarEmil Velikov <emil.velikov@collabora.com>
parent 063ce5c7
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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");
......
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