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)
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
Currently when a unique pipeline is created and added to the pipeline
cache that pipeline will live forever which includes keeping a
reference to any large resources that the pipeline has such as
textures. These textures don't actually need to be kept for the
pipeline to be used as a key in the hash table so ideally we wouldn't
do this. This test case tries rendering with a pipeline that has
textures and then checks whether the textures are successfully
destroyed after the pipeline is unreffed. The test is currently marked
as a known failure because the pipeline cache will prevent them from
being destroyed.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 0056f805dadd46b966d57f66b02890b8c29971ac)
The quartz image backend is using functions from the
ApplicationServices framework and I was getting linker errors if I
didn't use this option. I'm not sure how anyone managed to build it
before without this.
https://bugzilla.gnome.org/show_bug.cgi?id=696730
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 54d9139a929560d6703428371b38b83e7d965f45)
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)
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)
The clients should be flushed before going idle, not after so the call
to wl_display_flush_clients was in the wrong place.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit a191366fbababd5b551140ef9297a9c6e3852c59)
Instead of always drawing at 60FPS without ever going idle, Cogland
now only redraws when a client commits a frame or a surface is
destroyed. This is acheived using an idle handler on the glib main
loop.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 906e1b5eb535a86a849bed7a363f800ad71ab9bc)
Conflicts:
examples/cogland.c
The previous display size of 640x480 was a bit small to test with.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 835626e220137765df5acf7419036218e3fc7c97)
Previously Cogland would always split the desktop into four outputs.
Although this is quite neat to demonstrate that it's possible, it's
quite annoying in practice while testing. This patch turns it into a
command line option which defaults to off.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 5570bf892268c8d2ea36bc26473aeb607c0e2c1d)
Previously Cogl would accept any version of Wayland when building the
Wayland backend. Seeing as there is now a stable API we might as well
specify that we require at least version 1.0.0. This is now also
mentioned in the README. This patch also changes it to use
PKG_CHECK_MODULES instead of PKG_CHECK_EXISTS because it does need to
abort if it fails and it shouldn't be checking it silently.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit d899955b714e5ed50c6c89b9fde4b341bcf80558)
This updates Cogland example compositor to use the stable Wayland 1.0
API.
• When the client attaches a new buffer to a surface it is now added
to a struct contaning pending the state instead of immediately
switching to the new buffer. This state is then flushed when the
surface is committed.
• The frame callbacks are now queued in a pending list and only added
to the compositor's main list when the surface is committed. Both
lists are now a wl_list instead of a GQueue because it makes it
easier to remove the callback without knowing which list it is in.
• When the buffer is destroyed for a surface the resource for the
buffer is now sent a release event.
• It now flushes the clients in the prepare for the for the Wayland
event GSource. This is part of the multi-threaded API in this
Wayland patch:
http://cgit.freedesktop.org/wayland/wayland/commit/?id=53d24713a31d59
• Implements a dummy wl_region interface. The only interfaces that
actually use regions (the opaque and input regions) are ignored but
we need the interface to create a resource.
• Most the of the SHM interface is now implemented directly in
libwayland-server except that it still needs to copy the data to the
subregion of the texture when the damage region is committed.
• The callback list for when a resource is destroyed has been unified
into a generic wl_signal implementation so the signature for the
functions has been changed.
http://cgit.freedesktop.org/wayland/wayland/commit/?h=6802eaa68af9022
• The wl_buffer struct no longer has a user_data parameter so we can't
attach our own CoglandBuffer data to it. Instead the CoglandSurface
now just keeps track of the wl_buffer directly.
• The Cogland example is now unconditionally built instead of checking
the Wayland version number in the configure script. It looks like
this check was broken anyway because it was checking the version of
the gbm package rather than a Wayland package.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 4cbbc0f8e3de1fd44dee08b487f1c3f97dda8ede)
Conflicts:
examples/Makefile.am
examples/cogland.c
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)
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)
The current recommendation for pipelines is that once they have been
used for painting then they should be considered immutable. If you
want to modify a pipeline you should instead make a copy and unref the
original pipeline. Internally we try to check whether the modified
copy replaces all of the properties of the parent and prune a
redundant ancestor hierarchy. Pruning the hierarchy is particularly
important if the pipelines contain textures because otherwise the
textures may be leaked when the parent pipeline keeps a reference to
it.
This test verifies that usage pattern by creating a chain of pipeline
copies each with their own replacement texture. Some user data is then
set on the textures with a callback so that we can verify that once
the original pipelines are destroyed then the textures are also
destroyed.
The test is currently failing because Cogl doesn't correctly prune
ancestory for layer state authority.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 3fbec92acb90008492eb125025f92b42d6e07930)
The config.h.in generated by autotools has much more entries than before,
so update the pre-configured config.h.win32.in.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
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>
-Make entries of the property sheets more like the property sheets of the
projects in the GTK+/Clutter stack, mainly changing CoglApiVersion to
ApiVersion, for better consistency, and update the corresponding projects
-Add command item in property sheets to build introspection files for Cogl
and Cogl Pango.
-Stop building and installing the cogl-msaa example, as it is something
that isn't really meant for Windows, and causes an internal compiler error
on Visual Studio 2010 x64 builds
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)
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)
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)
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)
Some public headers were added, so these need to be "installed" as well.
Also clean up the preprocessor definitions as they were meant to be
in cogl/cogl-defines.h.
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
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)
To avoid linking trouble in C++ stuff
Reviewed-By: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit b194f1bf58055ef1f5075508f19336cae648a0c8)
Conflicts:
cogl/cogl-object.h
This fixes some minor errors and warnings that were preventing Cogl
building with mingw32:
• cogl-framebuffer-gl.c was not including cogl-texture-private.h.
Presumably something else ends up including that when building for
GLX.
• The WGL winsys was not including cogl-error-private.h
• A call to strsplit in the WGL winsys was wrong.
• For some reason the test-wrap-rectangle-textures test was trying to
include the GDKPixbuf header.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 5380343399f834d9f96ca3b137d49c9c2193900a)
The version of Pango that the script downloads is using G_CONST_RETURN
in the public headers. This won't build if G_DISABLE_DEPRECATED is
enabled so instead the build script now just recommends to pass
--enable-deprecated to cogl's configure script.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 4715f0f01d4de55a9cf690f52d4da211c243565b)
Cogl now requires at least version 2.32.0 of GLib. There are no
pre-built binaries for this from tml so we have to build glib from
source. This also requires libffi. The binary packages for libffi and
zlib don't install a pc file so the script just manually generates a
fake one.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 9e47972759a5dda4c9e9bf13df3369510be0e324)
Mesa's libGLU tesselator code has had a commit on it since it was
copied into Cogl. It sounds like it fixes a potential crash so we
should probably have it in Cogl too.
http://cgit.freedesktop.org/mesa/glu/commit/?id=bfdf99d6ff64b9c2
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c6b2429546d3ea0aa91caa47c7c90f932984ea33)
There was a missing backslash in the LDFLAGS for libcogl-pango2. This
was stopping it having the right library version information and the
library would have the wrong filename.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit cf3d2b3de84d4e1e90b83cf3f69653f38997ef97)
glMapBufferRange is documented to fail with GL_INVALID_OPERATION if
GL_MAP_INVALIDATE_BUFFER_BIT is set as well as GL_MAP_READ_BIT. I
guess this makes sense when only read access is requested because
there would be no point in reading back uninitialised data. However,
Clutter requests read/write access with the discard hint when
rendering to a CoglBitmap with Cairo. The data is new so the discard
hint makes sense but it also needs read access so that it can read
back the data it just wrote for blending.
This patch works around the GL restriction by skipping the discard
hints if read access is requested. If the buffer discard hint is set
along with read access it will recreate the buffer store as an
alternative way to discard the buffer as it does in the case where the
GL_ARB_map_buffer_range extension is not supported.
https://bugzilla.gnome.org/show_bug.cgi?id=694164
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 986675d6043e8701f2d65415cf72ffc91734debd)
The journal manually flushes its own modelview matrix state so it
needs to mark the state as dirty so that if a primitive is drawn with
the same matrix state as the last primitive it will correctly reflush
it.
https://bugzilla.gnome.org/show_bug.cgi?id=693612
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit c7290c994c742456ff0977cb394c289afb377049)
This adds a conformance test which draws a rectangle using the journal
in-between two rectangles drawn with primitives without changing any
other state. Currently this is failing because the modelview matrix
state is not correctly flushed.
The journal also flushes in own clip state so the test additionally
puts everything in a clip and verifies that that worked. This is not
currently broken but we might as well test it.
https://bugzilla.gnome.org/show_bug.cgi?id=693612
Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit b703f9a1a98894a12021cbdd632e1d59214e612f)