Commit Graph

1734 Commits

Author SHA1 Message Date
Neil Roberts
534e535a28 Use the Wayland embedded linked list implementation instead of BSD's
This removes cogl-queue.h and adds a copy of Wayland's embedded list
implementation. The advantage of the Wayland model is that it is much
simpler and so it is easier to follow. It also doesn't require
defining a typedef for every list type.

The downside is that there is only one list type which is a
doubly-linked list where the head has a pointer to both the beginning
and the end. The BSD implementation has many more combinations some of
which we were taking advantage of to reduce the size of critical
structs where we didn't need a pointer to the end of the list.

The corresponding changes to uses of cogl-queue.h are:

• COGL_STAILQ_* was used for onscreen the list of events and dirty
  notifications. This makes the size of the CoglContext grow by one
  pointer.

• COGL_TAILQ_* was used for fences.

• COGL_LIST_* for CoglClosures. In this case the list head now has an
  extra pointer which means CoglOnscreen will grow by the size of
  three pointers, but this doesn't seem like a particularly important
  struct to optimise for size anyway.

• COGL_LIST_* was used for the list of foreign GLES2 offscreens.

• COGL_TAILQ_* was used for the list of sub stacks in a
  CoglMemoryStack.

• COGL_LIST_* was used to track the list of layers that haven't had
  code generated yet while generating a fragment shader for a
  pipeline.

• COGL_LIST_* was used to track the pipeline hierarchy in CoglNode.

The last part is a bit more controversial because it increases the
size of CoglPipeline and CoglPipelineLayer by one pointer in order to
have the redundant tail pointer for the list head. Normally we try to
be very careful about the size of the CoglPipeline struct. Because
CoglPipeline is slice-allocated, this effectively ends up adding two
pointers to the size because GSlice rounds up to the size of two
pointers.

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

(cherry picked from commit 13abf613b15f571ba1fcf6d2eb831ffc6fa31324)

Conflicts:
	cogl/cogl-context-private.h
	cogl/cogl-context.c
	cogl/driver/gl/cogl-pipeline-fragend-glsl.c
	doc/reference/cogl-2.0-experimental/Makefile.am
2013-06-13 13:45:47 +01:00
Neil Roberts
ed510dbe6d Use a GList instead of a BSD list for CoglPipelineSnippetList
Previously CoglPipelineSnippetList was using the BSD embedded list
type with a mini struct to combine the list node with a pointer to the
snippet. This is effectively equivalent to just using a GList so we
might as well do that. This will help if we eventually want to get rid
of cogl-queue.h

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

(cherry picked from commit 54a168f3c7829c427d54ab517533bb9f7384d022)
2013-06-13 13:45:46 +01:00
Neil Roberts
fa0df6ea96 Fix freeing an atlas texture that hasn't been allocated
The free function for atlas textures was previously always assuming
that there will be a valid sub_texture pointer but this might not be
the case if the texture was never successfully allocated. This was
causing Cogl to crash if the application tries to make a texture that
can not fit in the atlas using the automagic texture API.

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

(cherry picked from commit a7a8b7aefc8cb03fe8b716bee06b3449a7dba85f)
2013-06-13 13:45:46 +01:00
Neil Roberts
6d51a18e7c Add support for per-vertex point sizes
This adds a new function to enable per-vertex point size on a
pipeline. This can be set with
cogl_pipeline_set_per_vertex_point_size(). Once enabled the point size
can be set either by drawing with an attribute named
'cogl_point_size_in' or by writing to the 'cogl_point_size_out'
builtin from a snippet.

There is a feature flag which must be checked for before using
per-vertex point sizes. This will only be set on GL >= 2.0 or on GLES
2.0. GL will only let you set a per-vertex point size from GLSL by
writing to gl_PointSize. This is only available in GL2 and not in the
older GLSL extensions.

The per-vertex point size has its own pipeline state flag so that it
can be part of the state that affects vertex shader generation.

