summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2016-09-02Add new test of filter reduction from BILINEAR to NEARESTSøren Sandmann Pedersen2-0/+113
This new test tests a bunch of bilinear downscalings, where many have a transformation such that the BILINEAR filter can be reduced to NEAREST (and many don't). A CRC32 is computed for all the resulting images and compared to a known-good value for both 4-bit and 7-bit interpolation. V2: Remove leftover comment, some minor formatting fixes, use a timestamp as the PRNG seed. Signed-off-by: Søren Sandmann <soren.sandmann@gmail.com> Reviewed-by: Bill Spitzak <spitzak@gmail.com>
2015-12-30build: Distinguish SKIP and FAIL on Win32Andrea Canciani1-11/+20
The `check` target in test/Makefile.win32 assumed that any non-0 exit code from the tests was an error, but the testsuite is currently using 77 as a SKIP exit code (based on the convention used in autotools). Fixes fence-image-self-test and cover-test (now reported as SKIP). Signed-off-by: Andrea Canciani <ranma42@gmail.com> Acked-by: Oded Gabbay <oded.gabbay@gmail.com>
2015-12-23build: Avoid phony `pixman` target in test/Makefile.win32Andrea Canciani1-6/+4
Instead of explicitly depending on "pixman" for the "all" and "check" targets, rely on the dependency to the .lib file Signed-off-by: Andrea Canciani <ranma42@gmail.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
2015-10-16test: Fix fence-image-self-test on MacAndrea Canciani2-8/+10
On MacOS X, according to the manpage of mprotect(), "When a program violates the protections of a page, it gets a SIGBUS or SIGSEGV signal.", but fence-image-self-test was only accepting a SIGSEGV as notification of invalid access. Fixes fence-image-self-test Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-09-25affine-bench: remove 8e margin from COVER areaBen Avison1-6/+18
Patch "Remove the 8e extra safety margin in COVER_CLIP analysis" reduced the required image area for setting the COVER flags in pixman.c:analyze_extent(). Do the same reduction in affine-bench. Leaving the old calculations in place would be very confusing for anyone reading the code. Also add a comment that explains how affine-bench wants to hit the COVER paths. This explains why the intricate extent calculations are copied from pixman.c. [Pekka: split patch, change comments, write commit message] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-09-20test: add a check for FE_DIVBYZEROThomas Petazzoni1-0/+2
Some architectures, such as Microblaze and Nios2, currently do not implement FE_DIVBYZERO, even though they have <fenv.h> and feenableexcept(). This commit adds a configure.ac check to verify whether FE_DIVBYZERO is defined or not, and if not, disables the problematic code in test/utils.c. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Marek Vasut <marex@denx.de> Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
2015-09-16test: Add cover-test v5Ben Avison2-0/+450
This test aims to verify both numerical correctness and the honouring of array bounds for scaled plots (both nearest-neighbour and bilinear) at or close to the boundary conditions for applicability of "cover" type fast paths and iter fetch routines. It has a secondary purpose: by setting the env var EXACT (to any value) it will only test plots that are exactly on the boundary condition. This makes it possible to ensure that "cover" routines are being used to the maximum, although this requires the use of a debugger or code instrumentation to verify. Changes in v4: Check the fence page size and skip the test if it is too large. Since we need to deal with pixman_fixed_t coordinates that go beyond the real image width, make the page size limit 16 kB. A 32 kB or larger page size would cause an a8 image width to be 32k or more, which is no longer representable in pixman_fixed_t. Use a shorthand variable 'filter' in test_cover(). Whitespace adjustments. Changes in v5: Skip if fenced memory is not supported. Do you know of any such platform? Signed-off-by: Ben Avison <bavison@riscosopen.org> [Pekka: changes in v4 and v5] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org> Acked-by: Oded Gabbay <oded.gabbay@gmail.com>
2015-09-09utils.[ch]: add fence_get_page_size()Pekka Paalanen2-3/+22
Add a function to get the page size used for memory fence purposes, and use it everywhere where getpagesize() was used. This offers a single point in code to override the page size, in case one wants to experiment how the tests work with a higher page size than what the developer's machine has. This also offers a clean API, without adding #ifdefs, to tests for checking the page size. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-09-09utils.c: fix fallback code for fence_image_create_bits()Pekka Paalanen1-1/+1
Used a wrong variable name, causing: /home/pq/git/pixman/demos/../test/utils.c: In function ‘fence_image_create_bits’: /home/pq/git/pixman/demos/../test/utils.c:562:46: error: ‘width’ undeclared (first use in this function) Use the correct variable. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-09-03test: add fence-image-self-testPekka Paalanen2-0/+238
Tests that fence_malloc and fence_image_create_bits actually work: that out-of-bounds and out-of-row (unused stride area) accesses trigger SIGSEGV. If fence_malloc is a dummy (FENCE_MALLOC_ACTIVE not defined), this test is skipped. Changes in v2: - check FENCE_MALLOC_ACTIVE value, not whether it is defined - test that reading bytes near the fence pages does not cause a segmentation fault Changes in v3: - Do not print progress messages unless VERBOSE environment variable is set. Avoid spamming the terminal output of 'make check' on some versions of autotools. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-09-01utils.[ch]: add fence_image_create_bits ()Pekka Paalanen2-0/+112
Useful for detecting out-of-bounds accesses in composite operations. This will be used by follow-up patches adding new tests. Changes in v2: - fix style on fence_image_create_bits args - add page to stride only if stride_fence - add comment on the fallback definition about freeing storage Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-09-01utils.[ch]: add FENCE_MALLOC_ACTIVEPekka Paalanen2-3/+14
Define a new token to simplify checking whether fence_malloc() actually can catch out-of-bounds access. This will be used in the future to skip tests that rely on fence_malloc checking functionality. Changes in v2: - #define FENCE_MALLOC_ACTIVE always, but change its value to help catch use of it without including utils.h Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-08-28scaling-test: list more details when verboseBen Avison1-22/+44
Add mask details to the output. [Pekka: redo whitespace and print src,dst,mask x and y.] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-08-18lowlevel-blt-bench: make extra arguments an errorPekka Paalanen1-0/+6
If a user gives multiple patterns or extra arguments, only the last one was used as the pattern while the former were just ignored. This is a user error silently converted to something possibly unexpected. In presence of extra arguments, complain and quit. Cc: Ben Avison <bavison@riscosopen.org> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-06lowlevel-blt-bench: add option to skip memcpy measurementPekka Paalanen1-3/+8
The memcpy speed measurement takes several seconds. When you are running single tests in a harness that iterates dozens or hundreds of times, the repeated measurements are redundant and take a lot of time. It is also an open question whether the measured speed changes over long test runs due to unidentified platform reasons (Raspberry Pi). Add a command line option to set the reference memcpy speed, skipping the measuring. The speed is mainly used to compute how many iterations do run inside the bench_*() functions, so for repeated testing on the same hardware, it makes sense to lock that number to a constant. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: add CSV output modePekka Paalanen1-21/+47
Add a command line option for choosing CSV output mode. In CSV mode, only the results in Mpixels/s are printed in an easily machine-parseable format. All user-friendly printing is suppressed. This is intended for cases where you benchmark one particular operation at a time. Running the "all" set of benchmarks will print just fine, but you may have trouble matching rows to operations as you have to look at the tests_tbl[] to see what row is which. Reviewed-by: Ben Avison <bavison@riscosopen.org> v2: don't add a space after comma in CSV. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-06lowlevel-blt-bench: refactor to Mpx_per_sec()Pekka Paalanen1-7/+16
Refactor the Mpixels/s computations into a function. Easier to read and better documents what is being computed. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: all bench funcs to return pix_cntPekka Paalanen1-14/+16
The bench_* functions, that did not already do it, are modified to return the number of pixels processed during the benchmark. This moves the computation to the site that actually determines the number, and simplifies bench_composite() a bit. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: move speed and scaling printingPekka Paalanen1-15/+22
Move the printing of the memory speed and scaling mode into a new function. This will help with implementing a machine-readable output option. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: print single pattern detailsPekka Paalanen1-3/+25
When given just a single test pattern instead of "all", print the test details. This can be used to verify the pattern parser agrees with the user, just like scaling settings are printed. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: make test_entry::testname constPekka Paalanen1-7/+7
We assign string literals to it, so it better be const. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: move explanation printingPekka Paalanen1-27/+33
Move explanation printing to a new function. This will help with implementing a machine-readable output option. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-07-06lowlevel-blt-bench: move usage to a functionPekka Paalanen1-3/+9
Move printing of usage into a new function and use argv[0] as the program name. This will help printing usage from multiple places. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-06-01test: Fix solid-test for big-endian targetsBen Avison1-3/+6
When generating test data, we need to make sure the interpretation of the data is the same regardless of endianess. That is, the pixel value for each channel is the same on both little and big-endians. This fixes a test failure on ppc64 (big-endian). Tested-by: Fernando Seiti Furusato <ferseiti@linux.vnet.ibm.com> (ppc64le, ppc64, powerpc) Tested-by: Ben Avison <bavison@riscosopen.org> (armv6l, armv7l, i686) [Pekka: added commit message] Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> (x86_64)
2015-05-15test: Add new fuzz tester targeting solid imagesBen Avison2-0/+351
This places a heavier emphasis on solid images than the other fuzz testers, and tests both single-pixel repeating bitmap images as well as those created using pixman_image_create_solid_fill(). In the former case, it also exercises the case where the bitmap contents are written to after the image's first use, which is not a use-case that any other test has previously covered. [Pekka: added the default case to the switch in test_solid ().] Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-04-24test: Add a new benchmarker targeting affine operationsBen Avison2-0/+437
Affine-bench is written by following the example of lowlevel-blt-bench. Affine-bench differs from lowlevel-blt-bench in the following: - does not test different sized operations fitting to specific caches, destination is always 1920x1080 - allows defining the affine transformation parameters - carefully computes operation extents to hit the COVER_CLIP fast paths Original version by Ben Avison. Changes by Pekka in v3: - commit message - style fixes - more comments - refactoring (e.g. bench_info_t) - help output tweak Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-20lowlevel-blt-bench: use a8r8g8b8 for CA solid masksPekka Paalanen1-1/+5
When doing component alpha with a solid mask, use a mask format that has all the color channels instead of just a8. As Ben Avison explains it: "Lowlevel-blt-bench initialises all its images using memset(0xCC) so an a8 solid image would be converted by _pixman_image_get_solid() to 0xCC000000 whereas an a8r8g8b8 would be 0xCCCCCCCC. When you're not in component alpha mode, only the alpha byte matters for the mask image, but in the case of component alpha operations, a fast path might decide that it can save itself a lot of multiplications if it spots that 3 constant mask components are already 0." No (default) test so far has a solid mask with CA. This is just future-proofing lowlevel-blt-bench to do what one would expect. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15lowlevel-blt-bench: use the test pattern parserPekka Paalanen1-20/+44
Let lowlevel-blt-bench parse the test name string from the command line, allowing to run almost infinitely more tests. One is no longer limited to the tests listed in the big table. While you can use the old short-hand names like src_8888_8888, you can also use all possible operators now, and specify pixel formats exactly rather than just x888, for instance. This even allows to run crazy patterns like conjoint_over_reverse_a8b8g8r8_n_r8g8b8x8. All individual patterns are now interpreted through the parser. The pattern "all" runs the same old default test set as before but through the parser instead of the hard-coded parameters. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15lowlevel-blt-bench: add test name parser and self-testPekka Paalanen1-3/+228
This patch is inspired by "lowlevel-blt-bench: Parse test name strings in general case" by Ben Avison. From Ben's commit message: "There are many types of composite operation that are useful to benchmark but which are omitted from the table. Continually having to add extra entries to the table is a nuisance and is prone to human error, so this patch adds the ability to break down unknow strings of the format <operation>_<src>[_<mask]_<dst>[_ca] where bitmap formats are specified by number of bits of each component (assumed in ARGB order) or 'n' to indicate a solid source or mask." Add the parser to lowlevel-blt-bench.c, but do not hook it up to the command line just yet. Instead, make it run a self-test. As we now dynamically parse strings similar to the test names in the huge table 'tests_tbl', we should make sure we can parse the old well-known test names and produce exactly the same test parameters. The self-test goes through this old table and verifies the parsing results. Unfortunately the old table is not exactly consistent, it contains some special cases that cannot be produced by the parsing rules. Whether these special cases are intentional or just an oversight is not always clear. Anyway, add a small table to reproduce the special cases verbatim. If we wanted, we could remove the big old table in a follow-up commit, but then we would also lose the parser self-test. The point of this whole excercise to let lowlevel-blt-bench recognize novel test patterns in the future, following exactly the conventions used in the old table. Ben, from what I see, this parser has one major difference to what you wrote. For a solid mask, your parser uses a8r8g8b8 format, while mine uses a8 which comes from the old table. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15test/utils: add format aliases used by lowlevel-blt-benchPekka Paalanen1-0/+11
Lowlevel-blt-bench uses several pixel format shorthands. Pick them from the great table in lowlevel-blt-bench.c and add them here so that format_from_string() can recognize them. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15test/utils: add operator aliases for lowlevel-blt-benchPekka Paalanen1-0/+4
Lowlevel-blt-bench uses the operator alias "outrev". Add an alias for it in the operator-name table. Also add aliases for overrev, inrev and atoprev, so that lowlevel-blt-bench can later recognize them for new test cases. The aliases are added such, that an operator to name lookup will never return them; it returns the proper names instead. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15test/utils: support format name aliasesPekka Paalanen1-127/+126
Previously there was a flat list of formats, used to iterate over all formats when looking up a format from name or listing them. This cannot support name aliases. To support name aliases (multiple name strings mapping to the same format), create a format-name mapping table. Functions format_name(), format_from_string(), and list_formats() should keep on working exactly like before, except format_from_string() now recognizes the additional formats that format_name() already supported. The only the formats from the old format list are added with ENTRY, so that list_formats() works as before. The whole list is verified against the authoritative list in pixman.h, entries missing from the old list are commented out. The extra formats supported by the old format_name() are added as ALIASes. A side-effect of that is that now also format_from_string() recognizes the following new names: x4c4 / c8, x4g4 / g8, c4, g4, g1, yuy2, yv12, null, solid, pixbuf, rpixbuf, unknown. Name aliases will be useful in follow-up patches, where lowlevel-blt-bench.c is converted to parse short-hand format names from strings. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-15test/utils: support operator name aliasesPekka Paalanen1-126/+104
Previously there was a flat list of operators (pixman_op_t), used to iterate over all operators when looking up an operator from name or listing them. This cannot support name aliases. To support name aliases (multiple name strings mapping to the same operator), create an operator-name mapping table. Functions operator_name, operator_from_string, and list_operators should keep on working exactly like before, except operator_from_string now recognizes a few aliases too. Name aliases will be useful in follow-up patches, where lowlevel-blt-bench.c is converted to parse operator names from strings. Lowlevel-blt-bench uses shorthand names instead of the usual names. This change allows lowlevel-blt-bench.s to use operator_from_string in the future. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ben Avison <bavison@riscosopen.org>
2015-04-13test: Move format and operator string functions to utils.[ch]Ben Avison3-192/+205
This permits format_from_string(), list_formats(), list_operators() and operator_from_string() to be used from tests other than check-formats. Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-06-28test: Rearrange tests in order of increasing runtimeSøren Sandmann Pedersen1-30/+30
Making short tests run first is convenient to catch obvious bugs early.
2014-05-15test: Add radial-invalid test programSøren Sandmann Pedersen4-0/+66
This program demonstrates a bug in gradient walker, where some integer overflows cause colors outside the range [0, 255] to be generated, which in turns cause 'invalid' floating point exceptions when those colors are converted to uint8_t. The bug was first reported by Owen Taylor on the #cairo IRC channel.
2014-04-02test: Fix OpenMP clauses for the tolerance-testSiarhei Siamashka1-2/+2
Compiling with the Intel Compiler reveals a problem: tolerance-test.c(350): error: index variable "i" of for statement following an OpenMP for pragma must be private # pragma omp parallel for default(none) shared(i) private (result) ^ In addition to this, the 'result' variable also should not be private (otherwise its value does not survive after the end of the loop). It needs to be either shared or use the reduction clause to describe how the results from multiple threads are combined together. Reduction seems to be more appropriate here.
2014-04-02configure.ac: Check if the compiler supports GCC vector extensionsSiarhei Siamashka2-10/+9
The Intel Compiler 14.0.0 claims version GCC 4.7.3 compatibility via __GNUC__/__GNUC__MINOR__ macros, but does not provide the same level of GCC vector extensions support as the original GCC compiler: http://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html Which results in the following compilation failure: In file included from ../test/utils.h(7), from ../test/utils.c(3): ../test/utils-prng.h(138): error: expression must have integral type uint32x4 e = x->a - ((x->b << 27) + (x->b >> (32 - 27))); ^ The problem is fixed by doing a special check in configure for this feature.
2014-03-20lowlevel-blt-bench: add in_reverse_8888_8888 testBen Avison1-0/+1
in_reverse_8888_8888 is one of the more commonly used operations in the cairo-perf-trace suite that hasn't been in lowlevel-blt-bench until now. v4, Pekka Paalanen <pekka.paalanen@collabora.co.uk> : Split from "Add extra test to lowlevel-blt-bench and fix an existing one", new summary.
2014-03-20lowlevel-blt-bench: over_reverse_n_8888 needs solid sourceBen Avison1-1/+1
v4, Pekka Paalanen <pekka.paalanen@collabora.co.uk> : Split from "Add extra test to lowlevel-blt-bench and fix an existing one", new summary.
2014-01-04utils.c: Set DEVIATION to 0.0128Søren Sandmann Pedersen1-1/+1
Consider a HARD_LIGHT operation with the following pixels: - source: 15 (6 bits) - source alpha: 255 (8 bits) - mask alpha: 223 (8 bits) - dest 255 (8 bits) - dest alpha: 0 (8 bits) Since 2 times the source is less than source alpha, the first branch of the hard light blend mode is taken: (1 - sa) * d + (1 - da) * s + 2 * s * d Since da is 0 and d is 1, this degenerates to: (1 - sa) + 3 * s Taking (src IN mask) into account along with the fact that sa is 1, this becomes: (1 - ma) + 3 * s * ma = (1 - 223/255.0) + 3 * (15/63.0) * (223/255.0) = 0.7501400560224089 When computed with the source converted by bit replication to eight bits, and additionally with the (src IN mask) part rounded to eight bits, we get: ma = 223/255.0 s * ma = (60 / 255.0) * (223/255.0) which rounds to 52 / 255 and the result is (1 - ma) + 3 * s * ma = (1 - 223/255.0) + 3 * 52/255.0 = 0.7372549019607844 so now we have an error of 0.012885. Without making changes to the way pixman does integer rounding/arithmetic, this error must then be considered acceptable. Due to conservative computations in the test suite we can however get away with 0.0128 as the acceptable deviation. This fixes the remaining failures in pixel-test.
2014-01-04Use floating point combiners for all operators that involve divisionsSøren Sandmann2-38/+11
Consider a DISJOINT_ATOP operation with the following pixels: - source: 0xff (8 bits) - source alpha: 0x01 (8 bits) - mask alpha: 0x7b (8 bits) - dest: 0x00 (8 bits) - dest alpha: 0xff (8 bits) When (src IN mask) is computed in 8 bits, the resulting alpha channel is 0 due to rounding: floor ((0x01 * 0x7b) / 255.0 + 0.5) = floor (0.9823) = 0 which means that since Render defines any division by zero as infinity, the Fa and Fb for this operator end up as follows: Fa = max (1 - (1 - 1) / 0, 0) = 0 Fb = min (1, (1 - 0) / 1) = 1 and so since dest is 0x00, the overall result is 0. However, when computed in full precision, the alpha value no longer rounds to 0, and so Fa ends up being Fa = max (1 - (1 - 1) / 0.0001, 0) = 1 and so the result is now s * ma * Fa + d * Fb = (1.0 * (0x7b / 255.0) * 1) + d * 0 = 0x7b / 255.0 = 0.4823 so the error in this case ends up being 0.48235294, which is clearly not something that can be considered acceptable. In order to avoid this problem, we need to do all arithmetic in such a way that a multiplication of two tiny numbers can never end up being zero unless one of the input numbers is itself zero. This patch makes all computations that involve divisions take place in floating point, which is sufficient to fix the test cases This brings the number of failures in pixel-test down to 14.
2014-01-04Soft Light: Consistent approach to division by zeroSøren Sandmann1-1/+1
The Soft Light operator has several branches. One them is decided based on whether 2 * s is less than or equal to 2 * sa. In floating point implementations, when those two values are very close to each other, it may not be completely predictable which branch we hit. This is a problem because in one branch, when destination alpha is zero, we get the result r = d * as and in the other we get r = 0 So when d and as are not 0, this causes two different results to be returned from essentially identical input values. In other words, there is a discontinuity in the current implementation. This patch randomly changes the second branch such that it now returns d * sa instead. There is no deep meaning behind this, because essentially this is an attempt to assign meaning to division by zero, and all that is requires is that that meaning doesn't depend on minute differences in input values. This makes the number of failed pixels in pixel-test go down to 347.
2014-01-04pixman-combine32.c: Fix bugs related to integer promotionSøren Sandmann Pedersen1-1/+1
In the component alpha part of the PDF_SEPARABLE_BLEND_MODE macro, the expression ~RED_8 (m) is used. Because RED_8(m) gets promoted to int before ~ is applied, the whole expression typically becomes some negative value rather than (255 - RED_8(m)) as desired. Fix this by using unsigned temporary variables. This reduces the number of failures in pixel-test to 363.
2014-01-04pixman/pixman-combine32.c: Bug fixes for separable blend modesSøren Sandmann Pedersen2-2/+2
This commit fixes four separate bugs: 1. In the computation (1 - sa) * d + (1 - da) * s + sa * da * B(s, d) we were using regular addition for all four channels, but for superluminescent pixels, the addition could overflow causing nonsensical results. 2. The variables and return types used for the results of the blend mode calculations were unsigned, but for various blend modes (and especially with superluminescent pixels), the blend mode calculations could be negative, resulting in underflows. 3. The blend mode computations were returned as 8-bit values, which is not sufficient precision (especially considering that we need signed results). 4. The value before the final division by 255 was not properly clamped to [0, 255]. This patch fixes all those bugs. The blend mode computations are now returned as signed 16 bit values with 1 represented as 255 * 255. With these fixes, the number of failing pixels in pixel-test goes down from 431 to 384.
2014-01-04pixel-test.c: Add a number of pixels that have failed at some pointSøren Sandmann1-0/+2680
This commit adds a large number of pixel regressions to pixel-test. All of these have at some point been failing in blend-mode-test, and most of them do fail currently. To be specific, with this commit, pixel-test reports 431 failed tests.
2014-01-04test/tolerance-test: New test programSøren Sandmann Pedersen2-0/+361
This new test program is similar to test/composite in that it relies on the pixel_checker_t API to do tolerance based verification. But unlike the composite test, which verifies combinations of a fixed set of pixels, this one generates random images and verifies that those composite correctly. Also unlike composite, tolerance-test supports all the separable blend mode operators in addition to the original Render operators. When tests fail, a C struct is printed that can be pasted into pixel-test for regression purposes. There is an option "--forever" which causes the random seed to be set to the current time, and then the test runs until interrupted. This is useful for overnight runs. This test currently fails badly due to various bugs in the blend mode operators. Later commits will fix those.
2014-01-04pixel-test: Command line argument to specify the regression to runSøren Sandmann1-1/+13
A new command line argument allows the user to specify which one of the regressions should be run.
2014-01-04pixel-test: Add support for mask pixelsSøren Sandmann1-11/+75
Support is added to pixel-test for verifying operations involving masks. If a regression includes a mask, it is verified with the pixel_checker API in in both unified and component alpha modes.
2014-01-04test/check-formats.c: Add support for separable blend modesSøren Sandmann Pedersen1-0/+16