Commit Graph

8 Commits

Author SHA1 Message Date
Owen W. Taylor
24733abf68 onscreen: Add CoglFrameInfo and _add_frame_callback() api
Add a CoglFrameInfo object that tracks timing information for frames
that are drawn. We track a frame counter and frame timing information
for each CoglOnscreen. Internally a CoglFrameInfo is automatically
created for each frame, delimited by cogl_onscreen_swap_buffers() or
cogl_onscreen_swap_region() calls.

CoglFrameInfos are delivered to applications via frame event callbacks
that can be registered with a new cogl_onscreen_add_frame_callback()
api. Two initial event types (dispatched on all platforms) have been
defined; a _SYNC event used for throttling the frame rate of
applications and a _COMPLETE event used so signify the end of a frame.

Note: This new _add_frame_callback() api makes the
cogl_onscreen_add_swap_complete_callback() api redundant and so it
should be considered deprecated. Since the _add_swap_complete_callback()
api is still experimental api, we will be looking to quickly migrate
users to the new api so we can remove the old api.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 700401667db2522045e4623d78797b17f9184501)
2013-01-30 20:09:49 +00:00
Owen W. Taylor
5ce058c0e5 Prefer OML_sync_control over SGI_video_sync when waiting for swap
When we block waiting for the swap, prefer doing that using
glXWaitForMsc() from OML_sync_control because that returns a system
time value for the precise time of the swap.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1e8114aabc78b90373d3d5f3f7c0224f8786e399)
2013-01-30 20:09:40 +00:00
Adel Gadllah
860fb00fdc cogl-onscreen: Add buffer_age support
Add a new BUFFER_AGE winsys feature and a get_buffer_age method to
cogl-onscreen that allows to query the value.

https://bugzilla.gnome.org/show_bug.cgi?id=669122

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

Note: When landing the patch I made some gtk-doc updates and changed
_get_buffer_age to return an age of 0 always if the age feature isn't
support instead of using _COGL_RETURN_VAL_IF_FAIL. -- Robert Bragg

(cherry picked from commit 427b1038051e9b53a071d8c229b363b075bb1dc0)
2013-01-23 17:58:10 +00:00
Neil Roberts
fe3aa8b8b3 Query glX* functions before getting the context to fix GL3 driver
The GL3 context is created using the glXCreateContextAttribs function
which is part of the GLX_ARB_create_context extension. However
previously the function pointers from GLX extensions were only
retrieved once the GL context is created. That meant that the GL3
context creation function would always assume that the extension is
not supported so it would always fail.

This patch changes it to query the functions when the renderer is set
up instead. The base winsys feature flags that are determined while
querying the functions are stored in a member of CoglGLXRenderer.
These are then copied to the CoglContext when it is initialised.

The spec for glXGetProcAddress says that the functions returned are
context-independent. That implies that it is safe to call it without
binding a context although that is not explicitly stated as far as I
can tell. A big of googling finds this DRI documentation which says it
can be used without a context:

http://dri.freedesktop.org/wiki/glXGetProcAddressNeverReturnsNULL

And also this code sample:

http://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29

One point that makes me concerned that this might not always work in
practice is that the code in SDL2 to create a GL3 context first
creates a dummy GL2 context in order to have something bound before it
calls glXGetProcAddress. I think this may just be a misunderstanding
based on how wglGetProcAddress works however.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 04a7aca9a98e84e43ac5559305a1358112902e30)
2013-01-22 17:48:18 +00:00
Neil Roberts
2616ae0fa9 Add a GL 3 driver
This adds a new CoglDriver for GL 3 called COGL_DRIVER_GL3. When
requested, the GLX, EGL and SDL2 winsyss will set the necessary
attributes to request a forward-compatible core profile 3.1 context.
That means it will have no deprecated features.

To simplify the explosion of checks for specific combinations of
context->driver, many of these conditionals have now been replaced
with private feature flags that are checked instead. The GL and GLES
drivers now initialise these private feature flags depending on which
driver is used.

The fixed function backends now explicitly check whether the fixed
function private feature is available which means the GL3 driver will
fall back to always using the GLSL progend. Since Rob's latest patches
the GLSL progend no longer uses any fixed function API anyway so it
should just work.

The driver is currently lower priority than COGL_DRIVER_GL so it will
not be used unless it is specificly requested. We may want to change
this priority at some point because apparently Mesa can make some
memory savings if a core profile context is used.

In GL 3, getting the combined extensions string with glGetString is
deprecated so this patch changes it to use glGetStringi to build up an
array of extensions instead. _cogl_context_get_gl_extensions now
returns this array instead of trying to return a const string. The
caller is expected to free the array.

Some issues with this patch:

• GL 3 does not support GL_ALPHA format textures. We should probably
  make this a feature flag or something. Cogl uses this to render text
  which currently just throws a GL error and breaks so it's pretty
  important to do something about this before considering the GL3
  driver to be stable.

• GL 3 doesn't support client side vertex buffers. This probably
  doesn't matter because CoglBuffer won't normally use malloc'd
  buffers if VBOs are available, but it might but worth making
  malloc'd buffers a private feature and forcing it not to use them.

• GL 3 doesn't support the default vertex array object. This patch
  just makes it create and bind a single non-default vertex array
  object which gets used just like the normal default object. Ideally
  it would be good to use vertex array objects properly and attach
  them to a CoglPrimitive to cache the state.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 66c9db993595b3a22e63f4c201ea468bc9b88cb6)
2013-01-22 17:48:01 +00:00
Adel Gadllah
fd31da45e2 winsys-glx: Don't assume that copy_sub_buffer is synchronized
We initially assumed that copy_sub_buffer is synchronized on
which is only the case for a subset of GPUs for example it is not
synchronized on INTEL gen6 and gen7, so we remove this assumption
for now.

We should have a specific driver / GPU whitelist if we want to enable
this.

https://bugzilla.gnome.org/show_bug.cgi?id=669122

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-03-15 15:48:13 +00:00
Adel Gadllah
671a4dfb34 winsys-glx: Fix synchronisation behaviour in _cogl_winsys_onscreen_swap_region
This patch basically restores the logic from 1.6.  There we assumed that
glXCopySubBuffer won't tear and thus only needs to be throttled to the
framerate, while glBlitFramebuffer needs to always wait to avoid
tearing.

With Nvidia drivers specifically we have seen that glBlitFramebuffer is
not synchronized. Eventually the plan is that Cogl will actually take
into consideration the underlying driver/hw vendor and driver version
and we may want to only mark glBlitFramebuffer un-synchronized on
Nvidia.

https://bugzilla.gnome.org/show_bug.cgi?id=659360

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-09-19 16:40:06 +01:00
Robert Bragg
d40cdfa3e1 Moves all GLX code down from Clutter to Cogl
This migrates all the GLX window system code down from the Clutter
backend code into a Cogl winsys. Moving OpenGL window system binding
code down from Clutter into Cogl is the biggest blocker to having Cogl
become a standalone 3D graphics library, so this is an important step in
that direction.
2011-04-11 17:54:36 +01:00