Having to enable the per vertex point size with a separate function is
a bit awkward. Ideally it would work like the color attribute where
you can just set it for every vertex in your primitive with
cogl_pipeline_set_color or set it per-vertex by just using the
attribute. This is harder to get working with the point size because
we need to generate a different vertex shader depending on what
attributes are bound. I think if we wanted to make this work
transparently we would still want to internally have a pipeline
property describing whether the shader was generated with per-vertex
support so that it would work with the shader cache correctly.
Potentially we could make the per-vertex property internal and
automatically make a weak pipeline whenever the attribute is bound.
However we would then also need to automatically detect when an
application is writing to cogl_point_size_out from a snippet.

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

(cherry picked from commit 8495d9c1c15ce389885a9356d965eabd97758115)

Conflicts:
	cogl/cogl-context.c
	cogl/cogl-pipeline-private.h
	cogl/cogl-pipeline.c
	cogl/cogl-private.h
	cogl/driver/gl/cogl-pipeline-progend-fixed.c
	cogl/driver/gl/gl/cogl-pipeline-progend-fixed-arbfp.c
2013-06-07 16:53:29 +01:00
Robert Bragg
2d24248a3c pipeline: only maintain breadcrumb for debug builds
This ensures we only add a static_breadcrumb pointer to every
CoglPipeline when build with debugging enabled. Since applications may
allocate a lot of pipelines we want to keep the basic size of pipelines
(ignoring optional sparse state) down to a minimum.

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

(cherry picked from commit 4716312e14bc253cd174a22b3db9d2c9cf031fa1)
2013-06-06 21:49:14 +01:00
Robert Bragg
d264b30090 units: remove test-bitmask and add UNIT_TEST instead
This moves the code in test-bitmask into a UNIT_TEST() directly in
cogl-bitmask.c which will now be run as a tests/unit/ test.

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

(cherry picked from commit 693c85e0cde8a1ffbffc03a5f8fcc1f92e8d0ac7)

Includes fix to build conform tests with -I$(top_builddir)/cogl to
be able to find cogl-gl-header.h
2013-06-06 21:45:11 +01:00
Robert Bragg
eb7fafe700 tests: Adds our first white-box unit test
This adds a white-box unit test that verifies that GL_BLEND is disabled
when drawing an opaque rectangle, enabled when drawing a transparent
rectangle and then disabled again when drawing a transparent rectangle
but with a blend string that effectively disables blending.

This shares the test utilities and launcher infrastructure we are using
for conformance tests so we get consistent reporting and so unit tests
will be run against a range of different drivers.

This adds a --enable-unit-tests configure option which is enabled by
default but if disabled will make all UNIT_TESTS() into static inline
functions that we should expect the compiler to discard since they won't
be referenced by anything.

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

(cherry picked from commit 9047cce06bbf9051ec77e622be2fdbb96ed767a8)
2013-06-06 21:27:16 +01:00
Robert Bragg
8f9151303d pipeline: improve real_blend_enable checks
Since _cogl_pipeline_update_blend_enable() can sometimes show up quite
high in profiles; instead of calling
_cogl_pipeline_update_blend_enable() whenever we change pipeline state
that may affect blending we now just set a dirty flag and when we flush
a pipeline we check this dirty flag and lazily calculate whether blender
really needs to be enabled if it's set.

Since it turns out we were too optimistic in assuming most GL drivers
would recognize blending with ADD(src,0) is equivalent to disabling
GL_BLEND we now check this case ourselves so we can always explicitly
disable GL_BLEND if we know we don't need blending.

This introduces the idea of an 'unknown_color_alpha' boolean to the
pipeline flush code which is set whenever we can't guarantee that the
color attribute is opaque. For example this is set whenever a user
specifies a color attribute with 4 components when drawing a primitive.
This boolean needs to be cached along with every pipeline because
pipeline::real_blend_enabled depends on this and so we need to also call
_cogl_pipeline_update_blend_enable() if the status of this changes.

Incidentally with this patch we now no longer ever use
_cogl_pipeline_set_blend_enable() internally. For now the internal api
hasn't been removed though since we might want to consider re-purposing
it as a public api since it will now not conflict with our own internal
state tracking and could provide a more convenient way to disable
blending than setting a blend string.

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

(cherry picked from commit ab2ae18f3207514c91fa6fd9f2d3f2ed93a86497)
2013-06-06 21:27:09 +01:00
Neil Roberts
2ed926120d Fix a warning in the EGL winsys
_cogl_egl_query_wayland_buffer was using _COGL_RETURN_IF_FAIL but the
function needs to return a CoglBool so it was giving a warning.

