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/effects/placeholder_effect.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/effects/placeholder_effect.cc')
| -rw-r--r-- | src/effects/placeholder_effect.cc | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/effects/placeholder_effect.cc b/src/effects/placeholder_effect.cc index a83d922..a014a71 100644 --- a/src/effects/placeholder_effect.cc +++ b/src/effects/placeholder_effect.cc @@ -1,6 +1,7 @@ // Placeholder effect v2 implementation - logs TODO warning once #include "effects/placeholder_effect.h" +#include "util/fatal_error.h" #include "gpu/post_process_helper.h" #include "gpu/shaders.h" #include <cstdio> @@ -13,23 +14,23 @@ PlaceholderEffect::PlaceholderEffect(const GpuContext& ctx, sampler_(nullptr), name_(placeholder_name) { // Log once on construction fprintf(stderr, "TODO: %s not yet ported to v2, using passthrough\n", name_); - + + // Headless mode: skip GPU resource creation (compiled out in STRIP_ALL) + HEADLESS_RETURN_IF_NULL(ctx_.device); + uniforms_buffer_.init(ctx_.device); pipeline_ = create_post_process_pipeline(ctx_.device, WGPUTextureFormat_RGBA8Unorm, passthrough_v2_shader_wgsl); - // Headless mode: skip sampler creation - if (ctx_.device != nullptr) { - WGPUSamplerDescriptor sampler_desc = {}; - sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge; - sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge; - sampler_desc.addressModeW = WGPUAddressMode_ClampToEdge; - sampler_desc.magFilter = WGPUFilterMode_Linear; - sampler_desc.minFilter = WGPUFilterMode_Linear; - sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Nearest; - sampler_desc.maxAnisotropy = 1; - sampler_ = wgpuDeviceCreateSampler(ctx_.device, &sampler_desc); - } + WGPUSamplerDescriptor sampler_desc = {}; + sampler_desc.addressModeU = WGPUAddressMode_ClampToEdge; + sampler_desc.addressModeV = WGPUAddressMode_ClampToEdge; + sampler_desc.addressModeW = WGPUAddressMode_ClampToEdge; + sampler_desc.magFilter = WGPUFilterMode_Linear; + sampler_desc.minFilter = WGPUFilterMode_Linear; + sampler_desc.mipmapFilter = WGPUMipmapFilterMode_Nearest; + sampler_desc.maxAnisotropy = 1; + sampler_ = wgpuDeviceCreateSampler(ctx_.device, &sampler_desc); } void PlaceholderEffect::render(WGPUCommandEncoder encoder, |
