| TGX 1.1.3 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// generic check for FPU support
46#if defined(__ARM_FP) && ((__ARM_FP & 0x4) != 0)
47 #define TGX_COMPILER_HAS_FPU 1
48#elif defined(__XTENSA__) && !defined(__XTENSA_SOFT_FLOAT__)
49 #define TGX_COMPILER_HAS_FPU 1
50#elif defined(__riscv_flen) && (__riscv_flen >= 32)
51 #define TGX_COMPILER_HAS_FPU 1
52#else
53 #define TGX_COMPILER_HAS_FPU 0
54#endif
55
56
57//
58// Board specific optimizations.
59//
60// - TGX_PROGMEM_DEFAULT_CACHE_SIZE : size of the cache when reading from PROGMEM. Use to optimize cache read when accessing image in flash.
61//
62// - TGX_USE_FAST_INV_SQRT_TRICK : fast inverse 'quake like' square root trick to speed up computations.
63// - TGX_USE_FAST_SQRT_TRICK : fast 'quake like' square root trick to speed up computations.
64// - TGX_USE_FAST_INV_TRICK : fast inverse 'quake like' trick to speed up computations.
65// - TGX_USE_FMA_MATH : use explicit fused multiply-add in small floating-point vector/matrix operations.
66// - TGX_USE_FMA_MATH_MISC : use explicit fused multiply-add in Misc.h fast math approximations.
67// - TGX_DRAWSPHERE_USE_STRIP_BANDS : use triangle strips for Gouraud shaded sphere bands.
68// - TGX_RASTERIZE_TRIANGLE_INLINE : inlining strategy for the main triangle rasterizer entry point.
69// - TGX_RENDERER3D_CLIP_NOINLINE : noinline strategy for Renderer3D clipping helpers.
70// - TGX_BSEG_RUNTIME_MOVE_INLINE : inlining strategy for the runtime Bresenham move wrapper.
71//
72// - TGX_INLINE/TGX_NOINLINE : inlining strategy for time critical/non-critical functions.
73//
110#if defined(_WIN32) || defined(_WIN64) || defined(__linux__) || defined(__APPLE__) || defined(__MACH__) || defined(__ANDROID__) || defined(__unix__)
111 // TGX is running on a computer.
112 #define TGX_RUN_ON_CPU
113 #define TGX_CONFIG_HAS_FPU 1
114 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 262144
115 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
116 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
117 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
118 #define TGX_CONFIG_USE_FMA_MATH 0
119 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
120 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
121 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
122 #define TGX_CONFIG_INLINE
123 #define TGX_CONFIG_INLINE_ZDIVIDE
124 #define TGX_CONFIG_NOINLINE
125 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
126 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
127
128#elif defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41)
129 // teensy 4.0 and 4.1
130 #define TGX_RUN_ON_TEENSY4
131 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
132 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 8192
133 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
134 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 1
135 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
136 #define TGX_CONFIG_USE_FMA_MATH 1
137 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
138 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 1
139 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
140 #define TGX_CONFIG_RASTERIZE_TRIANGLE_INLINE
141 #define TGX_CONFIG_INLINE __attribute__((always_inline))
142 #define TGX_CONFIG_INLINE_ZDIVIDE __attribute__((always_inline))
143 #define TGX_CONFIG_NOINLINE
144 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
145 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
146
147#elif defined(ARDUINO_TEENSY36)
148 // teensy 3.6
149 #define TGX_RUN_ON_TEENSY3
150 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
151 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 2048
152 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
153 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
154 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
155 #define TGX_CONFIG_USE_FMA_MATH 0
156 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
157 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
158 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
159 #define TGX_CONFIG_INLINE __attribute__((always_inline))
160 #define TGX_CONFIG_INLINE_ZDIVIDE
161 #define TGX_CONFIG_NOINLINE
162 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
163 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
164
165#elif defined(ARDUINO_TEENSY35)
166 // teensy 3.5
167 #define TGX_RUN_ON_TEENSY3
168 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
169 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 2048
170 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
171 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
172 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
173 #define TGX_CONFIG_USE_FMA_MATH 0
174 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
175 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
176 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
177 #define TGX_CONFIG_INLINE __attribute__((always_inline))
178 #define TGX_CONFIG_INLINE_ZDIVIDE
179 #define TGX_CONFIG_NOINLINE
180 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
181 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
182
183#elif defined(ARDUINO_TEENSY32) || defined(ARDUINO_TEENSY31)
184 // teensy 3.1 and 3.2
185 #define TGX_RUN_ON_TEENSY3
186 #define TGX_CONFIG_HAS_FPU 0
187 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 1024
188 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
189 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
190 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
191 #define TGX_CONFIG_USE_FMA_MATH 0
192 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
193 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
194 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
195 #define TGX_CONFIG_INLINE __attribute__((always_inline))
196 #define TGX_CONFIG_INLINE_ZDIVIDE
197 #define TGX_CONFIG_NOINLINE
198 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
199 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
200
201#elif defined(ARDUINO_TEENSYLC)
202 // teensy LC
203 #define TGX_RUN_ON_TEENSYLC
204 #define TGX_CONFIG_HAS_FPU 0
205 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 256
206 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
207 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
208 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
209 #define TGX_CONFIG_USE_FMA_MATH 0
210 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
211 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
212 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
213 #define TGX_CONFIG_INLINE
214 #define TGX_CONFIG_INLINE_ZDIVIDE
215 #define TGX_CONFIG_NOINLINE
216 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
217 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
218
219#elif defined(ARDUINO_ARCH_RP2350) || defined(PICO_RP2350) || defined(TARGET_RP2350)
220 // Raspberry Pico 2350
221 #define TGX_RUN_ON_RP2350
222 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
223 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
224 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
225 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 1
226 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
227 #define TGX_CONFIG_USE_FMA_MATH 0
228 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
229 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 1
230 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
231 #define TGX_CONFIG_INLINE __attribute__((always_inline))
232 #define TGX_CONFIG_INLINE_ZDIVIDE __attribute__((always_inline))
233 #define TGX_CONFIG_NOINLINE
234 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
235 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE
236
237#elif defined(ARDUINO_ARCH_RP2040) || defined(PICO_RP2040) || defined(TARGET_RP2040)
238 // Raspberry Pico 2040
239 #define TGX_RUN_ON_RP2040
240 #define TGX_CONFIG_HAS_FPU 0
241 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 2048
242 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
243 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
244 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
245 #define TGX_CONFIG_USE_FMA_MATH 0
246 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
247 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
248 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
249 #define TGX_CONFIG_INLINE
250 #define TGX_CONFIG_INLINE_ZDIVIDE
251 #define TGX_CONFIG_NOINLINE
252 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
253 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE
254
255#elif defined(CONFIG_IDF_TARGET_ESP32S2) || defined(ESP32S2)
256 // ESP32 S2
257 #define TGX_RUN_ON_ESP32S2
258 #define TGX_CONFIG_HAS_FPU 0
259 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 2048
260 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
261 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
262 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
263 #define TGX_CONFIG_USE_FMA_MATH 0
264 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
265 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
266 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
267 #define TGX_CONFIG_INLINE
268 #define TGX_CONFIG_INLINE_ZDIVIDE
269 #define TGX_CONFIG_NOINLINE
270 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
271 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
272
273#elif defined(CONFIG_IDF_TARGET_ESP32S3) || defined(ESP32S3)
274 // ESP32 S3
275 #define TGX_RUN_ON_ESP32S3
276 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
277 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
278 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0 // unused: specific assembly code used instead.
279 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0 //
280 #define TGX_CONFIG_USE_FAST_INV_TRICK 0 // unused: specific assembly code used instead.
281 #define TGX_CONFIG_USE_FMA_MATH 0
282 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
283 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
284 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
285 #define TGX_CONFIG_RASTERIZE_TRIANGLE_INLINE
286 #define TGX_CONFIG_INLINE __attribute__((always_inline))
287 #define TGX_CONFIG_INLINE_ZDIVIDE __attribute__((always_inline))
288 #define TGX_CONFIG_NOINLINE
289 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
290 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
291
292#elif defined(CONFIG_IDF_TARGET_ESP32P4) || defined(ESP32P4)
293 // ESP32 P4
294 #define TGX_RUN_ON_ESP32P4
295 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
296 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
297 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
298 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 1
299 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
300 #define TGX_CONFIG_USE_FMA_MATH 0
301 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
302 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
303 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
304 #define TGX_CONFIG_INLINE __attribute__((always_inline))
305 #define TGX_CONFIG_INLINE_ZDIVIDE
306 #define TGX_CONFIG_NOINLINE
307 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
308 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
309
310#elif defined(CONFIG_IDF_TARGET_ESP32) || defined(ESP32)
311 // fallback to original
312 // nb: `ESP32` is defined for all ESP32 variants so this case should be the last
313 #define TGX_RUN_ON_ESP32
314 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
315 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
316 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0 // unused: specific assembly code used instead.
317 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0 //
318 #define TGX_CONFIG_USE_FAST_INV_TRICK 0 //
319 #define TGX_CONFIG_USE_FMA_MATH 0
320 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
321 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
322 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
323 #define TGX_CONFIG_RASTERIZE_TRIANGLE_INLINE __attribute__((always_inline))
324 #define TGX_CONFIG_INLINE __attribute__((always_inline))
325 #define TGX_CONFIG_INLINE_ZDIVIDE
326 #define TGX_CONFIG_NOINLINE
327 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE __attribute__((noinline, noclone))
328 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
329
330#elif defined(__ARM_ARCH_6M__)
331 // generic Cortex-M0 (use same setting as Teensy LC)
332 #define TGX_RUN_ON_TEENSYLC
333 #define TGX_CONFIG_HAS_FPU 0
334 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 256
335 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
336 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
337 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
338 #define TGX_CONFIG_USE_FMA_MATH 0
339 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
340 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
341 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
342 #define TGX_CONFIG_INLINE
343 #define TGX_CONFIG_INLINE_ZDIVIDE
344 #define TGX_CONFIG_NOINLINE
345 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
346 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
347
348#elif defined(__ARM_ARCH_7M__)
349 // generic Cortex-M3 (use same setting as Teensy3.2)
350 #define TGX_RUN_ON_TEENSY3
351 #define TGX_CONFIG_HAS_FPU 0
352 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 1024
353 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
354 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
355 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
356 #define TGX_CONFIG_USE_FMA_MATH 0
357 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
358 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
359 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
360 #define TGX_CONFIG_INLINE __attribute__((always_inline))
361 #define TGX_CONFIG_INLINE_ZDIVIDE
362 #define TGX_CONFIG_NOINLINE
363 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
364 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
365
366#elif (defined(__ARM_ARCH_7EM__) && defined(__ARM_FP) && ((__ARM_FP & 0x8) != 0)) || defined(STM32H7xx)
367 // generic Cortex-M7 (use same setting as Teensy 4.0/4.1)
368 #define TGX_RUN_ON_TEENSY4
369 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
370 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
371 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
372 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 1
373 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
374 #define TGX_CONFIG_USE_FMA_MATH 1
375 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
376 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
377 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 1
378 #define TGX_CONFIG_INLINE __attribute__((always_inline))
379 #define TGX_CONFIG_INLINE_ZDIVIDE __attribute__((always_inline))
380 #define TGX_CONFIG_NOINLINE
381 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
382 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
383
384#elif defined(__ARM_ARCH_7EM__)
385 // generic Cortex-M4 (use same setting as Teensy 3.6/3.5)
386 #define TGX_RUN_ON_TEENSY3
387 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
388 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 2048
389 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
390 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
391 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
392 #define TGX_CONFIG_USE_FMA_MATH 0
393 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
394 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
395 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
396 #define TGX_CONFIG_INLINE __attribute__((always_inline))
397 #define TGX_CONFIG_INLINE_ZDIVIDE
398 #define TGX_CONFIG_NOINLINE
399 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
400 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
401
402#elif defined(__ARM_ARCH_8M_MAIN__)
403 // generic Cortex-M33 (use same setting as RP2350)
404 #define TGX_RUN_ON_RP2350
405 #define TGX_CONFIG_HAS_FPU TGX_COMPILER_HAS_FPU
406 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 4096
407 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 1
408 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 1
409 #define TGX_CONFIG_USE_FAST_INV_TRICK 1
410 #define TGX_CONFIG_USE_FMA_MATH 0
411 #define TGX_CONFIG_USE_FMA_MATH_MISC 1
412 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 1
413 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
414 #define TGX_CONFIG_INLINE __attribute__((always_inline))
415 #define TGX_CONFIG_INLINE_ZDIVIDE __attribute__((always_inline))
416 #define TGX_CONFIG_NOINLINE
417 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
418 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE
419
420#else
421 // unknown board/architecture
422 #define TGX_RUN_ON_CPU
423 #define TGX_CONFIG_HAS_FPU 1
424 #define TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE 1024
425 #define TGX_CONFIG_USE_FAST_INV_SQRT_TRICK 0
426 #define TGX_CONFIG_USE_FAST_SQRT_TRICK 0
427 #define TGX_CONFIG_USE_FAST_INV_TRICK 0
428 #define TGX_CONFIG_USE_FMA_MATH 0
429 #define TGX_CONFIG_USE_FMA_MATH_MISC 0
430 #define TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS 0
431 #define TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS 0
432 #define TGX_CONFIG_INLINE
433 #define TGX_CONFIG_INLINE_ZDIVIDE
434 #define TGX_CONFIG_NOINLINE
435 #define TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
436 #define TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE TGX_INLINE
437#endif
438
439
440// Apply board defaults unless the user supplied an explicit TGX_* override.
441#ifndef TGX_HAS_FPU
442 #define TGX_HAS_FPU TGX_CONFIG_HAS_FPU
443#endif
444
445#ifndef TGX_PROGMEM_DEFAULT_CACHE_SIZE
446 #define TGX_PROGMEM_DEFAULT_CACHE_SIZE TGX_CONFIG_PROGMEM_DEFAULT_CACHE_SIZE
447#endif
448
449#ifndef TGX_USE_FAST_INV_SQRT_TRICK
450 #define TGX_USE_FAST_INV_SQRT_TRICK TGX_CONFIG_USE_FAST_INV_SQRT_TRICK
451#endif
452
453#ifndef TGX_USE_FAST_SQRT_TRICK
454 #define TGX_USE_FAST_SQRT_TRICK TGX_CONFIG_USE_FAST_SQRT_TRICK
455#endif
456
457#ifndef TGX_USE_FAST_INV_TRICK
458 #define TGX_USE_FAST_INV_TRICK TGX_CONFIG_USE_FAST_INV_TRICK
459#endif
460
461#ifndef TGX_USE_FMA_MATH
462 #define TGX_USE_FMA_MATH TGX_CONFIG_USE_FMA_MATH
463#endif
464
465#ifndef TGX_USE_FMA_MATH_MISC
466 #define TGX_USE_FMA_MATH_MISC TGX_CONFIG_USE_FMA_MATH_MISC
467#endif
468
469#ifndef TGX_SHADER_USE_INCREMENTAL_PIXEL_POINTERS
470 #define TGX_SHADER_USE_INCREMENTAL_PIXEL_POINTERS TGX_CONFIG_SHADER_USE_INCREMENTAL_PIXEL_POINTERS
471#endif
472
473#ifndef TGX_DRAWSPHERE_USE_STRIP_BANDS
474 #define TGX_DRAWSPHERE_USE_STRIP_BANDS TGX_CONFIG_DRAWSPHERE_USE_STRIP_BANDS
475#endif
476
477#ifndef TGX_INLINE
478 #define TGX_INLINE TGX_CONFIG_INLINE
479#endif
480
481#ifndef TGX_INLINE_ZDIVIDE
482 #define TGX_INLINE_ZDIVIDE TGX_CONFIG_INLINE_ZDIVIDE
483#endif
484
485#ifndef TGX_NOINLINE
486 #define TGX_NOINLINE TGX_CONFIG_NOINLINE
487#endif
488
489#ifndef TGX_RASTERIZE_TRIANGLE_INLINE
490 #ifdef TGX_CONFIG_RASTERIZE_TRIANGLE_INLINE
491 #define TGX_RASTERIZE_TRIANGLE_INLINE TGX_CONFIG_RASTERIZE_TRIANGLE_INLINE
492 #else
493 #define TGX_RASTERIZE_TRIANGLE_INLINE TGX_INLINE
494 #endif
495#endif
496
497#ifndef TGX_UBER_SHADER_INLINE
498 #define TGX_UBER_SHADER_INLINE TGX_INLINE
499#endif
500
501#ifndef TGX_SHADER_SELECT_INLINE
502 #define TGX_SHADER_SELECT_INLINE TGX_INLINE
503#endif
504
505#ifndef TGX_RENDERER3D_SHADING_INLINE
506 #define TGX_RENDERER3D_SHADING_INLINE TGX_INLINE
507#endif
508
509#ifndef TGX_RENDERER3D_CLIP_NOINLINE
510 #define TGX_RENDERER3D_CLIP_NOINLINE TGX_CONFIG_RENDERER3D_CLIP_NOINLINE
511#endif
512
513#ifndef TGX_BSEG_RUNTIME_MOVE_INLINE
514 #define TGX_BSEG_RUNTIME_MOVE_INLINE TGX_CONFIG_BSEG_RUNTIME_MOVE_INLINE
515#endif
516
517#if defined(ESP32) || defined(ESP_PLATFORM)
518 #include "esp_attr.h"
519 #define TGX_HOT_IRAM IRAM_ATTR
520#else
521 #define TGX_HOT_IRAM
522#endif
523
524
525
526
527
532#ifndef TGX_SHADER_GOURAUD_TEXTURE_FLOAT_INCREMENTAL
533#if TGX_HAS_FPU
534#define TGX_SHADER_GOURAUD_TEXTURE_FLOAT_INCREMENTAL 1
535#else // disable incremental float computation for Gouraud shading on architectures without FPU
536#define TGX_SHADER_GOURAUD_TEXTURE_FLOAT_INCREMENTAL 0
537#endif
538#endif
539
540#ifndef TGX_SHADER_GOURAUD_RGB565_FLOAT_INCREMENTAL
541#if TGX_HAS_FPU
542#define TGX_SHADER_GOURAUD_RGB565_FLOAT_INCREMENTAL 1
543#else // disable incremental float computation for Gouraud shading on architectures without FPU
544#define TGX_SHADER_GOURAUD_RGB565_FLOAT_INCREMENTAL 0
545#endif
546#endif
547
548#ifndef TGX_SHADER_RGB565_FAST_TEXTURE_MODULATE
549#define TGX_SHADER_RGB565_FAST_TEXTURE_MODULATE 1
550#endif
551
552#ifndef TGX_SHADER_RGB565_FAST_BILINEAR
553#define TGX_SHADER_RGB565_FAST_BILINEAR 1
554#endif
555
556#ifndef TGX_SHADER_RGB565_FAST_CLAMP
557#define TGX_SHADER_RGB565_FAST_CLAMP 0
558#endif
559
560
561
562
563
564
565
570#ifndef TGX_SINGLE_PRECISION_COMPUTATIONS
571 #define TGX_SINGLE_PRECISION_COMPUTATIONS 1
572#endif
573
574
579#define TGX_DEFAULT_NO_BLENDING -1.0f
580
581
586#ifndef TGX_MESHLET_SPHERE_CLIP
587 #define TGX_MESHLET_SPHERE_CLIP 1
588#endif
589
594#ifndef TGX_MESHLET_WIREFRAME_CULL
595 #define TGX_MESHLET_WIREFRAME_CULL 1
596#endif
597
598