From 42de5c4e5aeb486b4afb5b73bcb6a9d5ba567cbd Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 16 Feb 2026 15:15:40 +0100 Subject: fix(headless): add nullptr checks for GPU resource creation - NodeRegistry::create_texture: skip texture creation when device is nullptr - Post-process helpers: skip pipeline/bind group creation in headless mode - SamplerCache: return nullptr for headless mode - BindGroupLayoutBuilder/BindGroupBuilder: skip creation with null device - RenderPipelineBuilder: skip shader module and pipeline creation in headless - PlaceholderEffect: skip sampler creation in headless mode - RotatingCubeEffect: early return in constructor for headless mode WIP: Some effects (GaussianBlur, etc.) still need headless checks Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/bind_group_builder.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gpu/bind_group_builder.h') diff --git a/src/gpu/bind_group_builder.h b/src/gpu/bind_group_builder.h index 55b7291..3b25ba9 100644 --- a/src/gpu/bind_group_builder.h +++ b/src/gpu/bind_group_builder.h @@ -93,6 +93,10 @@ class BindGroupLayoutBuilder { } WGPUBindGroupLayout build(WGPUDevice device) { + // Headless mode: skip bind group layout creation + if (device == nullptr) { + return nullptr; + } WGPUBindGroupLayoutDescriptor desc{}; desc.entryCount = entries_.size(); desc.entries = entries_.data(); @@ -130,6 +134,10 @@ class BindGroupBuilder { } WGPUBindGroup build(WGPUDevice device, WGPUBindGroupLayout layout) { + // Headless mode: skip bind group creation + if (device == nullptr) { + return nullptr; + } WGPUBindGroupDescriptor desc{}; desc.layout = layout; desc.entryCount = entries_.size(); -- cgit v1.2.3