TGX
1.0.8
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
Loading...
Searching...
No Matches
tgx_config.h
Go to the documentation of this file.
1
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
// disable mtools extensions by default
24
#ifndef MTOOLS_TGX_EXTENSIONS
25
#define MTOOLS_TGX_EXTENSIONS 0
26
#endif
27
28
#ifdef ARDUINO
29
#include <Arduino.h>
30
#define TGX_ON_ARDUINO
31
#elif defined(ESP_PLATFORM)
32
#include "sdkconfig.h"
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 accessing 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
//
62
#if defined(_WIN32) || defined(_WIN64) || defined(__linux__) || defined(__APPLE__) || defined(__MACH__) || defined(__ANDROID__) || defined(__unix__)
63
// TGX is running on a computer.
64
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 262144
65
#define TGX_USE_FAST_INV_SQRT_TRICK 0
66
#define TGX_USE_FAST_SQRT_TRICK 0
67
#define TGX_USE_FAST_INV_TRICK 0
68
#define TGX_INLINE
69
#define TGX_NOINLINE
70
71
#elif defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
72
// teensy 4.0 and 4.1
73
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 8192
74
#define TGX_USE_FAST_INV_SQRT_TRICK 1
75
#define TGX_USE_FAST_SQRT_TRICK 1
76
#define TGX_USE_FAST_INV_TRICK 1
77
#define TGX_INLINE __attribute__((always_inline))
78
#define TGX_NOINLINE __attribute__((noinline, noclone)) FLASHMEM
79
80
#elif defined(ARDUINO_TEENSY36)
81
// teensy 3.6
82
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048
83
#define TGX_USE_FAST_INV_SQRT_TRICK 1
84
#define TGX_USE_FAST_SQRT_TRICK 0
85
#define TGX_USE_FAST_INV_TRICK 0
86
#define TGX_INLINE __attribute__((always_inline))
87
#define TGX_NOINLINE
88
89
#elif defined(ARDUINO_TEENSY35)
90
// teensy 3.5
91
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048
92
#define TGX_USE_FAST_INV_SQRT_TRICK 1
93
#define TGX_USE_FAST_SQRT_TRICK 0
94
#define TGX_USE_FAST_INV_TRICK 0
95
#define TGX_INLINE __attribute__((always_inline))
96
#define TGX_NOINLINE
97
98
#elif defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY31)
99
// teensy 3.1 and 3.2
100
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024
101
#define TGX_USE_FAST_INV_SQRT_TRICK 1
102
#define TGX_USE_FAST_SQRT_TRICK 0
103
#define TGX_USE_FAST_INV_TRICK 0
104
#define TGX_INLINE __attribute__((always_inline))
105
#define TGX_NOINLINE
106
107
#elif defined(ARDUINO_TEENSYLC)
108
// teensy LC
109
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 256
110
#define TGX_USE_FAST_INV_SQRT_TRICK 0
111
#define TGX_USE_FAST_SQRT_TRICK 0
112
#define TGX_USE_FAST_INV_TRICK 0
113
#define TGX_INLINE
114
#define TGX_NOINLINE
115
116
#elif defined(ARDUINO_ARCH_RP2350) || defined(PICO_RP2350)
117
// Raspberry Pico 2350
118
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
119
#define TGX_USE_FAST_INV_SQRT_TRICK 1
120
#define TGX_USE_FAST_SQRT_TRICK 1
121
#define TGX_USE_FAST_INV_TRICK 1
122
#define TGX_INLINE __attribute__((always_inline))
123
#define TGX_NOINLINE
124
125
#elif defined(ARDUINO_ARCH_RP2040) || defined(PICO_RP2040)
126
// Raspberry Pico 2040
127
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048
128
#define TGX_USE_FAST_INV_SQRT_TRICK 1
129
#define TGX_USE_FAST_SQRT_TRICK 0
130
#define TGX_USE_FAST_INV_TRICK 0
131
#define TGX_INLINE
132
#define TGX_NOINLINE
133
134
#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(ESP32S2)
135
// ESP32 S2
136
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048
137
#define TGX_USE_FAST_INV_SQRT_TRICK 0
138
#define TGX_USE_FAST_SQRT_TRICK 0
139
#define TGX_USE_FAST_INV_TRICK 0
140
#define TGX_INLINE
141
#define TGX_NOINLINE
142
143
#elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(ESP32S3)
144
// ESP32 S3
145
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
146
#define TGX_USE_FAST_INV_SQRT_TRICK 0
// unused: specific assembly code used instead.
147
#define TGX_USE_FAST_SQRT_TRICK 0
//
148
#define TGX_USE_FAST_INV_TRICK 0
//
149
#define TGX_INLINE __attribute__((always_inline))
150
#define TGX_NOINLINE
151
152
#elif defined(CONFIG_IDF_TARGET_ESP32P4) || defined(ESP32P4)
153
// ESP32 P4
154
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
155
#define TGX_USE_FAST_INV_SQRT_TRICK 0
// unused: specific assembly code used instead.
156
#define TGX_USE_FAST_SQRT_TRICK 0
//
157
#define TGX_USE_FAST_INV_TRICK 0
//
158
#define TGX_INLINE __attribute__((always_inline))
159
#define TGX_NOINLINE
160
161
#elif defined(CONFIG_IDF_TARGET_ESP32) || defined(ESP32)
162
// fallback to original
163
// nb: `ESP32` is defined for all ESP32 variants so this case should be the last
164
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
165
#define TGX_USE_FAST_INV_SQRT_TRICK 0
// unused: specific assembly code used instead.
166
#define TGX_USE_FAST_SQRT_TRICK 0
//
167
#define TGX_USE_FAST_INV_TRICK 0
//
168
#define TGX_INLINE __attribute__((always_inline))
169
#define TGX_NOINLINE
170
171
#elif defined(__ARM_ARCH_6M__)
172
// generic Cortex-M0 (use same setting as Teensy LC)
173
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 256
174
#define TGX_USE_FAST_INV_SQRT_TRICK 0
175
#define TGX_USE_FAST_SQRT_TRICK 0
176
#define TGX_USE_FAST_INV_TRICK 0
177
#define TGX_INLINE
178
#define TGX_NOINLINE
179
180
#elif defined(__ARM_ARCH_7M__)
181
// generic Cortex-M3 (use same setting as Teensy3.2)
182
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024
183
#define TGX_USE_FAST_INV_SQRT_TRICK 1
184
#define TGX_USE_FAST_SQRT_TRICK 0
185
#define TGX_USE_FAST_INV_TRICK 0
186
#define TGX_INLINE __attribute__((always_inline))
187
#define TGX_NOINLINE
188
189
#elif (defined(__ARM_ARCH_7EM__) && defined(__ARM_FP) && (__ARM_FP == 0xC)) || defined(STM32H7xx)
190
// generic Cortex-M7 (use same setting as Teensy 4.0/4.1)
191
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
192
#define TGX_USE_FAST_INV_SQRT_TRICK 1
193
#define TGX_USE_FAST_SQRT_TRICK 1
194
#define TGX_USE_FAST_INV_TRICK 1
195
#define TGX_INLINE __attribute__((always_inline))
196
#define TGX_NOINLINE
197
198
#elif defined(__ARM_ARCH_7EM__)
199
// generic Cortex-M4 (use same setting as Teensy 3.6/3.5)
200
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 2048
201
#define TGX_USE_FAST_INV_SQRT_TRICK 1
202
#define TGX_USE_FAST_SQRT_TRICK 0
203
#define TGX_USE_FAST_INV_TRICK 0
204
#define TGX_INLINE __attribute__((always_inline))
205
#define TGX_NOINLINE
206
207
#elif defined(__ARM_ARCH_8M_MAIN__)
208
// generic Cortex-M33 (use same setting as RP2350)
209
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 4096
210
#define TGX_USE_FAST_INV_SQRT_TRICK 1
211
#define TGX_USE_FAST_SQRT_TRICK 1
212
#define TGX_USE_FAST_INV_TRICK 1
213
#define TGX_INLINE __attribute__((always_inline))
214
#define TGX_NOINLINE
215
216
#else
217
// unknown board/architecture
218
#define TGX_PROGMEM_DEFAULT_CACHE_SIZE 1024
219
#define TGX_USE_FAST_INV_SQRT_TRICK 0
220
#define TGX_USE_FAST_SQRT_TRICK 0
221
#define TGX_USE_FAST_INV_TRICK 0
222
#define TGX_INLINE
223
#define TGX_NOINLINE
224
#endif
225
226
227
228
233
#ifndef TGX_SINGLE_PRECISION_COMPUTATIONS
234
#define TGX_SINGLE_PRECISION_COMPUTATIONS 1
235
#endif
236
237
242
#define TGX_DEFAULT_NO_BLENDING -1.0f
243
244
src
tgx_config.h
Generated by
1.9.5