Repository navigation
[hal vulkan] Fail the pipeline, not the device, when the driver rejects it - #14
Open
matthargett wants to merge 3 commits into
Open
matthargett wants to merge 3 commits into
matthargett wants to merge 3 commits into
Conversation
…ts it `vkCreateGraphicsPipelines`, `vkCreateComputePipelines` and `vkCreateRayTracingPipelinesKHR` results other than out-of-memory were mapped to `DeviceError::Unexpected`, which dropped the result code. wgpu-core loses the device on that error, so one shader a driver could not compile made every later operation on the device fail, and nothing said which pipeline or which result was the cause. With the `internal_error_panic` feature, which `cts_runner` enables, the process panicked. Drivers return such results for shaders they cannot compile, and only the pipeline is affected. Arm's proprietary Mali driver (seen with r20p0 on a Mali-G52 MC2) returns `VK_ERROR_INITIALIZATION_FAILED` for a shader that declares a multisampled depth image. The GPU tests expect the same result from MoltenVK in eight tests, and gfx-rs#10027 reports it for Mesa ANV and NVIDIA's driver with compute shaders that need too much private memory. Report these as `PipelineError::Linkage` with the command name and the result, as the DX12 and Metal backends do when pipeline creation fails. wgpu-core turns that into an internal error on the pipeline, with the pipeline's label, and the device stays usable. `VK_ERROR_DEVICE_LOST` is now reported as a lost device instead of an unexpected error. Since the device now outlives a failed creation, destroy the temporary shader modules before checking the result instead of leaking them. The MoltenVK expectations of those eight GPU tests matched the old panic text and are updated to the new error.
When a backend error makes wgpu-core lose a device, the device-lost callback gets "Device is lost" or "Unexpected error variant (driver implementation is at fault)" and nothing is logged. Neither says which operation failed, which driver was in use, or what the driver returned, so a report from the field cannot be matched to a cause. Log an error the first time a device is lost, with the caller of `handle_hal_error` (`#[track_caller]`, so the location in wgpu-core of the operation that failed), the adapter name, the backend, and the driver name and version. In the Vulkan backend, log the `VkResult` of an unexpected error, which `DeviceError::Unexpected` cannot carry. The message passed to the device-lost callback is unchanged: embedders may hand it to web content, and the driver strings are already available to the application from `AdapterInfo`.
`GPUError::Internal` had no payload, and the JS `GPUInternalError` constructor took no message, so `message` was `undefined` on an internal error popped from an error scope or passed to `uncapturederror`. A script could tell that pipeline creation failed in the backend but not why. Carry the message, as `GPUValidationError` does. WebGPU declares the constructor of all three error classes with a `message` argument. `createComputePipelineAsync()` and `createRenderPipelineAsync()` rejected with reason "validation" for every failure. Use "internal" when the error is an internal one.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connections
Upstream issue
10027in gfx-rs/wgpu describes the first problem for Mesa ANV and NVIDIA's driver. It was closed by its author without a linked change, and the code it describes is the same on trunk60cef2be8.Found running the WebGPU CTS with
cts_runneron a Mali-G52 MC2 (Arm proprietary Vulkan 1.1 driverv1.r20p0-01rel0, Android 10). #7 fixes the shader that triggers it on that device; this PR is about what happens when a driver rejects a pipeline for any reason. Other fixes for the device: #8, #9, #10.Description
Three commits.
vkCreate*Pipelinesresults other than out-of-memory becameDeviceError::Unexpected, which drops the result code, and wgpu-core loses the device on that. They are nowPipelineError::Linkagewith the command name and the result, as on DX12 and Metal: an internal error on the pipeline, and the device stays usable.VK_ERROR_DEVICE_LOSTmaps to a lost device.#[track_caller]onhandle_hal_error), the adapter, the backend and the driver name and version. The Vulkan backend logs theVkResultof an unexpected error. The message passed to the device-lost callback is unchanged.GPUInternalError.messagewasundefined. The async pipeline creation methods now reject with reason"internal"for an internal error instead of"validation".To check when reviewing:
internal_error_panic(whichcts_runnerenables) these results no longer panic. Eight GPU tests expect this failure from MoltenVK and matched the panic text; their expectations now match the new error. I have no MoltenVK install, so only CI checks them.{:?}, which is long now thatShaderStageshas two parts. Not changed here.Testing
cargo fmt --checkand clippy for wgpu-hal, wgpu-core and deno_webgpu are clean; the wgpu-hal unit tests pass, including a new one for the result mapping. Not run locally: the GPU tests andcts_runner's own tests.cts_runnerbuilt from trunk60cef2be8and from this branch.A compute pipeline whose shader declares a
texture_depth_multisampled_2d, which this driver rejects withVK_ERROR_INITIALIZATION_FAILED, then more work on the same device. The second "before" run is trunk built withoutinternal_error_panic, which is what an application gets:A render pass that loses the device on this driver (the layout bug #9 works around). Both runs end in the deno_webgpu panic and hang that #10 fixes; the difference is the
ERRORline, which points at the fence wait inDevice::maintain:textureNumSamplesand the tworesource_compatibilitygroups, 199 cases: on trunk four of the nine processes abort and 139 cases report a result. With this branch all 199 report one: 195 pass and 4 fail. The four declare a multisampled depth texture, and each failure message names the Vulkan command and the result.Squash or Rebase?
Rebase. The three commits are independent.
LLM Use?
Claude Code (Claude Mythos 5.2) found this on the device, wrote the code and the probe, ran the tests and drafted this description.