Commit Graph

2813 Commits

Author SHA1 Message Date
Neil Roberts
fda5e15bda Add a conformance test using alpha textures
This adds a conformance test with an alpha-component texture. The
texture is rendered using a pipeline with the same layer combine mode
as cogl-pango.

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

(cherry picked from commit 05190519bad4519e66cbdb5326943c832d15a841)
2013-01-22 17:48:06 +00:00
Neil Roberts
996260ceab tests: Differentiate between known failures and missing requirements
Previously when make test is run it would say ‘fail’ in lower case
letters for both tests that are known bugs we need to fix and for
drivers that can't run the test. This makes it too easy to lose track
of bugs.

To fix this, the ADD_TEST macro has now been changed to take two sets
of flags instead of just one. The first specifies the requirements for
the test to run at all. The second specifies the set of flags required
to run without any known failures. The table in the test report now
says ‘n/a’ instead of ‘fail’ for tests that don't match the feature
requirements.

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

(cherry picked from commit 723f8d4402e7b2ef3a71f51bb29b10d1c0ec8d81)
2013-01-22 17:48:06 +00:00
Neil Roberts
0b8780f94c tests: Don't report success when the test is skipped
The tests that were using GLSL or 3D textures were directly printing
“Skipped” and then reporting success. Instead of doing this they now
just try to continue without checking for the feature but the
appropriate test requirement flag is now set in test-conform-main so
the table of results will correctly display that is a failure.

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

(cherry picked from commit b8f918e44b243a5fa36d5f382a90bebb0de0728f)
2013-01-22 17:48:06 +00:00
Robert Bragg
fa62fe2a4f tests: update inline with master
This renames the global ctx and fb variables to test_ctx and test_fb
respectively in line with the names use on the master branch. This is to
make it easier to cherry pick patches from master.
2013-01-22 17:48:06 +00:00
Robert Bragg
31d105abd8 Check for out-of-memory when allocating 2d textures
This makes Cogl explicitly check for out-of-memory errors reported by
the opengl driver in cogl_texture_2d_new_with_size() calls. This allows
us to throw a COGL_SYSTEM_ERROR_NO_MEMORY error and return NULL so
applications may gracefully handle this condition.

This patch only affects the cogl_texture_2d_new_with_size() api not
_new_from_data() or _new_from_bitmap().

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

(cherry picked from commit 0283423dad59ba3d3e4cde400c29ac8e7803f888)
2013-01-22 17:48:06 +00:00
Neil Roberts
4f6fe6f0e2 Fixes for --disable-glib
This fixes some problems which were stopping --disable-glib from
working properly:

• A lot of the public headers were including glib.h. This shouldn't be
  necessary because the API doesn't expose any glib types. Otherwise
  any apps would require glib in order to get the header.

• The public headers were using G_BEGIN_DECLS. There is now a
  replacement macro called COGL_BEGIN_DECLS which is defined in
  cogl-types.h.

• A similar fix has been done for G_GNUC_NULL_TERMINATED and
  G_GNUC_DEPRECATED.

• The CFLAGS were not including $(builddir)/deps/glib which was
  preventing it finding the generated glibconfig.h when building out
  of tree.

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

(cherry picked from commit 4138b3141c2f39cddaea3d72bfc04342ed5092d0)
2013-01-22 17:48:05 +00:00
Neil Roberts
5c8eebb3d9 configure: Don't allow --enable-gdk-pixbuf with --disable-glib
The GDK pixbuf support requires being able to propagate errors from
GDKPixbuf as GErrors. This won't work if we are using the builtin
version of GLib because any attempt to call g_error_free from within
Cogl will use the internal version which will free the error using the
wrong slice allocator. It probably doesn't make much sense to build
without glib but with gdk-pixbuf so there's not much point in trying
to work around this situation.

Previously if you specified --enable-gdk-pixbuf but gdk-pixbuf was not
available it would silently disable it. This pach also fixes it so
that it will report an error in that case.

If --enable-gdk-pixbuf is not specified it will now default to
enabling it only if both glib is enabled and gdk-pixbuf is available.

This patch looks slightly longer than it ought to be because it moves
the check for glib up to above the descisions about the image backend.

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

(cherry picked from commit 8b1eabdc08da89a57792f9eb666e893a6cbb4e26)
2013-01-22 17:48:05 +00:00
Neil Roberts
eec0f1cd65 Add cogl_sdl_onscreen_get_window()
This adds a function to get a pointer to the SDL_Window associated
with a CoglOnscreen when using the SDL2 winsys.

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

