![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
Pins the drawlayer batch rasterizer against the per-dab one. More...
#include "iop/drawlayer/brush.h"#include "iop/drawlayer/cache.h"#include "iop/drawlayer/paint.h"#include <setjmp.h>#include <stdarg.h>#include <stddef.h>#include <stdint.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <time.h>#include <cmocka.h>
Include dependency graph for test_drawlayer_batch_raster.c:Go to the source code of this file.
Data Structures | |
| struct | plane_t |
Macros | |
| #define | W 96 |
| #define | H 96 |
Typedefs | |
| typedef struct plane_t | plane_t |
Functions | |
| static void | _plane_init (plane_t *p) |
| static void | _plane_free (plane_t *p) |
| static void | _build_dabs_tex (dt_drawlayer_brush_dab_t *dabs, const int count, const int mode, const float opacity, const float radius, const float step, const float sprinkles) |
| A short stroke of overlapping dabs, uniform in everything the gate tests. | |
| static void | _build_dabs (dt_drawlayer_brush_dab_t *dabs, const int count, const int mode, const float opacity, const float radius, const float step) |
| static void | _run_serial (plane_t *p, const dt_drawlayer_brush_dab_t *dabs, const int count) |
Run the reference path: one dt_drawlayer_brush_rasterize per dab, in order. | |
| static void | _run_batch (plane_t *p, const dt_drawlayer_brush_dab_t *dabs, const int count) |
| static double | _max_abs_diff (const float *a, const float *b, const size_t n) |
| static void | _compare_tex (const int mode, const float opacity, const float radius, const float step, const int count, const float sprinkles) |
| static void | _compare (const int mode, const float opacity, const float radius, const float step, const int count) |
| static void | test_batch_matches_serial_sprinkles (void **state) |
| Texture on: the batch shares ONE sprinkle field across every dab. | |
| static void | test_batch_matches_serial_paint_dense (void **state) |
| Heavy overlap, the shipped regime: spacing far below the diameter. | |
| static void | test_batch_matches_serial_paint_capped (void **state) |
| The cap binds mid-batch: opacity well below 1 with many overlapping dabs. | |
| static void | test_batch_matches_serial_paint_sparse (void **state) |
| Sparse dabs, barely overlapping. | |
| static void | test_batch_matches_serial_erase (void **state) |
| static void | test_gate_refuses_non_uniform (void **state) |
| The gate must refuse everything the closed form is not derived for. | |
| static void | test_batch_is_thread_count_independent (void **state) |
| The batch result must not depend on the thread count. | |
| static void | _clear_mask (float *const mask, const size_t px) |
| Time both paths on the shipped regime, so the speedup is measured and not derived. | |
| static void | _report_speedup (const float sprinkles) |
| static void | test_report_batch_speedup (void **state) |
| int | main (void) |
Pins the drawlayer batch rasterizer against the per-dab one.
dt_drawlayer_brush_rasterize_batch accumulates a product of per-dab transmittance factors and composites once, where dt_drawlayer_brush_rasterize composites per dab. The two are algebraically equal ONLY under the conditions dt_drawlayer_brush_batch_is_uniform tests for, and that equality is the whole basis of the fast path – so it is pinned here rather than argued about.
The comparison is a tolerance, not equality: the batch form evaluates a different (shorter) sequence of floating-point operations, so the two agree to rounding and not to the bit. The tolerance is tight enough that a real algebraic mistake – a dropped cap, a wrong order of operations, a missing clamp – moves it by orders of magnitude.
Definition in file test_drawlayer_batch_raster.c.
| #define H 96 |
Definition at line 52 of file test_drawlayer_batch_raster.c.
| #define W 96 |
Definition at line 51 of file test_drawlayer_batch_raster.c.
|
static |
Definition at line 109 of file test_drawlayer_batch_raster.c.
References _build_dabs_tex().
Referenced by test_batch_is_thread_count_independent(), and test_gate_refuses_non_uniform().
|
static |
A short stroke of overlapping dabs, uniform in everything the gate tests.
Definition at line 79 of file test_drawlayer_batch_raster.c.
References color, DT_DRAWLAYER_BRUSH_SHAPE_LINEAR, DT_DRAWLAYER_PAINT_STROKE_FIRST, DT_DRAWLAYER_PAINT_STROKE_MIDDLE, i, and dt_drawlayer_brush_dab_t::x.
Referenced by _build_dabs(), _compare_tex(), and test_gate_refuses_non_uniform().
Time both paths on the shipped regime, so the speedup is measured and not derived.
Defaults are size 64 (a 128 px diameter) and distance 0 (1 px spacing), which is ~128x overdraw – the case the batch path exists for. Reported, never asserted: a wall-clock assertion on a shared runner is a flaky test, and the equality tests above are what actually protect the behaviour.
Definition at line 343 of file test_drawlayer_batch_raster.c.
References i.
Referenced by _report_speedup().
|
static |
Definition at line 195 of file test_drawlayer_batch_raster.c.
References _compare_tex().
Referenced by test_batch_matches_serial_erase(), test_batch_matches_serial_paint_capped(), test_batch_matches_serial_paint_dense(), and test_batch_matches_serial_paint_sparse().
|
static |
Definition at line 150 of file test_drawlayer_batch_raster.c.
References _build_dabs_tex(), _max_abs_diff(), _plane_free(), _plane_init(), _run_batch(), _run_serial(), DT_DRAWLAYER_BRUSH_MODE_ERASE, H, i, L, plane_t::mask, plane_t::patch, dt_drawlayer_cache_patch_t::pixels, and W.
Referenced by _compare(), and test_batch_matches_serial_sprinkles().
Definition at line 139 of file test_drawlayer_batch_raster.c.
Referenced by _compare_tex().
Definition at line 72 of file test_drawlayer_batch_raster.c.
References p.
Referenced by _compare_tex(), and test_batch_is_thread_count_independent().
Definition at line 60 of file test_drawlayer_batch_raster.c.
References H, L, p, plane_t::patch, TRUE, W, and dt_drawlayer_cache_patch_t::x.
Referenced by _compare_tex(), and test_batch_is_thread_count_independent().
Definition at line 348 of file test_drawlayer_batch_raster.c.
References _clear_mask(), color, double(), dt_drawlayer_brush_batch_is_uniform(), DT_DRAWLAYER_BRUSH_MODE_PAINT, dt_drawlayer_brush_rasterize(), dt_drawlayer_brush_rasterize_batch(), DT_DRAWLAYER_BRUSH_SHAPE_LINEAR, dt_drawlayer_paint_runtime_private_create(), dt_drawlayer_paint_runtime_private_destroy(), DT_DRAWLAYER_PAINT_STROKE_FIRST, DT_DRAWLAYER_PAINT_STROKE_MIDDLE, i, L, noise, r, TRUE, dt_drawlayer_cache_patch_t::width, and dt_drawlayer_brush_dab_t::x.
Referenced by test_report_batch_speedup().
|
static |
Definition at line 125 of file test_drawlayer_batch_raster.c.
References dt_drawlayer_brush_batch_is_uniform(), dt_drawlayer_brush_rasterize_batch(), H, L, noise, p, and W.
Referenced by _compare_tex(), and test_batch_is_thread_count_independent().
|
static |
Run the reference path: one dt_drawlayer_brush_rasterize per dab, in order.
Definition at line 116 of file test_drawlayer_batch_raster.c.
References dt_drawlayer_brush_rasterize(), dt_drawlayer_paint_runtime_private_create(), dt_drawlayer_paint_runtime_private_destroy(), i, L, and p.
Referenced by _compare_tex().
| int main | ( | void | ) |
Definition at line 431 of file test_drawlayer_batch_raster.c.
References L, test_batch_is_thread_count_independent(), test_batch_matches_serial_erase(), test_batch_matches_serial_paint_capped(), test_batch_matches_serial_paint_dense(), test_batch_matches_serial_paint_sparse(), test_batch_matches_serial_sprinkles(), test_gate_refuses_non_uniform(), and test_report_batch_speedup().
The batch result must not depend on the thread count.
This is the property the tile-lock scheme it replaces did NOT have: omp_lock_t per tile gives mutual exclusion but says nothing about the order two threads take a tile in, and the per-pixel alpha depends on the running stroke alpha – so that path produced a different picture run to run. Accumulating a commutative product removes the dependence entirely, and rows are disjoint, so this must be BIT-identical, not merely close.
Definition at line 297 of file test_drawlayer_batch_raster.c.
References _build_dabs(), _plane_free(), _plane_init(), _run_batch(), DT_DRAWLAYER_BRUSH_MODE_PAINT, H, L, omp_get_max_threads, state, void(), and W.
Referenced by main().
Definition at line 236 of file test_drawlayer_batch_raster.c.
References _compare(), DT_DRAWLAYER_BRUSH_MODE_ERASE, state, and void().
Referenced by main().
The cap binds mid-batch: opacity well below 1 with many overlapping dabs.
Definition at line 223 of file test_drawlayer_batch_raster.c.
References _compare(), DT_DRAWLAYER_BRUSH_MODE_PAINT, state, and void().
Referenced by main().
Heavy overlap, the shipped regime: spacing far below the diameter.
Definition at line 216 of file test_drawlayer_batch_raster.c.
References _compare(), DT_DRAWLAYER_BRUSH_MODE_PAINT, state, and void().
Referenced by main().
Sparse dabs, barely overlapping.
Definition at line 230 of file test_drawlayer_batch_raster.c.
References _compare(), DT_DRAWLAYER_BRUSH_MODE_PAINT, state, and void().
Referenced by main().
Texture on: the batch shares ONE sprinkle field across every dab.
The field is a function of layer position and the stroke seed alone, so every overlapping dab samples the same value – which is why the gate also requires the sprinkle parameters to match. _cellular_grain_2d costs 9 cells x 4 splitmix32 per octave, up to three octaves, so sharing it divides the dominant per-pixel cost by the overdraw factor.
Definition at line 209 of file test_drawlayer_batch_raster.c.
References _compare_tex(), DT_DRAWLAYER_BRUSH_MODE_PAINT, state, and void().
Referenced by main().
The gate must refuse everything the closed form is not derived for.
Definition at line 243 of file test_drawlayer_batch_raster.c.
References _build_dabs(), _build_dabs_tex(), dt_drawlayer_brush_dab_t::color, dt_drawlayer_brush_batch_is_uniform(), DT_DRAWLAYER_BRUSH_MODE_BLUR, DT_DRAWLAYER_BRUSH_MODE_ERASE, DT_DRAWLAYER_BRUSH_MODE_PAINT, DT_DRAWLAYER_BRUSH_MODE_SMUDGE, dt_drawlayer_brush_dab_t::flow, L, dt_drawlayer_brush_dab_t::mode, dt_drawlayer_brush_dab_t::opacity, dt_drawlayer_brush_dab_t::sprinkle_size, dt_drawlayer_brush_dab_t::sprinkles, state, and void().
Referenced by main().
Definition at line 424 of file test_drawlayer_batch_raster.c.
References _report_speedup(), state, and void().
Referenced by main().