From 45feda8f077d6875dfe532bd6216d9cbbbee2b95 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 24 Mar 2026 16:59:49 +0100 Subject: [PATCH] Fix Firefox and Safari bug with missing bind group layout --- .../WebGPU/GPUPipelineStateWebGPU.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp index 568847bf2..0b1a3c3ab 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp @@ -664,8 +664,21 @@ void GPUPipelineStateWebGPU::InitLayout(const GPUContextBindingsWebGPU& bindings for (int32 groupIndex = 0; groupIndex < ARRAY_COUNT(BindGroupDescriptors); groupIndex++) { auto descriptors = BindGroupDescriptors[groupIndex]; + WGPUBindGroupLayout bindGroupLayout = nullptr; if (descriptors) - BindGroupLayouts[groupIndex] = CreateBindGroupLayout(_device->Device, bindings, groupIndex, *descriptors, entries, debugName, log); + bindGroupLayout = CreateBindGroupLayout(_device->Device, bindings, groupIndex, *descriptors, entries, debugName, log); + if (!bindGroupLayout) + { + // Firefox and Safari have a bug that causes pipeline creation to fail when bind group layout is empty (no entries) and used in the pipeline layout + static WGPUBindGroupLayout EmptyBindGroup = nullptr; + if (!EmptyBindGroup) + { + WGPUBindGroupLayoutDescriptor bindGroupLayoutDesc = WGPU_BIND_GROUP_LAYOUT_DESCRIPTOR_INIT; + EmptyBindGroup = wgpuDeviceCreateBindGroupLayout(_device->Device, &bindGroupLayoutDesc); + } + bindGroupLayout = EmptyBindGroup; + } + BindGroupLayouts[groupIndex] = bindGroupLayout; } // Create the pipeline layout @@ -673,7 +686,7 @@ void GPUPipelineStateWebGPU::InitLayout(const GPUContextBindingsWebGPU& bindings #if GPU_ENABLE_RESOURCE_NAMING layoutDesc.label = PipelineDesc.label; #endif - layoutDesc.bindGroupLayoutCount = GPUBindGroupsWebGPU::GraphicsMax; + layoutDesc.bindGroupLayoutCount = ARRAY_COUNT(BindGroupLayouts); layoutDesc.bindGroupLayouts = BindGroupLayouts; PipelineDesc.layout = wgpuDeviceCreatePipelineLayout(_device->Device, &layoutDesc); if (!PipelineDesc.layout)