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/post_process_helper.cc | |
| 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/post_process_helper.cc')
| -rw-r--r-- | src/gpu/post_process_helper.cc | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/gpu/post_process_helper.cc b/src/gpu/post_process_helper.cc index 6026f6e..281fde6 100644 --- a/src/gpu/post_process_helper.cc +++ b/src/gpu/post_process_helper.cc @@ -8,16 +8,15 @@ #include "gpu/pipeline_builder.h" #include "gpu/sampler_cache.h" #include "gpu/shader_composer.h" +#include "util/fatal_error.h" #include <cstring> // Helper to create a standard post-processing pipeline WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, WGPUTextureFormat format, const char* shader_code) { - // Headless mode: skip pipeline creation - if (device == nullptr) { - return nullptr; - } + // Headless mode: skip pipeline creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); WGPUBindGroupLayout bgl = BindGroupLayoutBuilder() @@ -45,10 +44,8 @@ WGPURenderPipeline create_post_process_pipeline(WGPUDevice device, WGPURenderPipeline create_post_process_pipeline_simple(WGPUDevice device, WGPUTextureFormat format, const char* shader_code) { - // Headless mode: skip pipeline creation - if (device == nullptr) { - return nullptr; - } + // Headless mode: skip pipeline creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_VAL_IF_NULL(device, nullptr); WGPUBindGroupLayout bgl = BindGroupLayoutBuilder() @@ -77,10 +74,9 @@ static GpuBuffer g_dummy_buffer = {nullptr, 0}; void pp_update_bind_group(WGPUDevice device, WGPURenderPipeline pipeline, WGPUBindGroup* bind_group, WGPUTextureView input_view, GpuBuffer uniforms, GpuBuffer effect_params) { - // Headless mode: skip bind group creation - if (device == nullptr || pipeline == nullptr) { - return; - } + // Headless mode: skip bind group creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_IF_NULL(device); + HEADLESS_RETURN_IF_NULL(pipeline); if (!g_dummy_buffer.buffer) { g_dummy_buffer = gpu_create_buffer(device, 32, WGPUBufferUsage_Uniform); |
