From 1c9bc4abd5ab90a61e3485fe30ff3c6f9b4b319c Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 16 Feb 2026 15:20:39 +0100 Subject: 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 --- src/gpu/sequence.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/gpu/sequence.cc') diff --git a/src/gpu/sequence.cc b/src/gpu/sequence.cc index 578fc01..62c2933 100644 --- a/src/gpu/sequence.cc +++ b/src/gpu/sequence.cc @@ -130,12 +130,10 @@ void NodeRegistry::set_external_view(const std::string& name, } void NodeRegistry::create_texture(Node& node) { - // Headless mode: skip texture creation - if (device_ == nullptr) { - node.texture = nullptr; - node.view = nullptr; - return; - } + // Headless mode: skip texture creation (compiled out in STRIP_ALL) + node.texture = nullptr; + node.view = nullptr; + HEADLESS_RETURN_IF_NULL(device_); WGPUTextureFormat format; WGPUTextureUsage usage; -- cgit v1.2.3