(cherry picked from commit 071f4b80daa8a2f967746a30b3acf014d74f781a)
2013-01-22 17:48:05 +00:00
Neil Roberts
ff11a2b207 Use GL_ARB_texture_swizzle to emulate GL_ALPHA textures
The core profile of GL3 has removed support for component-alpha
textures. Previously the GL3 driver would just ignore this and try to
create them anyway. This would generate a GL error on Mesa.

To fix this the GL texture driver will now create a GL_RED texture
when GL_ALPHA textures are not supported natively. It will then set a
texture swizzle using the GL_ARB_texture_swizzle extension so that the
alpha component will be taken from the red component of the texture.
The swizzle is part of the texture object state so it only needs to be
set once when the texture is created.

The ‘gen’ virtual function of the texture driver has been changed to
also take the internal format as a parameter. The GL driver will now
set the swizzle as appropriate here.

The GL3 driver now reports an error if the texture swizzle extension
is not available because Cogl can't really work properly without out
it. The extension is part of GL 3.3 so it is quite likely that it has
wide support from drivers. Eventually we could get rid of this
requirement if we have our own GLSL front-end and we could generate
the swizzle ourselves.

When uploading or downloading texture data to or from a
component-alpha texture, we can no longer rely on GL to do the
conversion. The swizzle doesn't have any effect on the texture data
functions. In these cases Cogl will now force an intermediate buffer
to be used and it will manually do the conversion as it does for the
GLES drivers.

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

(cherry picked from commit 32bacf81ebaa3be21a8f26af07d8f6eed6607652)
2013-01-22 17:48:04 +00:00
Neil Roberts
05ebbfdae7 sdl: Support setting resizable before allocate in SDL 1
The SDL 1 winsys now checks for the initial resizable state of the
onscreen framebuffer when it is allocated and updates the video flags
accordingly.

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

(cherry picked from commit f5fb9be70a92f751886a94da0b34e14252ed197e)
2013-01-22 17:48:04 +00:00
Neil Roberts
982ee75319 Fix flushing the stencil viewport clipping workaround
There were two problems with the stencil viewport clip workaround
introduced in afc5daab8:

• When the viewport is changed the current clip state is not marked as
  dirty. That means that when the framebuffer state is next flushed it
  would continue to use the stencil from the previous viewport.

• When the viewport is automatically updated due to the window being
  resized the viewport age was not incremented so the clip state
  wouldn't be flushed.

I noticed the bugs by running cogl-sdl2-hello.

This patch makes it so that the clip state is dirtied in
cogl_framebuffer_set_viewport if the workaround is enabled.

The automatic viewport changing code now just calls
cogl_framebuffer_set_viewport instead of directly prodding the
viewport values. This has the side-effect that it will also cause the
journal to be flushed. This seems like the right thing to do anyway
and presumably there would have been a bug before where it wouldn't
have flushed the journal, although presumably this is extremely
unlikely because it would have to have done a resize in the middle of
painting the scene.

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

(cherry picked from commit 0dca99ddf728c8d4e3003861a03e8a2beccf282d)
2013-01-22 17:48:04 +00:00
Neil Roberts
9f107ab3fb Support window resizing in the SDL 2 winsys
The SDL2 winsys will now set the SDL_WINDOW_RESIZABLE flag on the
window before creating it if the resizable property is set on the
onscreen. Note that there doesn't appear to be a way in SDL to change
the flag later so unlike the other winsyses it will only take affect
if it is set before allocating the framebuffer.

The winsys now registers a callback for SDL events so that it can
report window size changes back to the application.

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

(cherry picked from commit 0dea9aeb897faf029828379b120970477df3c7d5)
2013-01-22 17:48:04 +00:00
Neil Roberts
11126a1b7e tests: Convert test-npot-texture to Cogl
This updates the npot-texture test to use Cogl directly instead of
relying on Clutter.

Note that this currently fails when Cogl ends up using sliced
textures. It looks like there is some bug with the meta texture
function to iterate the primitive textures. This happens when
COGL_DEBUG=disable-npot-textures is set.

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

(cherry picked from commit 32f0e1e8fff56be3123dc4571f07bb5a314f6818)
2013-01-22 17:48:04 +00:00
Adel Gadllah
41d59c0af7 cogl: Enable PBO path for all mesa versions when using intel
There seem to be other cases where the slow path is hit even with mesa 9.0.

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

