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

Support array bindings of buffers #2282

Merged
merged 6 commits into from
Apr 25, 2023
Merged

Conversation

kvark
Copy link
Member

@kvark kvark commented Mar 16, 2023

Built upon #2256 , which should land first. I can also move this one out (so far just one commit).
Only WGSL -> IR -> SPV path supported right now.
Closes #1864

@codecov-commenter
Copy link

codecov-commenter commented Mar 18, 2023

Codecov Report

Merging #2282 (a5d2d09) into master (53d62b9) will increase coverage by 0.00%.
The diff coverage is 95.16%.

❗ Current head a5d2d09 differs from pull request most recent head 7866e97. Consider uploading reports for the commit 7866e97 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##           master    #2282   +/-   ##
=======================================
  Coverage   82.19%   82.19%           
=======================================
  Files          82       82           
  Lines       44267    44296   +29     
=======================================
+ Hits        36384    36410   +26     
- Misses       7883     7886    +3     
Impacted Files Coverage Δ
src/back/spv/mod.rs 95.23% <ø> (ø)
src/valid/type.rs 90.48% <80.00%> (-0.18%) ⬇️
src/back/spv/block.rs 91.41% <94.73%> (-0.07%) ⬇️
src/back/spv/helpers.rs 96.66% <100.00%> (+0.05%) ⬆️
src/back/spv/writer.rs 96.74% <100.00%> (+0.02%) ⬆️
src/proc/index.rs 90.66% <100.00%> (+0.06%) ⬆️
src/proc/typifier.rs 77.41% <100.00%> (+0.08%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@kvark kvark force-pushed the storage-array branch 5 times, most recently from faf65b0 to 777f5e5 Compare March 18, 2023 22:34
@kvark kvark mentioned this pull request Mar 22, 2023
5 tasks
@kvark kvark force-pushed the storage-array branch 3 times, most recently from a5d2d09 to 7866e97 Compare March 23, 2023 03:40
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Just a few comments so far:

src/proc/typifier.rs Show resolved Hide resolved
Comment on lines 634 to 626
if base >= handle {
return Err(TypeError::UnresolvedBase(base));
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't need these checks any more, since they're all handled up front in valid/handles.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are still doing these checks for Ti::Pointer and Ti::Array, so this one is there for consistency. If we want to remove them all, that's fine by me, but should be done separately.

Copy link
Member

Choose a reason for hiding this comment

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

We do want to remove them all, since they're redundant. There's no reason to make more work for the person who has to clean that up. Filed as #2303.

Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be removed in this PR if you don't want. It's not like we'll be able to miss it when we fix #2303.

Copy link
Member

Choose a reason for hiding this comment

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

CI seems to now be failing due to this since we already merged #2308.

src/valid/type.rs Outdated Show resolved Hide resolved
Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

I see why TypeFlags::DATA is needed, but I'd also like us to pass this test, in the wgsl-errors.rs style:

#[test]
fn binding_array_local() {
    check_validation! {
        "fn f() { var x: binding_array<i32, 4>; }":
        Err(_)
    }
}

@kvark
Copy link
Member Author

kvark commented Apr 14, 2023

@jimblandy take a look at the new commit. We aren't putting DATA on the binding arrays any more.

@kvark kvark force-pushed the storage-array branch 3 times, most recently from 728e41e to a067ea5 Compare April 18, 2023 04:45
@jimblandy
Copy link
Member

jimblandy commented Apr 19, 2023

How about this one:

#[test]
fn binding_array_private() {
    check_validation! {
        "var<private> x: binding_array<i32, 4>;":
        Err(_)
    }
}

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

I think that test case I posted above shows that validate_global_var can't quite treat a binding_array<T> just like a T, although there's good reason to think that's usually the right thing.

src/valid/interface.rs Show resolved Hide resolved
@jimblandy
Copy link
Member

jimblandy commented Apr 19, 2023

Is this comment on BlockContext::write_expression_pointer in back/spv/block.rs still accurate?

    /// Some cases we need to generate a different return type than what the IR gives us.
    /// This is because pointers to binding arrays don't exist in the IR, but we need to
    /// create them to create an access chain in SPIRV.

Because, we certainly do generate pointers to binding arrays in the IR now.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Other than these issues, and the additional test I mentioned above, this looks good to go.

src/valid/type.rs Show resolved Hide resolved
src/back/spv/mod.rs Show resolved Hide resolved
src/back/spv/block.rs Show resolved Hide resolved
@kvark
Copy link
Member Author

kvark commented Apr 24, 2023

@jimblandy thanks for suggestions! New validation error is added, tests improved, and documentation patches applied.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

Thank you!

@jimblandy jimblandy merged commit 37b3c36 into gfx-rs:master Apr 25, 2023
@kvark kvark deleted the storage-array branch April 25, 2023 17:58
@kvark kvark added the can backport PR that can be back-ported to a release branch label May 24, 2023
kvark added a commit to kvark/naga that referenced this pull request May 30, 2023
* Support buffer resource arrays in IR, wgsl-in, and spv-out

* spv-out: refactor non-uniform indexing semantics to support buffers

* Update the doc comment on BindingArray type

* Improve TypeInfo restrictions on binding arrays

* Strip DATA out of binding arrays

* Include suggested documentation, more binding array tests, enforce structs
jimblandy pushed a commit that referenced this pull request May 30, 2023
* Support buffer resource arrays in IR, wgsl-in, and spv-out

* spv-out: refactor non-uniform indexing semantics to support buffers

* Update the doc comment on BindingArray type

* Improve TypeInfo restrictions on binding arrays

* Strip DATA out of binding arrays

* Include suggested documentation, more binding array tests, enforce structs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can backport PR that can be back-ported to a release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Storage buffers in binding arrays aren't writable
4 participants