![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
#include "develop/develop.h"#include "develop/pixelpipe_hb.h"#include <stdarg.h>#include <stddef.h>#include <setjmp.h>#include <stdint.h>#include <cmocka.h>#include <glib.h>
Include dependency graph for test_backbuf_publish.c:Go to the source code of this file.
Data Structures | |
| struct | publisher_t |
Macros | |
| #define | SHAPE_A_W 4032 |
| #define | SHAPE_A_H 3024 |
| #define | SHAPE_A_HASH 0x1111111111111111ull |
| #define | SHAPE_B_W 5104 |
| #define | SHAPE_B_H 3880 |
| #define | SHAPE_B_HASH 0x2222222222222222ull |
| #define | HUNT_MICROSECONDS 400000 |
Typedefs | |
| typedef struct publisher_t | publisher_t |
Functions | |
| static gpointer | _publisher_main (gpointer user_data) |
| static gboolean | _pairing_is_coherent (const uint64_t hash, const size_t width, const size_t height) |
| Is this (hash, width, height) triple one that was ever published together? | |
| static void | test_field_by_field_read_crosses_publications (void **state) |
| static void | test_snapshot_never_crosses_publications (void **state) |
| static void | test_single_field_setter_is_a_publication (void **state) |
| A single-field setter must publish coherently too – the histogram backbuffers are invalidated that way when a view leaves. | |
| int | main (void) |
| #define HUNT_MICROSECONDS 400000 |
Definition at line 92 of file test_backbuf_publish.c.
| #define SHAPE_A_H 3024 |
Definition at line 57 of file test_backbuf_publish.c.
| #define SHAPE_A_HASH 0x1111111111111111ull |
Definition at line 58 of file test_backbuf_publish.c.
| #define SHAPE_A_W 4032 |
The backbuffer publication is one fact, and a consumer must read it as one.
‘hash’ names a cacheline; ‘width’/‘height’ say what shape the pixels in it are. A consumer that pairs a hash from one publication with dimensions from the next computes a cairo stride from a width the data does not have and paints the diagonal striping of a stride error. The cacheline cannot help: it records how many BYTES it holds and nothing about their layout, and it is routinely LARGER than width x height x bpp (aligned allocation, pool reuse), so a size check passes.
The first test reproduces the cross-pairing against the fields read one at a time – the way every display path read them – and fails the day it stops being reproducible, which is the point: it is what says the second test is measuring something. The second asserts that a snapshot never crosses. Both run the same writer.
This is a race, so the first test is written to be overwhelmingly likely rather than certain: a writer flipping between two shapes as fast as it can, against a reader that reads the hash, does a little work, and then reads the dimensions – the same shape as "resolve the cacheline, then compute the stride". If it ever goes quiet on some machine, do not delete it: it is reporting that the window closed on that scheduler, not that the hazard is gone.
Definition at line 56 of file test_backbuf_publish.c.
| #define SHAPE_B_H 3880 |
Definition at line 60 of file test_backbuf_publish.c.
| #define SHAPE_B_HASH 0x2222222222222222ull |
Definition at line 61 of file test_backbuf_publish.c.
| #define SHAPE_B_W 5104 |
Definition at line 59 of file test_backbuf_publish.c.
| typedef struct publisher_t publisher_t |
|
static |
Is this (hash, width, height) triple one that was ever published together?
Definition at line 83 of file test_backbuf_publish.c.
References height, SHAPE_A_H, SHAPE_A_HASH, SHAPE_A_W, SHAPE_B_H, SHAPE_B_HASH, SHAPE_B_W, TRUE, and width.
Referenced by test_field_by_field_read_crosses_publications(), and test_snapshot_never_crosses_publications().
|
static |
Definition at line 70 of file test_backbuf_publish.c.
References dt_dev_set_backbuf(), p, SHAPE_A_H, SHAPE_A_HASH, SHAPE_A_W, SHAPE_B_H, SHAPE_B_HASH, and SHAPE_B_W.
Referenced by test_field_by_field_read_crosses_publications(), and test_snapshot_never_crosses_publications().
| int main | ( | void | ) |
Definition at line 170 of file test_backbuf_publish.c.
References test_field_by_field_read_crosses_publications(), test_single_field_setter_is_a_publication(), and test_snapshot_never_crosses_publications().
Definition at line 94 of file test_backbuf_publish.c.
References _pairing_is_coherent(), _publisher_main(), dt_dev_backbuf_get_hash(), dt_dev_set_backbuf(), height, HUNT_MICROSECONDS, p, SHAPE_A_H, SHAPE_A_HASH, SHAPE_A_W, state, void(), and width.
Referenced by main().
A single-field setter must publish coherently too – the histogram backbuffers are invalidated that way when a view leaves.
Definition at line 156 of file test_backbuf_publish.c.
References dt_dev_backbuf_set_hash(), dt_dev_backbuf_snapshot(), dt_dev_set_backbuf(), DT_PIXELPIPE_CACHE_HASH_INVALID, dt_backbuf_state_t::hash, dt_backbuf_state_t::height, SHAPE_A_H, SHAPE_A_HASH, SHAPE_A_W, state, void(), and dt_backbuf_state_t::width.
Referenced by main().
Definition at line 128 of file test_backbuf_publish.c.
References _pairing_is_coherent(), _publisher_main(), dt_dev_backbuf_snapshot(), dt_dev_set_backbuf(), dt_backbuf_state_t::hash, dt_backbuf_state_t::height, HUNT_MICROSECONDS, p, SHAPE_A_H, SHAPE_A_HASH, SHAPE_A_W, state, void(), and dt_backbuf_state_t::width.
Referenced by main().