这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 28 additions & 79 deletions wgsl/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -360,58 +360,36 @@ Note: literals are parsed greedy. This means that for statements like `a -5`
<tr><td>`VEC4`<td>vec4
<tr><td>`VOID`<td>void
<tr><td><td>
<tr><td>`ALL`<td>all
<tr><td>`ANY`<td>any
<tr><td>`AS`<td>as
<tr><td>`BINDING`<td>binding
<tr><td>`BLOCK`<td>block
<tr><td>`BREAK`<td>break
<tr><td>`BUILTIN`<td>builtin
<tr><td>`CASE`<td>case
<tr><td>`CAST`<td>cast
<tr><td>`COARSE`<td>coarse
<tr><td>`COMPUTE`<td>compute
<tr><td>`CONST`<td>const
<tr><td>`CONTINUE`<td>continue
<tr><td>`CONTINUING`<td>continuing
<tr><td>`DEFAULT`<td>default
<tr><td>`DOT`<td>dot
<tr><td>`DPDX`<td>dpdx
<tr><td>`DPDY`<td>dpdy
<tr><td>`FWIDTH`<td>fwidth
<tr><td>`ELSE`<td>else
<tr><td>`ELSE_IF`<td>elseif
<tr><td>`ENTRY_POINT`<td>entry_point
<tr><td>`FALLTHROUGH`<td>fallthrough
<tr><td>`FALSE`<td>false
<tr><td>`FINE`<td>fine
<tr><td>`FN`<td>fn
<tr><td>`FRAG_COORD`<td>frag_coord
<tr><td>`FRAG_DEPTH`<td>frag_depth
<tr><td>`FRAGMENT`<td>fragment
<tr><td>`FRONT_FACING`<td>front_facing
<tr><td>`FUNCTION`<td>function
<tr><td>`GLOBAL_INVOC_ID`<td>global_invocation_id
<tr><td>`IF`<td>if
<tr><td>`IMAGE`<td>image
<tr><td>`IMPORT_`<td>import
<tr><td>`IN`<td>in
<tr><td>`INSTANCE_IDX`<td>instance_idx
<tr><td>`IS_NAN`<td>is_nan
<tr><td>`IS_INF`<td>is_inf
<tr><td>`IS_FINITE`<td>is_finite
<tr><td>`IS_NORMAL`<td>is_normal
<tr><td>`KILL`<td>kill
<tr><td>`LOCAL_INVOC_ID`<td>local_invocation_id
<tr><td>`LOCAL_INVOC_IDX`<td>local_invocation_idx
<tr><td>`LOCATION`<td>location
<tr><td>`LOOP`<td>loop
<tr><td>`NOP`<td>nop
<tr><td>`NUM_WORKGROUPS`<td>num_workgroups
<tr><td>`OFFSET`<td>offset
<tr><td>`OUT`<td>out
<tr><td>`OUTER_PRODUCT`<td>outer_product
<tr><td>`POSITION`<td> position
<tr><td>`PREMREGE`<td>premerge
<tr><td>`PRIVATE`<td>private
<tr><td>`REGARDLESS`<td>regardless
Expand All @@ -426,9 +404,7 @@ Note: literals are parsed greedy. This means that for statements like `a -5`
<tr><td>`UNLESS`<td>unless
<tr><td>`VAR`<td>var
<tr><td>`VERTEX`<td>vertex
<tr><td>`VERTEX_IDX`<td>vertex_idx
<tr><td>`WORKGROUP`<td>workgroup
<tr><td>`WORKGROUP_SIZE`<td>workgroup_size
</table>

## Reserved Keywords ## {#reserved-keywords}
Expand Down Expand Up @@ -569,7 +545,7 @@ variable_decoration_list

variable_decoration
: LOCATION INT_LITERAL
| BUILTIN builtin_decoration
| BUILTIN IDENT
| BINDING INT_LITERAL
| SET INT_LITERAL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The possible values for each decoration isn't defined anywhere anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, listed now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not mix builtins and intrinsics together in this PR?
I don't see them being the same. The case about intrinsic functions is somewhat strong, since they are, well, functions. The case about builtins is not yet convincing to me and needs to be made first.

</pre>
Expand All @@ -585,22 +561,7 @@ variable_decoration
</xmp>
</div>

