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

[WGSL] Generate the correct code for arrayLength #18697

Conversation

tadeuzagallo
Copy link
Member

@tadeuzagallo tadeuzagallo commented Oct 5, 2023

8f80944

[WGSL] Generate the correct code for arrayLength
https://bugs.webkit.org/show_bug.cgi?id=262703
rdar://116524838

Reviewed by Mike Wyrzykowski.

As of 268884@main, the API now exposes the size of runtime-sized arrays at the
end of the argument buffer. This patch updates the compiler to match this argument
buffer layout and rewrite calls to arrayLength to read these sizes.

* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::getPacking):
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::containsRuntimeArray):
(WGSL::RewriteGlobalVariables::packArrayType):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::emitArrayLength):
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/tests/valid/array-length.wgsl: Added.

Canonical link: https://commits.webkit.org/268995@main

4091e28

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug 🧪 wpe-wk2
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🛠 gtk
✅ 🧪 ios-wk2-wpt ✅ 🧪 gtk-wk2
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🧪 api-gtk
✅ 🛠 tv 🧪 mac-AS-debug-wk2
✅ 🛠 tv-sim
✅ 🛠 🧪 merge ✅ 🛠 watch
✅ 🛠 watch-sim

@tadeuzagallo tadeuzagallo self-assigned this Oct 5, 2023
@tadeuzagallo tadeuzagallo added the WebGPU For bugs in WebGPU label Oct 5, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 5, 2023
mwyrzykowski
mwyrzykowski previously approved these changes Oct 5, 2023
@mwyrzykowski mwyrzykowski dismissed their stale review October 5, 2023 19:25

found an issue

@mwyrzykowski
Copy link
Contributor

Approval is based on having the compiler error fixed, but I tried the change and it works great

@tadeuzagallo tadeuzagallo force-pushed the eng/WGSL-Generate-the-correct-code-for-arrayLength branch from 2757bc5 to 4091e28 Compare October 6, 2023 14:26
@tadeuzagallo tadeuzagallo added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Oct 6, 2023
https://bugs.webkit.org/show_bug.cgi?id=262703
rdar://116524838

Reviewed by Mike Wyrzykowski.

As of 268884@main, the API now exposes the size of runtime-sized arrays at the
end of the argument buffer. This patch updates the compiler to match this argument
buffer layout and rewrite calls to arrayLength to read these sizes.

* Source/WebGPU/WGSL/GlobalVariableRewriter.cpp:
(WGSL::RewriteGlobalVariables::getPacking):
(WGSL::RewriteGlobalVariables::collectGlobals):
(WGSL::RewriteGlobalVariables::containsRuntimeArray):
(WGSL::RewriteGlobalVariables::packArrayType):
* Source/WebGPU/WGSL/Metal/MetalFunctionWriter.cpp:
(WGSL::Metal::emitArrayLength):
(WGSL::Metal::FunctionDefinitionWriter::visit):
* Source/WebGPU/WGSL/tests/valid/array-length.wgsl: Added.

Canonical link: https://commits.webkit.org/268995@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WGSL-Generate-the-correct-code-for-arrayLength branch from 4091e28 to 8f80944 Compare October 6, 2023 16:42
@webkit-commit-queue
Copy link
Collaborator

Committed 268995@main (8f80944): https://commits.webkit.org/268995@main

Reviewed commits have been landed. Closing PR #18697 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 8f80944 into WebKit:main Oct 6, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebGPU For bugs in WebGPU
Projects
None yet
5 participants