1
0
Fork 0
Commit graph

160 commits

Author SHA1 Message Date
Emmanuele Bassi
853a9b6e49 conform: Mark XFAIL tests
Bisection would be useful.
2015-07-23 12:59:55 +01:00
Emmanuele Bassi
2482384312 conform: Disable deprecation warnings
The conformance test suite exercises deprecated API, so we don't need to
get compiler warnings for it.
2015-06-10 15:16:15 +01:00
Neil Roberts
eb7ef457cb Add support for RG textures
This adds COGL_PIXEL_FORMAT_RG_88 and COGL_TEXTURE_COMPONENTS_RG in
order to support two-component textures. The RG components for a
texture is only supported if COGL_FEATURE_ID_TEXTURE_RG is advertised.
This is only available on GL 3, GL 2 with the GL_ARB_texture_rg
extension or GLES with the GL_EXT_texture_rg extension. The RG pixel
format is always supported for images because Cogl can easily do the
conversion if an application uses this format to upload to a texture
with a different format.

If an application tries to create an RG texture when the feature isn't
supported then it will raise an error when the texture is allocated.

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

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

(cherry picked from commit 568677ab3bcb62ababad1623be0d6b9b117d0a26)

Conflicts:
	cogl/cogl-bitmap-packing.h
	cogl/cogl-types.h
	cogl/driver/gl/gl/cogl-driver-gl.c
	tests/conform/test-read-texture-formats.c
	tests/conform/test-write-texture-formats.c
2014-01-20 14:40:45 +00:00
Robert Bragg
a77dc1319c texture-rectangle: update _new_with_size in line with master
This updates the cogl_texture_rectangle_new_with_size() api in line with
master to be consistent with other texture constructors. This removes
the internal_format and error arguments and allows the texture to be
allocated lazily which means the texture can be configured with apis
like cogl_texture_set_components() and cogl_texture_set_premultiplied()
before it is allocated.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2014-01-13 17:35:05 +00:00
Robert Bragg
af7398788a remove internal_format and redundant error arguments
Texture allocation is now consistently handled lazily such that the
internal format can now be controlled using
cogl_texture_set_components() and cogl_texture_set_premultiplied()
before allocating the texture with cogl_texture_allocate(). This means
that the internal_format arguments to texture constructors are now
redundant and since most of the texture constructors now can't ever fail
the error arguments are also redundant. This now means we no longer
use CoglPixelFormat in the public api for describing the internal format
of textures which had been bad solution originally due to how specific
CoglPixelFormat is which is missleading when we don't support such
explicit control over the internal format.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 99a53c82e9ab0a1e5ee35941bf83dc334b1fbe87)

Note: there are numerous API changes for functions currently marked
as 'unstable' which we don't think are in use by anyone depending on
a stable 1.x api. Compared to the original patch though this avoids
changing the cogl_texture_rectangle_new_with_size() api which we know
is used by Mutter.
2014-01-09 15:49:47 +00:00
Neil Roberts
0596fe8020 Fix calculating the bounds when clipping from a primitive
When projecting the bounding rectangle of a primitive it was using the
modelview matrix twice instead of the modelview and projection
matrices so it was coming out with garbage.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 7e1f05c84013bb91248d691091df00f4f634c6cf)
2013-12-03 15:28:35 +00:00
Neil Roberts
7f7187eaf1 Add a test for cogl_framebuffer_push_path_clip
The test makes an L-shaped path that fills the whole framebuffer
except for the top right quadrant. It then clips to that and tries to
fill the framebuffer with a rectangle. Then it verifies that all of
the quadrants have the expected colour.

This is currently failing due to a bug in the primitive clipping.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 5404033220099b4a3c6cf32a0d269c4e98489fee)
2013-12-03 15:28:24 +00:00
Robert Bragg
6436cd073d Declare interface types as void and remove cast macros
This declares the interface types CoglFramebuffer, CoglBuffer,
CoglTexture, CoglMetaTexture and CoglPrimitiveTexture as void when
including the public cogl.h header so that users don't have to use lots
of C type casts between instance types and interface types.

This also removes all of the COGL_XYZ() type cast macros since they do
nothing more than compile time type casting but it's less readable if
you haven't seen that coding pattern before.

Unlike with gobject based apis that use per-type macros for casting and
performing runtime type checking we instead prefer to do our runtime
type checking internally within the front-end public apis when objects
are passed into Cogl. This greatly reduces the verbosity for users of
the api and may help reduce the chance of excessive runtime type
checking that can sometimes be a problem.

(cherry picked from commit 248a76f5eac7e5ae4fb45208577f9a55360812a7)

