Commit Graph

2032 Commits

Author SHA1 Message Date
Neil Roberts
da154b9a3b pipeline: Add a missing break for the uniforms state
_cogl_pipeline_init_multi_property_sparse_state was missing a break in
the case statement handling uniforms. This doesn't yet matter because
it is the last one handled anyway but it will bite someone later.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-29 13:03:25 +00:00
Robert Bragg
be40cbb8c3 build: include missing headers in cogl-winsys-egl-private.h
We were missing various platform header includes in
cogl-winsys-egl-private.h when building support for non KMS egl
platforms.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-28 23:19:45 +00:00
Robert Bragg
c2729e4ea8 build: don't inc egl headers for non EGL builds
For example when building on windows we don't want to require EGL
headers when compiling cogl-renderer.c or cogl-texture-2d.c so we make
sure not to include cogl-winsys-egl-private.h if we aren't supporting
EGL.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-28 23:19:35 +00:00
Robert Bragg
40b14c6084 kms: avoid using redundant g* and GL* types
A small, pedantic change to remove the use of redundant gint and GLuint
types instead of int and unsigned int.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-28 22:43:15 +00:00
Robert Bragg
056daad850 build: only include cogl-winsys-kms.h if KMS enabled
Only include cogl-winsys-kms.h in cogl-winsys-egl-private.h if KMS
support has been enabled.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-28 22:39:19 +00:00
Robert Bragg
aa6433d8c5 kms: Check for EGL_KHR_surfaceless_opengl extension
This adds a check for the EGL_KHR_surfaceless_opengl extension which we
depend on for being able to MakeCurrent (NO_SURFACE) as well as create a
context without and EGLConfig.

Reviewed-by: Rob Bradford <rob@linux.intel.com>
2011-11-28 17:38:17 +00:00
Robert Bragg
7a91c91994 kms: flatten setup_kms into _cogl_winsys_kms_display_setup
Since _cogl_winsys_kms_display_setup was basically just calling
setup_kms() it made sense to fold the code of setup_kms() back into the
_cogl_winsys_kms_display_setup() function.

Reviewed-by: Rob Bradford <rob@linux.intel.com>
2011-11-28 17:38:15 +00:00
Robert Bragg
607bfec48d kms: move Cogl*EGL typedefs to cogl-winsys-egl-private.h
So that the various internal Cogl*EGL typedefs can be available to
cogl-winsys-kms.c this moves them into cogl-winsys-egl-private.h

Reviewed-by: Rob Bradford <rob@linux.intel.com>
2011-11-28 17:37:31 +00:00
Rob Bradford
1b54c8023e kms: Add first version of "baremetal" backend for EGL on KMS
To start with this backend only supports creating a single CoglOnscreen
framebuffer and will automatically set is up to display fullscreen on
the first suitable crtc it can find.

To compile this backend - get some dribbly black candles, sacrifice a
goat and configure with: --enable-kms-egl-platform

Note: There is currently a problem with using GLES2 with this winsys
so you need to run with EGL_DRIVER=gl
Note: If you have problems with mesa crashing in XCB during
eglInitialize then you may need to explicitly run with EGL_PLATFORM=gbm

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-28 17:37:28 +00:00
Neil Roberts
d44e548715 cogl-debug: Mark _cogl_debug_flags with dllexport for MSVC
When building with MSVC, symbols to be exported that point to data
need to be marked with dllimport to be successfully imported. The
_cogl_debug_flags variable is currently exported because it is used
from cogl-pango. This patch adds a COGL_EXPORT macro to cogl-util.h
which is used in cogl-debug.h

Based on a patch by Chun-wei Fan

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-25 13:14:10 +00:00
Chun-wei Fan
2055f6ba91 VS 2008/2010 project files to build Cogl
These are the VS 2008/2010 project files to build Cogl, with a README.txt
to explain the process involved.

Note that the Cogl and Cogl-Pango projects (and filters for VS2010) are
expanded with the correct source file listings during "make dist", which
is done to simplify maintenance of these project files.

-added preconfigured config.h(.win32.in), which is expanded with the
 correct versioining info during autogen
-added preconfigued cogl/cogl-defines.h.win32
-added symbols files for cogl and cogl-pango
-Have configure.ac expand the config.h.win32.in into config.h.win32
 with the correct versioning info, etc, and to include the Visual C++
 project files for distribution
-Added rules in cogl/Makefile.am to expand the cogl VS 2008/2010 projects
 and filters from the templates with up-to-date source file listings, to
 distribute cogl-enum-types.c, cogl-enum-types.h to ease compilation and
 to avoid depending on PERL on Windows installations.