(cherry picked from commit d0290eb19fc9bf56fb24f8eab573e19966ea7e1a)
2013-05-30 13:59:13 +01:00
Neil Roberts
d0944b8fbd Add a callback to get dirty events from a CoglOnscreen
This adds a callback that can be registered with
cogl_onscreen_add_dirty_callback which will get called whenever the
window system determines that the contents of the window is dirty and
needs to be redrawn. Under the two X-based winsys's, this is reported
off the back of the Expose events, under SDL it is reported from
SDL_VIDEOEXPOSE or SDL_WINDOWEVENT_EXPOSED and under Windows from the
WM_PAINT messages. The Wayland winsys doesn't really have the concept
of dirtying the buffer but in order to allow applications to work the
same way on all platforms it will emit the event when the surface is
first shown and whenever it is resized.

There is a private feature flag to specify whether dirty events are
supported. If the winsys does not set this then Cogl will simulate
dirty events by emitting one when the window is first allocated and
when it is resized. The only winsys's that don't set this flag are
things like KMS or the EGL null winsys where there is no windowing
system and showing and hiding the onscreen doesn't really make any
sense. In that case Cogl can assume the buffer will only become dirty
once when it is first allocated.

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

(cherry picked from commit 85c5a9ba419b2247bd768284c79ee69164a0c098)

Conflicts:
	cogl/cogl-private.h
2013-05-30 13:42:56 +01:00
Neil Roberts
45e18e0fb7 wayland: Don't delay resize if nothing is drawn since last swap
After discussing with Kristian Høgsberg it seems that the semantics of
wl_egl_window_resize is meant to be that if nothing has been drawn to
the framebuffer since the last swap then the resize will take effect
immediately. Cogl was previously always delaying the call to
wl_egl_window_resize until the next swap. That meant that if you
wanted to resize the surface you would have to call
cogl_wayland_onscreen_resize and then redundantly draw a frame at the
old size so that you can swap to get the resize to occur before
drawing again at the right size. Typically an application would decide
to resize at the start of its paint sequence so it should be able to
just resize immediately.

In current Mesa master it seems that there is a bug which means that
it won't actually delay a resize that is done mid-scene and instead it
will just discard what came before. To get consistent behaviour in
Cogl, the code to delay the call to wl_egl_window_resize is still used
if it determines that the buffer is dirty. There is an existing
_cogl_framebuffer_mark_mid_scene call which was being used to track
when the framebuffer becomes dirty since the last clear. This function
is now also used to track a new flag to track whether something has
been drawn since the last swap. It is called ‘mid_scene’ under the
assumption that this may also be useful for other things later.

cogl_framebuffer_clear has been slightly altered to always call
_cogl_framebuffer_mark_mid_scene even if it determines that it doesn't
need to clear because the framebuffer should still be considered to be
in the middle of a scene. Adding a quad to the journal now also begins
the scene.

This also fixes a potential bug where it looks like pending_dx/dy were
never cleared so they would always be accumulated even after the
resize is flushed.

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

(cherry picked from commit 945689a62903990a20abb87a85d2c96eb3985fe7)
2013-05-30 13:42:11 +01:00
Neil Roberts
2a42576fe7 Rename _cogl_framebuffer_dirty to _cogl_framebuffer_mark_mid_scene
In some later patches we want to be able to use the term ‘dirty’ as a
public facing concept which represents expose events from the window
system. In that case the internal concept of dirtying the framebuffer
is confusing, so this patch changes the name to instead mean that
we've doing something which causes the framebuffer to be in the middle
of a frame.

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

(cherry picked from commit 88eed85b52c29f66659ea112038f3522c9bd864e)
2013-05-30 13:42:11 +01:00
Neil Roberts
0b2b46ce4c wayland: Don't set the surface to toplevel until it is shown
If we delay setting the surface to toplevel until it is shown then
that gives the application an opportunity to avoid calling show so
that it can set its own surface type.

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