(cherry picked from commit 6b14fa222bafb7e67c4845b26439322b34ac26a2)
2013-01-22 17:48:04 +00:00
Robert Bragg
6cfc93f26f clip-stack: workaround intel gen6 viewport clip bug
The Intel Mesa gen6 driver doesn't currently handle scissoring offset
viewports correctly, so this implements a workaround to intersect the
current viewport bounds with the scissor rectangle.

(cherry picked from commit afc5daab85e5faca99d6d6866658cb82c3954830)
2013-01-22 17:48:04 +00:00
Neil Roberts
362db1c445 Don't add the ARB suffix for the GL_ARB_map_buffer_range extension
The functions defined in the GL_ARB_map_buffer_range extension have no
suffix.

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

(cherry picked from commit f355d0a01af9015ffdcd574477090cdc69025280)
2013-01-22 17:48:04 +00:00
Neil Roberts
7654c7cffc Make cogl_color_init_from_4fv take a const array
The passed in array isn't written to so it's more convenient to use if
it is const.

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

(cherry picked from commit 87c02670107f00008611cbb0a8cfc97c8b6ea956)
2013-01-22 17:48:03 +00:00
Neil Roberts
53f43a428f Add a test case for cogl_buffer_map_range
This adds a small test case which maps a sub region of a small
attribute buffer and replaces the texture coordinates of one of the
vertices. The vertices are then drawn and the correct colours are
checked.

There is now a new test requirement for the
COGL_FEATURE_ID_MAP_BUFFER_FOR_WRITE feature which this test requires.

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

(cherry picked from commit 22183265b021dd038338b4398056c0a1eae77edb)
2013-01-22 17:48:03 +00:00
Neil Roberts
6db9427e8a Use cogl_buffer_map_range from the journal
The journal maintains a cache of attribute buffers to upload the
vertices for the rectangles. The buffers are mapped to fill in the
data. However, if the previous journal was larger than the one being
flushed now then the buffers may be larger than is actually needed. In
that case we might as well only map the range that is actually used so
that the driver can potentially avoid having to set up a mapping for
the entire buffer. The COGL_BUFFER_MAP_HINT_DISCARD flag is still set
so that the driver is free to discard the entire buffer, not just the
subrange.

The _cogl_buffer_map_for_fill_or_fallback has been replaced with
_cogl_buffer_map_range_for_fill_or_fallback so that the range
parameters can be passed. The original function is now just a wrapper
around the latter.

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

(cherry picked from commit 27769e54806dcfc1a12fdc4b07b054b8f2f4215b)
2013-01-22 17:48:03 +00:00
Neil Roberts
ec03357e88 Add cogl_buffer_map_range()
This adds a buffer method to map a subregion of the buffer. This works
using the GL_ARB_map_buffer_range extension. If the extension is not
available then it will fallback to using glMapBuffer to map the entire
buffer and then just add the offset to the returned pointer.

cogl_buffer_map() is now just a wrapper which maps the entire range of
the buffer. The driver backend functions have been renamed to
map_range and they now all take the offset and size arguments.

When the COGL_BUFFER_MAP_HINT_DISCARD hint is used and the map range
extension is available instead of using glBufferData to invalidate the
buffer it will instead pass the new GL_MAP_HINT_INVALIDATE_BUFFER
flag. There is now additionally a COGL_BUFFER_MAP_HINT_DISCARD_REGION
hint which can be used if the application only wants to discard the
small region that is mapped. glMapBufferRange is always used if it is
available even if the entire buffer is being mapped because it seems
more robust to pass those flags then to call glBufferData.

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

(cherry picked from commit 55ca02b5ca9cafc750251ec974e0d6a536cb80b8)
2013-01-22 17:48:03 +00:00
Damien Lespiau
8a3fb7a10d context: Re-add /<* private *>/ for _COGL_N_FEATURE_IDS
Turns out gtk-doc really needs 'private' and glib-mkenums needs 'skip'.
So let's have both.

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

(cherry picked from commit e51206b2a9c9a582ac83fb71290524c99a8dbbb6)
2013-01-22 17:48:03 +00:00
Damien Lespiau
979a3d5517 error: Fix 'burden' typo
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 9af7dda5d7de69522b152d853ed8921c00c15f4e)
2013-01-22 17:48:03 +00:00
Damien Lespiau
08205a40e1 context: glib-mkenums chokes on /*< private >*/ but supports /*< skip >*/
The private option is really part of gtk-doc, glib-mkenums does not
support it. Use skip instead.

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

