framebuffer: adds cogl_framebuffer_get_samples_per_pixel
It's useful to be able to query back the number of point_samples_per_pixel that may have previously be chosen using cogl_framebuffer_set_samples_per_pixel(). Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
648bec9523
commit
1ee861a82c
6 changed files with 88 additions and 0 deletions
|
@ -91,6 +91,8 @@ struct _CoglFramebuffer
|
||||||
gboolean dither_enabled;
|
gboolean dither_enabled;
|
||||||
CoglColorMask color_mask;
|
CoglColorMask color_mask;
|
||||||
|
|
||||||
|
int samples_per_pixel;
|
||||||
|
|
||||||
/* We journal the textured rectangles we want to submit to OpenGL so
|
/* We journal the textured rectangles we want to submit to OpenGL so
|
||||||
* we have an oppertunity to batch them together into less draw
|
* we have an oppertunity to batch them together into less draw
|
||||||
* calls. */
|
* calls. */
|
||||||
|
|
|
@ -92,6 +92,9 @@
|
||||||
#ifndef GL_DRAW_FRAMEBUFFER
|
#ifndef GL_DRAW_FRAMEBUFFER
|
||||||
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
#define GL_DRAW_FRAMEBUFFER 0x8CA9
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GL_TEXTURE_SAMPLES_IMG
|
||||||
|
#define GL_TEXTURE_SAMPLES_IMG 0x9136
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
_TRY_DEPTH_STENCIL = 1L<<0,
|
_TRY_DEPTH_STENCIL = 1L<<0,
|
||||||
|
@ -163,6 +166,8 @@ _cogl_framebuffer_init (CoglFramebuffer *framebuffer,
|
||||||
|
|
||||||
framebuffer->color_mask = COGL_COLOR_MASK_ALL;
|
framebuffer->color_mask = COGL_COLOR_MASK_ALL;
|
||||||
|
|
||||||
|
framebuffer->samples_per_pixel = 0;
|
||||||
|
|
||||||
/* Initialise the clip stack */
|
/* Initialise the clip stack */
|
||||||
_cogl_clip_state_init (&framebuffer->clip_state);
|
_cogl_clip_state_init (&framebuffer->clip_state);
|
||||||
|
|
||||||
|
@ -941,6 +946,21 @@ try_creating_fbo (CoglOffscreen *offscreen,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the real number of samples_per_pixel now that we have a
|
||||||
|
* complete framebuffer */
|
||||||
|
if (n_samples)
|
||||||
|
{
|
||||||
|
GLenum attachment = GL_COLOR_ATTACHMENT0;
|
||||||
|
GLenum pname = GL_TEXTURE_SAMPLES_IMG;
|
||||||
|
int texture_samples;
|
||||||
|
|
||||||
|
GE( ctx, glGetFramebufferAttachmentParameteriv (GL_FRAMEBUFFER,
|
||||||
|
attachment,
|
||||||
|
pname,
|
||||||
|
&texture_samples) );
|
||||||
|
fb->samples_per_pixel = texture_samples;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1526,6 +1546,15 @@ cogl_framebuffer_get_color_format (CoglFramebuffer *framebuffer)
|
||||||
return framebuffer->format;
|
return framebuffer->format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
cogl_framebuffer_get_samples_per_pixel (CoglFramebuffer *framebuffer)
|
||||||
|
{
|
||||||
|
if (framebuffer->allocated)
|
||||||
|
return framebuffer->samples_per_pixel;
|
||||||
|
else
|
||||||
|
return framebuffer->config.samples_per_pixel;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
|
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
|
||||||
int samples_per_pixel)
|
int samples_per_pixel)
|
||||||
|
|
|
@ -326,6 +326,36 @@ void
|
||||||
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
|
cogl_framebuffer_set_samples_per_pixel (CoglFramebuffer *framebuffer,
|
||||||
int samples_per_pixel);
|
int samples_per_pixel);
|
||||||
|
|
||||||
|
#define cogl_framebuffer_get_samples_per_pixel \
|
||||||
|
cogl_framebuffer_get_samples_per_pixel_EXP
|
||||||
|
/**
|
||||||
|
* cogl_framebuffer_get_samples_per_pixel:
|
||||||
|
* @framebuffer: A #CoglFramebuffer framebuffer
|
||||||
|
*
|
||||||
|
* Gets the number of points that are sampled per-pixel when
|
||||||
|
* rasterizing geometry. Usually by default this will return 0 which
|
||||||
|
* means that single-sample not multisample rendering has been chosen.
|
||||||
|
* When using a GPU supporting multisample rendering it's possible to
|
||||||
|
* increase the number of samples per pixel using
|
||||||
|
* cogl_framebuffer_set_samples_per_pixel().
|
||||||
|
*
|
||||||
|
* Calling cogl_framebuffer_get_samples_per_pixel() before the
|
||||||
|
* framebuffer has been allocated will simply return the value set
|
||||||
|
* using cogl_framebuffer_set_samples_per_pixel(). After the
|
||||||
|
* framebuffer has been allocated the value will reflect the actual
|
||||||
|
* number of samples that will be made by the GPU.
|
||||||
|
*
|
||||||
|
* Returns: The number of point samples made per pixel when
|
||||||
|
* rasterizing geometry or 0 if single-sample rendering
|
||||||
|
* has been chosen.
|
||||||
|
*
|
||||||
|
* Since: 1.10
|
||||||
|
* Stability: unstable
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
cogl_framebuffer_get_samples_per_pixel (CoglFramebuffer *framebuffer);
|
||||||
|
|
||||||
|
|
||||||
#define cogl_framebuffer_resolve_samples \
|
#define cogl_framebuffer_resolve_samples \
|
||||||
cogl_framebuffer_resolve_samples_EXP
|
cogl_framebuffer_resolve_samples_EXP
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1251,6 +1251,18 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the real number of samples_per_pixel now that we have
|
||||||
|
* found an egl_config... */
|
||||||
|
if (framebuffer->config.samples_per_pixel)
|
||||||
|
{
|
||||||
|
EGLint samples;
|
||||||
|
status = eglGetConfigAttrib (egl_renderer->edpy,
|
||||||
|
egl_config,
|
||||||
|
EGL_SAMPLES, &samples);
|
||||||
|
g_return_val_if_fail (status == EGL_TRUE, TRUE);
|
||||||
|
framebuffer->samples_per_pixel = samples;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
#ifdef COGL_HAS_EGL_PLATFORM_POWERVR_X11_SUPPORT
|
||||||
|
|
||||||
/* FIXME: We need to explicitly Select for ConfigureNotify events.
|
/* FIXME: We need to explicitly Select for ConfigureNotify events.
|
||||||
|
|
|
@ -818,6 +818,19 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the real number of samples_per_pixel now that we have
|
||||||
|
* found an fbconfig... */
|
||||||
|
if (framebuffer->config.samples_per_pixel)
|
||||||
|
{
|
||||||
|
int samples;
|
||||||
|
int status = glx_renderer->glXGetFBConfigAttrib (xlib_renderer->xdpy,
|
||||||
|
fbconfig,
|
||||||
|
GLX_SAMPLES,
|
||||||
|
&samples);
|
||||||
|
g_return_val_if_fail (status == Success, TRUE);
|
||||||
|
framebuffer->samples_per_pixel = samples;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: We need to explicitly Select for ConfigureNotify events.
|
/* FIXME: We need to explicitly Select for ConfigureNotify events.
|
||||||
* For foreign windows we need to be careful not to mess up any
|
* For foreign windows we need to be careful not to mess up any
|
||||||
* existing event mask.
|
* existing event mask.
|
||||||
|
|
|
@ -348,6 +348,8 @@ cogl_framebuffer_get_blue_bits
|
||||||
cogl_framebuffer_get_blue_bits
|
cogl_framebuffer_get_blue_bits
|
||||||
cogl_framebuffer_get_color_mask
|
cogl_framebuffer_get_color_mask
|
||||||
cogl_framebuffer_set_color_mask
|
cogl_framebuffer_set_color_mask
|
||||||
|
cogl_framebuffer_get_point_samples_per_pixel
|
||||||
|
cogl_framebuffer_set_point_samples_per_pixel
|
||||||
cogl_framebuffer_get_context
|
cogl_framebuffer_get_context
|
||||||
cogl_framebuffer_clear
|
cogl_framebuffer_clear
|
||||||
cogl_framebuffer_clear4f
|
cogl_framebuffer_clear4f
|
||||||
|
|
Loading…
Reference in a new issue