(cherry picked from commit ab59c3a421968d7f159d89ca2f0ba8a9f098cbf6)
2013-05-30 13:42:11 +01:00
Neil Roberts
4543ed6ac3 win32: Automatically process windows messages when using a GMainLoop
Previously the WGL winsys was expecting the application to send all
windows messages to Cogl via the cogl_win32_renderer_handle_event
function. When using a GLib main loop we can make this work
transparently to the application with a GSource for the magic
G_WIN32_MSG_HANDLE file descriptor. That causes the GMainLoop to wake
up whenever a message is available.

This patch makes the WGL winsys add that magic value as a source fd.
This will only have any meaning if the application is using glib, but
it shouldn't matter because the cogl_poll_renderer_get_info function
is documented to only work on Unix-based winsys's anyway.

This patch is an API break because by default Cogl will now start
stealing all of the Windows messages. Something like Clutter that wants to handle
its own event retrieval would now need to call
cogl_win32_renderer_set_event_retrieval_enabled to stop Cogl from
stealing the events.

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

(cherry picked from commit 99a7f84d7149f24f3e86c5d3562f9f2632ff6df8)
2013-05-30 13:41:44 +01:00
Robert Bragg
cc4e144dd7 check the wayland buffer format when creating texture
The implementation of cogl_wayland_texture_2d_new_from_buffer now uses
eglQueryWaylandBuffer to query the format of the buffer before trying to
create a texture from the buffer.  This makes sure we don't try and
create a texture from YUV buffers for instance that may actually require
multiple textures. We now also report an error when we don't understand
the buffer type or format.

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

(cherry picked from commit 79252d4e419e2462c5bc89ea4614b40bddc932c5)
2013-05-29 19:30:44 +01:00
Robert Bragg
cf002a7989 pipeline: ignore driver in blend state tracking
This removes the various checks for != COGL_DRIVER_GLES1 when tracking
blend state that was trying to avoid checking the equation or alpha
component factors when they are known to be fixed on gles1. Now we just
rely on the opengl driver to do the right thing for the different
drivers and ignore the differences in the general pipeline state
tracking.

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

(cherry picked from commit f67c7eaf23e1e2088e9956cb2b66dfdc9abc8b3b)
2013-05-29 19:30:44 +01:00
Robert Bragg
0e7a632e13 Adds initial Emscripten support to Cogl
This enables basic Emscripten support in Cogl via the SDL winsys.
Assuming you have setup an emscripten toolchain you can configure Cogl
like this:

 emconfigure ./configure --enable-debug --enable-emscripten

Building the examples will build .html files that can be loaded directly
by a WebGL enabled browser.

Note: at this point the emscripten support has just barely been smoke
tested so it's expected that as we continue to build on this we will
learn about more things we need to change in Cogl to full support this
environment.

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

(cherry picked from commit a3bc2e7539391b074e697839dfae60b69c37cf10)
2013-05-29 19:30:44 +01:00
Robert Bragg
d39f4b8a16 gl: #ifdef guard ARB_sync api in cogl-all-functions.h
The ARB_sync api depends on a GLsync type which may not be available if
GL_ARB_sync isn't defined, such as when building for gles2 only. This
guards the prototypes with #ifdef GL_ARB_sync to fix compilation when a
GLsync type isn't defined.

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

(cherry picked from commit ba79020e0f5b102e8b25cd831c408dd68d241297)
2013-05-29 19:30:44 +01:00
Andreas Oberritter
bb1f787e6a cogl-error.h: add COGL_BEGIN_DECLS/COGL_END_DECLS
Fixes 'undefined reference to cogl_error_free' when using g++.

Signed-off-by: Andreas Oberritter <obi@saftware.de>

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

(cherry picked from commit 41c54fcaba5b4bf76a0e943bac6bca777f3dae2f)
2013-05-29 11:58:48 +01:00
Daniel Stone
ea7d3b8476 Add fence API
cogl_framebuffer_add_fence creates a synchronisation fence, which will
invoke a user-specified callback when the GPU has finished executing all
commands provided to it up to that point in time.

Support is currently provided for GL 3.x's GL_ARB_sync extension, and
EGL's EGL_KHR_fence_sync (when used with OpenGL ES).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

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

