Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test default layout bindgroups #3374

Merged
merged 6 commits into from
Feb 10, 2024

Conversation

greggman
Copy link
Contributor

@greggman greggman commented Feb 7, 2024

It's probably a good idea to decide what we want to happen here and fix it ASAP because as it is, Chrome will allow bind groups made with different layout: 'auto' pipelines to work with each other but the spec seems to say that's disallowed. It's easy to imagine lots of WebGPU pages are already breaking this rule.

I also suspect the spec would like to say that all empty bind group layouts are compatible but I don't see that in the spec currently so it's tested that they are not compatible in this PR.


Requirements for PR author:

  • All missing test coverage is tracked with "TODO" or .unimplemented().
  • New helpers are /** documented */ and new helper files are found in helper_index.txt.
  • Test behaves as expected in a WebGPU implementation. (If not passing, explain above.)

Requirements for reviewer sign-off:

  • Tests are properly located in the test tree.
  • Test descriptions allow a reader to "read only the test plans and evaluate coverage completeness", and accurately reflect the test code.
  • Tests provide complete coverage (including validation control cases). Missing coverage MUST be covered by TODOs.
  • Helpers and types promote readability and maintainability.

When landing this PR, be sure to make any necessary issue status updates.

@greggman greggman requested a review from kainino0x February 7, 2024 23:36
Comment on lines 926 to 927
* Test empty bindgroup layouts on the same default layout pipeline are not compatible. In other words if
you only define group(2) then group(0)'s empty layout and group(1)'s empty layout should be incompatible.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The spec rules as written only require it to come from the same pipeline, not the same slot:
https://gpuweb.github.io/gpuweb/#bind-group-compatibility
This is a little odd, but probably fine as I don't think it's much of a footgun?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case we need to test that 2 bind groups that appear the same, are the same? In other words

      @group(0) @binding(0) var s1: sampler;
      @group(0) @binding(1) var t1: texture_2d<f32>;

      @group(1) @binding(0) var s2: sampler;
      @group(1) @binding(1) var t2: texture_2d<f32>;

If we use layout: 'auto' on this then a bindGroup made with pipeline.getBindGroupLayout(0) should work bound to bind group 1.

I don't think there is a test for that and it would be easy for browsers to disagree on this without a test?

It does make me wonder why they aren't just compatible in general. The rules are spelled out for what gets generated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

good point, we would definitely need to test that. Unless we want to make a breaking change in the spec and make it stricter.

The exclusivePipeline thing was added as a way to prevent footguns because auto layouts are sensitive to static uses in WGSL which are fairly subtle and easy to change (like by commenting out a function call, it removes from the BGL some binding that was used by that function's call tree). But I do wonder if it's really needed. Maybe with some good error messages there would be no footgun, like, "bindgroup created with auto BGL from pipeline 'X' but is used with pipeline 'Y' which has an incompatible auto BGL. Note that auto BGLs do not include declared bindings which are not reachable from the entrypoint of the pipeline".
Jasper and Brandon both had more opinions about this. We definitely picked the current behavior knowing it was a more "safe for 1.0" decision that we didn't necessarily have to keep forever.

greggman and others added 6 commits February 9, 2024 16:26
According to the current WebGPU spec, a bind group created
with a bind group layout that itself is from a default layout
pipeline (a pipeline created with `layout: 'auto'` is
incompatible with any other bind group created with a different
bind group layout, even if they'd appear to match by their
resource types and binding locations. Further, no excpetion is made
for empty bind groups.
@greggman greggman force-pushed the test-default-layout-bindgroups branch from 9794bf9 to 4d39a49 Compare February 10, 2024 00:30
@greggman greggman enabled auto-merge (squash) February 10, 2024 00:32
@greggman greggman merged commit 726c24a into gpuweb:main Feb 10, 2024
1 check passed
@greggman greggman deleted the test-default-layout-bindgroups branch February 10, 2024 00:36
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