Since we can't break the 1.x api this version of the patch actually
defines compatible NOP macros within deprecated/cogl-type-casts.h
2013-11-27 19:33:44 +00:00
Hans Petter Jansson
a8e04a7d6b Add API to control per-framebuffer depth writing
Add framebuffer methods cogl_framebuffer_[gs]et_depth_write_enabled()
and backend bits to pass the state on to glDepthMask().

This allows us to enable or disable depth writing per-framebuffer, which
if disabled saves us some work in glClear(). When rendering, the flag
is combined with the pipeline's depth writing flag using a logical AND.

Depth writing is enabled by default.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 71406438c5357eb4e0ef03e940c5456a536602a0)
2013-10-28 16:34:58 +00:00
Robert Bragg
99a0be890e conform: check we invalidate ancestor cached state
In the cases where we cache vertex state with an ancestor pipeline (whose
vertex processing state is equivalent) we need to invalidate that state
if that ancestor is later modified.

This conformance test checks this case but currently fails because we
only notify the progend directly associated with the pipeline being
changed.

In this case the pipeline can be using a different progend to the
ancestor which it is caching state with so when the ancestor is changed
it needs to notify all the progends that they may need to clear their
private state.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit e112af5f770d6c46688fdcb5ba38b75ca0778891)
2013-10-28 16:34:57 +00:00
Neil Roberts
4d98bdd9e5 Fix building the conformance and unit tests on mingw32
The unit tests were failing to build with mingw32 because the
libtest-fixtures was being included both by libcogl and the
test-conformance and test-unit executables. That meant that the
symbols were defined twice and it wouldn't link.

The rule which depends on test-unit being built needs to be called
test-unit.exe on Windows so this patch fixes it to use the $(EXEEXT)
variable to get the right name.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 575bac47fee0b425f4fd30761e5819443e6c045f)

Conflicts:
	tests/conform/Makefile.am
	tests/unit/Makefile.am
2013-09-02 18:08:09 +01:00
Neil Roberts
a849ecae1b Add a conformance test for using cogl_point_coord in a shader
This adds a modification to the test-point-sprite test which uses a
shader snippet which directly references cogl_point_coord instead of
relying on cogl_pipeline_set_layer_point_sprite_coords_enabled to
replace the texture coordinates with the point coords.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 5ea57b14f5ec7d52ae378f4ca64574ef56342f56)
2013-09-02 16:22:08 +01:00
Robert Bragg
04d943579b gl: bind position attribute to location 0
Full GL treats the position attribute specially and requires that it
must be bound to generic attribute location 0 unlike GLES 2.0 or
GL 3.2 core. We now make sure to unconditionally bind the
cogl_position_in attribute to location 0 before linking any glsl program
in cogl.

For reference the relevant part of the GL 3.0 spec that covers these
semantics is Section 2.7 "Vertex Specification" pg 27

After this change there was one remaining problem in
test-custom-attributes where the test_short_verts() test was using its
own "pos" attribute instead of cogl_position_in and so cogl wasn't able
to ensure it would be bound to location 0.

This updates the test to use cogl_position_in but to work around the
fact that glVertexPointer doesn't support UNSIGNED_SHORT components we
force the test to use the glsl backend by setting a shader snippet on
the pipeline.

https://bugs.freedesktop.org/show_bug.cgi?id=67548

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

(cherry picked from commit 992ef7b3b49ebb56adde2133bb36330c04133a3f)
2013-08-19 22:44:45 +01:00
Robert Bragg
1317a25a91 offscreen: rename _new_to_texture to _new_with_texture
This renames cogl_offscreen_new_to_texture to
cogl_offscreen_new_with_texture. The intention is to then cherry-pick
this back to the cogl-1.16 branch so we can maintain a parallel
cogl_offscreen_new_to_texture() function which keeps the synchronous
allocation semantics that some clutter applications are currently
relying on.

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

(cherry picked from commit ecc6d2f64481626992b2fe6cdfa7b999270b28f5)

Note: Since we can't break the 1.x api on this branch this keeps a
thin shim around cogl_offscreen_new_with_texture to implement
cogl_offscreen_new_to_texture with its synchronous allocation
semantics.
2013-08-19 22:44:44 +01:00
Robert Bragg
7365c3aa77 Separate out CoglPath api into sub-library
This splits out the cogl_path_ api into a separate cogl-path sub-library
like cogl-pango and cogl-gst. This enables developers to build Cogl with
this sub-library disabled if they don't need it which can be useful when
its important to keep the size of an application and its dependencies
down to a minimum. The functions cogl_framebuffer_{fill,stroke}_path
have been renamed to cogl_path_{fill,stroke}.