(cherry picked from commit e6d37470da9294adc1554c0a8c91aa2af560ed9f)
2013-05-28 21:36:03 +01:00
Robert Bragg
7b14b5e3da poll: Add general way to hook into mainloop without fd
This adds a _cogl_poll_renderer_add_source() function that we can use
within cogl to hook into the mainloop without necessarily having a file
descriptor to poll. Since the intention is to use this to support
polling for fence completions this also updates the
CoglPollCheckCallback type to take a timeout pointer so sources can
optionally update the timeout that will be passed to poll.

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

(cherry picked from commit 81c1ce0ffce4e75e08622e20848405987e00b3cc)
2013-05-28 21:36:03 +01:00
Adam Jackson
c08fe74cd0 xlib: Don't crash just because the display doesn't expose RANDR
If this happens, XRRGetScreenResources will return NULL, so just treat
that like nothing happened.

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

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 57a79912ac70080a2f9cbe65181a25b00bf1192a)
2013-05-16 15:28:01 +01:00
Robert Bragg
74b8cc3acb Include cogl-defines.h before checking COGL_HAS_ define
This makes sure we include cogl-defines.h in cogl-matrix.h before
checking if COGL_HAS_GYPE_SUPPORT is defined

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

(cherry picked from commit aa5ba324bb3b2ce77be29942f8716d61919cefeb)
2013-05-16 15:28:00 +01:00
Robert Bragg
3a7c1263f1 onscreen: Adds swap_buffers_with_damage api
This adds api to be able requests a swap_buffers and also pass a list of
damage rectangles that can be passed on to a compositor to enable it to
minimize how much of the screen it needs to recompose.

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

(cherry picked from commit 0d9684c7b7c2018bb42715c369555330d38514a2)
2013-04-30 16:39:31 +01:00
Robert Bragg
95a41e177a Associate check and dispatch funcs with poll fds
Instead of driving event dispatching through a per winsys poll_dispatch
vfunc its now possible to associate a check and dispatch function with
each file descriptor that is registered for polling. This means we can
remove the winsys get_dispatch_timeout and poll_dispatch vfuncs and it
also makes it easier for more orthogonal internal components to add file
descriptors for polling to the mainloop.

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

(cherry picked from commit 627947622df36dd529b9dc60a3ae9e6083532b19)
2013-04-30 16:39:31 +01:00
Robert Bragg
e3975d1711 Add api for queuing idle callback internally
This adds a _cogl_poll_renderer_add_idle api that can be used internally
for queuing an idle callback without needing to make any assumption
about the system mainloop that is being used. This is now used to avoid
having the _cogl_poll_renderer_dispatch() directly check for all kinds of
events to dispatch, and to avoid having the winsys dispatch vfuncs need
to directly know about CoglContext. This means we can now avoid having a
back reference from CoglRenderer to the CoglContext.

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

(cherry picked from commit a1e169f18f4257caec58760adccfe4ec09b9805d)
2013-04-30 16:39:31 +01:00
Robert Bragg
04a1655804 Adds internal cogl closure list utility
This adds some utility code to help us manage lists of closures
consistently within Cogl. The utilities are from Rig and were originally
written by Neil Roberts.

This adapts the way we track CoglOnscreen resize and frame closures to
use the new utilities.

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

(cherry picked from commit 2e15fc76eb29bf5932418f7ee80f1fcb2f6a816c)
2013-04-30 16:39:31 +01:00
Robert Bragg
ed90c6fed9 Move event polling into CoglRenderer
This updates the cogl_poll_ apis to allow dispatching events before we
have a CoglContext and to also enables pollfd state to be changed in a
more add-hoc way by different Cogl components by replacing the
winsys->get_poll_info with _cogl_poll_renderer_add/remove_fd functions
and a winsys->get_dispatch_timeout vfunc.

One of the intentions here is that applications should be able to run
their mainloop before creating a CoglContext to potentially get events
relating to CoglOutputs.

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

(cherry picked from commit 667e58c9cb2662aef5f44e580a9eda42dc8d0176)
2013-04-30 16:39:31 +01:00
Neil Roberts
816a5bc437 onscreen: Make the resize callback work the same as the frame callback
When adding the frame callback API in 70040166 we decided on a common
idiom for adding callbacks which would return an opaque pointer
representing the closure for the callback. This pointer can then be
used to later remove the callback. The closure can also contain an
optional callback to invoke when the user data parameter is destroyed.
The resize callback didn't work this way and instead had an integer
handle to identify the closure. This patch changes it to work the same
way as the frame callback.

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

