Skip to content

Conversation

@andyleiserson
Copy link
Contributor

@andyleiserson andyleiserson commented Jan 8, 2026

The depth-related fields are optional in the WebGPU API, and must be specified iff they are relevant to the configuration. In order to have wgpu-core provide a common implementation of this validation for all the JS clients, this changes pipeline descriptors to use a new DepthStencilStateIdl struct that matches the spec (at least for the enable/compare -- it still differs from the spec in that the depth bias values are not inlined).

DepthStencilState is maintained as-is so that implementations can keep the same struct literals and just add a call to .into(). I also added some associated method constructors that will be forwards-compatible with making DepthStencilState look like DepthStencilStateIdl.

There is some related discussion in Matrix. We may decide to create a separate DepthState struct instead.

This PR conflicts with #8856. Whichever lands second should enable the entire depth_stencil_state suite.

Testing
Enables some relevant CTS tests.

Squash or Rebase? Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

The depth-related fields are optional in the WebGPU API, and must be
specified iff they are relevant to the configuration.
@andyleiserson
Copy link
Contributor Author

(Responding to discussion of a possible DepthState struct in matrix): The rules are that depthWriteEnabled must be provided if using a depth format; depthCompare must be provided if depthWriteEnabled is true or if stencil has an active depthFailOp. So while depthWriteEnabled could be mandatory in DepthState, depthCompare would still need to be optional. I think that makes it harder to justify a breaking change to introduce DepthState.

A data point: https://github.com/search?q=language%3ARust+RenderPipelineDescriptor+DepthStencilState&type=code finds 6.7k files 😬. Even the need to add .into() doesn't seem great, but I couldn't figure out an alternative that didn't involve duplicating or adding a type parameter to all the pipeline descriptors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants