Skip to content

[WGSL] Add mechanism to validate override values#34501

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
tadeuzagallo:eng/WGSL-Add-mechanism-to-validate-override-values
Oct 2, 2024
Merged

[WGSL] Add mechanism to validate override values#34501
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
tadeuzagallo:eng/WGSL-Add-mechanism-to-validate-override-values

Conversation

@tadeuzagallo
Copy link
Copy Markdown
Member

@tadeuzagallo tadeuzagallo commented Oct 1, 2024

a9fce28

[WGSL] Add mechanism to validate override values
https://bugs.webkit.org/show_bug.cgi?id=280676
rdar://136876110

Reviewed by Mike Wyrzykowski.

At compile time we validate constant values according to the spec,
as an example in this patch we cover that array sizes must be bigger
than 0. However, when the value can only be computed after overrides
have been provided, we need a way to validate the these values at a
later stage. This patch introduces the mechanism that will be used
for such validations, by storing the necessary validations in the
shader module, and then executing each validation every time the
module is used in a pipeline.

* Source/WebGPU/WGSL/CompilationMessage.h:
(WGSL::CompilationMessage::CompilationMessage):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visit):
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::generate):
* Source/WebGPU/WGSL/WGSL.h:
* Source/WebGPU/WGSL/WGSLShaderModule.cpp: Added.
(WGSL::ShaderModule::validateOverrides):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::addOverrideValidation):
* Source/WebGPU/WGSL/tests/invalid/override.wgsl: Added.
* Source/WebGPU/WGSL/wgslc.cpp:
(runWGSL):
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Source/WebGPU/WebGPU/Pipeline.mm:
(WebGPU::createLibrary):
* Source/WebGPU/WebGPU/ShaderModule.mm:
(WebGPU::earlyCompileShaderModule):

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

b1ce966

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ❌ 🧪 mac-intel-wk2
✅ 🛠 tv
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@tadeuzagallo tadeuzagallo self-assigned this Oct 1, 2024
@tadeuzagallo tadeuzagallo added the WebGPU For bugs in WebGPU label Oct 1, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 1, 2024
@tadeuzagallo tadeuzagallo removed the merging-blocked Applied to prevent a change from being merged label Oct 1, 2024
@tadeuzagallo tadeuzagallo force-pushed the eng/WGSL-Add-mechanism-to-validate-override-values branch from 03b79cb to b1ce966 Compare October 1, 2024 12:30
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 1, 2024
@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 2, 2024
https://bugs.webkit.org/show_bug.cgi?id=280676
rdar://136876110

Reviewed by Mike Wyrzykowski.

At compile time we validate constant values according to the spec,
as an example in this patch we cover that array sizes must be bigger
than 0. However, when the value can only be computed after overrides
have been provided, we need a way to validate the these values at a
later stage. This patch introduces the mechanism that will be used
for such validations, by storing the necessary validations in the
shader module, and then executing each validation every time the
module is used in a pipeline.

* Source/WebGPU/WGSL/CompilationMessage.h:
(WGSL::CompilationMessage::CompilationMessage):
* Source/WebGPU/WGSL/TypeCheck.cpp:
(WGSL::TypeChecker::visit):
* Source/WebGPU/WGSL/WGSL.cpp:
(WGSL::generate):
* Source/WebGPU/WGSL/WGSL.h:
* Source/WebGPU/WGSL/WGSLShaderModule.cpp: Added.
(WGSL::ShaderModule::validateOverrides):
* Source/WebGPU/WGSL/WGSLShaderModule.h:
(WGSL::ShaderModule::addOverrideValidation):
* Source/WebGPU/WGSL/tests/invalid/override.wgsl: Added.
* Source/WebGPU/WGSL/wgslc.cpp:
(runWGSL):
* Source/WebGPU/WebGPU.xcodeproj/project.pbxproj:
* Source/WebGPU/WebGPU/Pipeline.mm:
(WebGPU::createLibrary):
* Source/WebGPU/WebGPU/ShaderModule.mm:
(WebGPU::earlyCompileShaderModule):

Canonical link: https://commits.webkit.org/284570@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/WGSL-Add-mechanism-to-validate-override-values branch from b1ce966 to a9fce28 Compare October 2, 2024 18:33
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 284570@main (a9fce28): https://commits.webkit.org/284570@main

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

@webkit-commit-queue webkit-commit-queue merged commit a9fce28 into WebKit:main Oct 2, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 2, 2024
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

Development

Successfully merging this pull request may close these issues.

5 participants