(cherry picked from commit 33164c4b04d253ebe0ff41b12c1e90232c519274)
2013-04-30 16:39:31 +01:00
Chris Cummins
59a04cd0e6 wayland: implement foreign surfaces for CoglOnscreen
This adds support for optionally providing a foreign Wayland surface to
a CoglOnscreen before allocation. Setting a foreign surface prevents
Cogl from creating a toplevel Wayland shell surface for the OnScreen.

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

(cherry picked from commit e447d9878f3bcfe5fe336d367238383b02879223)
2013-04-26 17:53:07 +01:00
Chris Cummins
4327b7a364 wayland: free framebuffer's shell surface on destroy
This prevents leaking the Wayland shell surface associated with a Cogl
OnScreen when it is finalised.

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

(cherry picked from commit 760fc9f3af5475530262b82a55df311fceca358a)
2013-04-26 17:52:57 +01:00
Robert Bragg
afbb13e1a4 Add compiler deprecation warnings
This adds compiler symbol deprecation declarations for old Cogl APIs so
that users can easily see via compiler warning when they are using these
symbols, and also see a hint for what the apis should be replaced with.

So that users of Cogl can manage when to show these warnings this
introduces a scheme borrowed from glib whereby you can declare what
version of the Cogl api you are using:

COGL_VERSION_MIN_REQUIRED can be defined to indicate the oldest Cogl api
that the application wants to use. Cogl will only warn about
deprecations for symbols that were deprecated earlier than this required
version. If this is left undefined then by default Cogl will warn about
all deprecations.

COGL_VERSION_MAX_ALLOWED can be defined to indicate the newest api
that the application uses. If the application uses symbols newer than
this then Cogl will give a warning about that.

This patch removes the need to maintain the COGL_DISABLE_DEPRECATED
guards around deprecated symbols.

This patch fixes a few uses of deprecated symbols in the examples/

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-04-24 22:23:50 +01:00
Andreas Oberritter
b5e57c914b wayland: implement poll_get_info and poll_dispatch
Call wl_display_dispatch on POLLIN. This follows the implementation
in weston/clients/window.c and improves integration of input events,
at least.

Signed-off-by: Andreas Oberritter <obi@saftware.de>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 323fe1887487f19c3e26aa6b7644de31d8d0a532)
2013-04-24 22:23:49 +01:00
Emanuele Aina
b8673fbb2f build: Use LT_LIB_M to find the math library in a portable way
https://bugzilla.gnome.org/show_bug.cgi?id=697330

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

(cherry picked from commit a7b4930e14add7d955c22f396178b71083dfb52f)

Conflicts:
	cogl/Makefile.am
2013-04-23 18:30:50 +01:00
Andreas Oberritter
a2168cedb3 cogl-xlib.h: add missing COGL_END_DECLS
Fixes compilation with C++ compiler.

Signed-off-by: Andreas Oberritter <obi@saftware.de>
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 7b3c6dd7f6810f3c8dec62904daa887c917ab7e2)
2013-04-16 19:50:09 +01:00
Neil Roberts
20657d6245 pipeline-cache: Use a special trimmed down pipeline for the key
When a pipeline is added to the cache, a normal copy would previously be
made to use as the key in the hash table. This copy keeps a reference
to the real pipeline which means all of the resources it contains are
retained forever, even if they aren't necessary to generate the hash.

This patch changes it to create a trimmed down copy that only has the
state necessary to generate the hash. A new function called
_cogl_pipeline_deep_copy is added which makes a new pipeline that is
directly a child of the root pipeline. It then copies over the
pertinent state from the original pipeline. The pipeline state is
copied using the existing _cogl_pipeline_copy_differences function.
There was no equivalent function for the layer state so I have added
one.

That way the pipeline key doesn't have the texture data state and it
doesn't hold a reference to the original pipeline so it should be much
cheaper to keep around.

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