-Added rules in cogl-pango/Makefile.am to expand the cogl-pango VS2008/
 2010 projects and filters from the templates with up-to-date source file
 listings.
-Added/edited various Makefile.am's in build to distribute the VS2008/2010
 project files and associated items required for the build.
-Update .gitignore. There needs to be a pre-configured
 config.h(.win32) and its template, config.h.win32.in for Visual C++
 builds

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2011-11-25 13:12:45 +00:00
Yinghua Wang
cc18d64331 Update Simplified Chinese translation. 2011-11-25 20:40:41 +08:00
Neil Roberts
9e52b4d714 Fix comparing the uniforms state
When comparing uniform values, it was not correctly handling the case
where pipeline0 has the value set but pipeline1 does not (only the
other way around) so it would crash.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-24 13:23:00 +00:00
Chun-wei Fan
80a9c3bb32 Update cogl/winsys/cogl-winsys-stub.c
Deal with c99ism... I know it's not pretty, but it is the way
to go with non-c99 compilers.  That's life...

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-23 12:16:45 +00:00
Robert Bragg
36e4c98bdc Bump development version to 1.9.3 2011-11-22 17:28:05 +00:00
Robert Bragg
9111f49f22 Release 1.9.2 (snapshot) 2011-11-22 17:12:43 +00:00
Robert Bragg
62f5134eff Updates NEWS for the 1.9.2 release 2011-11-22 17:12:43 +00:00
Robert Bragg
607151c717 reference: don't look for $(top_srcdir)/cogl/winsys/*.h
There are no headers built under the winsys directory so avoid looking
for them since that breaks dist rules.
2011-11-22 17:12:43 +00:00
Neil Roberts
61d71c0926 cogl-flags: Fix iterating flag when the most-significant bit is set
When the flags contain a value that only has the most-significant bit
set then ffsl will return the size of an unsigned long. According to
the C spec it is undefined what happens when shifting by a number
greater than or equal to the size of the left operand. On Intel (and
probably others) this seems to end up being a no-op so the iteration
breaks. To fix this we can split the shift into two separate
shifts. We always need to shift by at least one bit so we can put this
one bit shift into a separate operator.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-22 16:07:21 +00:00
Jorge González
3e56883c98 Updated Spanish translation 2011-11-17 14:20:46 +01:00
Neil Roberts
c269817edd cogl-pipeline: Use a hash table for faster uniform name lookup
The uniform names are now stored in a GPtrArray instead of a linked
list. There is also a hash table to speed up converting names to
locations.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
4a7cd0d2ac cogl-pipeline: Store the uniform overrides in an array instead of list
Previously the uniform overrides were stored in a linked list. Now
they are stored in a g_malloc'd array. The values are still tightly
packed so that there is only a value for each uniform that has a
corresponding bit in override_mask. The allocated size of the array
always exactly corresponds to the number of bits set in the
override_mask. This means that when a new uniform value is set on a
pipeline it will have to grow the array and copy the old values
in. The assumption is that setting a value for a new uniform is much
less frequent then setting a value for an existing uniform so it makes
more sense to optimise the latter.

The advantage of using an array is that we can quickly jump to right
boxed value given a uniform location by doing a population count in
the bitmask for the number of bits less than the given uniform
location. This can be done in O(1) time whereas the old approach using
a list would scale by the number of bits set.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
f23b12a886 cogl-bitmask: Add _cogl_bitmask_popcount
This returns a population count of all the bits that are set in the
bitmask.

There is now also a _cogl_bitmask_popcount_upto which counts the
number of bits set up to but not including the given bit index. This
will be useful to determine the number of uniform overrides to skip if
we tightly pack the values in an array.

The test-bitmask test has been modified to check these two functions.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
8805d835aa Add a conformance test for setting uniforms on a pipeline
The tests tries all of the various combinations of setting uniform
values on a pipeline and verifies the expected results with a some
example shaders.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
4553ca0695 cogl-pipeline: Add support for setting uniform values
This adds the following new public experimental functions to set
uniform values on a CoglPipeline:

void
cogl_pipeline_set_uniform_1f (CoglPipeline *pipeline,
                              int uniform_location,
                              float value);
void
cogl_pipeline_set_uniform_1i (CoglPipeline *pipeline,
                              int uniform_location,
                              int value);
void
cogl_pipeline_set_uniform_float (CoglPipeline *pipeline,
                                 int uniform_location,
                                 int n_components,
                                 int count,
                                 const float *value);
void
cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
                               int uniform_location,
                               int n_components,
                               int count,
                               const int *value);
