Skip to content

wgsl: Limit dynamic indexes to references to matrices and arrays.#1801

Merged
dneto0 merged 1 commit intogpuweb:mainfrom
jimblandy:matrix-array-indexing
Jun 3, 2021
Merged

wgsl: Limit dynamic indexes to references to matrices and arrays.#1801
dneto0 merged 1 commit intogpuweb:mainfrom
jimblandy:matrix-array-indexing

Conversation

@jimblandy
Copy link
Contributor

Fixes #1782.

Note that dynamic indexing of vectors is allowed, since SPIR-V does have the
OpVectorExtractDynamic instruction.

At present, this simply requires that indices for subscripting arrays and
matrices by value must be i32 or u32 literals. Once #1272 is resolved, then that
will provide a more flexible concept of "constant" that we can use instead.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2021

Previews, as seen when this build job started (61dbc5e):
WebGPU | IDL
WGSL
Explainer

@jimblandy jimblandy force-pushed the matrix-array-indexing branch from 61dbc5e to a4b5977 Compare June 3, 2021 05:24
@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2021

Previews, as seen when this build job started (a4b5977):
WebGPU | IDL
WGSL
Explainer

Fixes gpuweb#1782.

Note that dynamic indexing of vectors is allowed, since SPIR-V does have the
OpVectorExtractDynamic instruction.
@jimblandy jimblandy force-pushed the matrix-array-indexing branch from a4b5977 to 29b7e09 Compare June 3, 2021 05:36
@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2021

Previews, as seen when this build job started (29b7e09):
WebGPU | IDL
WGSL
Explainer

Copy link
Contributor

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

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

Thanks!

Note: Reflecting the limitations of the languages WGSL is meant to be translated
into, it is only possible to use dynamically computed indices to subscript
references to matrices. A matrix not behind a reference may only be indexed by a
`const_expr`. To work around this restriction, consider storing the matrix in a
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice note.

|e|: mat|N|x|M|&lt;|T|&gt;<br>
|i|: [INT]
|i|: [INT]<br>
|i| is a `const_expr` expression
Copy link
Contributor

Choose a reason for hiding this comment

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

While working through #1792, I realized we don't have a defined term for const_expr and we probably need one. (that's for later.) This is great for now though.

@dneto0 dneto0 merged commit c365257 into gpuweb:main Jun 3, 2021
github-actions bot added a commit that referenced this pull request Jun 3, 2021
…1801)

SHA: c365257
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Jun 3, 2021
…1801)

SHA: c365257
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Jun 3, 2021
…1801)

SHA: c365257
Reason: push, by @dneto0

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jimblandy added a commit to jimblandy/naga that referenced this pull request Jun 4, 2021
This makes Naga IR validation impose the restrictions added to WGSL in
gpuweb/gpuweb#1801.

Remove code in the SPIR-V writer to spill arrays to temporary variables in order
to index them dynamically. If such IR is encountered, treat it as a failure of
validation.
jimblandy added a commit to jimblandy/naga that referenced this pull request Jun 4, 2021
This makes Naga IR validation impose the restrictions added to WGSL in
gpuweb/gpuweb#1801.

Remove code in the SPIR-V writer to spill arrays to temporary variables in order
to index them dynamically. If such IR is encountered, treat it as a failure of
validation.
kvark pushed a commit to gfx-rs/naga that referenced this pull request Jun 4, 2021
…#949)

This makes Naga IR validation impose the restrictions added to WGSL in
gpuweb/gpuweb#1801.

Remove code in the SPIR-V writer to spill arrays to temporary variables in order
to index them dynamically. If such IR is encountered, treat it as a failure of
validation.
@jimblandy jimblandy changed the title wgsl: Limit dynamic indexes to references to matrices and arrrays. wgsl: Limit dynamic indexes to references to matrices and arrays. Jun 14, 2021
ben-clayton pushed a commit to ben-clayton/Tint that referenced this pull request Jun 21, 2021
Dynamic indexes are limited to references to matrices and arrays
gpuweb/gpuweb#1801

Bug: tint:867
Change-Id: I114daa053c8a4ffd23ce784ac4538567a551cc21
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54701
Kokoro: Kokoro <[email protected]>
Reviewed-by: Ben Clayton <[email protected]>
Commit-Queue: Ben Clayton <[email protected]>
Auto-Submit: Sarah Mashayekhi <[email protected]>
ben-clayton pushed a commit to ben-clayton/Tint that referenced this pull request Jun 21, 2021
gpuweb/gpuweb#1801
indexes must be of type 'i32' or 'u32'

Bug: tint:867
Change-Id: Ie5bfacf87af5a06d5428dc510145e96fb156c42e
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54720
Kokoro: Kokoro <[email protected]>
Auto-Submit: Sarah Mashayekhi <[email protected]>
Reviewed-by: Antonio Maiorano <[email protected]>
Reviewed-by: Ben Clayton <[email protected]>
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
Useful for configuring global parameters for running tests, and for
registering hooks to receive callbacks back from the test runner.
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.

WGSL requires dynamic matrix indexing, which requires surprising SPIR-V

3 participants