(cherry picked from commit e27e01c1215e7e7c7c0183ded11dd769bb112c5c)
2013-04-04 13:38:43 +01:00
Neil Roberts
4e03bd47bf pipeline-hash-table: Store the hash value in the entry
Calculating the hash value for a pipeline can be a bit expensive.
Previously when adding a new pipeline to the hash table we would end
up calculating the hash value once when checking whether the pipeline
is already in the hash table and then again when adding the pipeline
to the hash table. Ideally GHashTable would provide some API to add an
entry with a precalculated hash value to avoid the recalculation, but
seeing as it doesn't do that we can force it to avoid recalculating by
storing the hash value as part of the struct we are using for the key.
That way the hash func passed to GHashTable can simply return the
precalculated value and we can calculate the hash outside of the
GHashTable calls.

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

(cherry picked from commit 4a0460a452fd1be382fd5a92d8cfd5e0cdfd4403)
2013-04-04 13:38:43 +01:00
Neil Roberts
3b8d328652 pipeline-cache: Use a shared hash table wrapper
The pipeline cache contains three separate hash tables, one for the
state affecting the vertex shaders, one for the fragment shaders and
one for the resulting combined program. Previously these hash tables
had a fair bit of duplicated code to calculate the hashes, check for
equality and copy the pipeline when it is added. This patch moves the
common bits of code to a new type called CoglPipelineHashTable which
just wraps a GHashTable with a given set of state flags to use for
hashing and checking for equality.

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

(cherry picked from commit 402796430c839038339e531363b8c2463f9b2a9e)

Conflicts:
	cogl/Makefile.am
2013-04-04 13:38:41 +01:00
Neil Roberts
a1952a25ad quartz-image: Pass a CoglError argument to the bitmap functions
Since 67cad9c0 and f7735e141a the bitmap allocation and mapping
functions now take an extra error argument. The quartz image backend
was missed in this update so Cogl would fail to compile if
--enable-quartz-image is used.

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

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

(cherry picked from commit 1827965befccf331b0787f71cb191d370640a9de)
2013-04-04 13:37:51 +01:00
Robert Bragg
af8803baab egl: define missing EGL_KHR_create_context enums
This makes sure the EGL_KHR_create_context enums are always defined in
cogl-winsys-egl.c so we will build with drivers that don't support this
extension. Cogl will do runtime checks to explicitly check that the
extension is available before ever referencing these enums so this is
safe to do.

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

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

(cherry picked from commit bd034b7451e7d9c602bcc91f1a00f6aaa7b05ec0)
2013-03-24 23:55:10 +00:00
Plamena Manolova
b833d26b3f Fix multiple snippet interleaving bug
Interleaving multiple snippets with different hooks
(COGL_SNIPPET_HOOK_VERTEX and COGL_SNIPPET_HOOK_VERTEX_TRANSFORM,
for instance) used to cause a bug during shader code generation.

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

(cherry picked from commit 38ca76695d54bbbfe3b940a6d0b2ae879e6fd66b)
2013-03-20 14:37:58 +00:00
Neil Roberts
22363a4137 Prune redundant pipeline ancestry after adding a layer difference
Adding a layer difference may mean the pipeline overrides all of the
layers of its parent which might make the parent redundant so we
should try to prune the hierarchy.

This is particularly important for CoglGst because whenever a new
frame is ready it tries to make a copy of the pipeline it last used
and then replace all of the textures in the layers. Without this patch
the new pipeline would keep the parent pipeline alive which means also
keeping the old textures alive so all of the frames of the video would
effectively be leaked.

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

(cherry picked from commit 576c7b55aa835448c977f1d79d128dffd40e7cd8)
2013-03-19 17:53:43 +00:00
Chun-wei Fan
8906f7139a Update cogl.symbols
Add the newly-added symbols during the development cycle, and drop those
that are dropped.  Also, clean up the private symbols that were exported,
those that are still left in cogl.symbols are those still being referenced
by Cogl-Pango

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-03-15 00:25:41 +08:00
Robert Bragg
e886ad46e0 Revert "cogl-buffer: Stop warning spam running in sw rendering"
This reverts commit 83dbf79986981fac9ec0f2575b7c7cb32f629f0f.

On further consideration we realized that needing this change either
indicated a bug in the code using cogl, or that it was a symptom of
some other bug in Cogl resulting in us returning NULL in
cogl_buffer_map_range but not returning a CoglError too.

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

