Skip to content

feat(types): Add conversions to/from feature name strings#9163

Merged
andyleiserson merged 3 commits intogfx-rs:trunkfrom
andyleiserson:jj-push-srlt
Mar 18, 2026
Merged

feat(types): Add conversions to/from feature name strings#9163
andyleiserson merged 3 commits intogfx-rs:trunkfrom
andyleiserson:jj-push-srlt

Conversation

@andyleiserson
Copy link
Copy Markdown
Contributor

Moves feature name logic from deno to wgpu-types so we can use it in other clients, and so that it will stay up-to-date as features are added.

Adds the wgpu- prefix to all the native features, but for the ones that were previously accepted without it, continues to do so. Exceptions: subgroups and primitive-index are currently grouped with the wgpu features, but are standard-track features, so they use the standard-defined feature name. There is also a special backcompat case to accept shader-primitive-index as an alias for primitive-index. I'm not sure how necessary all the backcompat handling is.

Testing
Adds a unit test.

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.
  • Needs a CHANGELOG.md entry, although really it's the Deno changelog that matters.

}

#[test]
fn check_features_bits() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before moving my new stuff to a separate test, I was modifying this test, and noticed that it repeated the same code 3x. I assume that was a mistake and the intent was to do the same checks for each of Features, FeaturesWebGPU, and FeaturesWGPU, so I changed it to do that.

Copy link
Copy Markdown
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It would be really nice if there could b a single macro that defines both lists, so we don't have desync issues (or even better if it could be the original Features list so we don't forget any (though that will be covered by the test case).

Approving, feel free to do this now, boot this to another PR or not at all.

Copy link
Copy Markdown
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minus a nit.

Comment on lines -245 to 250
desc = { requiredFeatures: ['external-texture'] };
desc = { requiredFeatures: ['wgpu-external-texture'] };
} else if (!desc.requiredFeatures) {
desc.requiredFeatures = ['external-texture'];
desc.requiredFeatures = ['wgpu-external-texture'];
} else {
desc.requiredFeatures.push('external-texture');
desc.requiredFeatures.push('wgpu-external-texture');
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: This change seems unnecessary since external-texture is still accepted, and is ultimately the feature name we want for cts_runner as a strictly WebGPU environment. Was there a reason you wanted to migrate this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

External texture (originally I wrote "external feature" here 🫠) is part of the WebGPU core feature set. The notion of it as an optional feature is a wgpu-ism. So I prefixed it on the rationale that any name that is not defined by WebGPU, should have the wgpu- prefix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I think that's fair. 👍🏻 No objection, then!

@ErichDonGubler
Copy link
Copy Markdown
Member

@cwfitzgerald:

It would be really nice if there could b a single macro that defines both lists, so we don't have desync issues (or even better if it could be the original Features list so we don't forget any (though that will be covered by the test case).

+1!

@andyleiserson andyleiserson merged commit 04cce5a into gfx-rs:trunk Mar 18, 2026
59 checks passed
@andyleiserson andyleiserson deleted the jj-push-srlt branch March 18, 2026 16:59
inner-daemons pushed a commit to inner-daemons/wgpu that referenced this pull request Mar 18, 2026
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.

3 participants