mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
onscreen: Support multisample based onscreen rendering
This adds support for multisample based rendering of onscreen windows whereby multiple point samples per pixel can be requested and if the hardware supports that it results in reduced aliasing (especially considering the jagged edges of polygons) Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
98e5a9c777
commit
a74c81ada3
@ -51,6 +51,7 @@ typedef struct
|
||||
{
|
||||
CoglSwapChain *swap_chain;
|
||||
gboolean need_stencil;
|
||||
int samples_per_pixel;
|
||||
} CoglFramebufferConfig;
|
||||
|
||||
struct _CoglFramebuffer
|
||||
|
@ -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.samples_per_pixel = 0;
|
||||
|
||||
user_config = getenv ("COGL_POINT_SAMPLES_PER_PIXEL");
|
||||
if (user_config)
|
||||
{
|
||||
unsigned long samples_per_pixel = strtoul (user_config, NULL, 10);
|
||||
if (samples_per_pixel != ULONG_MAX)
|
||||
onscreen_template->config.samples_per_pixel =
|
||||
samples_per_pixel;
|
||||
}
|
||||
|
||||
return _cogl_onscreen_template_object_new (onscreen_template);
|
||||
}
|
||||
|
||||
void
|
||||
cogl_onscreen_template_set_samples_per_pixel (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
int samples_per_pixel)
|
||||
{
|
||||
onscreen_template->config.samples_per_pixel = samples_per_pixel;
|
||||
}
|
||||
|
@ -43,6 +43,34 @@ typedef struct _CoglOnscreenTemplate CoglOnscreenTemplate;
|
||||
CoglOnscreenTemplate *
|
||||
cogl_onscreen_template_new (CoglSwapChain *swap_chain);
|
||||
|
||||
/**
|
||||
* cogl_onscreen_template_set_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 at least @n samples per pixel
|
||||
* which will all contribute to the final resolved color for that
|
||||
* pixel.
|
||||
*
|
||||
* By default this value is usually set to 0 and that is referred to
|
||||
* as "single-sample" rendering. A value of 1 or greater is referred
|
||||
* to as "multisample" rendering.
|
||||
*
|
||||
* <note>There are some semantic differences between single-sample
|
||||
* rendering and multisampling with just 1 point sample such as it
|
||||
* being redundant to use the cogl_framebuffer_resolve_samples() and
|
||||
* cogl_framebuffer_resolve_samples_region() apis with single-sample
|
||||
* rendering.</note>
|
||||
*
|
||||
* Since: 1.10
|
||||
* Stability: unstable
|
||||
*/
|
||||
void
|
||||
cogl_onscreen_template_set_samples_per_pixel (
|
||||
CoglOnscreenTemplate *onscreen_template,
|
||||
int n);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __COGL_ONSCREEN_TEMPLATE_H__ */
|
||||
|
@ -644,6 +644,14 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
|
||||
attributes[i++] = EGL_SURFACE_TYPE;
|
||||
attributes[i++] = EGL_WINDOW_BIT;
|
||||
|
||||
if (config->samples_per_pixel)
|
||||
{
|
||||
attributes[i++] = EGL_SAMPLE_BUFFERS;
|
||||
attributes[i++] = 1;
|
||||
attributes[i++] = EGL_SAMPLES;
|
||||
attributes[i++] = config->samples_per_pixel;
|
||||
}
|
||||
|
||||
attributes[i++] = EGL_NONE;
|
||||
|
||||
g_assert (i < MAX_EGL_CONFIG_ATTRIBS);
|
||||
|
@ -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->samples_per_pixel)
|
||||
{
|
||||
attributes[i++] = GLX_SAMPLE_BUFFERS;
|
||||
attributes[i++] = 1;
|
||||
attributes[i++] = GLX_SAMPLES;
|
||||
attributes[i++] = config->samples_per_pixel;
|
||||
}
|
||||
|
||||
attributes[i++] = None;
|
||||
|
||||
g_assert (i < MAX_GLX_CONFIG_ATTRIBS);
|
||||
|
@ -324,6 +324,10 @@ choose_pixel_format (CoglFramebufferConfig *config,
|
||||
|
||||
num_formats = DescribePixelFormat (dc, 0, sizeof (best_pfd), NULL);
|
||||
|
||||
/* XXX: currently we don't support multisampling on windows... */
|
||||
if (config->samples_per_pixel)
|
||||
return best_pf;
|
||||
|
||||
for (i = 1; i <= num_formats; i++)
|
||||
{
|
||||
memset (pfd, 0, sizeof (*pfd));
|
||||
|
Loading…
Reference in New Issue
Block a user