(cherry picked from commit 015c36af27a8ce68d60f8aab6a10acdc48c5f38c)
2013-01-22 17:48:03 +00:00
Rico Tzschichholz
87e15d6693 build: fix make dist
(cherry picked from commit 6a78a8c6b6d368f2816f50e10cb9602f5c47de71)
2013-01-22 17:48:03 +00:00
Neil Roberts
76843fc529 sdl2: Fix GL3 context creation
The check to verify whether we've got the right GL context was
checking that the GL version was less than 3 whenever the non-GL3
driver is used. However it looks like the driver is free to return a
GL3 context that is compatible with GL2 if GL2 is requested so this
was breaking the GL2 driver.

This also adds the necessary SDL attributes to request a forward
compatible core context like the GLX and EGL winsys's do. I haven't
actually tested this because it looks like SDL will only create a GL
context with GLX and I haven't got a recent enough X server to handle
the glXCreateContextAttribs request.

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

(cherry picked from commit d46acafa3ea7ba2e6c4ac7a45f00a132df1b2872)
2013-01-22 17:48:02 +00:00
Neil Roberts
8039c2c779 Fix a warning when building the SDL2 winsys
The SDL2 winsys was using _cogl_set_error without including its header
so it was giving an annoying warning. This patch also fixes some
indentation issues.

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

(cherry picked from commit 9c8433087b7573f7606dfae2bae3045803ead115)
2013-01-22 17:48:02 +00:00
Damien Lespiau
2582fa1519 display: Fix 'arguments' typo
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 1f30d200be65cd44dbd6f224532b9c4030d6c39c)
2013-01-22 17:48:02 +00:00
Damien Lespiau
f9c7e9d270 framebuffer: Annotate the output parameter of get_viewport4fv()
Annotate that the float* is an out parameter that points to a caller
allocated array of 4 floats.

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

(cherry picked from commit f40b0d03d796c16c62f4937e99e16de084fc6b9a)
2013-01-22 17:48:02 +00:00
Damien Lespiau
0866b90069 object: Move cogl_object_{ref,unref}() to cogl-object.h
Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit d2f07344a361c43ccdb85a0587812ca3a103078b)
2013-01-22 17:48:02 +00:00
Neil Roberts
2e77c039c9 Fix a warning when building without GLES2 support
Since commit 2701b93f cogl-pipeline-opengl.c always has code which
calls _cogl_pipeline_progend_glsl_get_attrib_location but the header
declaring this function was only included if GLES2 support was
enabled. This was making it give an annoying warning so let's just
unconditionally include it.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
(cherry picked from commit 34143bc6f1239c9cb22ba613521ba9ee7ec7059a)
2013-01-22 17:48:02 +00:00
Neil Roberts
bf8a1b1eda progend-glsl: Fix handling of the builtin uniforms on non-GLES2
The ‘builtin uniforms’ are added to the GLSL code generated for the
GLES2 driver to implement missing fixed functionality such as the
builtin point sprite size and the alpha test reference. Previously the
code that accessed these was #ifdef'd to be compiled only when GLES2
was enabled. However since 2701b93f part of this code is now always
used even for non-GLES2 drivers. The code that accessed the builtin
uniforms array was however no longer #ifdef'd which meant that it
wouldn't compile any more if GLES2 was not enabled. This was further
broken becase the GL3 driver actually should be using the alpha test
uniform because that also does not provide any fixed functionality for
alpha testing.

To fix this the builtin uniform array is now always compiled in and
the code to access it is always used. A new member has been added to
the array to mark which private feature the uniform is used to
replace. That is checked before updating the uniform so that under
GLES2 it will update both uniforms but under GL3 it will only update
the alpha test reference.

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

(cherry picked from commit 5469a25413883080df75a80153accf5d9124f716)
2013-01-22 17:48:02 +00:00
Neil Roberts
9b59588c53 Add a simple conformance test for alpha testing
This adds a simple test which sets an alpha test on a pipeline and
then renders a texture. It then verifies that the transparent parts of
the texture aren't drawn. This is currently failing with the GL3
driver because GL3 requires the alpha test to be implemented in GLSL
but the generated alpha test uniform is only updated for the GLES2
driver.

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

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

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

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

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

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

Some issues with this patch:

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

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

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

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