There were a few places in core cogl and cogl-gst that referenced the
CoglPath api and these have been decoupled by using the CoglPrimitive
api instead. In the case of cogl_framebuffer_push_path_clip() the core
clip stack no longer accepts path clips directly but it's now possible
to get a CoglPrimitive for the fill of a path and so the implementation
of cogl_framebuffer_push_path_clip() now lives in cogl-path and works as
a shim that first gets a CoglPrimitive and uses
cogl_framebuffer_push_primitive_clip instead.

We may want to consider renaming cogl_framebuffer_push_path_clip to
put it in the cogl_path_ namespace.

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

(cherry picked from commit 8aadfd829239534fb4ec8255cdea813d698c5a3f)

So as to avoid breaking the 1.x API or even the ABI since we are quite
late in the 1.16 development cycle the patch was modified to build
cogl-path as a noinst_LTLIBRARY before building cogl and link the code
directly into libcogl.so as it was previously. This way we can wait
until the start of the 1.18 cycle before splitting the code into a
separate libcogl-path.so.

This also adds shims for cogl_framebuffer_fill/stroke_path() to avoid
breaking the 1.x API/ABI.
2013-08-19 22:44:35 +01:00
Robert Bragg
e4f24dba75 framebuffer: remove attribute drawing apis
Almost nothing draws attributes directly and for those things that do
it's trivial to adapt them to instead draw via the cogl_primitive api.
This simplifies the Cogl api a bit.

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

(cherry picked from commit 7395925bcc01aad6c695fd0d9af78b784b3c64d4)

Conflicts:
	cogl/cogl-framebuffer.c
	cogl/cogl-framebuffer.h
2013-07-30 15:08:39 +01:00
Robert Bragg
e9f721216e Add _primitive_draw to replace _framebuffer_draw_primitive
When splitting out the CoglPath api we saw that we would be left with
inconsistent drawing apis if the drawing apis in core Cogl were lumped
into the cogl_framebuffer_ api considering other Cogl sub-libraries or
that others will want to create higher level drawing apis outside of
Cogl but can't use the same namespace.

So that we can aim for a more consistent style this adds a
cogl_primitive_draw() api, comparable to cogl_path_fill() or
cogl_pango_show_layout() that's intended to replace
cogl_framebuffer_draw_primitive()

Note: the attribute and rectangle drawing apis are still in the
cogl_framebuffer_ namespace and this might potentially change but in
these cases there is no single object representing the thing being drawn
so it seems a more reasonable they they live in the framebuffer
namespace for now.

Note: the cogl_framebuffer_draw_primitive() api isn't removed by this
patch so it can more conveniently be cherry picked to the 1.16 branch so
we can mark it deprecated for a short while. Even though it's marked as
experimental api we know that there are people using the api so we'd
like to give them a chance to switch to the new api.

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

(cherry picked from commit 418912b93ff81a47f9b38114d05335ab76277c48)

Conflicts:
	cogl-pango/cogl-pango-display-list.c
	cogl/Makefile.am
	cogl/cogl-framebuffer.c
	cogl/cogl-pipeline-layer-state.h
	cogl/cogl2-path.c
	cogl/driver/gl/cogl-clip-stack-gl.c
2013-07-29 18:31:36 +01:00
Robert Bragg
937337993d tests: stop using cogl-auto-texture apis
The plan is to remove the cogl-auto-texture apis since they hide a bit
too much from developers but currently the conformance tests depend on
these apis in numerous places.

For the conformance tests it makes some sense to continue using high
level texture apis similar to the auto-texture apis since we may want
to make broad variations to how textures are allocated as part of the
testing running if that might help exercise more code paths.

This patch copies much of the auto-texture functionality into some
slightly more special purpose utilities in test-utils.c/h. Minor changes
include being constrained to the public Cogl api and they also don't
let you catch CoglErrors and just assume they should abort on error.

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

(cherry picked from commit 911df79776ce6f695351c15e9872b4f1479d30bf)

Conflicts:
	tests/conform/test-atlas-migration.c
	tests/conform/test-backface-culling.c
	tests/conform/test-blend-strings.c
	tests/conform/test-color-mask.c
	tests/conform/test-just-vertex-shader.c
	tests/conform/test-npot-texture.c
	tests/conform/test-primitive.c
	tests/conform/test-snippets.c
	tests/conform/test-texture-get-set-data.c
	tests/conform/test-texture-mipmap-get-set.c
	tests/conform/test-texture-no-allocate.c
	tests/conform/test-wrap-modes.c
