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/sampler_cache.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/gpu/sampler_cache.h') diff --git a/src/gpu/sampler_cache.h b/src/gpu/sampler_cache.h index b3fdb19..7d88109 100644 --- a/src/gpu/sampler_cache.h +++ b/src/gpu/sampler_cache.h @@ -9,6 +9,7 @@ struct WGPUSamplerImpl; typedef struct WGPUSamplerImpl* WGPUSampler; #include "platform/platform.h" +#include "util/fatal_error.h" struct SamplerSpec { WGPUAddressMode u, v; @@ -39,10 +40,8 @@ class SamplerCache { } WGPUSampler get_or_create(WGPUDevice device, const SamplerSpec& spec) { - // Headless mode: skip sampler creation - if (device == nullptr) { - return nullptr; - } + // Headless mode: skip sampler creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); auto it = cache_.find(spec); if (it != cache_.end()) -- cgit v1.2.3