Skip to content
Open
Changes from 1 commit
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
Next Next commit
Start built-in constants section
  • Loading branch information
mehmetoguzderin committed Jan 31, 2024
commit 1984cc43042b529951fa5e7dfbe7af330dcf2245
32 changes: 32 additions & 0 deletions wgsl/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -17492,6 +17492,38 @@ All synchronization functions [=shader-creation error|must=] only be invoked in
space.
</table>

# Built-in Constants # {#builtin-constants}

<dfn noexport>Built-in constants</dfn> are [=predeclared=] values provided by
the implementation and, therefore, always available for use in a WGSL module.
All built-in constants are [=const-declarations=], and all their names are
valid [=identifiers=].

Note: The built-in constants with
[[#abstract-types|abstract numeric types]] that represent symbolic
values are subject to the same rules, including
[[#abstract-float-accuracy|abstract float accuracy]]. As such, where
applicable, expressions involving them might be evaluated at
[=shader module creation|shader-creation time=] and
and result in better approximations than operating on target types, reducing
the need for specializations such as `PI_2` for scales and offsets.

<table class='data builtin constants'>
<caption>
<dfn noexport>Built-in mathematical constants</dfn>
</caption>
<thead>
<tr><th>Names<th>Type<th>Description
</thead>
<tr><td>`PI`, `π`<td>[=abstractfloat|AbstractFloat=]<td>Approximates the ratio of the
circumference of a circle to its diameter, known as π, pi, or Archimedes'
constant.
<tr><td>`TAU`, `τ`<td>[=abstractfloat|AbstractFloat=]<td>Approximates the perimeter of a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any other constants we need? e or phi for example?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@Kangz I think that e is certainly a good addition in terms of practicality, though group decided to start with pi and tau initially. If there's consensus, I can certainly add to PR

unit circle, known as τ, tau, 2π, or a turn.
</thead>
</table>
</div>

# Grammar for Recursive Descent Parsing # {#grammar-recursive-descent}

This section is non-normative.
Expand Down