summaryrefslogtreecommitdiff
path: root/src/util/fatal_error.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-16 15:20:39 +0100
committerskal <pascal.massimino@gmail.com>2026-02-16 15:20:39 +0100
commit1c9bc4abd5ab90a61e3485fe30ff3c6f9b4b319c (patch)
treeae97a9712411eedc1fee98c134fc54e53de8b047 /src/util/fatal_error.h
parent80d395b8bc0c37778401eb771094c25db7a1b8a4 (diff)
refactor(headless): convert nullptr checks to strippable macros
Added HEADLESS_RETURN_IF_NULL/HEADLESS_RETURN_VAL_IF_NULL macros that compile to no-ops in STRIP_ALL/FINAL_STRIP modes. Files updated: - fatal_error.h: New headless check macros - sequence.cc: NodeRegistry::create_texture - post_process_helper.cc: Pipeline creation functions - sampler_cache.h: SamplerCache::get_or_create - bind_group_builder.h: Layout/group builders - pipeline_builder.h: Shader and pipeline builders - All effect constructors (7 files) Headless tests passing. STRIP_ALL builds will have zero overhead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/util/fatal_error.h')
-rw-r--r--src/util/fatal_error.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/util/fatal_error.h b/src/util/fatal_error.h
index c0f7c65..988ec1d 100644
--- a/src/util/fatal_error.h
+++ b/src/util/fatal_error.h
@@ -14,6 +14,38 @@
//
// FINAL_STRIP implies STRIP_ALL (stricter superset)
+#if defined(STRIP_ALL) || defined(FINAL_STRIP)
+
+// ==============================================================================
+// STRIP_ALL / FINAL_STRIP: Headless checks compiled out (production builds)
+// ==============================================================================
+
+// Headless mode nullptr checks - compiles to nothing in production
+#define HEADLESS_RETURN_IF_NULL(device) ((void)0)
+#define HEADLESS_RETURN_VAL_IF_NULL(device, val) ((void)0)
+
+#else
+
+// ==============================================================================
+// Debug: Headless mode nullptr checks enabled
+// ==============================================================================
+
+// Early return if device is nullptr (headless mode stub)
+#define HEADLESS_RETURN_IF_NULL(device) \
+ do { \
+ if ((device) == nullptr) \
+ return; \
+ } while (0)
+
+// Early return with value if device is nullptr (headless mode stub)
+#define HEADLESS_RETURN_VAL_IF_NULL(device, val) \
+ do { \
+ if ((device) == nullptr) \
+ return (val); \
+ } while (0)
+
+#endif /* defined(STRIP_ALL) || defined(FINAL_STRIP) */
+
#if defined(FINAL_STRIP)
// ==============================================================================