-
Notifications
You must be signed in to change notification settings - Fork 1k
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 spv-out] Indexing arrays by value causes unnecessary copies #6358
Labels
area: naga back-end
Outputs of naga shader conversion
area: performance
How fast things go
lang: SPIR-V
Vulkan's Shading Language
naga
Shader Translator
Comments
6 tasks
More exact link to comment: #6188 (comment) |
6 tasks
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. Permit dynamic indexing of matrices in validation. Handle matrices and arrays consistently; remove special cases for arrays. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessIndex` for the entire thing. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Alternative to gfx-rs#6362.
3 tasks
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. Permit dynamic indexing of matrices in validation. Handle matrices and arrays consistently; remove special cases for arrays. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessIndex` for the entire thing. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessIndex` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessIndex` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 10, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 11, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 11, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
to jimblandy/wgpu
that referenced
this issue
Oct 11, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes gfx-rs#6358. Fixes gfx-rs#4337. Alternative to gfx-rs#6362.
jimblandy
added a commit
that referenced
this issue
Oct 11, 2024
Improve handling of `Access` expressions whose base is an array or matrix (not a pointer to such), and whose index is not known at compile time. SPIR-V does not have instructions that can do this directly, so spill such values to temporary variables, and perform the accesses using `OpAccessChain` instructions applied to the temporaries. When performing chains of accesses like `a[i].x[j]`, do not reify intermediate values; generate a single `OpAccessChain` for the entire thing. Remove special cases for arrays; the same code now handles arrays and matrices. Update validation to permit dynamic indexing of matrices. For details, see the comments on the new tracking structures in `naga::back::spv::Function`. Add snapshot test `index-by-value.wgsl`. Fixes #6358. Fixes #4337. Alternative to #6362.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: naga back-end
Outputs of naga shader conversion
area: performance
How fast things go
lang: SPIR-V
Vulkan's Shading Language
naga
Shader Translator
Given code like this:
the changes in #6188 will copy each intermediate indexing result into a separate variable. It would be much nicer to simply spill the value into a variable the moment we know it will be indexed dynamically, and then always use it from there.
The text was updated successfully, but these errors were encountered: