Commit Graph

69 Commits

Author SHA1 Message Date
Neil Roberts
1d59fccf10 Add a conformance test for point sprites
This adds a conformance test which renders a texture point using a 2x2
texture with a different color for each texel. It then verifies that
each texel is mapped to the correct position on the point. The test is
currently failing.

The test requires the point sprite feature flag so this patch also
adds a TEST_REQUIREMENT_* flag for that.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:29 +00:00
Neil Roberts
3c0226b3fb Add a conformance test for point sizes
This tries rendering some points at various sizes and checks that they
are the expected size and make a rectangle shape. This is currently
failing when the GLSL vertend is used because it flushes the point
size in the wrong place.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:29 +00:00
Neil Roberts
58cf84f8ef tests: Add a flag to say that the test is known to fail in all cases
This renames the TestRequirement enum to TestFlags and then adds a
TEST_KNOWN_FAILURE flag. The rename is because the new flag is not
really a requirement. If the flag is set then the test is assumed to
always fail.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-07 15:13:29 +00:00
Neil Roberts
185630085c Add -Wmissing-declarations to maintainer flags and fix problems
This option to GCC makes it give a warning whenever a global function
is defined without a declaration. This should catch cases were we've
defined a function but forgot to put it in a header. In that case it
is either only used within one file so we should make it static or we
should declare it in a header.

The following changes where made to fix problems:

• Some functions were made static

• cogl-path.h (the one containing the 1.0 API) was split into two
  files, one defining the functions and one defining the enums so that
  cogl-path.c can include the enum and function declarations from the
  2.0 API as well as the function declarations from the 1.0 API.

• cogl2-clip-state has been removed. This only had one experimental
  function called cogl_clip_push_from_path but as this is unstable we
  might as well remove it favour of the equivalent cogl_framebuffer_*
  API.

• The GLX, SDL and WGL winsys's now have a private header to define
  their get_vtable function instead of directly declaring in the C
  file where it is called.

• All places that were calling COGL_OBJECT_DEFINE need to have the
  cogl_is_whatever function declared so these have been added either
  as a public function or in a private header.

• Some files that were not including the header containing their
  function declarations have been fixed to do so.

• Any unused error quark functions have been removed. If we later want
  them we should add them back one by one and add a declaration for
  them in a header.

• _cogl_is_framebuffer has been renamed to cogl_is_framebuffer and
  made a public function with a declaration in cogl-framebuffer.h

• Similarly for CoglOnscreen.

• cogl_vdraw_indexed_attributes is called
  cogl_framebuffer_vdraw_indexed_attributes in the header. The
  definition has been changed to match the header.

• cogl_index_buffer_allocate has been removed. This had no declaration
  and I'm not sure what it's supposed to do.

• CoglJournal has been changed to use the internal CoglObject macro so
  that it won't define an exported cogl_is_journal symbol.

• The _cogl_blah_pointer_from_handle functions have been removed.
  CoglHandle isn't used much anymore anyway and in the few places
  where it is used I think it's safe to just use the implicit cast
  from void* to the right type.

• The test-utils.h header for the conformance tests explicitly
  disables the -Wmissing-declaration option using a pragma because all
  of the tests declare their main function without a header. Any
  mistakes relating to missing declarations aren't really important
  for the tests.

• cogl_quaternion_init_from_quaternion and init_from_matrix have been
  given declarations in cogl-quaternion.h

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-06 18:45:44 +00:00
Robert Bragg
316a515f9b build: clean .log file in tests/conform dir
When running the conformance tests we write to a .log file which wasn't
being removed by make clean which was causing make release-check to
fail.
2012-03-05 23:25:30 +00:00
Robert Bragg
13ba312d3a test: remove FEATURE_GL requirement for sub_texture test
test-cogl-sub-texture was fixed to now run on GLES2 since commit
5928cade0b so this removes the TEST_REQUIREMENT_GL flag for this test
so it doesn't get flagged as an unexpected pass.
2012-03-05 22:58:42 +00:00
Neil Roberts
6ad168e4be Port the test-pixel-buffer test
This ports the text-pixel-buffer test from being a Clutter test to a
straight Cogl test.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 19:02:37 +00:00
Neil Roberts
b85f2e907a tests: Add a test which writes all pixel formats
This adds a test similar to the test-read-texture-formats test but
that updates data on a 1x1 pixel RGBA texture instead. On GLES2 this
should end up testing all of the convesion code because in that case
GL only supports reading back RGBA data.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:52 +00:00
Neil Roberts
70dfbdd5e3 tests: Test reading all pixel formats
The test-read-alpha-texture test has been replaced with a test that
tries reading an RGBA texture in all current pixel formats. On GLES2
this should end up testing all of the convesion code because in that
case GL only supports reading back RGBA data. The test now works on
GLES2 since the conversion code for all of the formats has been added
so this also removes the GL requirement.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:44:51 +00:00
Neil Roberts
b6dc23370d Add a conformance test for reading back an RGBA texture as alpha-only
This just creates a 1x1 RGBA texture and then reads it back in
COGL_PIXEL_FORMAT_A_8 format. Gnome Shell is doing this to create a
shadow and I accidentally broke it so this should hopefully stop that
happening again.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-03-05 17:43:46 +00:00
Robert Bragg
bbcbece6c9 tests: Improve thoroughness and reporting of make test
This patch reworks our conformance testing framework because it seems
that glib's gtesting framework isn't really well suited to our use case.
For example we weren't able to test windows builds given the way we
were using it and also for each test we'd like to repeat the test
with several different environments so we can test important driver and
feature combinations.

This patch instead switches away to a simplified but custom approach for
running our unit tests. We hope that having a more bespoke setup will
enable us to easily extend it to focus on the details important to us.

Notable changes with this new approach are:

We can now run 'make test' for our mingw windows builds.

We've got rid of all the test-*report* make rules and we're just left
with 'make test'

'make test' now runs each test several times with different driver and
feature combinations checking the result for each run. 'make test' will
then output a concise table of all of the results.

The combinations tested are:
- OpenGL Fixed Function
- OpenGL ARBfp
- OpenGL GLSL
- OpenGL No NPOT texture support
- OpenGLES 2.0
- OpenGLES 2.0 No NPOT texture support

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-24 14:42:31 +00:00
Neil Roberts
5928cade0b test-sub-texture: Request texture data in premult format
When requesting the texture data to test that we get back what we
uploaded, we need to ask for it in a premult format otherwise it will
get converted and the test will fail. This was working for the GL
driver because of a bug where it would fail to do the conversion.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-23 18:08:45 +00:00
Robert Bragg
785e6375eb Adds a context arg to cogl_pipeline_new()
As we move towards Cogl 2.0 we are aiming to remove the need for a
default global CoglContext and so everything should be explicitly
related to a context somehow. CoglPipelines are top level objects and
so this patch adds a context argument to cogl_pipeline_new().

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:38:24 +00:00
Robert Bragg
13c36fff0d offscreen: Replace use of CoglHandle with CoglOffscreen
This updates cogl_offscreen_new_to_texture to return a CoglOffscreen
pointer instead of a CoglHandle.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:38:10 +00:00
Robert Bragg
47868e1f3e texture-3d: remove _EXP defines + CoglHandle and pass context
We are in the process of removing all _EXP suffix mangling for
experimental APIs (Ref: c6528c4b6c) and adding missing gtk-doc
comments so that we can instead rely on the "Stability: unstable"
markers in the gtk-doc comments. This patch tackles the cogl-texture-3d
api symbols.

This patch also replaces use of CoglHandle with a CoglTexture3D type
instead.

Finally this patch also ensures the CoglTexture3D constructors take an
explicit CoglContext pointer but not a CoglTextureFlags argument,
consistent with other CoglTexture constructors.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-21 12:37:44 +00:00
Robert Bragg
e3c4522a86 Adds a _cogl_util_pixel_format_from_masks API
This adds a utility function for inferring a CoglPixelFormat from a
set of channel masks, a bits-per-pixel value, a pixel-depth value and
pixel byte order.

This plan is to use this to improve how we map X visuals to Cogl pixel
formats.

This patch was based on some ideas from Damien Leone <dleone@nvidia.com>

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

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-20 23:12:45 +00:00
Neil Roberts
a654dac122 test-snippets: Add a test case for sampling arbitrary units
This adds a sub-test that samples from two texture units by naming
their layer numbers.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:29:29 +00:00
Neil Roberts
d7164f9579 tests: Move the create_color_texture function to test-utils
This adds a shared utility function to create a 1x1 texture with a
given color.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:29:28 +00:00
Neil Roberts
39b9e717f5 test-snippets: Add a test for using cogl_sampler in tex hook
This adds a test for doing custom sampling using the cogl_sampler
variable in the texture lookup hook.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:29:28 +00:00
Neil Roberts
6ca852fad6 test-snippets: Split up the tests into multiple functions
There were lots of tests bundled into a single long function which was
becoming a bit unwieldy. It was also quite difficult to match up the
test's drawing with its color test. This patch just moves each little
sub test into its own function.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:29:28 +00:00
Neil Roberts
bf7f1e358d Add a test for pipelines with sparse layer indices
There are currently quite a few places in Cogl where we muddle the
layer index and the texture unit number. The theory is that these two
numbers shouldn't be related and it should be possible to pick large
layer numbers with gaps.

This patch adds a test case to check that we can reference a large
layer number from a texture combine string by creating a pipeline with
only three layers but that have very large layer indices. This doesn't
currently work because Cogl interprets the numbers in the combine
strings to be the unit indices and not the layer indices. The
documentation however calls these numbers layer numbers so presumably
it is not meant to work that way.

There are probably many other bugs related to this that the test case
doesn't pick up so it would be good to add some more tests here, for
example to test that you can bind an attribute to the texture
coordinates for a large layer index.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Neil Roberts
971d7f33a0 test-texture-3d: Add a test for multi-texturing 3D and 2D textures
The ARBfp fragend has a bug when the texture combine string references
another texture unit where it will use the texture type of the current
layer rather than the texture type of the layer the string refers to.
This patch adds a small test which demonstrates that.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Neil Roberts
7cd2f25eb0 test-texture-3d: Port to Cogl
This ports the texture-3d test to Cogl instead of depending on
Clutter.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-13 17:15:35 +00:00
Robert Bragg
3ea6acc072 buffer: explicitly relate buffers to a context
All CoglBuffer constructors now take an explicit CoglContext
constructor. This is part of the on going effort to adapt to Cogl API so
it no longer depends on a global, default context.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 14:28:02 +00:00
Robert Bragg
92c3063014 framebuffer: Add cogl_framebuffer draw methods
This adds cogl_framebuffer_ apis for drawing attributes and primitives
that replace corresponding apis that depend on the default CoglContext.
This is part of the on going effort to adapt the Cogl api so it no
longer depends on a global context variable.

All the new drawing functions also take an explicit pipeline argument
since we are also aiming to avoid being a stateful api like Cairo and
OpenGL. Being stateless makes it easier for orthogonal components to
share access to the GPU. Being stateless should also minimize any
impedance miss-match for those wanting to build higher level stateless
apis on top of Cogl.

Note: none of the legacy, global state options such as
cogl_set_depth_test_enabled(), cogl_set_backface_culling_enabled() or
cogl_program_use() are supported by these new drawing apis and if set
will simply be silently ignored.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
2012-02-09 13:09:15 +00:00
Neil Roberts
389198a0d5 test-primitive: Add a test for cogl_primitive_copy
This adds a little test which makes a copy of a CoglPrimitive and
verifies that all of the properties on the new primitive are the same
as the old one.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
a226b368f3 Port the test-primitive test from Clutter to Cogl
This converts test-primitive to be a standalone Cogl test instead of
relying on Clutter code.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-02-07 15:25:36 +00:00
Neil Roberts
f4a42fe988 test-offscreen: Add tests that the offscreen's journal gets flushed
This adds an extra test to test-offscreen then ensures the offscreen
framebuffer for a texture automatically flushes its journal in the
following three situations:

1. cogl_read_pixels is called immediately when the offscreen buffer is
   current.

2. cogl_texture_get_data is called on the offscreen's texture
   immediately after rendering to it.

3. The texture is rendered to the screen and immediately read back
   with cogl_read_pixels.

Currently the 2nd situation fails.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-31 12:01:20 +00:00
Neil Roberts
cd9e1be6ae test-utils: Expose the compare_pixel function
The compare pixel function was a static function used internally by
the test_utils_check_* functions. It takes a pointer to a pixel in a
buffer read back from Cogl and compares it with an expected value.
This function could also be useful in tests wanting to check the data
returned from a call to cogl_texture_get_data so we should share it
with the rest of the tests.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-31 12:01:20 +00:00
Neil Roberts
bd6810de10 tests: Port test-offscreen
This ports the test-offscreen test from being a Clutter test to a
straight Cogl test.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2012-01-31 12:01:20 +00:00
Neil Roberts
fcaca87fd4 test-launcher: Pass on the exit code
This makes the test launcher script pass on the exit code from the
conformance test as its own exit status. This makes using a particular
test with git bisect run easier.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-07 19:01:48 +00:00
Neil Roberts
4c8966122f test-utils: Add some fuzz to the pixel comparison routine
When comparing a pixel, the comparison routines now allow each
component to be off by +/- 1. This is to compensate for varying
rounding across drivers.

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

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-07 19:01:38 +00:00
Neil Roberts
6320aab9b4 test-snippets: Add a test to verify the order of the snippets
This verifies that the post strings are executed in the order they
were added to the pipeline and the post strings are executed in the
reverse order.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
72097ac01d Add a conformance test for custom attributes
The test creates some pipelines with snippets with custom attributes
and uses CoglAttribute to define values for them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
7590fc3ec3 snippet: Add a hook for the vertex transform
This adds a hook to wrap or replace the vertex transform stage.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
68b3643b25 snippet: Add a hook for the layer texture coordinate transformation
This adds a hook called COGL_SNIPPET_HOOK_TEXTURE_COORD_TRANSFORM.
This can be used to alter the application of the layer user matrix to
a texture coordinate or it can bypass it altogether.

This is the first per-layer hook that affects the vertex shader state
so the patch includes the boilerplate needed to get that to work.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
b7e15929b6 snippet: Add a hook for the layer fragment processing
This adds a hook to replace or wrap the fragment processing for a
particular layer.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
4581ce5f15 fragend-glsl: Don't generate the default texture lookup if replaced
Previously the function containing the default texture lookup is
always generated regardless of whether there is a snippet with a
replace string which would cause it not be used. Now this snippets are
all scanned to check for replace strings before generating the texture
lookup.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
a0903e0cfb snippet: Don't generate code for snippets that are replaced
The loop that generates code for a list of snippets now starts from
the first snippet that has a replace string. Any snippets before that
would be ignored so there's no point in generating code for them.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
09c2e4abe7 snippet: Move the hook to be a property of the snippet
Instead of specifying the hook point when adding to the pipeline using
a separate function for each hook, the hook is now a property of the
snippet. The hook is set on construction and is then read-only.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
df0f9a862f pipeline: Add a snippet hook for the texture lookup
This adds a per-layer snippet hook for the texure lookup. Here the
snippet can modify the texture coordinates used for the lookup or
modify the texel resulting from the lookup. This is the first
per-layer hook so this also adds the
COGL_PIPELINE_LAYER_STATE_FRAGMENT_SNIPPETS state and all of the
boilerplate needed to make that work.

Most of the functions used by the pipeline state to manage the snippet
list has been moved into cogl-pipeline-snippet.c so that it can be
shared with the layer state.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:06 +00:00
Neil Roberts
717e96b304 snippet: Add a 'replace' string
If present, the 'replace' string will be used instead of whatever code
would normally be invoked for that hook point. It will also replace
any previous snippets.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:05 +00:00
Neil Roberts
0fdd5690c6 pipeline: Wrap each snippet in its own function
Each snippet is now given its own function which contains the pre and
post strings. Between these strings the function will chain on to
another function. The generated cogl source is now stored in a
function called cogl_generated_source() which the last snippet will
chain on to. This should make it so that each snippet has its own
namespace for local variables and it can share variables declared in
the pre string in the post string. Hopefully the GLSL compiler will
just inline all of the functions so it shouldn't make much difference
to the compiled output.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:05 +00:00
Neil Roberts
2f66cd7036 Add a conformance test for CoglSnippets
This adds a conformance test testing various operations on
CoglSnippets.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
2011-12-06 19:02:05 +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
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
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
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
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