Bug 189121 - [WHLSL] Not all functions should be able to run in all shader stages
Summary: [WHLSL] Not all functions should be able to run in all shader stages
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks: 176199 189202
  Show dependency treegraph
 
Reported: 2018-08-29 16:34 PDT by Myles C. Maxfield
Modified: 2018-10-13 14:51 PDT (History)
7 users (show)

See Also:


Attachments
Patch (18.81 KB, patch)
2018-09-22 02:59 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (21.27 KB, patch)
2018-09-22 14:00 PDT, Myles C. Maxfield
fpizlo: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2018-08-29 16:34:17 PDT
Derivative functions can only run in fragment shaders. There are probably others like this.

Same for built-in variables.
Comment 1 Myles C. Maxfield 2018-08-29 16:38:20 PDT
Barriers can only be used in compute shaders
Comment 2 Thomas Denney 2018-08-29 17:18:57 PDT
When these functions are introduced in the standard library it would be nice if we could add the restriction there, e.g.

native fragment float ddx(float)

And then enforce that native functions with the fragment annotation can only be called from inside fragment shaders. I’d prefer to have a syntactic restriction like this than something that the interpreter/spec has to worry about.
Comment 3 Radar WebKit Bug Importer 2018-09-12 18:51:06 PDT
<rdar://problem/44403005>
Comment 4 Myles C. Maxfield 2018-09-22 01:59:22 PDT
The built-in variables are handled in https://bugs.webkit.org/show_bug.cgi?id=189134
Comment 5 Myles C. Maxfield 2018-09-22 02:59:08 PDT
Created attachment 350512 [details]
Patch
Comment 6 Myles C. Maxfield 2018-09-22 04:24:55 PDT
I'm not sure that additions to the grammar are a good idea. If we add new keywords here, it seems we should also be doing it in https://bugs.webkit.org/show_bug.cgi?id=189122, but I don't think a proliferation of these keywords are a good idea. It seems like the compiler could "just know" which functions have which properties.
Comment 7 Myles C. Maxfield 2018-09-22 14:00:11 PDT
Created attachment 350533 [details]
Patch
Comment 8 WebKit Commit Bot 2018-09-24 17:29:22 PDT
Comment on attachment 350533 [details]
Patch

Rejecting attachment 350533 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-01', 'apply-attachment', '--no-update', '--non-interactive', 350533, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Logging in as commit-queue@webkit.org...
Fetching: https://bugs.webkit.org/attachment.cgi?id=350533&action=edit
Fetching: https://bugs.webkit.org/show_bug.cgi?id=189121&ctype=xml&excludefield=attachmentdata
Processing 1 patch from 1 bug.
Processing patch 350533 from bug 189121.
Fetching: https://bugs.webkit.org/attachment.cgi?id=350533
Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Filip Pizlo']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Parsed 15 diffs from patch file(s).
patching file Tools/ChangeLog
Hunk #1 succeeded at 1 with fuzz 3.
patching file Tools/WebGPUShadingLanguageRI/All.js
patching file Tools/WebGPUShadingLanguageRI/CheckNativeFuncStages.js
patching file Tools/WebGPUShadingLanguageRI/Intrinsics.js
Hunk #1 succeeded at 715 (offset 4 lines).
Hunk #2 succeeded at 822 (offset 4 lines).
patching file Tools/WebGPUShadingLanguageRI/LateChecker.js
Hunk #1 succeeded at 72 with fuzz 2 (offset 2 lines).
patching file Tools/WebGPUShadingLanguageRI/NativeFunc.js
patching file Tools/WebGPUShadingLanguageRI/Parse.js
Hunk #1 FAILED at 1171.
Hunk #2 succeeded at 1290 (offset 53 lines).
Hunk #3 succeeded at 1300 (offset 55 lines).
Hunk #4 succeeded at 1320 (offset 55 lines).
1 out of 4 hunks FAILED -- saving rejects to file Tools/WebGPUShadingLanguageRI/Parse.js.rej
patching file Tools/WebGPUShadingLanguageRI/Prepare.js
patching file Tools/WebGPUShadingLanguageRI/SPIRV.html
patching file Tools/WebGPUShadingLanguageRI/StandardLibrary.js
Hunk #4 succeeded at 1794 (offset 9 lines).
Hunk #5 FAILED at 1905.
Hunk #6 FAILED at 1915.
2 out of 6 hunks FAILED -- saving rejects to file Tools/WebGPUShadingLanguageRI/StandardLibrary.js.rej
patching file Tools/WebGPUShadingLanguageRI/StatementCloner.js
Hunk #1 succeeded at 46 (offset 3 lines).
patching file Tools/WebGPUShadingLanguageRI/Test.html
patching file Tools/WebGPUShadingLanguageRI/Test.js
patching file Tools/WebGPUShadingLanguageRI/WSyntaxError.js
patching file Tools/WebGPUShadingLanguageRI/index.html

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Filip Pizlo']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: https://webkit-queues.webkit.org/results/9338063
Comment 9 Myles C. Maxfield 2018-09-24 23:36:18 PDT
Committed r236455: <https://trac.webkit.org/changeset/236455>
Comment 10 Myles C. Maxfield 2018-09-25 12:35:10 PDT
Committed r236470: <https://trac.webkit.org/changeset/236470>
Comment 11 Myles C. Maxfield 2018-10-13 14:51:37 PDT
Migrated to https://github.com/gpuweb/WHLSL/issues/59