void
cogl_pipeline_set_uniform_matrix (CoglPipeline *pipeline,
                                  int uniform_location,
                                  int dimensions,
                                  int count,
                                  gboolean transpose,
                                  const float *value);

These are similar to the old functions used to set uniforms on a
CoglProgram. To get a value to pass in as the uniform_location there
is also:

int
cogl_pipeline_get_uniform_location (CoglPipeline *pipeline,
                                    const char *uniform_name);

Conceptually the uniform locations are tied to the pipeline so that
whenever setting a value for a new pipeline the application is
expected to call this function. However in practice the uniform
locations are global to the CoglContext. The names are stored in a
linked list where the position in the list is the uniform location.

The global indices are used so that each pipeline can store a mask of
which uniforms it overrides. That way it is quicker to detect which
uniforms are different from the last pipeline that used the same
CoglProgramState so it can avoid flushing uniforms that haven't
changed. Currently the values are not actually compared which means
that it will only avoid flushing a uniform if there is a common
ancestor that sets the value (or if the same pipeline is being flushed
again - in which case the pipeline and its common ancestor are the
same thing).

The uniform values are stored in the big state of the pipeline as a
sparse linked list. A bitmask stores which values have been overridden
and only overridden values are stored in the linked list.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
4e760d51f1 cogl-bitmask: Add _cogl_bitmask_set_flags
This adds a _cogl_bitmask_set_flags function which can be used to copy
the values from a CoglBitmask to an array of unsigned longs which can
be used with the COGL_FLAGS_* macros. The values are or'd in so that
in can be used multiple times to combine multiple bitmasks.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
d2fd168351 cogl-matrix: Add a public cogl_matrix_transpose()
This function takes a single matrix argument and replaces the matrix
with its transpose.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
037c0aa88c Move POPCOUNTL to cogl-util
This moves the POPCOUNTL macro from cogl-winsys-glx to cogl-util and
renames it to _cogl_util_popcountl so that it can be used in more
places. The fallback function for when the GCC builtin is not
available has been replaced with an 8-bit lookup table because the
HAKMEM implementation doesn't look like it would work when longs are
64-bit so it's not suitable for a general purpose function on 64-bit
architectures. Some of the pages regarding population counts seem to
suggest that using a lookup table is the fastest method anyway.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
436a7a45da cogl-boxed-value: Add _cogl_boxed_value_copy
This adds a function to copy one boxed value to another. It is assumed
that the destination boxed value is totally initialised (so it won't
try to free any memory in it).

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
7068849ae6 cogl-boxed-value: Wrap the GL calls in the GE() macro
This wraps all of the calls to glUniform* in the GE() macro so that it
will detect GL errors in the right place.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:11 +00:00
Neil Roberts
256f5791fd cogl-program: Move the code for CoglBoxedValue to its own file
The code for manipulating CoglBoxedValues is now separated from
cogl-program.c into its own file. That way when we add support for
setting uniform values on a CoglPipeline the code for storing the
values can be shared.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:10 +00:00
Neil Roberts
d706991579 cogl-flags: Add some macros to help iterate the bits
This adds some macros to iterate over all the bits set in an array of
flags. The macros are a bit awkward because it tries to avoid using a
callback pointer so that the code is inlined.

cogl_bitmask is now using these macros as well so that the logic can
be shared.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:32:00 +00:00
Neil Roberts
dbc31b70cc cogl-bitmask: Add a return value for the foreach callback
The foreach callback can now return FALSE to stop the iteration.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:31 +00:00
Neil Roberts
f4c1ba9ed9 cogl-flags: Use longs instead of ints
Previously cogl-flags was using an array of ints to store the
flags. There was a comment saying that it would be nice to use longs
but this is awkward because g_parse_debug_flags can only work in
ints. This is a silly reason not to use longs because we can just
parse multiple sets of flags per long. This patch therefore changes
cogl-flags to use longs and tweaks the debug key parsing code.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:31 +00:00
Neil Roberts
2ba4fe417a cogl-bitmask: Use ffsl to speedup bitmask iteration
Instead of testing each bit when iterating a bitmask, we can use ffsl
to skip over unset bits in single instruction. That way it will scale
by the number of bits set, not the total number of bits.

