Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
darktable.h
Go to the documentation of this file.
1/*
2 This file is part of darktable,
3 Copyright (C) 2009-2012 johannes hanika.
4 Copyright (C) 2010-2011 Henrik Andersson.
5 Copyright (C) 2010, 2012 Pascal de Bruijn.
6 Copyright (C) 2010 Richard Hughes.
7 Copyright (C) 2010-2020 Tobias Ellinghaus.
8 Copyright (C) 2011, 2014-2015 Bruce Guenter.
9 Copyright (C) 2011-2013, 2017 Ulrich Pegelow.
10 Copyright (C) 2012 Ammon Riley.
11 Copyright (C) 2012 Christian Himpel.
12 Copyright (C) 2012 Christian Tellefsen.
13 Copyright (C) 2012 James C. McPherson.
14 Copyright (C) 2012 Jean-Sébastien Pédron.
15 Copyright (C) 2012-2014 Jérémy Rosen.
16 Copyright (C) 2012 Moritz Lipp.
17 Copyright (C) 2012 Richard Wonka.
18 Copyright (C) 2012 Simon Spannagel.
19 Copyright (C) 2013, 2021 Aldric Renaudin.
20 Copyright (C) 2013, 2015, 2019-2021 Pascal Obry.
21 Copyright (C) 2013-2017 Roman Lebedev.
22 Copyright (C) 2014-2015 Pedro Côrte-Real.
23 Copyright (C) 2015 Matthias Gehre.
24 Copyright (C) 2016-2019 Peter Budai.
25 Copyright (C) 2016 Stuart Henderson.
26 Copyright (C) 2018-2020, 2022-2026 Aurélien PIERRE.
27 Copyright (C) 2018-2019 Edgardo Hoszowski.
28 Copyright (C) 2018 parafin.
29 Copyright (C) 2018 rawfiner.
30 Copyright (C) 2019-2020 Andreas Schneider.
31 Copyright (C) 2019-2022 Hanno Schwalm.
32 Copyright (C) 2019 Heiko Bauke.
33 Copyright (C) 2020 David-Tillmann Schaefer.
34 Copyright (C) 2020-2021 Diederik Ter Rahe.
35 Copyright (C) 2020-2021 Hubert Kowalski.
36 Copyright (C) 2020-2021 Ralf Brown.
37 Copyright (C) 2021 Hubert Figuière.
38 Copyright (C) 2021 Paolo DePetrillo.
39 Copyright (C) 2021 Robert Bridge.
40 Copyright (C) 2021 Roman Khatko.
41 Copyright (C) 2022 Martin Bařinka.
42 Copyright (C) 2022 Philippe Weyland.
43 Copyright (C) 2023-2025 Alynx Zhou.
44 Copyright (C) 2023 lologor.
45 Copyright (C) 2023 Luca Zulberti.
46
47 darktable is free software: you can redistribute it and/or modify
48 it under the terms of the GNU General Public License as published by
49 the Free Software Foundation, either version 3 of the License, or
50 (at your option) any later version.
51
52 darktable is distributed in the hope that it will be useful,
53 but WITHOUT ANY WARRANTY; without even the implied warranty of
54 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55 GNU General Public License for more details.
56
57 You should have received a copy of the GNU General Public License
58 along with darktable. If not, see <http://www.gnu.org/licenses/>.
59*/
60
61#pragma once
62
63// just to be sure. the build system should set this for us already:
64#if defined __DragonFly__ || defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__
65#define _WITH_DPRINTF
66#define _WITH_GETLINE
67#elif !defined _XOPEN_SOURCE && !defined _WIN32
68#define _XOPEN_SOURCE 700 // for localtime_r and dprintf
69#endif
70
71// needs to be defined before any system header includes for control/conf.h to work in C++ code
72#define __STDC_FORMAT_MACROS
73
74#if !defined(O_BINARY)
75// To have portable g_open() on *nix and on Windows
76#define O_BINARY 0
77#endif
78
79#include "external/ThreadSafetyAnalysis.h"
80
81#ifdef HAVE_CONFIG_H
82#include "config.h"
83#endif
84#include "common/database.h"
85#include "common/dtpthread.h"
86#include "common/utility.h"
87#ifdef _WIN32
88#include "win/getrusage.h"
89#else
90#include <sys/resource.h>
91#endif
92#include <stdint.h>
93#include <glib.h>
94#include <glib/gstdio.h>
95#include <glib/gi18n.h>
96#include <inttypes.h>
97#include <json-glib/json-glib.h>
98#include <lua/lua.h>
99#include <math.h>
100#include <sqlite3.h>
101#include <stdio.h>
102#include <sys/time.h>
103#include <sys/types.h>
104#include <unistd.h>
105
106#ifndef _RELEASE
107#include "common/poison.h"
108#endif
109
111
112// for signal debugging symbols
113#include "control/signal.h"
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118
119#define DT_MODULE_VERSION 23 // version of dt's module interface
120
121// version of current performance configuration version
122// if you want to run an updated version of the performance configuration later
123// bump this number and make sure you have an updated logic in dt_configure_performance()
124#define DT_CURRENT_PERFORMANCE_CONFIGURE_VERSION 11
125#define DT_PERF_INFOSIZE 4096
126
127// every module has to define this:
128#ifdef _DEBUG
129#define DT_MODULE(MODVER) \
130 int dt_module_dt_version() \
131 { \
132 return -DT_MODULE_VERSION; \
133 } \
134 int dt_module_mod_version() \
135 { \
136 return MODVER; \
137 }
138#else
139#define DT_MODULE(MODVER) \
140 int dt_module_dt_version() \
141 { \
142 return DT_MODULE_VERSION; \
143 } \
144 int dt_module_mod_version() \
145 { \
146 return MODVER; \
147 }
148#endif
149
150#define DT_MODULE_INTROSPECTION(MODVER, PARAMSTYPE) DT_MODULE(MODVER)
151
152// ..to be able to compare it against this:
153static inline int dt_version()
154{
155#ifdef _DEBUG
156 return -DT_MODULE_VERSION;
157#else
158 return DT_MODULE_VERSION;
159#endif
160}
161
162// returns the darktable version as <major>.<minor>
164
165#undef STR_HELPER
166#define STR_HELPER(x) #x
167
168#undef STR
169#define STR(x) STR_HELPER(x)
170
171#define DT_IMAGE_DBLOCKS 64
172
173// When included by a C++ file, restrict qualifiers are not allowed
174#ifdef __cplusplus
175#define DT_RESTRICT
176#else
177#define DT_RESTRICT restrict
178#endif
179
180// Default code for imgid meaning the picture is unknown or invalid
181#define UNKNOWN_IMAGE -1
182
183#ifdef __cplusplus
184}
185#endif
186
187/********************************* */
188
195#if defined _WIN32
196#include "win/win.h"
197#endif
198
199#ifdef __APPLE__
200#include <mach/mach.h>
201#include <sys/sysctl.h>
202#endif
203
204#if defined(__DragonFly__) || defined(__FreeBSD__)
205typedef unsigned int u_int;
206#include <sys/sysctl.h>
207#include <sys/types.h>
208#endif
209#if defined(__NetBSD__) || defined(__OpenBSD__)
210#include <sys/param.h>
211#include <sys/sysctl.h>
212#endif
213
214#if defined(__aarch64__)
215#include <arm_neon.h>
216#endif
217
218#if defined(__SSE__)
219#include <xmmintrin.h> // needed for _mm_stream_ps
220#endif
221
222#ifdef _OPENMP
223# include <omp.h>
224
225/* See https://redmine.darktable.org/issues/12568#note-14 */
226# ifdef HAVE_OMP_FIRSTPRIVATE_WITH_CONST
227 /* If the compiler correctly supports firstprivate, use it. */
228# define dt_omp_firstprivate(...) firstprivate(__VA_ARGS__)
229# else /* HAVE_OMP_FIRSTPRIVATE_WITH_CONST */
230 /* This is needed for clang < 7.0 */
231# define dt_omp_firstprivate(...)
232# endif/* HAVE_OMP_FIRSTPRIVATE_WITH_CONST */
233
234#ifndef dt_omp_sharedconst
235#ifdef _OPENMP
236#if defined(__clang__) || __GNUC__ > 8
237# define dt_omp_sharedconst(...) shared(__VA_ARGS__)
238#else
239 // GCC 8.4 throws string of errors "'x' is predetermined 'shared' for 'shared'" if we explicitly declare
240 // 'const' variables as shared
241# define dt_omp_sharedconst(var, ...)
242#endif
243#endif /* _OPENMP */
244#endif /* dt_omp_sharedconst */
245
246#ifndef dt_omp_nontemporal
247// Clang 10+ supports the nontemporal() OpenMP directive
248// GCC 9 recognizes it as valid, but does not do anything with it
249// GCC 10+ ???
250#if (__clang__+0 >= 10 || __GNUC__ >= 9)
251# define dt_omp_nontemporal(...) nontemporal(__VA_ARGS__)
252#else
253// GCC7/8 only support OpenMP 4.5, which does not have the nontemporal() directive.
254# define dt_omp_nontemporal(var, ...)
255#endif
256#endif /* dt_omp_nontemporal */
257
258#else /* _OPENMP */
259
260# define omp_get_max_threads() 1
261# define omp_get_thread_num() 0
262
263#endif /* _OPENMP */
264
265#ifdef __cplusplus
266extern "C" {
267#endif
268
269static inline int dt_get_thread_num()
270{
271#ifdef _OPENMP
272 return omp_get_thread_num();
273#else
274 return 0;
275#endif
276}
277
278/* Create cloned functions for various CPU SSE generations */
279/* See for instructions https://hannes.hauswedell.net/post/2017/12/09/fmv/ */
280/* TL;DR : use only on SIMD functions containing low-level paralellized/vectorized loops */
281#if __has_attribute(target_clones) && !defined(_WIN32) && !defined(__APPLE__) && !defined(NATIVE_ARCH)
282 # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
283 #define __DT_CLONE_TARGETS__ __attribute__((target_clones("default", "sse2", "avx", "avx2")))
284 # elif defined(__PPC64__)
285 /* __PPC64__ is the only macro tested for in is_supported_platform.h, other macros would fail there anyway. */
286 #define __DT_CLONE_TARGETS__ __attribute__((target_clones("default","cpu=power9")))
287 # else
288 #define __DT_CLONE_TARGETS__
289 # endif
290#else
291 #define __DT_CLONE_TARGETS__
292#endif
293
294/* Helper to force stack vectors to be aligned on DT_CACHELINE_BYTES blocks to enable AVX2 */
295#define DT_IS_ALIGNED(x) __builtin_assume_aligned(x, DT_CACHELINE_BYTES)
296
297// Configure the size of a CPU cacheline in bytes, floats, and pixels. On most current architectures,
298// a cacheline contains 64 bytes, but Apple Silicon (M-series processors) uses 128-byte cache lines.
299#if defined(__APPLE__) && defined(__aarch64__)
300 #define DT_CACHELINE_BYTES 128
301 #define DT_CACHELINE_FLOATS 32
302 #define DT_CACHELINE_PIXELS 8
303#else
304 #define DT_CACHELINE_BYTES 64
305 #define DT_CACHELINE_FLOATS 16
306 #define DT_CACHELINE_PIXELS 4
307#endif /* __APPLE__ && __aarch64__ */
308
309// Helper to force heap vectors to be aligned on 64 byte blocks to enable AVX2
310// If this is applied to a struct member and the struct is allocated on the heap, then it must be allocated
311// on a 64 byte boundary to avoid crashes or undefined behavior because of unaligned memory access.
312#define DT_ALIGNED_ARRAY __attribute__((aligned(DT_CACHELINE_BYTES)))
313#define DT_ALIGNED_PIXEL __attribute__((aligned(16)))
314
315
316static inline gboolean dt_is_aligned(const void *pointer, size_t byte_count)
317{
318 return (uintptr_t)pointer % byte_count == 0;
319}
320
321static inline size_t dt_round_size(const size_t size, const size_t alignment)
322{
323 // Round the size of a buffer to the closest higher multiple
324 return ((size % alignment) == 0) ? size : ((size - 1) / alignment + 1) * alignment;
325}
326
327static inline size_t dt_round_size_sse(const size_t size)
328{
329 // Round the size of a buffer to the closest 64 higher multiple
330 return dt_round_size(size, 64);
331}
332
333static inline void *dt_alloc_align_internal(size_t size)
334{
335 const size_t alignment = DT_CACHELINE_BYTES;
336 const size_t aligned_size = dt_round_size(size, alignment);
337#if defined(__FreeBSD_version) && __FreeBSD_version < 700013
338 return malloc(aligned_size);
339#elif defined(_WIN32)
340 return _aligned_malloc(aligned_size, alignment);
341#else
342 void *ptr = NULL;
343 if(posix_memalign(&ptr, alignment, aligned_size)) return NULL;
344 return ptr;
345#endif
346}
347
348void *dt_alloc_align(size_t size);
349
351
352#define DT_STRINGIFY_HELPER(x) #x
353#define DT_STRINGIFY(x) DT_STRINGIFY_HELPER(x)
354
356 const char *name);
357#define dt_pixelpipe_cache_alloc_align_cache(size, id) \
358 dt_pixelpipe_cache_alloc_align_cache_impl(darktable.pixelpipe_cache, (size), (id), __FILE__ ":" DT_STRINGIFY(__LINE__))
359
360#ifndef dt_pixelpipe_cache_alloc_align
361#define dt_pixelpipe_cache_alloc_align(size, pipe) \
362 dt_pixelpipe_cache_alloc_align_cache((size), (pipe)->type)
363#endif
364
365#ifndef dt_pixelpipe_cache_alloc_align_float
366#define dt_pixelpipe_cache_alloc_align_float(pixels, pipe) \
367 ((float *)dt_pixelpipe_cache_alloc_align((size_t)(pixels) * sizeof(float), (pipe)))
368#endif
369
370#ifndef dt_pixelpipe_cache_alloc_align_float_cache
371#define dt_pixelpipe_cache_alloc_align_float_cache(pixels, id) \
372 ((float *)dt_pixelpipe_cache_alloc_align_cache((size_t)(pixels) * sizeof(float), (id)))
373#endif
374
375void dt_pixelpipe_cache_free_align_cache(struct dt_dev_pixelpipe_cache_t *cache, void **mem, const char *message);
376
377#define dt_pixelpipe_cache_free_align(mem) \
378 dt_pixelpipe_cache_free_align_cache(darktable.pixelpipe_cache, (void **)&(mem), __FILE__ ":" DT_STRINGIFY(__LINE__));
379
380#define dt_free(ptr) \
381 do \
382 { \
383 g_free((void *)(ptr)); \
384 *(void **)(&(ptr)) = NULL; \
385 } while(0)
386
387static inline void dt_free_gpointer(gpointer ptr)
388{
389 g_free(ptr);
390 ptr = NULL;
391}
392
393#ifdef _WIN32
394 static inline void dt_free_align_ptr(void *mem)
395 {
396 _aligned_free(mem);
397 }
398#else
399 static inline void dt_free_align_ptr(void *mem)
400 {
401 dt_free(mem);
402 }
403#endif
404
405#define dt_free_align(ptr) \
406 do \
407 { \
408 dt_free_align_ptr((void *)(ptr)); \
409 *(void **)(&(ptr)) = NULL; \
410 } while(0)
411
412static inline void* dt_calloc_align(size_t size)
413{
414 void *buf = dt_alloc_align(size);
415 if(buf) memset(buf, 0, size);
416 return buf;
417}
418static inline float *dt_alloc_align_float(size_t pixels)
419{
420 return (float*)__builtin_assume_aligned(dt_alloc_align(pixels * sizeof(float)), DT_CACHELINE_BYTES);
421}
422static inline float *dt_calloc_align_float(size_t pixels)
423{
424 float *const buf = (float*)dt_alloc_align(pixels * sizeof(float));
425 if(buf) memset(buf, 0, pixels * sizeof(float));
426 return (float*)__builtin_assume_aligned(buf, DT_CACHELINE_BYTES);
427}
428static inline void * dt_check_sse_aligned(void * pointer)
429{
431 return __builtin_assume_aligned(pointer, DT_CACHELINE_BYTES);
432 else
433 return NULL;
434}
435
436// Most code in dt assumes that the compiler is capable of auto-vectorization. In some cases, this will yield
437// suboptimal code if the compiler in fact does NOT auto-vectorize. Uncomment the following line for such a
438// compiler.
439//#define DT_NO_VECTORIZATION
440
441// For some combinations of compiler and architecture, the compiler may actually emit inferior code if given
442// a hint to vectorize a loop. Uncomment the following line if such a combination is the compilation target.
443//#define DT_NO_SIMD_HINTS
444
445// utility type to ease declaration of aligned small arrays to hold a pixel (and document their purpose)
446typedef DT_ALIGNED_PIXEL float dt_aligned_pixel_t[4];
447// SIMD view matching dt_aligned_pixel_t layout, for explicit 4-float vector math.
448typedef float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)));
449
450static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t dt_simd_set1(const float value)
451{
452 return (dt_aligned_pixel_simd_t){ value, value, value, value };
453}
454
455static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
456dt_simd_abs(const dt_aligned_pixel_simd_t value)
457{
458 dt_aligned_pixel_simd_t out = value;
459 for(int c = 0; c < 4; c++)
460 out[c] = fabsf(value[c]);
461 return out;
462}
463
464static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
465dt_simd_max_zero(const dt_aligned_pixel_simd_t value)
466{
467 dt_aligned_pixel_simd_t out = value;
468 for(int c = 0; c < 4; c++)
469 out[c] = MAX(value[c], 0.0f);
470 return out;
471}
472
473static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
474dt_simd_copysign(const dt_aligned_pixel_simd_t magnitude, const dt_aligned_pixel_simd_t sign)
475{
476 dt_aligned_pixel_simd_t out = magnitude;
477 for(int c = 0; c < 4; c++)
478 out[c] = copysignf(magnitude[c], sign[c]);
479 return out;
480}
481
482static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
483dt_simd_pow(const dt_aligned_pixel_simd_t base, const dt_aligned_pixel_simd_t exponent)
484{
485 dt_aligned_pixel_simd_t out = base;
486 for(int c = 0; c < 4; c++)
487 out[c] = powf(base[c], exponent[c]);
488 return out;
489}
490
491static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
492dt_load_simd(const float *const pixel)
493{
494 dt_aligned_pixel_simd_t out;
495 __builtin_memcpy(&out, pixel, sizeof(out));
496 return out;
497}
498
499static inline __attribute__((always_inline)) void
500dt_store_simd(float *const pixel, const dt_aligned_pixel_simd_t value)
501{
502 __builtin_memcpy(pixel, &value, sizeof(value));
503}
504
505static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
506dt_load_simd_aligned(const float *const pixel)
507{
508 const float *const in = (const float *const)__builtin_assume_aligned(pixel, 16);
509 return dt_load_simd(in);
510}
511
512static inline __attribute__((always_inline)) void
513dt_store_simd_aligned(float *const pixel, const dt_aligned_pixel_simd_t value)
514{
515 float *const out = (float *const)__builtin_assume_aligned(pixel, 16);
517}
518
519static inline __attribute__((always_inline)) void
520dt_store_simd_nontemporal(float *const pixel, const dt_aligned_pixel_simd_t value)
521{
522 float *const out = (float *const)__builtin_assume_aligned(pixel, 16);
523
524#if defined(__SSE__)
525 const union
526 {
527 dt_aligned_pixel_simd_t simd;
528 __m128 sse;
529 } cast = { .simd = value };
530 _mm_stream_ps(out, cast.sse);
531#elif defined(__aarch64__)
532 const union
533 {
534 dt_aligned_pixel_simd_t simd;
535 float32x4_t neon;
536 } cast = { .simd = value };
537 vst1q_f32(out, cast.neon);
538#elif (__clang__+0 > 7) && (__clang__+0 < 10)
539 for_each_channel(k,aligned(out:16)) __builtin_nontemporal_store(value[k], out[k]);
540#else
541 for_each_channel(k,aligned(out:16) dt_omp_nontemporal(out)) out[k] = value[k];
542#endif
543}
544
545static inline __attribute__((always_inline)) dt_aligned_pixel_simd_t
546dt_mat3x4_mul_vec4(const dt_aligned_pixel_simd_t in, const dt_aligned_pixel_simd_t row0,
547 const dt_aligned_pixel_simd_t row1, const dt_aligned_pixel_simd_t row2)
548{
549 return row0 * in[0] + row1 * in[1] + row2 * in[2];
550}
551
552// To be able to vectorize per-pixel loops, we need to operate on all four channels, but if the compiler does
553// not auto-vectorize, doing so increases computation by 1/3 for a channel which typically is ignored anyway.
554// Select the appropriate number of channels over which to loop to produce the fastest code.
555#ifdef DT_NO_VECTORIZATION
556#define DT_PIXEL_SIMD_CHANNELS 3
557#else
558#define DT_PIXEL_SIMD_CHANNELS 4
559#endif
560
561// A macro which gives us a configurable shorthand to produce the optimal performance when processing all of the
562// channels in a pixel. Its first argument is the name of the variable to be used inside the 'for' loop it creates,
563// while the optional second argument is a set of OpenMP directives, typically specifying variable alignment.
564// If indexing off of the begining of any buffer allocated with dt's image or aligned allocation functions, the
565// alignment to specify is 64; otherwise, use 16, as there may have been an odd number of pixels from the start.
566// Sample usage:
567// for_each_channel(k,aligned(src,dest:16))
568// {
569// src[k] = dest[k] / 3.0f;
570// }
571#if defined(_OPENMP) && defined(OPENMP_SIMD_) && !defined(DT_NO_SIMD_HINTS)
572//https://stackoverflow.com/questions/45762357/how-to-concatenate-strings-in-the-arguments-of-pragma
573#define _DT_Pragma_(x) _Pragma(#x)
574#define _DT_Pragma(x) _DT_Pragma_(x)
575#define for_each_channel(_var, ...) \
576 _DT_Pragma(omp simd __VA_ARGS__) \
577 for (size_t _var = 0; _var < DT_PIXEL_SIMD_CHANNELS; _var++)
578#define for_four_channels(_var, ...) \
579 _DT_Pragma(omp simd __VA_ARGS__) \
580 for (size_t _var = 0; _var < 4; _var++)
581#else
582#define for_each_channel(_var, ...) \
583 for (size_t _var = 0; _var < DT_PIXEL_SIMD_CHANNELS; _var++)
584#define for_four_channels(_var, ...) \
585 for (size_t _var = 0; _var < 4; _var++)
586#endif
587
588
589// copy the RGB channels of a pixel using nontemporal stores if
590// possible; includes the 'alpha' channel as well if faster due to
591// vectorization, but subsequent code should ignore the value of the
592// alpha unless explicitly set afterwards (since it might not have
593// been copied). NOTE: nontemporal stores will actually be *slower*
594// if we immediately access the pixel again. This function should
595// only be used when processing an entire image before doing anything
596// else with the destination buffer.
597static inline void copy_pixel_nontemporal(
598 float *const __restrict__ out,
599 const float *const __restrict__ in)
600{
601 dt_store_simd_nontemporal(out, dt_load_simd(in));
602}
603
604
605// copy the RGB channels of a pixel; includes the 'alpha' channel as well if faster due to vectorization, but
606// subsequent code should ignore the value of the alpha unless explicitly set afterwards (since it might not have
607// been copied)
608static inline void copy_pixel(float *const __restrict__ out, const float *const __restrict__ in)
609{
610 for_each_channel(k,aligned(in,out:16)) out[k] = in[k];
611}
612
613
614/********************************* */
615
616struct dt_gui_gtk_t;
617struct dt_control_t;
618struct dt_develop_t;
619struct dt_mipmap_cache_t;
620struct dt_image_cache_t;
621struct dt_lib_t;
622struct dt_conf_t;
623struct dt_points_t;
624struct dt_imageio_t;
625struct dt_bauhaus_t;
626struct dt_undo_t;
627struct dt_colorspaces_t;
628struct dt_l10n_t;
629
630typedef float dt_boundingbox_t[4]; //(x,y) of upperleft, then (x,y) of lowerright
631
633{
634 DT_DEBUG_ALWAYS = 0, // always print regardless of debug flags
635 // powers of two, masking
638 DT_DEBUG_DEV = 1 << 2,
643 DT_DEBUG_SQL = 1 << 8,
646 DT_DEBUG_NAN = 1 << 11,
647 DT_DEBUG_MASKS = 1 << 12,
648 DT_DEBUG_LUA = 1 << 13,
649 DT_DEBUG_INPUT = 1 << 14,
650 DT_DEBUG_PRINT = 1 << 15,
654 DT_DEBUG_UNDO = 1 << 19,
661 DT_DEBUG_PIPE = 1 << 26,
665 DT_DEBUG_NOCACHE_REUSE = 1 << 30
667
668typedef struct dt_codepath_t
669{
670 unsigned int SSE2 : 1;
671 unsigned int _no_intrinsics : 1;
672 unsigned int OPENMP_SIMD : 1; // always stays the last one
674
675typedef struct dt_sys_resources_t
676{
677 size_t total_memory; // All RAM on system
678 size_t mipmap_memory; // RAM allocated to mipmap cache
679 size_t headroom_memory; // RAM left to OS & other Apps
680 size_t pixelpipe_memory; // RAM used by the pixelpipe cache (approx.)
682
683typedef struct darktable_t
684{
687
688 int32_t unmuted;
689 GList *iop;
692
693 // Keep track of optional features that may depend on environnement
694 // ond compiling options : OpenCL, libsecret, kwallet
699 struct dt_lib_t *lib;
707 const struct dt_database_t *db;
719
720 // Protects from concurrent writing at export time
721 dt_pthread_mutex_t plugin_threadsafe;
722
723 // Protect appending/removing GList links to the darktable.capabilities list
724 dt_pthread_mutex_t capabilities_threadsafe;
725
726 // Exiv2 readMetadata() was not thread-safe prior to 0.27
727 // FIXME: Is it now ?
728 dt_pthread_mutex_t exiv2_threadsafe;
729
730 // RawSpeed readFile() method is apparently not thread-safe
731 dt_pthread_mutex_t readFile_mutex;
732
733 // Prevent concurrent export/thumbnail pipelines from runnnig at the same time
734 // It brings no additional performance since the CPU is our bottleneck,
735 // and CPU pixel code is already multi-threaded internally through OpenMP
736 dt_pthread_mutex_t pipeline_threadsafe;
737
738 // Building SQL transactions through `dt_database_start_transaction_debug()`
739 // from "too many" threads (like loading all thumbnails from a new collection)
740 // leads to SQL error:
741 // `BEGIN": cannot start a transaction within a transaction`
742 // Also, we need to ensure that image metadata/history reads & writes
743 // happen each in their all time, from all pipeline jobs/threads.
745
746 char *progname;
747 char *datadir;
748 char *sharedir;
751 char *tmpdir;
753 char *cachedir;
756 GList *guides;
758 GList *themes;
761 GTimeZone *utc_tz;
762 GDateTime *origin_gdt;
764
765 // Working message displayed over the main preview when working
768
769typedef struct
770{
771 double clock;
772 double user;
773} dt_times_t;
774
776
777int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load_data, lua_State *L);
778void dt_cleanup();
779void dt_print(dt_debug_thread_t thread, const char *msg, ...) __attribute__((format(printf, 2, 3)));
780/* same as above but without time stamp : nts = no time stamp */
781void dt_print_nts(dt_debug_thread_t thread, const char *msg, ...) __attribute__((format(printf, 2, 3)));
782/* same as above but requires additional DT_DEBUG_VERBOSE flag to be true */
783void dt_vprint(dt_debug_thread_t thread, const char *msg, ...) __attribute__((format(printf, 2, 3)));
784
785// Number of workers, on top of reserved workers (1 for main preview, 1 for thumbnail in darkroom)
786// This is currently set to 2, so 4 workers total, without user config.
787// Workers will process a queue of jobs that they share together (except for reserved ones).
788// It is useless to use more than 2 workers
789// since those jobs very often lock some mutex that prevents concurrent running.
790// All jobs finding an idle worker will "start" immediately, as far as the OS knows from outside the program,
791// but may do nothing internally except for waiting a mutex locked by another worker/thread.
792// In that situation, we loose the ability to flush the queue, since jobs are "running".
793// So it's better to have few workers with long queues, rather
794// than many workers, to be able to control queued jobs.
796
797// Get the remaining memory available for pipeline allocations,
798// once we subtracted caches memory and headroom from system memory
799size_t dt_get_available_mem();
800
801// Get the maximum size of allocation of a single image buffer
803
804// Get the maximum size for the whole mipmap cache
805size_t dt_get_mipmap_mem();
806
813static inline void memset_zero(void *const buffer, size_t size)
814{
815 // Same as memset_s in C11. memset might be optimized away by compilers, this will not.
816 // Not parallelized or vectorized since it's applied only on "small" tiles.
817 for(size_t k = 0; k < size / sizeof(unsigned char); k++) {
818 unsigned char *const item = (unsigned char *const)buffer + k;
819 *item = 0;
820 }
821}
822
823// check whether the specified mask of modifier keys exactly matches, among the set Shift+Control+(Alt/Meta).
824// ignores the state of any other shifting keys
825static inline gboolean dt_modifier_is(const GdkModifierType state, const GdkModifierType desired_modifier_mask)
826{
827 const GdkModifierType modifiers = gtk_accelerator_get_default_mod_mask();
828//TODO: on Macs, remap the GDK_CONTROL_MASK bit in desired_modifier_mask to be the bit for the Cmd key
829 return (state & modifiers) == desired_modifier_mask;
830}
831
832// check whether the given modifier state includes AT LEAST the specified mask of modifier keys
833static inline gboolean dt_modifiers_include(const GdkModifierType state, const GdkModifierType desired_modifier_mask)
834{
835//TODO: on Macs, remap the GDK_CONTROL_MASK bit in desired_modifier_mask to be the bit for the Cmd key
836 const GdkModifierType modifiers = gtk_accelerator_get_default_mod_mask();
837 // check whether all modifier bits of interest are turned on
838 return (state & (modifiers & desired_modifier_mask)) == desired_modifier_mask;
839}
840
841int dt_capabilities_check(char *capability);
842void dt_capabilities_add(char *capability);
843void dt_capabilities_remove(char *capability);
845
846static inline double dt_get_wtime(void)
847{
848 struct timeval time;
849 gettimeofday(&time, NULL);
850 return time.tv_sec - 1290608000 + (1.0 / 1000000.0) * time.tv_usec;
851}
852
853static inline void dt_get_times(dt_times_t *t)
854{
855 struct rusage ru;
856
858 t->clock = dt_get_wtime();
859 t->user = ru.ru_utime.tv_sec + ru.ru_utime.tv_usec * (1.0 / 1000000.0);
860}
861
862void dt_show_times(const dt_times_t *start, const char *prefix);
863
864void dt_show_times_f(const dt_times_t *start, const char *prefix, const char *suffix, ...) __attribute__((format(printf, 3, 4)));
865
867gboolean dt_supported_image(const gchar *filename);
868
869// a few macros and helper functions to speed up certain frequently-used GLib operations
870#define g_list_is_singleton(list) ((list) && (!(list)->next))
871static inline gboolean g_list_shorter_than(const GList *list, unsigned len)
872{
873 // instead of scanning the full list to compute its length and then comparing against the limit,
874 // bail out as soon as the limit is reached. Usage: g_list_shorter_than(l,4) instead of g_list_length(l)<4
875 while (len-- > 0)
876 {
877 if (!list) return TRUE;
878 list = g_list_next(list);
879 }
880 return FALSE;
881}
882
883// advance the list by one position, unless already at the final node
884static inline GList *g_list_next_bounded(GList *list)
885{
886 return g_list_next(list) ? g_list_next(list) : list;
887}
888
889static inline const GList *g_list_next_wraparound(const GList *list, const GList *head)
890{
891 return g_list_next(list) ? g_list_next(list) : head;
892}
893
894static inline const GList *g_list_prev_wraparound(const GList *list)
895{
896 // return the prior element of the list, unless already on the first element; in that case, return the last
897 // element of the list.
898 return g_list_previous(list) ? g_list_previous(list) : g_list_last((GList*)list);
899}
900
901void dt_print_mem_usage();
902
903void dt_configure_runtime_performance(dt_sys_resources_t *resources, gboolean init_gui);
904
905// helper function which loads whatever image_to_load points to: single image files or whole directories
906// it tells you if it was a single image or a directory in single_image (when it's not NULL)
907int dt_load_from_string(const gchar *image_to_load, gboolean open_image_in_dr, gboolean *single_image);
908
909#define dt_unreachable_codepath_with_desc(D) \
910 dt_unreachable_codepath_with_caller(D, __FILE__, __LINE__, __FUNCTION__)
911#define dt_unreachable_codepath() dt_unreachable_codepath_with_caller("unreachable", __FILE__, __LINE__, __FUNCTION__)
912static inline void dt_unreachable_codepath_with_caller(const char *description, const char *file,
913 const int line, const char *function)
914{
915 fprintf(stderr, "[dt_unreachable_codepath] {%s} %s:%d (%s) - we should not be here. please report this to "
916 "the developers.",
917 description, file, line, function);
918 __builtin_unreachable();
919}
920
921// Allocate a buffer for 'n' objects each of size 'objsize' bytes for each of the program's threads.
922// Ensures that there is no false sharing among threads by aligning and rounding up the allocation to
923// a multiple of the cache line size. Returns a pointer to the allocated pool and the adjusted number
924// of objects in each thread's buffer. Use dt_get_perthread or dt_get_bythread (see below) to access
925// a specific thread's buffer.
926static inline void *dt_pixelpipe_cache_alloc_perthread_impl(const size_t n, const size_t objsize, size_t* padded_size, const char *message)
927{
928 const size_t alloc_size = n * objsize;
929 const size_t cache_lines = (alloc_size + DT_CACHELINE_BYTES - 1) / DT_CACHELINE_BYTES;
930 *padded_size = DT_CACHELINE_BYTES * cache_lines / objsize;
931 const size_t total_bytes = DT_CACHELINE_BYTES * cache_lines * darktable.num_openmp_threads;
932 void *buf = dt_pixelpipe_cache_alloc_align_cache_impl(darktable.pixelpipe_cache, total_bytes, 0, message);
933 if(!buf) return NULL;
934 return __builtin_assume_aligned(buf, DT_CACHELINE_BYTES);
935}
936
937#ifndef dt_pixelpipe_cache_alloc_perthread
938#define dt_pixelpipe_cache_alloc_perthread(n, objsize, padded_size) \
939 ((void *)dt_pixelpipe_cache_alloc_perthread_impl((n), (objsize), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
940#endif
941
942static inline void *dt_pixelpipe_cache_calloc_perthread_impl(const size_t n, const size_t objsize, size_t* padded_size, const char *message)
943{
944 void *const buf = (float*)dt_pixelpipe_cache_alloc_perthread_impl(n, objsize, padded_size, message);
945 if(!buf) return NULL;
946 memset(buf, 0, *padded_size * darktable.num_openmp_threads * objsize);
947 return buf;
948}
949
950#ifndef dt_pixelpipe_cache_calloc_perthread
951#define dt_pixelpipe_cache_calloc_perthread(n, objsize, padded_size) \
952 ((void *)dt_pixelpipe_cache_calloc_perthread_impl((n), (objsize), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
953#endif
954
955// Same as dt_pixelpipe_cache_alloc_perthread, but the object is a float.
956static inline float *dt_pixelpipe_cache_alloc_perthread_float_impl(const size_t n, size_t* padded_size, const char *message)
957{
958 return (float*)dt_pixelpipe_cache_alloc_perthread_impl(n, sizeof(float), padded_size, message);
959}
960
961#ifndef dt_pixelpipe_cache_alloc_perthread_float
962#define dt_pixelpipe_cache_alloc_perthread_float(n, padded_size) \
963 ((float *)dt_pixelpipe_cache_alloc_perthread_float_impl((n), (padded_size), __FILE__ ":" DT_STRINGIFY(__LINE__)))
964#endif
965
966// Given the buffer and object count returned by dt_pixelpipe_cache_alloc_perthread, return the current thread's private buffer.
967#define dt_get_perthread(buf, padsize) DT_IS_ALIGNED((buf) + ((padsize) * dt_get_thread_num()))
968// Given the buffer and object count returned by dt_pixelpipe_cache_alloc_perthread and a thread count in 0..darktable.num_openmp_threads,
969// return a pointer to the indicated thread's private buffer.
970#define dt_get_bythread(buf, padsize, tnum) DT_IS_ALIGNED((buf) + ((padsize) * (tnum)))
971
972// Scramble bits in str to create an (hopefully) unique hash representing the state of str
973// Dan Bernstein algo v2 http://www.cse.yorku.ca/~oz/hash.html
974// hash should be inited to 5381 if first run, or from a previous hash computed with this function.
975static inline uint64_t dt_hash(uint64_t hash, const char *str, size_t size)
976{
977 for(size_t i = 0; i < size; i++)
978 hash = ((hash << 5) + hash) ^ str[i];
979
980 return hash;
981}
982
984#define DT_MAX_FILENAME_LEN 256
985
986#ifndef PATH_MAX
987/*
988 * from /usr/include/linux/limits.h (Linux 3.16.5)
989 * Some systems might not define it (e.g. Hurd)
990 *
991 * We do NOT depend on any specific value of this env variable.
992 * If you want constant value across all systems, use DT_MAX_PATH_FOR_PARAMS!
993 */
994#define PATH_MAX 4096
995#endif
996
997/*
998 * ONLY TO BE USED FOR PARAMS!!! (e.g. dt_imageio_disk_t)
999 *
1000 * WARNING: this should *NEVER* be changed, as it will break params,
1001 * created with previous DT_MAX_PATH_FOR_PARAMS.
1002 */
1003#define DT_MAX_PATH_FOR_PARAMS 4096
1004
1005static inline gchar *dt_string_replace(const char *string, const char *to_replace)
1006{
1007 if(!string || !to_replace) return NULL;
1008 gchar **split = g_strsplit(string, to_replace, -1);
1009 gchar *text = g_strjoinv("", split);
1010 g_strfreev(split);
1011 return text;
1012}
1013
1014// Remove underscore from GUI labels containing mnemonics
1015static inline gchar *delete_underscore(const char *s)
1016{
1017 return dt_string_replace(s, "_");
1018}
1019
1027static inline gchar *strip_markup(const char *s)
1028{
1029 if(!s) return g_strdup("");
1030
1031 PangoAttrList *attrs = NULL;
1032 gchar *plain = NULL;
1033
1034 const gchar *underscore = "_";
1035 gunichar mnemonic = underscore[0];
1036 if(!pango_parse_markup(s, -1, mnemonic, &attrs, &plain, NULL, NULL))
1037 plain = delete_underscore(s);
1038
1039 pango_attr_list_unref(attrs);
1040 return plain;
1041}
1042
1043#ifdef __cplusplus
1044}
1045#endif
1046
1047// clang-format off
1048// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
1049// vim: shiftwidth=2 expandtab tabstop=2 cindent
1050// kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;
1051// clang-format on
const char ** description(struct dt_iop_module_t *self)
Definition ashift.c:159
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
return vector dt_simd_set1(valid ?(scaling+NORM_MIN) :NORM_MIN)
const float i
Definition colorspaces_inline_conversions.h:669
const float c
Definition colorspaces_inline_conversions.h:1365
const float L
Definition colorspaces_inline_conversions.h:724
const float n
Definition colorspaces_inline_conversions.h:929
dt_store_simd_aligned(out, dt_mat3x4_mul_vec4(vin, dt_colormatrix_row_to_simd(matrix, 0), dt_colormatrix_row_to_simd(matrix, 1), dt_colormatrix_row_to_simd(matrix, 2)))
return dt_load_simd_aligned(JCH)
char * name
Definition common/metadata.c:61
static const dt_aligned_pixel_simd_t const dt_aligned_pixel_simd_t row1
Definition darktable.h:547
#define DT_ALIGNED_PIXEL
Definition darktable.h:313
dt_store_simd(out, value)
static void memset_zero(void *const buffer, size_t size)
Set the memory buffer to zero as a pack of unsigned char.
Definition darktable.h:813
void dt_show_times(const dt_times_t *start, const char *prefix)
Definition darktable.c:1568
static gchar * dt_string_replace(const char *string, const char *to_replace)
Definition darktable.h:1005
static float * dt_calloc_align_float(size_t pixels)
Definition darktable.h:422
static void * dt_calloc_align(size_t size)
Definition darktable.h:412
static gboolean dt_modifiers_include(const GdkModifierType state, const GdkModifierType desired_modifier_mask)
Definition darktable.h:833
dt_debug_thread_t
Definition darktable.h:633
@ DT_DEBUG_LIGHTTABLE
Definition darktable.h:645
@ DT_DEBUG_UNDO
Definition darktable.h:654
@ DT_DEBUG_INPUT
Definition darktable.h:649
@ DT_DEBUG_PRINT
Definition darktable.h:650
@ DT_DEBUG_OPENCL
Definition darktable.h:642
@ DT_DEBUG_PIPE
Definition darktable.h:661
@ DT_DEBUG_HISTORY
Definition darktable.h:660
@ DT_DEBUG_CAMERA_SUPPORT
Definition darktable.h:651
@ DT_DEBUG_NAN
Definition darktable.h:646
@ DT_DEBUG_DEMOSAIC
Definition darktable.h:657
@ DT_DEBUG_MEMORY
Definition darktable.h:644
@ DT_DEBUG_PERF
Definition darktable.h:639
@ DT_DEBUG_VERBOSE
Definition darktable.h:663
@ DT_DEBUG_PARAMS
Definition darktable.h:656
@ DT_DEBUG_CONTROL
Definition darktable.h:637
@ DT_DEBUG_COLORPROFILE
Definition darktable.h:664
@ DT_DEBUG_CACHE
Definition darktable.h:636
@ DT_DEBUG_ALWAYS
Definition darktable.h:634
@ DT_DEBUG_SIGNAL
Definition darktable.h:655
@ DT_DEBUG_PWSTORAGE
Definition darktable.h:641
@ DT_DEBUG_SHORTCUTS
Definition darktable.h:658
@ DT_DEBUG_IMAGEIO
Definition darktable.h:653
@ DT_DEBUG_DEV
Definition darktable.h:638
@ DT_DEBUG_NOCACHE_REUSE
Definition darktable.h:665
@ DT_DEBUG_CAMCTL
Definition darktable.h:640
@ DT_DEBUG_IMPORT
Definition darktable.h:662
@ DT_DEBUG_IOPORDER
Definition darktable.h:652
@ DT_DEBUG_MASKS
Definition darktable.h:647
@ DT_DEBUG_TILING
Definition darktable.h:659
@ DT_DEBUG_SQL
Definition darktable.h:643
@ DT_DEBUG_LUA
Definition darktable.h:648
void dt_pixelpipe_cache_free_align_cache(struct dt_dev_pixelpipe_cache_t *cache, void **mem, const char *message)
Definition pixelpipe_cache.c:1172
void dt_cleanup()
Definition darktable.c:1349
void gboolean dt_supported_image(const gchar *filename)
check if file is a supported image
Definition darktable.c:266
static void copy_pixel(float *const __restrict__ out, const float *const __restrict__ in)
Definition darktable.h:608
int dt_init(int argc, char *argv[], const gboolean init_gui, const gboolean load_data, lua_State *L)
Definition darktable.c:452
static void dt_free_align_ptr(void *mem)
Definition darktable.h:399
#define for_each_channel(_var,...)
Definition darktable.h:582
float dt_boundingbox_t[4]
Definition darktable.h:630
static float * dt_alloc_align_float(size_t pixels)
Definition darktable.h:418
static size_t dt_round_size_sse(const size_t size)
Definition darktable.h:327
void void dt_print_nts(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
static void * dt_check_sse_aligned(void *pointer)
Definition darktable.h:428
static gchar * strip_markup(const char *s)
Remove Pango/Gtk markup and accels mnemonics from text labels. If the markup parsing fails,...
Definition darktable.h:1027
darktable_t darktable
Definition darktable.c:178
static void * dt_alloc_align_internal(size_t size)
Definition darktable.h:333
void dt_print_mem_usage()
Definition darktable.c:1795
static void dt_free_gpointer(gpointer ptr)
Definition darktable.h:387
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Multi-tap smudge source sample with directional jitter.
Definition darktable.h:448
static void copy_pixel_nontemporal(float *const __restrict__ out, const float *const __restrict__ in)
Definition darktable.h:597
void void void int dt_worker_threads()
Definition darktable.c:1665
static void * dt_pixelpipe_cache_alloc_perthread_impl(const size_t n, const size_t objsize, size_t *padded_size, const char *message)
Definition darktable.h:926
static const GList * g_list_next_wraparound(const GList *list, const GList *head)
Definition darktable.h:889
static const dt_aligned_pixel_simd_t sign
Definition darktable.h:475
static int dt_get_thread_num()
Definition darktable.h:269
size_t dt_get_singlebuffer_mem()
Definition darktable.c:1675
void * dt_alloc_align(size_t size)
Definition darktable.c:447
#define dt_free(ptr)
Definition darktable.h:380
void dt_capabilities_remove(char *capability)
Definition darktable.c:1778
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
static void dt_get_times(dt_times_t *t)
Definition darktable.h:853
static float * dt_pixelpipe_cache_alloc_perthread_float_impl(const size_t n, size_t *padded_size, const char *message)
Definition darktable.h:956
#define omp_get_thread_num()
Definition darktable.h:261
static const GList * g_list_prev_wraparound(const GList *list)
Definition darktable.h:894
void void void dt_vprint(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
static int dt_version()
Definition darktable.h:153
static gchar * delete_underscore(const char *s)
Definition darktable.h:1015
static uint64_t dt_hash(uint64_t hash, const char *str, size_t size)
Definition darktable.h:975
size_t dt_get_mipmap_mem()
Definition darktable.c:1681
static size_t dt_round_size(const size_t size, const size_t alignment)
Definition darktable.h:321
static void dt_unreachable_codepath_with_caller(const char *description, const char *file, const int line, const char *function)
Definition darktable.h:912
int dt_load_from_string(const gchar *image_to_load, gboolean open_image_in_dr, gboolean *single_image)
Definition darktable.c:282
#define DT_MODULE_VERSION
Definition darktable.h:119
return out
Definition darktable.h:479
static const dt_aligned_pixel_simd_t const dt_aligned_pixel_simd_t const dt_aligned_pixel_simd_t row2
Definition darktable.h:548
static GList * g_list_next_bounded(GList *list)
Definition darktable.h:884
char * dt_version_major_minor()
Definition darktable.c:235
void dt_configure_runtime_performance(dt_sys_resources_t *resources, gboolean init_gui)
Definition darktable.c:1686
static const dt_aligned_pixel_simd_t value
Definition darktable.h:501
void dt_capabilities_add(char *capability)
Definition darktable.c:1767
static double dt_get_wtime(void)
Definition darktable.h:846
static void * dt_pixelpipe_cache_calloc_perthread_impl(const size_t n, const size_t objsize, size_t *padded_size, const char *message)
Definition darktable.h:942
void dt_capabilities_cleanup()
Definition darktable.c:1788
static gboolean dt_is_aligned(const void *pointer, size_t byte_count)
Definition darktable.h:316
static const dt_aligned_pixel_simd_t exponent
Definition darktable.h:484
void * dt_pixelpipe_cache_alloc_align_cache_impl(struct dt_dev_pixelpipe_cache_t *cache, size_t size, int id, const char *name)
Definition pixelpipe_cache.c:1124
static gboolean dt_modifier_is(const GdkModifierType state, const GdkModifierType desired_modifier_mask)
Definition darktable.h:825
void dt_show_times_f(const dt_times_t *start, const char *prefix, const char *suffix,...) __attribute__((format(printf
static const dt_aligned_pixel_simd_t row0
Definition darktable.h:546
size_t dt_get_available_mem()
Definition darktable.c:1670
int dt_capabilities_check(char *capability)
Definition darktable.c:1754
#define DT_CACHELINE_BYTES
Definition darktable.h:304
static gboolean g_list_shorter_than(const GList *list, unsigned len)
Definition darktable.h:871
#define dt_pthread_rwlock_t
Definition dtpthread.h:389
int getrusage(int who, struct rusage *usage)
Definition getrusage.c:56
#define RUSAGE_SELF
Definition getrusage.h:53
const int t
Definition iop_profile.h:227
int lua_State
Definition lua.h:95
size_t size
Definition mipmap_cache.c:3
k
Definition derive_filmic_v6_gamut_mapping.py:67
@ DT_SIGNAL_COUNT
Definition signal.h:288
unsigned __int64 uint64_t
Definition strptime.c:74
Definition darktable.h:684
struct dt_dbus_t * dbus
Definition darktable.h:714
struct dt_undo_t * undo
Definition darktable.h:715
char * tmpdir
Definition darktable.h:751
dt_pthread_mutex_t readFile_mutex
Definition darktable.h:731
char * cachedir
Definition darktable.h:753
dt_codepath_t codepath
Definition darktable.h:685
struct dt_lib_t * lib
Definition darktable.h:699
int32_t unmuted_signal_dbg_acts
Definition darktable.h:759
struct dt_imageio_t * imageio
Definition darktable.h:712
struct dt_dev_pixelpipe_cache_t * pixelpipe_cache
Definition darktable.h:718
int32_t num_openmp_threads
Definition darktable.h:686
struct dt_l10n_t * l10n
Definition darktable.h:717
struct dt_gui_gtk_t * gui
Definition darktable.h:703
dt_pthread_rwlock_t database_threadsafe
Definition darktable.h:744
struct dt_colorspaces_t * color_profiles
Definition darktable.h:716
GList * capabilities
Definition darktable.h:695
GTimeZone * utc_tz
Definition darktable.h:761
char * sharedir
Definition darktable.h:748
struct dt_collection_t * collection
Definition darktable.h:709
struct dt_mipmap_cache_t * mipmap_cache
Definition darktable.h:704
struct dt_selection_t * selection
Definition darktable.h:710
GList * iop
Definition darktable.h:689
dt_pthread_mutex_t exiv2_threadsafe
Definition darktable.h:728
struct dt_sys_resources_t dtresources
Definition darktable.h:763
dt_pthread_mutex_t plugin_threadsafe
Definition darktable.h:721
dt_lua_state_t lua_state
Definition darktable.h:755
char * moduledir
Definition darktable.h:749
dt_pthread_mutex_t capabilities_threadsafe
Definition darktable.h:724
GList * iop_order_list
Definition darktable.h:690
const struct dt_database_t * db
Definition darktable.h:707
GList * iop_order_rules
Definition darktable.h:691
struct dt_control_signal_t * signals
Definition darktable.h:702
struct dt_bauhaus_t * bauhaus
Definition darktable.h:706
struct dt_opencl_t * opencl
Definition darktable.h:713
char * configdir
Definition darktable.h:752
char * datadir
Definition darktable.h:747
GList * themes
Definition darktable.h:758
int32_t unmuted
Definition darktable.h:688
struct dt_image_cache_t * image_cache
Definition darktable.h:705
struct dt_develop_t * develop
Definition darktable.h:698
struct dt_points_t * points
Definition darktable.h:711
char * localedir
Definition darktable.h:750
dt_pthread_mutex_t pipeline_threadsafe
Definition darktable.h:736
struct dt_view_manager_t * view_manager
Definition darktable.h:700
char * kerneldir
Definition darktable.h:754
JsonParser * noiseprofile_parser
Definition darktable.h:696
GList * guides
Definition darktable.h:756
gboolean unmuted_signal_dbg[DT_SIGNAL_COUNT]
Definition darktable.h:760
char * main_message
Definition darktable.h:766
char * progname
Definition darktable.h:746
struct dt_conf_t * conf
Definition darktable.h:697
GDateTime * origin_gdt
Definition darktable.h:762
const struct dt_pwstorage_t * pwstorage
Definition darktable.h:708
double start_wtime
Definition darktable.h:757
struct dt_control_t * control
Definition darktable.h:701
Definition bauhaus.h:233
Definition darktable.h:669
unsigned int OPENMP_SIMD
Definition darktable.h:672
unsigned int _no_intrinsics
Definition darktable.h:671
unsigned int SSE2
Definition darktable.h:670
Definition collection.h:169
Definition colorspaces.h:172
Definition conf.h:80
Definition signal.c:50
Definition control.h:179
Definition common/database.c:99
Definition dbus.h:30
Definition pixelpipe_cache.h:55
Definition develop.h:155
Definition gtk.h:133
Definition image_cache.h:39
Definition imageio_module.h:133
Definition l10n.h:35
Definition libs/lib.h:62
Definition lua.h:100
Definition mipmap_cache.h:93
Definition opencl.h:508
Definition points.h:51
Definition pwstorage.h:49
Definition selection.c:48
Definition darktable.h:676
size_t headroom_memory
Definition darktable.h:679
size_t total_memory
Definition darktable.h:677
size_t mipmap_memory
Definition darktable.h:678
size_t pixelpipe_memory
Definition darktable.h:680
Definition darktable.h:770
double clock
Definition darktable.h:771
double user
Definition darktable.h:772
Definition undo.h:70
Definition views/view.h:167
Definition getrusage.h:33
struct timeval ru_utime
Definition getrusage.h:34
#define MAX(a, b)
Definition thinplate.c:29