(cherry picked from commit 8c5127c712570f1ea0d495a7fe7290ae5ee60ce6)
2013-03-06 16:46:03 +00:00
Robert Bragg
2fa7b5573d gl: ensure depth isn't masked during clear
If a pipeline has been flushed that disables depth writing and then we
try to clear the framebuffer with cogl_framebuffer_clear4f, passing
COGL_BUFFER_BIT_DEPTH then we need to make sure that depth writing is
re-enabled before issuing the glClear call. We also need to make sure
that when the next primitive is flushed that we re-check what state the
depth mask should be in.

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

(cherry picked from commit 3cf497042897d1aa6918bc55b71a36ff67e560b9)
2013-03-06 16:45:31 +00:00
Robert Bragg
3c5ebb8752 framebuffer: vp change = clip change for gen6 workaround
This makes sure that a viewport change when comparing between separate
framebuffers also implies a clip change when we are applying the Intel
gen6 workaround for broken viewport clipping. Without this then
switching between different size framebuffers could leave a scissor
matching the size of a previous framebuffer.

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

(cherry picked from commit f23f2129c58550f819cff783f47039d7bd91391e)
2013-03-06 16:45:14 +00:00
Robert Bragg
b62b9a68bb bitmap: don't mark bitmap bound on _gl_bind error
This makes some changes to _cogl_bitmap_gl_bind to be more paranoid
about bad access arguments and make sure we don't mark a bitmap as bound
if there was an error in _cogl_buffer_gl_bind.

We now validate the access argument upfront to check that one of _READ
or _WRITE access has been requested. In the case that cogl is built
without debug support then we will still detect a bad access argument
later and now explicitly return before marking the bitmap as bound, just
in case the g_assert_not_reach has been somehow disabled. Finally we
defer setting bitmap->bound = TRUE until after we have check for any
error with _cogl_bitmap_gl_bind.

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

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

(cherry picked from commit 1720d5cf32449a189fd9d400cf5e6696cd50a9fa)
2013-03-06 16:44:52 +00:00
Neil Roberts
a131b697d9 Add the layer's sampler and uniform declarations at the start
Previously the sampler uniform declarations such as cogl_sampler0 were
generated by walking the list of layers in the shader state. This had
two problems. Firstly it would only generate the declarations for
layers that have been referenced. If a layer has a combine mode of
replace then the samplers from previous layers couldn't be used by
custom snippets. Secondly it meant that the samplers couldn't be
referenced by functions in the declarations sections because the
samplers are declared too late.

This patch fixes it to generate the layer declarations in the backend
start function using all of the layers on the pipeline instead. In
addition it adds the sampler declarations to the vertex shader as they
were previously missing.

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

(cherry picked from commit 1824df902bbb9995cae6ffb7a413913f2df35eef)

Conflicts:
	cogl/driver/gl/cogl-pipeline-fragend-glsl.c
	cogl/driver/gl/cogl-pipeline-vertend-glsl.c
2013-02-27 15:53:43 +00:00
Neil Roberts
956d39ac30 Add fragment and vertex snippet hooks for global declarations
This adds hook points to add global function and variable declarations
to either the fragment or vertex shader. The declarations can then be
used by subsequent snippets. Only the ‘declarations’ string of the
snippet is used and the code is directly put in the global scope near
the top of the shader.

The reason this is necessary rather than just adding a normal snippet
with the declarations is that for the other hooks Cogl assumes that
the snippets are independent of each other. That means if a snippet
has a replace string then it will assume that it doesn't even need to
generate the code for earlier hooks which means the global
declarations would be lost.

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

(cherry picked from commit ebb82d5b0bc30487b7101dc66b769160b40f92ca)
2013-02-27 14:43:55 +00:00
Bastien Nocera
bd1e3e7642 cogl-buffer: Stop warning spam running in sw rendering
/etc/gdm/Xsession[731]: Aviso do gerenciador de janelas: Log level 8:
g_error_free: assertion `error != NULL' failed

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

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

(cherry picked from commit 83dbf79986981fac9ec0f2575b7c7cb32f629f0f)
2013-02-25 17:50:18 +00:00