diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-16 15:20:39 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-16 15:20:39 +0100 |
| commit | 1c9bc4abd5ab90a61e3485fe30ff3c6f9b4b319c (patch) | |
| tree | ae97a9712411eedc1fee98c134fc54e53de8b047 /src/gpu/bind_group_builder.h | |
| parent | 80d395b8bc0c37778401eb771094c25db7a1b8a4 (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/gpu/bind_group_builder.h')
| -rw-r--r-- | src/gpu/bind_group_builder.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/gpu/bind_group_builder.h b/src/gpu/bind_group_builder.h index 3b25ba9..49b7ebe 100644 --- a/src/gpu/bind_group_builder.h +++ b/src/gpu/bind_group_builder.h @@ -20,6 +20,7 @@ typedef struct WGPUSamplerImpl* WGPUSampler; typedef uint32_t WGPUShaderStageFlags; #include "platform/platform.h" +#include "util/fatal_error.h" class BindGroupLayoutBuilder { std::vector<WGPUBindGroupLayoutEntry> entries_; @@ -93,10 +94,8 @@ class BindGroupLayoutBuilder { } WGPUBindGroupLayout build(WGPUDevice device) { - // Headless mode: skip bind group layout creation - if (device == nullptr) { - return nullptr; - } + // Headless mode: skip bind group layout creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); WGPUBindGroupLayoutDescriptor desc{}; desc.entryCount = entries_.size(); desc.entries = entries_.data(); @@ -134,10 +133,8 @@ class BindGroupBuilder { } WGPUBindGroup build(WGPUDevice device, WGPUBindGroupLayout layout) { - // Headless mode: skip bind group creation - if (device == nullptr) { - return nullptr; - } + // Headless mode: skip bind group creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); WGPUBindGroupDescriptor desc{}; desc.layout = layout; desc.entryCount = entries_.size(); |