ffsl is a non-standard function which glibc only provides by defining
GNUC_SOURCE. However if we are compiling with GCC we can avoid that
mess and just use the equivalent builtin. When not compiling for GCC
it will fall back to _cogl_util_ffs if the size of ints and longs are
the same (which is the case on i686). Otherwise it fallbacks to a slow
function implementation.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:31 +00:00
Neil Roberts
f0f9493f5c cogl-fixed: Move the GType defs from cogl-util.c to cogl-fixed.c
The boilerplate for defining a GType for CoglFixed lived in
cogl-util.c but this didn't seem to make much sense seeing as nothing
in the cogl-util.h header file relates to CoglFixed and there is
already a separate C file for CoglFixed code. This also removes some
redundant header includes from cogl-util.c

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:31 +00:00
Neil Roberts
ec1c3406ad Add a conformance test for CoglBitmask
This adds a test which tries manipulating some bits on a CoglBitmask
and verifies that it gets the expected result. This test is fairly
unusual in that it is directly testing some internal Cogl code that
isn't exposed through the public API. To make this work it directly
includes the source for CoglBitmask.

CoglBitmask does some somewhat dodgy things with converting longs to
pointers and back so it makes sense to have a test case to verify that
this is working on all platforms.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 16:21:13 +00:00
Neil Roberts
93321d9b89 cogl-bitmask: Use longs instead of ints
Instead of storing only 31 bits in the pointer for a CoglBitmask, it
now assumes it can store a whole unsigned long minus the one bit used
to mark whether it has been converted to a GArray or not. This works
on the assumption that we can cast an unsigned long to a pointer and
back without losing information which I think should be true for any
platforms that Cogl is interested in. This has the advantage that on
64-bit architectures we can store 63 bits before we have to resort to
using a GArray at no extra cost. The values in the GArray are now
stored as unsigned longs as well on the assumption that it is more
efficient to load and store data in chunks of longs rather than ints.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-16 15:43:25 +00:00
Muhammet Kara
70eaf037e9 [l10n]Updated Turkish translation 2011-11-16 11:12:38 +02:00
Rob Bradford
3bf8d45529 examples: Query the size of the framebuffer
The size of the framebuffer may not be the size of the framebuffer that we
requested - we should use the actual size of the framebuffer in the
calculations to position the crate in the center.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:59:52 +00:00
Neil Roberts
39ca3e51df Don't take a reference to the last used onscreen framebuffer
Cogl keeps a pointer to the last used onscreen framebuffer from the
context to implement the deprecated cogl_set_draw_buffer function
which can take COGL_WINDOW_BUFFER as the target to use the last
onscreen buffer. Previously this would also take a reference to that
pointer. However that was causing a circular reference between the
framebuffer and the context which makes it impossible to clean up
resources properly when onscreen buffers are used. This patch instead
changes it to just store the pointer and then clear the pointer during
_cogl_onscreen_free as a kind of cheap weak reference.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:40:28 +00:00
Neil Roberts
18b0ad652c test-backface-culling: Use the experimental pipeline API
This tweaks the backface culling test to use the experimental pipeline
API as well as the legacy API. All of the primitives are now rendered
with all 16 combinations of front winding, cull face mode and legacy
state.

The test to 'draw a regular rectangle' has been removed. I think this
initially existed because their were different functions to draw a
rectangle with and without texturing. This is no longer the case so it
is no longer useful and it's awkward to implement because it need a
separate pipeline to disable the texturing.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:40:27 +00:00
Neil Roberts
5369b3c601 pipeline: Make the backface culling experimental public
This adds two new experimental public functions to replace the old
internal _cogl_pipeline_set_cull_face_state function:

void
cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
                                  CoglPipelineCullFaceMode cull_face_mode);

void
cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
                                      CoglWinding front_winding);

There are also the corresponding getters.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:40:27 +00:00
Neil Roberts
8be44f9876 cogl-utils: Include cogl-defines.h
cogl-utils.h needs to include cogl-defines.h so that it knows whether
COGL_HAS_GLIB_SUPPORT is defined.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-11-14 18:40:27 +00:00
Chun-wei Fan
91f91dc678 cogl-renderer.c: Fix includes
Only include cogl-xlib-renderer.h when XLIB support is available

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-14 18:37:57 +00:00
Simos Xenitellis
ecd063da67 l10n: Updated Greek translation for cogl 2011-11-13 16:08:11 +02:00
Fran Diéguez
586a69227d Updated Galician translations 2011-11-10 00:22:35 +01:00
Jorge González
dc8f564688 Updated Spanish translation 2011-11-06 13:45:03 +01:00
Neil Roberts
1566941c2f cogl-context: Destroy texture units later on
This patch moves the call to _cogl_destroy_texture_units() from
_cogl_context_free() to later on. When destroying a GL texture the
texture units are checked. This would end up accessing invalid memory
so we need to try to destroy the texture units only after everything
that might be referencing a texture has been destroyed.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-11-04 13:03:01 +00:00
Fran Diéguez
d7e1192630 Updated Galician translations 2011-11-04 13:16:09 +01:00