diff options
author | Robert Bragg <robert@linux.intel.com> | 2011-08-21 21:27:13 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2011-09-21 22:03:09 +0100 |
commit | ba8e4857b81a27f1dee61b7ea8dbf449fd9cf799 (patch) | |
tree | b73de622a36f7a627222ab6b0059355d40dbde87 | |
parent | e92e251390890408dbbaac181fb2b059844d53f9 (diff) | |
download | cogl-ba8e4857b81a27f1dee61b7ea8dbf449fd9cf799.tar.gz |
onscreen: Support point sample based onscreen rendering
This adds support for point sample based rendering of onscreen windows
whereby multiple point samples per pixel can be requested and if the
hardware supports that it typically results in reduced aliasing
(especially considering the jagged edges of polygons)
-rw-r--r-- | cogl/cogl-framebuffer-private.h | 1 | ||||
-rw-r--r-- | cogl/cogl-onscreen-template.c | 18 | ||||
-rw-r--r-- | cogl/cogl-onscreen-template.h | 19 | ||||
-rw-r--r-- | cogl/winsys/cogl-winsys-egl.c | 8 | ||||
-rw-r--r-- | cogl/winsys/cogl-winsys-glx.c | 9 |
5 files changed, 55 insertions, 0 deletions
diff --git a/cogl/cogl-framebuffer-private.h b/cogl/cogl-framebuffer-private.h index c429be9a..98a13ea0 100644 --- a/cogl/cogl-framebuffer-private.h +++ b/cogl/cogl-framebuffer-private.h @@ -51,6 +51,7 @@ typedef struct { CoglSwapChain *swap_chain; gboolean need_stencil; + int point_samples_per_pixel; } CoglFramebufferConfig; struct _CoglFramebuffer diff --git a/cogl/cogl-onscreen-template.c b/cogl/cogl-onscreen-template.c index b9fbd235..5cad9390 100644 --- a/cogl/cogl-onscreen-template.c +++ b/cogl/cogl-onscreen-template.c @@ -65,6 +65,24 @@ cogl_onscreen_template_new (CoglSwapChain *swap_chain) onscreen_template->config.swap_chain = cogl_swap_chain_new (); onscreen_template->config.need_stencil = TRUE; + onscreen_template->config.point_samples_per_pixel = 0; + + user_config = getenv ("COGL_POINT_SAMPLES_PER_PIXEL"); + if (user_config) + { + unsigned long point_samples_per_pixel = strtoul (user_config, NULL, 10); + if (point_samples_per_pixel != ULONG_MAX) + onscreen_template->config.point_samples_per_pixel = + point_samples_per_pixel; + } return _cogl_onscreen_template_object_new (onscreen_template); } + +void +cogl_onscreen_template_set_point_samples_per_pixel ( + CoglOnscreenTemplate *onscreen_template, + int samples_per_pixel) +{ + onscreen_template->config.point_samples_per_pixel = samples_per_pixel; +} diff --git a/cogl/cogl-onscreen-template.h b/cogl/cogl-onscreen-template.h index 4769f9f1..d4a0ea58 100644 --- a/cogl/cogl-onscreen-template.h +++ b/cogl/cogl-onscreen-template.h @@ -43,6 +43,25 @@ typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate; CoglOnscreenTemplate * cogl_onscreen_template_new (CoglSwapChain *swap_chain); +/** + * cogl_onscreen_template_set_point_samples_per_pixel: + * @onscreen: A #CoglOnscreenTemplate template framebuffer + * @n: The minimum number of samples per pixel + * + * Requires that any future CoglOnscreen framebuffers derived from + * this template must support making @n point samples per pixel which + * will all contribute to the final resolved color for that pixel. + * + * By default sampling is not based on point samples but rather by + * considering the whole rectangular area of the current pixel, so an + * @n value of %1 is not equivalent to the default behaviour. A value + * of %0 can be used to explicitly request non point based sampling. + */ +void +cogl_onscreen_template_set_point_samples_per_pixel ( + CoglOnscreenTemplate *onscreen_template, + int n); + G_END_DECLS #endif /* __COGL_ONSCREEN_TEMPLATE_H__ */ diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c index b8b0d309..e7c273a9 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -644,6 +644,14 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display, attributes[i++] = EGL_SURFACE_TYPE; attributes[i++] = EGL_WINDOW_BIT; + if (config->point_samples_per_pixel) + { + attributes[i++] = EGL_SAMPLE_BUFFERS; + attributes[i++] = 1; + attributes[i++] = EGL_SAMPLES; + attributes[i++] = config->point_samples_per_pixel; + } + attributes[i++] = EGL_NONE; g_assert (i < MAX_EGL_CONFIG_ATTRIBS); diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c index c41fe452..bde57a2f 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -485,6 +485,15 @@ glx_attributes_from_framebuffer_config (CoglDisplay *display, attributes[i++] = GLX_STENCIL_SIZE; attributes[i++] = config->need_stencil ? 1: GLX_DONT_CARE; + if (glx_renderer->glx_major == 1 && glx_renderer->glx_minor >= 4 && + config->point_samples_per_pixel) + { + attributes[i++] = GLX_SAMPLE_BUFFERS; + attributes[i++] = 1; + attributes[i++] = GLX_SAMPLES; + attributes[i++] = config->point_samples_per_pixel; + } + attributes[i++] = None; g_assert (i < MAX_GLX_CONFIG_ATTRIBS); |