<pre class='def'>
builtin_decoration
: POSITION
| VERTEX_IDX
| INSTANCE_IDX
| FRONT_FACING
| FRAG_COORD
| FRAG_DEPTH
| NUM_WORKGROUPS
| WORKGROUP_SIZE
| LOCAL_INVOC_ID
| LOCAL_INVOC_IDX
| GLOBAL_INVOC_ID
</pre>

<div class='example' heading="Builtin Decorations">
<div class='example' heading="Valid Builtin Decoration Identifiers">
<xmp>
[[builtin position]]
OpDecorate %gl_Position BuiltIn Position
Expand Down Expand Up @@ -928,6 +889,32 @@ param_list
</xmp>
</div>

### Builtin Functions ### {#builtin-functions}

<table class='data'>
<thead>
<tr><td>Builtins<td>SPIR-V
</thead>
<tr><td>dpdx(IDENT) -&gt; float<td>OpDPdx
<tr><td>dpdx_coarse(IDENT) -&gt; float<td>OpDPdxCoarse
<tr><td>dpdx_fine(IDENT) -&gt; float<td>OpDPdxFine
<tr><td>dpdy(IDENT) -&gt; float<td>OpDPdy
<tr><td>dpdy_coarse(IDENT) -&gt; float<td>OpDPdyCoarse
<tr><td>dpdy_fine(IDENT) -&gt; float<td>OpDPdyFine
<tr><td>fwidth(IDENT) -&gt; float<td>OpFwidth
<tr><td>fwidth_coarse(IDENT) -&gt; float<td>OpFwidthCoarse
<tr><td>fwidth_fine(IDENT) -&gt; float<td>OpFwidthFine

<tr><td>all(BoolVec) -&gt; bool<td>OpAll
<tr><td>any(BoolVec) -&gt; bool<td>OpAny
<tr><td>is_finite(float) -&gt; bool<td>OpIsFinite
<tr><td>is_inf(float) -&gt; bool<td>OpIsInf
<tr><td>is_nan(float) -&gt; bool<td>OpIsNan
<tr><td>is_normal(float) -&gt; bool<td>OpIsNormal
<tr><td>dot(vecN<f32>, vecN<f32>) -&gt; float<td>OpDot
<tr><td>outer_product(vecN<f32>, vecM<f32>) -&gt; matNxM<f32><td>OpOuterProduct
</table>

## Entry Points ## {#entry-points}
The `entry_point` declares an entry point into the module. The entry points may
be forward declarations but the functions referenced must be declared in the
Expand Down Expand Up @@ -1142,8 +1129,6 @@ unary_expression

singular_expression
: primary_expression postfix_expression
| intrinsic_expression
| derivative_function (LESS_THAN derivative_modifier GREATER_THAN)? PAREN_LEFT IDENT PAREN_RIGHT

Issue: (dsinclair): Add following. Do we want to add the regular versions as well?
# | unord_greater_than_equal(a, b)
Expand All @@ -1167,42 +1152,6 @@ Issue: (dsinclair): Add following. Do we want to add the regular versions as wel
# | signed_less_than(a, b)
# OpSLessThan

intrinsic_expression
: ANY PAREN_LEFT IDENT PAREN_RIGHT
OpAny
| ALL PAREN_LEFT IDENT PAREN_RIGHT
OpAll
| IS_NAN PAREN_LEFT IDENT PAREN_RIGHT
OpIsNan
| IS_INF PAREN_LEFT IDENT PAREN_RIGHT
OpIsInf
| IS_FINITE PAREN_LEFT IDENT PAREN_RIGHT
OpIsFinite
| IS_NORMAL PAREN_LEFT IDENT PAREN_RIGHT
OpIsNormal
| DOT PAREN_LEFT IDENT COMMA IDENT PAREN_RIGHT
OpDot
| OUTER_PRODUCT PAREN_LEFT IDENT COMMA IDENT PAREN_RIGHT
OpOuterProduct

derivative_function
: DPDX
OpDPdx
OpDPdxFine
OpDPdxCoarse
| DPDY
OpDPdy
OpDPdyFine
OpDPdyCoarse
| FWIDTH
OpFwidth
OpFwidthFine
OpFwidthCoarse

derivative_modifier
: FINE
| COARSE

multiplicative_expression
: unary_expression
| multiplicative_expression STAR unary_expression
Expand Down