2013-07-29 17:56:07 +01:00
Matthias Clasen
5e26d17ea7 Install conformance tests
Install the conformance tests, and metadata to run them
with gnome-desktop-testing-runner.

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

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

(cherry picked from commit 53f3eb421239982b69569ad03ccbfa4b4f601cf3)
2013-07-09 22:52:50 +01:00
Damien Lespiau
1c3cd74211 tests: Add a test for the RGB <-> HSL functions
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 32d67c2bf40641b2d1d30fa2d994013c3e6ce5bc)
2013-07-09 22:52:49 +01:00
Neil Roberts
b1542cf9dd Don't include cogl/cogl.h from test-utils.h
There was a circular depedency when building from a fresh git clone
where test-fixtures needs to be built before the cogl directory, but
test-fixtures also indirectly includes cogl-enum-types.h which is only
generated when building the cogl directory. If we change the header to
just include specific cogl headers instead of cogl/cogl.h then we can
break the circular dependency.

This needs a tweak to test-no-gl-header because that first undefines
COGL_COMPILATION before including test-utils.h. However it doesn't
really do any actual work so we can get away without including it.

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

(cherry picked from commit adb26bd13a48ed571ef4cae4de005e039b34e361)
2013-07-04 11:50:31 +01:00
Rico Tzschichholz
09a1365c3a build: Fix doc build and make dist
Reviewed-by: Neil Roberts <neil@linux.intel.com>
2013-07-02 14:19:05 +02: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
49a30eecfb Add test that Cogl doesn't crash when freeing unallocated texture
It looks like Cogl doesn't currently clean up an unallocated atlas
texture properly so if it fails to allocate it. It will then crash
when it is freed. This adds a conformance test to verify that all of
the various texture types can be freed without allocating them.

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

(cherry picked from commit bfada22d9a7f60baad5ae5615e45f10327e23e36)
2013-06-13 13:45:34 +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
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
f4fd724caf conform: Add color attribute based blending test
This adds a test to make sure that if the same pipeline is used to draw
two primitives, one which doesn't need blending because it has an opaque
color associated, and another using a color attribute that requires
blending then Cogl should recognize that it needs to enable blending for
the second primitive even though the pipeline hasn't changed.

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

(cherry picked from commit c15d91f1c6293bebd4494d1e20586121483cddef)
2013-06-06 21:27:16 +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
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
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
Neil Roberts
abaca02235 Add $(LIBM) to the LDADD for all of the examples and tests
Some of the examples and tests are using functions from -lm. With some
linkers, if we don't expicitly link against it an error will be
reported. This patch adds the library to all of the examples even
though not all of them use math functions because I don't think it
will do any harm and it will save us having to remember to add it if
an example later starts using some math functions.

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

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

(cherry picked from commit 66a1aeaee1f7cdcdd505f5745277723a43d714b6)

Conflicts:
	examples/Makefile.am
	tests/conform/Makefile.am
	tests/micro-perf/Makefile.am
2013-04-23 18:32:47 +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
e98960a685 Conformance test to check whether the pipeline cache holds textures
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)
2013-04-04 13:37:51 +01: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
Neil Roberts
f9456574ef Add test to verify replacing a layer doesn't leak the pipeline parent
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)
2013-03-19 17: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
Neil Roberts
fc86d0e12e win32: Minor build fixes for building for win32
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)
2013-02-21 15:20:55 +00:00
Neil Roberts
861b119a53 journal: Dirty the modelview matrix state when flushing
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)
2013-02-19 11:06:59 +00:00
Neil Roberts
806a2e5813 Add a test to check interleaving primitives and the journal
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)
2013-02-19 11:06:59 +00:00
Robert Bragg
255b815f76 conform: explicitly check value of boolean env vars
For the boolean environment variables that affect the running of the
conformance tests we now explicitly check the value of those variables
so that "0", "off" and "false" (upper or lower case) will be considered
as FALSE instead of just interpreting set as TRUE and unset as FALSE. If
the value is set to something entirely spurious then we abort with a
warning message. Thanks to Artie Eoff for suggesting this change.

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

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

(cherry picked from commit 25a8cf3607a482ca390eb9841295d1b365cbe53b)
2013-02-15 17:45:03 +00:00
Neil Roberts
0494e70955 test-gles2-context: Read pixels using GL_RGBA not GL_RGB
The GLES2 spec only guarantees calling glReadPixels with GL_RGBA and
an implementation specific format. Mesa seems to now reject reading
with GL_RGB so the test had started failing. This fixes it to just
read using GL_RGBA.

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

