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

[naga] Support dynamic indexing of by-value matrices #6362

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

sagudev
Copy link
Contributor

@sagudev sagudev commented Oct 3, 2024

Connections
Fix #4337

Description
Add support for dynamic indexing of by-value matrices, by introducing get_local_pointer_id and then follow #6188.

Testing
New tests added and because there was no expectation changes in servo's CTS run I wrote new test: gpuweb/cts#3982 (which passes with this PR).

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@sagudev

This comment was marked as duplicate.

Comment on lines 172 to 179
let element_pointer_type_id = match element_ty {
LookupType::Handle(handle) => {
self.get_pointer_id(ir_types, handle, spirv::StorageClass::Function)?
}
LookupType::Local(local_type) => {
self.get_local_pointer_id(local_type, spirv::StorageClass::Function)
}
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we pack this in one single get_pointer_id method?

BTW get_pointer_id never returns Err.

Copy link
Member

@teoxoy teoxoy Oct 8, 2024

Choose a reason for hiding this comment

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

I think we should update get_pointer_id and address the TODO that's currently in get_local_pointer_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

address the TODO that's currently in get_local_pointer_id

This is hard as we cannot pack LookupType in pointer (due to infinite struct size), except if we box it. Another alternative is to simply put u32 for local type, but this could get pretty chaotic.

I think boxing solution is the most nice one. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

What I hand in mind is adding a new ValuePointer variant. Similar to:

ValuePointer {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LocalType has pointers encoded in LocalType::Value field.

@sagudev sagudev marked this pull request as ready for review October 5, 2024 17:37
@sagudev sagudev requested a review from a team as a code owner October 5, 2024 17:37
@sagudev sagudev changed the title [naga] support dyn indexing of matrix [naga] Support dynamic indexing of by-value matrices Oct 5, 2024
Signed-off-by: sagudev <16504129 [email protected]>
TypeResolution::Handle(handle) => handle,
TypeResolution::Value(_) => {
return Err(Error::Validation(
"Array types should always be in the arena",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Array types should always be in the arena",
"Matrix types should always be in the arena",

I don't think this is always true:

/// - TypeInner::Matrix (generated by matrix multiplication)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was copy&paste from array, I will check and fix.

Signed-off-by: sagudev <16504129 [email protected]>
Signed-off-by: sagudev <16504129 [email protected]>
@jimblandy
Copy link
Member

I think actually just fixing #6358 for both matrices and arrays might be simpler than the combination of this and #6188. I'm taking a shot at it now, but if it's hard, then we'll take this PR instead.

@sagudev
Copy link
Contributor Author

sagudev commented Oct 8, 2024

I think actually just fixing #6358 for both matrices and arrays might be simpler than the combination of this and #6188. I'm taking a shot at it now, but if it's hard, then we'll take this PR instead.

Sounds good. Ping me on PR, so I will see it (and test it with servo against CTS).

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.

Support dynamic indexing of by-value matrices and arrays, per WGSL
3 participants