From 768d5f4879c956972866c659a204a138659ad1a3 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Fri, 27 Jun 2025 11:18:40 -0700 Subject: [PATCH] [metal] Increase MAX_COMMAND_BUFFERS (#7858) --- cts_runner/test.lst | 15 +++++++++++++-- wgpu-hal/src/metal/adapter.rs | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cts_runner/test.lst b/cts_runner/test.lst index 0535b9e0a..1cd2a7dc1 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -5,6 +5,8 @@ webgpu:api,operation,compute,basic:memcpy:* //FAIL: webgpu:api,operation,compute,basic:large_dispatch:* webgpu:api,operation,compute_pipeline,overrides:* webgpu:api,operation,device,lost:* +webgpu:api,validation,encoding,beginComputePass:* +webgpu:api,validation,encoding,beginRenderPass:* webgpu:api,validation,encoding,cmds,clearBuffer:* webgpu:api,validation,encoding,cmds,compute_pass:set_pipeline:* webgpu:api,validation,encoding,cmds,compute_pass:dispatch_sizes:* @@ -31,13 +33,22 @@ webgpu:api,validation,encoding,encoder_open_state:render_pass_commands:* //FAIL: webgpu:api,validation,encoding,encoder_open_state:render_bundle_commands:* // https://github.com/gfx-rs/wgpu/issues/7857 webgpu:api,validation,encoding,encoder_open_state:compute_pass_commands:* -webgpu:api,validation,encoding,beginComputePass:* -webgpu:api,validation,encoding,beginRenderPass:* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_binding_mismatch:encoderType="compute%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_binding_mismatch:encoderType="render%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_resource_type_mismatch:encoderType="compute%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_resource_type_mismatch:encoderType="render%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_visibility_mismatch:encoderType="compute%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bgl_visibility_mismatch:encoderType="render%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_groups_and_pipeline_layout_mismatch:encoderType="compute%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:bind_groups_and_pipeline_layout_mismatch:encoderType="render%20pass";* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:buffer_binding,render_pipeline:* +webgpu:api,validation,encoding,programmable,pipeline_bind_group_compat:sampler_binding,render_pipeline:* webgpu:api,validation,queue,submit:command_buffer,device_mismatch:* webgpu:api,validation,queue,submit:command_buffer,duplicate_buffers:* webgpu:api,validation,queue,submit:command_buffer,submit_invalidates:* //FAIL: webgpu:api,validation,queue,submit:command_buffer,invalid_submit_invalidates:* // https://github.com/gfx-rs/wgpu/issues/3911#issuecomment-2972995675 +webgpu:api,validation,render_pass,render_pass_descriptor:attachments,* webgpu:api,operation,render_pipeline,overrides:* webgpu:api,operation,rendering,basic:clear:* webgpu:api,operation,rendering,basic:fullscreen_quad:* diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index e15bcd82a..6ecbff679 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -10,7 +10,24 @@ use alloc::sync::Arc; use super::TimestampQuerySupport; -const MAX_COMMAND_BUFFERS: u64 = 2048; +/// Maximum number of command buffers for `MTLCommandQueue`s that we create. +/// +/// If a [new command buffer] is requested when Metal has run out of command +/// buffers, it waits indefinitely for one to become available. If the +/// outstanding command buffers are actively executing on the GPU, this will +/// happen relatively quickly. But if the outstanding command buffers will only +/// be recovered upon GC, and attempting to get a new command buffer prevents +/// forward progress towards that GC, there is a deadlock. +/// +/// This is mostly a problem for the CTS, which frequently creates command +/// buffers that it does not submit. It is unclear how likely command buffer +/// exhaustion is in real applications. +/// +/// This limit was increased from a previous value of 2048 for +/// . +/// +/// [new command buffer]: https://developer.apple.com/documentation/metal/mtlcommandqueue/makecommandbuffer()?language=objc +const MAX_COMMAND_BUFFERS: u64 = 4096; unsafe impl Send for super::Adapter {} unsafe impl Sync for super::Adapter {}