You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
entry_point_decl should be an annotation on the function #662
Just like how decorations are separate statements in SPIR-V, but were moved onto the variable declaration they are decorating in WGSL, the same treatment should be done on entry points. The benefit is that related concepts should be near each other in the source code.
Currently you can have multiple entry points with different names pointing at the same function. Those entry points are where, eventually, the execution modes [1] will attach.
Moving to decorations means you're going to have to have multiple decorations for a single function which isn't as nice as separating out to the entry point call.
Note, you could write your first example the same as the second as:
Moving to decorations means you're going to have to have multiple decorations for a single function which isn't as nice as separating out to the entry point call.
Why? All our existing decoration facilities accept lists of decorations, so I don’t see why this one shouldn’t as well.
Sorry, there's an easily confused thing going on here.
There's execution model (e.g. fragment vs. vertex vs. compute), and execution mode (describe/modify the behaviour of the shader stage).
Example of different execution modes:
the same compute shader body, but different workgroup sizes. (See LocalSize execution mode in SPIR-V)
the same shader stage but with different floating point behaviours (a newish Vulkan feature). See DenormPreserve, DenormFlushToZero, SignedZeroInfNanPreserve, RoundingModeRTE, and RoundingModeRTZ
If you attach these things to the function body itself, then you can always model the differences by having an extra layer of function wrapping, and attaching these attributes to the outside wrapper.
The multiple "expose_as" syntax is overly complex because now you have nested attributes on attributes. That's the "sublanguage" aspect I was complaining about in the meeting. That's a non-starter for me.
@dneto0 I agree that having meta-language for the attributes is not desired.
Would having separate wrapping functions (the second half of #662 (comment)) be a non-starter as well?
All popular human-writable shading languages annotate the function. No human-writable languages have standalone entry point decl statements. Somehow none of those languages have been crushed by the weight of the annotations.
From this list, I see some which a) aren't even applicable to shaders, b) aren't implementable on MSL / HLSL, or c) are regarding features we have no plans to include in WebGPU.
Activity
dj2 commentedon Apr 1, 2020
Currently you can have multiple entry points with different names pointing at the same function. Those entry points are where, eventually, the execution modes [1] will attach.
Moving to decorations means you're going to have to have multiple decorations for a single function which isn't as nice as separating out to the entry point call.
Note, you could write your first example the same as the second as:
which also keeps the related points together. The
entry_pointcan proceed the function it references.1- https://www.khronos.org/registry/spir-v/specs/1.0/SPIRV.html#Execution_Mode
litherum commentedon Apr 1, 2020
Why? All our existing decoration facilities accept lists of decorations, so I don’t see why this one shouldn’t as well.
dj2 commentedon Apr 1, 2020
True, that's subjective, I withdraw that objection.
This still doesn't solve the issue of attaching execution modes that differ per entry point.
What is the issue with writing the entry point directive above the function?
kvark commentedon Apr 2, 2020
For clarity, could you provide an example where a single function would be used in different execution modes?
litherum commentedon Apr 3, 2020
Right. The built-ins are all different anyway.
dneto0 commentedon Apr 7, 2020
Sorry, there's an easily confused thing going on here.
There's execution model (e.g. fragment vs. vertex vs. compute), and execution mode (describe/modify the behaviour of the shader stage).
Example of different execution modes:
If you attach these things to the function body itself, then you can always model the differences by having an extra layer of function wrapping, and attaching these attributes to the outside wrapper.
kvark commentedon Apr 8, 2020
Thank you, that makes sense! So it sounds like we could still just annotate the functions with entry point properties.
grorg commentedon Apr 14, 2020
Discussed at the 2020-04-14 meeting.
The discussion mostly focused on the syntax that @litherum was suggesting. He'll follow up here with more examples for us to discuss again.
litherum commentedon Apr 14, 2020
Simple cases look something like this:
However, if you wanted to expose the same entry point with two different workgroup sizes, you could write:
or
dneto0 commentedon Apr 15, 2020
The multiple "expose_as" syntax is overly complex because now you have nested attributes on attributes. That's the "sublanguage" aspect I was complaining about in the meeting. That's a non-starter for me.
dneto0 commentedon Apr 15, 2020
Surveying the execution modes from SPIR-V, https://www.khronos.org/registry/spir-v/specs/unified1/SPIRV.html#_a_id_execution_mode_a_execution_mode
there are:
kvark commentedon Apr 15, 2020
@dneto0 I agree that having meta-language for the attributes is not desired.
Would having separate wrapping functions (the second half of #662 (comment)) be a non-starter as well?
litherum commentedon Apr 18, 2020
All popular human-writable shading languages annotate the function. No human-writable languages have standalone entry point decl statements. Somehow none of those languages have been crushed by the weight of the annotations.
From this list, I see some which a) aren't even applicable to shaders, b) aren't implementable on MSL / HLSL, or c) are regarding features we have no plans to include in WebGPU.
4 remaining items
grorg commentedon Jun 23, 2020
Discussed at the 2020-06-23 Virtual F2F meeting
litherum commentedon Jun 23, 2020
I don't think it actually was. I think we discussed #644 instead.
grorg commentedon Jul 7, 2020
Discussed (really! this time!) at the 2020-07-07 meeting.
kainino0x commentedon Jul 7, 2020
nit: there are no arguments allowed here, it will be:
compute void entryPoint1() { foo(); }
kdashg commentedon Jul 7, 2020
We decided to do #662 (comment) with #662 (comment).
dneto0 commentedon Sep 2, 2020
Looking at this, the proposed syntax is un-WGSL-like.
It's either
or
I prefer the first. I don't think it causes a grammar ambiguity or collision.
Entry point fix, describe workgroups
Entry point fix, describe workgroups
Entry point fix, describe workgroups
Entry point fix, describe workgroups
Entry point fix, describe workgroups
Entry point fix, describe workgroups
Entry point fix, describe workgroups (#1046)
Fix shaders: const -> let (gpuweb#662)