(cherry picked from commit 66c9db993595b3a22e63f4c201ea468bc9b88cb6)
2013-01-22 17:48:01 +00:00
Neil Roberts
1abf0ed55e pipeline: Don't notify the undefined progend of layer changes
When a layer changes before the pipeline has decided which progend to
use it doesn't need to notify the progend of the change. This was
causing it to crash. This patch makes that change and also simplifies
the notification a bit by just making the calls directly instead of
having three separate functions.

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

(cherry picked from commit 2006ddd68ea6a5d53b5a810d8dbf39025d9ec04c)
2013-01-22 17:48:01 +00:00
Robert Bragg
de7416fd1d driver-gl: re-indent misleading if-else statement
There was a very, very, very misleading if else statement using no
braces for a single statement if block, followed by a blank line *and*
followed by a comment before the else which was aligned to the 'if'
column, all leading you to believe on first glance that there is no else
block. The fact that Neil and I were both separately mislead by this,
this week, is a pretty compelling reason to clarify this by deleting the
blank line, and moving the comment inside the else block.

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

(cherry picked from commit 96d9ea78eb56269c0de5283a5302ab095d8bdfce)
2013-01-22 17:48:01 +00:00
Robert Bragg
986ba3aa79 egl: remove special re-try without stencil code
The EGL winsys had a special case code path when trying to create a
context where if it failed it would try again except without requesting
a stencil buffer. Historically this code path was to allow Clutter to
run on PowerVR MBX hardware which doesn't support a stencil buffer. It
doesn't really make sense to keep this workaround in Cogl as it would
leave Cogl in a state where the clip stack doesn't work without
providing any feedback to the developer. If we need to support running
on MBX like hardware - probably not very likely these days - then we
should provide developer control over the stencil buffer so the
equivalent workaround could be implemented on top of Cogl.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit a7c391a985e82707b17f2fb1105de5d37822a390)
2013-01-22 17:48:01 +00:00
Robert Bragg
01937201e4 Unify a lot of gles2 vs gl glsl code
Since we used to support hybrid fixed-function + glsl pipelines when
running with OpenGL there were numerous differences in how we handled
codegen and uniform updates between GLES2 and full OpenGL. Now that we
only support end-to-end glsl pipelines this patch can largely unify how
we handle GLES2 and OpenGL.

Most notably we now never use the builtin attribute names. This should
also make it easy for us to support creating strict OpenGL 3.1 contexts
where the builtin names have been removed.

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

(cherry picked from commit 2701b93f159bf2d3387cedf2d06fe921ad5641f3)
2013-01-22 17:48:01 +00:00
Robert Bragg
62b472f4f5 add cogl-glsl-shader files to aid backporting patches
To aid with backporting patches from master made after the deprecated
CoglShader api was removed this patch adds the cogl-glsl- files that
have been added on master so we should get less conflicts when cherry
picking.
2013-01-22 17:48:01 +00:00
Robert Bragg
258aba3836 check the glsl version during init
This adds a check for the glsl version during driver init which gets
stored in ctx->glsl_major and ctx->glsl_minor.

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

(cherry picked from commit 9bde48bda6d602dd536c3536d56d2ff7545802c3)
2013-01-22 17:48:01 +00:00
Robert Bragg
2438d70b38 driver-gl: split out parse_gl_version function
This splits out the GL version parser code from
cogl-driver-gl.c:_cogl_get_gl_version() so it can also be used for
parsing other gl version strings.

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

(cherry picked from commit 66c2e74b9d61669fb5b93cf9a31cc8659a601fdd)
2013-01-22 17:48:00 +00:00
Neil Roberts
2bcf38d126 Fix a warning in the vtable for texture_2d_get_data
The function pointer for texture_2d_get_data in the driver vtable was
expecting an unsigned int for the rowstride but the definition in
cogl-texture-2d-gl.c took a size_t so it was giving an annoying
warning. This normalizes them both to just take an int. This seems to
better match the pattern used for cogl_bitmap_new_from_data and
cogl_texture_2d_new_from_data.

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

(cherry picked from commit 003f080531d5368835081568779b031ef4f09a77)
2013-01-22 17:48:00 +00:00
Robert Bragg
8f3380adc3 Clearly define 3 progends that own the frag+vertends
This adds a new "fixed-arbfp" progend so we now have 3 distinct ways of
setting up the state of a pipeline:

  » fixed; where the vertex and fragment processing are implemented
    using fixed function opengl apis.
  » fixed-arbfp; where vertex processing is implemented using fixed
    function opengl apis but fragment processing is implemented
    using the ARB Fragment Processing language.
  » glsl; there vertex and fragment processing are both implemented
    using glsl.

This means we avoid unusual, combinations such as glsl for vertex
processing and arbfp for fragment processing, and also avoid pairing
fixed-function vertex processing with glsl fragment processing which we
happen to know hits some awkward code paths in Mesa that lead to poor
performance.

As part of this change, the progend now implies specific vertend and
fragend choices so instead of associating a vertend and fragend with a
pipeline we now just associate a progend choice.

When flushing a pipeline and choosing what progend to use, we now call a
progend->start() method that is able to determine if the vertend and
fragend together will be able to handle the given pipeline so the
vertend and fragend ->start() methods no longer need to return a boolean
status.

Since we now don't need to support glsl used in conjunction with fixed
function this will allow us to avoid ever using OpenGL builtin attribute
names, though this patch doesn't change that yet.

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

(cherry picked from commit cec381f50c7a2f2186bd4a8c5f38fecd5f099075)
2013-01-22 17:48:00 +00:00
Robert Bragg
f05a1a62f4 pipeline: tidy up definition of *END defines
There is some fairly awkward #ifdefing to determine which vertends,
fragends and progends are available at build time. This patch
consolidates the #ifdefing of vertend, fragend and progend defines to
make for slightly easier reading.

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

(cherry picked from commit 098d6244bf7c8f2a4ca24206c6e8271d589ed4c9)
2013-01-22 17:48:00 +00:00
Robert Bragg
9fd201ffc6 pipeline: remove duplicate defines
There was a spurious duplication of the COGL_PIPELINE_VERTEND_DEFAULT
and COGL_PIPELINE_VERTEND_UNDEFINED defines which this patch removes.

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

(cherry picked from commit 1bcf34bd3eb0134b7ef1b30cba91d3e70a23e5ed)
2013-01-22 17:48:00 +00:00
Robert Bragg
d20c8e4a71 pipeline: remove unused _MASK defines
The COGL_PIPELINE_FRAGEND_XYZ_MASK and COGL_PIPELINE_VERTEND_XYZ_MASK
defines aren't used any more so this patch simply removes them.

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

(cherry picked from commit 119b0d771a4be2550ce1ca1e789db5b22776b066)
2013-01-22 17:48:00 +00:00
Robert Bragg
6712aaef45 pipeline: remove dubious optimization
This removes an optimization that I added at some point, which I'm
pretty certain I only added on a hunch. Reading the description I'm not
really convinced it makes sense to do this given that the fixed vertend
and fragend are currently listed before the glsl vertend and fragend in
the order that we look for a suitable backend. This means unless the
pipeline depends on glsl (e.g. due to an associated snippet) we would
reselect the fixed backend anyway, and if it really did depend on glsl
then we'd notice when we come to flush and switch backends there any way.

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

(cherry picked from commit 071698d2c017af33e41b838429d514f5df5e02a1)
2013-01-22 17:48:00 +00:00
Robert Bragg
b1ecfbf720 buffer: splits out GL specific code
As part of an on-going effort to be able to support non-opengl drivers
for Cogl this splits out the opengl specific code from cogl-buffer.c
into driver/gl/cogl-buffer-gl.c

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

(cherry picked from commit 4d7094a979ff2cbbe4054f4a44ca05fc41a9e447)
2013-01-22 17:47:59 +00:00
Robert Bragg
bcf6a61d0b Give buffer/bitmap bind functions gl infix
The buffer and bitmap _bind() functions are GL specific so to clarify
that, this patch adds a _gl infix to these functions, though it doesn't
yet move the implementations out into gl specific files.

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

(cherry picked from commit 6371fbb9637d88ff187dfb6c4bcd18468ba44d19)
2013-01-22 17:47:59 +00:00
Robert Bragg
91a02e9107 buffer: move choice about using malloc closer to driver
This moves the decision about whether a buffer should be allocated using
malloc or not into cogl-buffer.c closer to the driver since it seem
there could be other driver specific factors that might also influence
this choice that we don't currently consider.

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

(cherry picked from commit 06d46f10bf755d3009c28904e616a0adb4586cf5)
2013-01-22 17:47:59 +00:00
Robert Bragg
ffd2cf8ef8 clip-stack: Splits out opengl specific code
As part of an on-going effort to enable non-opengl drivers for Cogl this
splits out the opengl specific code in cogl-clip-stack.c into
cogl/driver/cogl-clip-stack-gl.c

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

(cherry picked from commit acf989f1bb628282c53d1249b2e3fc6f6579f1e9)
2013-01-22 17:47:59 +00:00