|
| 1 | +/** |
| 2 | + * @file tgx_config.h |
| 3 | + * Configuration file depending on the architecture |
| 4 | + */ |
| 5 | +// |
| 6 | +// Copyright 2020 Arvind Singh |
| 7 | +// |
| 8 | +// This library is free software; you can redistribute it and/or |
| 9 | +// modify it under the terms of the GNU Lesser General Public |
| 10 | +// License as published by the Free Software Foundation; either |
| 11 | +//version 2.1 of the License, or (at your option) any later version. |
| 12 | +// |
| 13 | +// This library is distributed in the hope that it will be useful, |
| 14 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU |
| 16 | +// Lesser General Public License for more details. |
| 17 | +// |
| 18 | +// You should have received a copy of the GNU Lesser General Public |
| 19 | +// License along with this library; If not, see <http://www.gnu.org/licenses/>. |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +// disable mtools extensions by default |
| 25 | +#ifndef MTOOLS_TGX_EXTENSIONS |
| 26 | +#define MTOOLS_TGX_EXTENSIONS 0 |
| 27 | +#endif |
| 28 | + |
| 29 | + |
| 30 | +#ifdef ARDUINO |
| 31 | + #include <Arduino.h> |
| 32 | + #define TGX_ON_ARDUINO |
| 33 | +#endif |
| 34 | + |
| 35 | +#ifndef PROGMEM |
| 36 | + #define PROGMEM |
| 37 | +#endif |
| 38 | + |
| 39 | +#ifndef FLASHMEM |
| 40 | + #define FLASHMEM |
| 41 | +#endif |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +// |
| 46 | +// Board specific optimizations. |
| 47 | +// |
| 48 | +// - TGX_PROGMEM_DEFAULT_CACHE_SIZE : size of the cache when reading from PROGMEM. Use to optimize cache read when accesing image in flash. |
| 49 | +// |
| 50 | +// - TGX_USE_FAST_INV_SQRT_TRICK : fast inverse 'quake like' square root trick to speed up computations. |
| 51 | +// - TGX_USE_FAST_SQRT_TRICK : fast 'quake like' square root trick to speed up computations. |
| 52 | +// - TGX_USE_FAST_INV_TRICK : fast inverse 'quake like' trick to speed up computations. |
| 53 | +// |
| 54 | +// - TGX_INLINE/TGX_NOINLINE : inlining strategy for time critical/non-critical functions. |
| 55 | +// |
| 56 | +#if defined(_WIN32) || defined(_WIN64) || defined(__linux__) || defined(__APPLE__) || defined(__MACH__) || defined(__ANDROID__) || defined(__unix__) |
| 57 | + // TGX is running on a computer. |
| 58 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 262144 |
| 59 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 |
| 60 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 61 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 62 | + #define TGX_INLINE |
| 63 | + #define TGX_NOINLINE |
| 64 | + |
| 65 | +#elif defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) |
| 66 | + // teensy 4.0 and 4.1 |
| 67 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 8192 |
| 68 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 69 | + #define TGX_USE_FAST_SQRT_TRICK 1 |
| 70 | + #define TGX_USE_FAST_INV_TRICK 1 |
| 71 | + #define TGX_INLINE __attribute__((always_inline)) |
| 72 | + #define TGX_NOINLINE __attribute__((noinline, noclone)) FLASHMEM |
| 73 | + |
| 74 | +#elif defined(ARDUINO_TEENSY36) |
| 75 | + // teensy 3.6 |
| 76 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048 |
| 77 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 78 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 79 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 80 | + #define TGX_INLINE __attribute__((always_inline)) |
| 81 | + #define TGX_NOINLINE |
| 82 | + |
| 83 | +#elif defined(ARDUINO_TEENSY35) |
| 84 | + // teensy 3.5 |
| 85 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048 |
| 86 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 87 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 88 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 89 | + #define TGX_INLINE __attribute__((always_inline)) |
| 90 | + #define TGX_NOINLINE |
| 91 | + |
| 92 | +#elif defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY31) |
| 93 | + // teensy 3.1 and 3.2 |
| 94 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024 |
| 95 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 96 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 97 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 98 | + #define TGX_INLINE __attribute__((always_inline)) |
| 99 | + #define TGX_NOINLINE |
| 100 | + |
| 101 | +#elif defined(ARDUINO_TEENSYLC) |
| 102 | + // teensy LC |
| 103 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 256 |
| 104 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 |
| 105 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 106 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 107 | + #define TGX_INLINE |
| 108 | + #define TGX_NOINLINE |
| 109 | + |
| 110 | +#elif defined(ARDUINO_ARCH_RP2350) || defined(PICO_RP2350) |
| 111 | + // Raspberry Pico 2350 |
| 112 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096 |
| 113 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 114 | + #define TGX_USE_FAST_SQRT_TRICK 1 |
| 115 | + #define TGX_USE_FAST_INV_TRICK 1 |
| 116 | + #define TGX_INLINE __attribute__((always_inline)) |
| 117 | + #define TGX_NOINLINE |
| 118 | + |
| 119 | +#elif defined(ARUINO_ARCH_RP2040) ||defined(PICO_RP2040) |
| 120 | + // Raspberry Pico 2040 |
| 121 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048 |
| 122 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 123 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 124 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 125 | + #define TGX_INLINE |
| 126 | + #define TGX_NOINLINE |
| 127 | + |
| 128 | +#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(ESP32S2) |
| 129 | + // ESP32 S2 |
| 130 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048 |
| 131 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 |
| 132 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 133 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 134 | + #define TGX_INLINE |
| 135 | + #define TGX_NOINLINE |
| 136 | + |
| 137 | +#elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(ESP32S3) |
| 138 | + // ESP32 S3 |
| 139 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096 |
| 140 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 // unused: specific assembly code used instead. |
| 141 | + #define TGX_USE_FAST_SQRT_TRICK 0 // |
| 142 | + #define TGX_USE_FAST_INV_TRICK 0 // |
| 143 | + #define TGX_INLINE __attribute__((always_inline)) |
| 144 | + #define TGX_NOINLINE |
| 145 | + |
| 146 | +#elif defined(CONFIG_IDF_TARGET_ESP32) || defined(ESP32) |
| 147 | + // fallback to original |
| 148 | + // nb: `ESP32` is defined for all ESP32 variants so this case should be the last |
| 149 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096 |
| 150 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 // unused: specific assembly code used instead. |
| 151 | + #define TGX_USE_FAST_SQRT_TRICK 0 // |
| 152 | + #define TGX_USE_FAST_INV_TRICK 0 // |
| 153 | + #define TGX_INLINE __attribute__((always_inline)) |
| 154 | + #define TGX_NOINLINE |
| 155 | + |
| 156 | +#elif defined(__ARM_ARCH_6M__) |
| 157 | + // generic Cortex-M0 (use same setting as Teensy LC) |
| 158 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 256 |
| 159 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 |
| 160 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 161 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 162 | + #define TGX_INLINE |
| 163 | + #define TGX_NOINLINE |
| 164 | + |
| 165 | +#elif defined(__ARM_ARCH_7M__) |
| 166 | + // generic Cortex-M3 (use same setting as Teensy3.2) |
| 167 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024 |
| 168 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 169 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 170 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 171 | + #define TGX_INLINE __attribute__((always_inline)) |
| 172 | + #define TGX_NOINLINE |
| 173 | + |
| 174 | +#elif (defined(__ARM_ARCH_7EM__) && defined(__ARM_FP) && (__ARM_FP == 0xC)) || defined(STM32H7xx) |
| 175 | + // generic Cortex-M7 (use same setting as Teensy 4.0/4.1) |
| 176 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096 |
| 177 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 178 | + #define TGX_USE_FAST_SQRT_TRICK 1 |
| 179 | + #define TGX_USE_FAST_INV_TRICK 1 |
| 180 | + #define TGX_INLINE __attribute__((always_inline)) |
| 181 | + #define TGX_NOINLINE |
| 182 | + |
| 183 | +#elif defined(__ARM_ARCH_7EM__) |
| 184 | + // generic Cortex-M4 (use same setting as Teensy 3.6/3.5) |
| 185 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048 |
| 186 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 187 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 188 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 189 | + #define TGX_INLINE __attribute__((always_inline)) |
| 190 | + #define TGX_NOINLINE |
| 191 | + |
| 192 | +#elif defined(__ARM_ARCH_8M_MAIN__) |
| 193 | + // generic Cortex-M33 (use same setting as RP2350) |
| 194 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096 |
| 195 | + #define TGX_USE_FAST_INV_SQRT_TRICK 1 |
| 196 | + #define TGX_USE_FAST_SQRT_TRICK 1 |
| 197 | + #define TGX_USE_FAST_INV_TRICK 1 |
| 198 | + #define TGX_INLINE __attribute__((always_inline)) |
| 199 | + #define TGX_NOINLINE |
| 200 | + |
| 201 | +#else |
| 202 | + // unkwown board/architecture |
| 203 | + #define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024 |
| 204 | + #define TGX_USE_FAST_INV_SQRT_TRICK 0 |
| 205 | + #define TGX_USE_FAST_SQRT_TRICK 0 |
| 206 | + #define TGX_USE_FAST_INV_TRICK 0 |
| 207 | + #define TGX_INLINE |
| 208 | + #define TGX_NOINLINE |
| 209 | +#endif |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | +// Set this to 1 to use float as the default floating point type and set it to 0 to use double precision instead. |
| 215 | +#ifndef TGX_SINGLE_PRECISION_COMPUTATIONS |
| 216 | + #define TGX_SINGLE_PRECISION_COMPUTATIONS 1 |
| 217 | +#endif |
| 218 | + |
| 219 | + |
| 220 | +// Default blending operation for drawing primitive: overwrite instead of blending. |
| 221 | +#define TGX_DEFAULT_NO_BLENDING -1.0f |
| 222 | + |
| 223 | + |
| 224 | +/** end of file */ |
| 225 | + |
0 commit comments