(cherry picked from commit 745cbcbdee0f5b4df4c6a735b03709248a551884)
2013-02-08 12:20:33 +00:00
Neil Roberts
d6dacf2f65 test-gles2-context: Use test_utils_compare_pixel instead of g_asserts
test_utils_compare_pixel makes the error report slightly easier to
read because it displays the values for the whole pixel instead of
reporting that there was a difference somewhere.

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

(cherry picked from commit a094ac9688a5e6b53be1cd379dc045973aab2fae)
2013-02-08 12:20:33 +00:00
Neil Roberts
9a8a26270c test-write-texture-formats: Add fuzziness to the pixel comparisons
The rounding used when storing 10-bit per component data into an 8-bit
per component texture seems to have changed in recent versions of Mesa
which was causing this test to fail. I've also noticed this failing on
the NVidia binary driver. This patch adds some fuzziness to the
comparison so that it will pass. There is a new test_utils function
called test_utils_compare_pixel_and_alpha which is the same as
test_utils_compare_pixel except that it also compares the alpha
component.

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

(cherry picked from commit ce626fb3939b0f200d85ccdf32809608b879212d)
2013-01-22 18:00:11 +00:00
Neil Roberts
364f232507 tests: Mark test_framebuffer_get_bits as only working on GL
It looks like it's not meant to be valid to create a framebuffer with
an alpha-only texture as a render target on GLES. Since the following
Mesa commit, this requirement is now enforced so that the
test_framebuffer_get_bits test fails:

http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf300eaa

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

(cherry picked from commit cfb0859cab843b000f4baa3ca155a245730edcfa)
2013-01-22 18:00:11 +00:00
Robert Bragg
50005a9364 build: update to build with automake 1.13
This make autogen.sh look for automake-1.13 and also updates all
Makefile.am files to no longer use the INCLUDES variable which automake
1.13 warns is deprecated by AM_CPPFLAGS.

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

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

(cherry picked from commit 5de5569e960102afe979a5f2f0403e1defebca62)
2013-01-22 18:00:05 +00:00
Robert Bragg
ebdac3162a tests: flag backface culling failure without NPOT support
This marks that test-backface-culling is currently known to fail without
NPOT texture support. This allows us do a 1.13 snapshot release before
we find a fix for this.
2013-01-22 17:48:19 +00:00
Neil Roberts
0b01c91fc5 framebuffer: Bind the framebuffer before querying the bits
The GL framebuffer driver now makes sure to bind the framebuffer
before counting the number of bits. Previously it would just query the
number of bits for whatever framebuffer happened to be used last.

In addition the virtual for querying the framebuffer bits has been
modified to take a pointer to a structure instead of a separate
pointer to each component. This should make it slightly more efficient
and easier to maintain.

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

(cherry picked from commit e9c58b2ba23a7cebcd4e633ea7c3191f02056fb5)
2013-01-22 17:48:18 +00:00
Neil Roberts
41612bfc74 Add a test for getting the component sizes from different fbs
This adds a test which creates two offscreen framebuffers, one with
just an alpha component texture and the other will a full RGBA
texture. The bit sizes of both framebuffers are then checked to verify
that they either have or haven't got bits for the RGB components.

The test currently fails because the framebuffer functions don't bind
the framebuffer before querying so they just query whichever
framebuffer happened to be used last.

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

(cherry picked from commit 7ca01373efe908efc9f18f2cb7f4a51c274ef677)
2013-01-22 17:48:18 +00:00
Neil Roberts
1e6ec66330 Add a conformance test for some wrap modes on a rectangle texture
This adds a conformance test which renders a rectangle texture using
the two wrap modes clamp-to-edge and repeat. It then verifies that the
correct region of the texture is drawn for the texture coordinates
that are > 1.0.

The test currently always fails. The cogl_framebuffer_draw_rectangle
function is documented to always take normalized texture coordinates
regardless of the coordinate system of the texture. This works
correctly if all of the texture coordinates are in the range [0.0,1.0]
because cogl-primitives uses a different code path in that case.
However if the multiple-quad code path is taken then the coordinates
actually need to un-normalized for it to work.

There is a comment in cogl_meta_texture_foreach_in_region() which
implies that the incoming coordinates should always be normalized.
The documentation for the callback says that the resulting sub-texture
coordinates will always be in the coordinate system of the low-level
texture. However it doesn't work out like this because the meta
texture function uses the span iterating function which always returns
normalized coordinates. It looks like there needs to be some more
conversions going on somewhere.

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

(cherry picked from commit d2059bb32b8015060e10f41dbbb68d4230b47ddb)
2013-01-22 17:48:18 +00:00