-
Notifications
You must be signed in to change notification settings - Fork 331
Add creation-time expressions #2668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice.
I have very minor edits/suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update.
I think two things remain:
- element_count_expression changes
- the 's' type parameter issue for matrix arithmetic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
LGTM. Now we only need W3C WebGPU group agreement.
WGSL meeting minutes 2022-03-29
|
WGSL meeting minutes 2022-04-05
|
* Allows vectors and matrices to have abstract components * Renames constexpr to creation-time expression and greatly expands functionality to include most expressions * to be creation-time expressions, all identifiers must be creation-time constants or creation-time functions * removes `const_expression` grammar (replacement for it) * Add new declaration type: creation-time constant * uses `const` keyword * usable at module and function scopes * Restrict `let` to function scope * Add `@const` attribute to declare creation-time constants * only usable for built-in functions currently * Define override expression in terms of creation-time expressions * Update fixed-size array declarations to allow creation-time expressions * Update texture functions to use creation-time expressions * Update builtin functions to specify which are usable with abstract types and which are usable with creation-time expressions * Update expressions to specify which are usable with abstract types * Clarify that `let` and `var` are always concrete * De-duplicate some builtin function table entries * Update some overload resolution exmaples * Clarify formulae for matrix arithmetic * Change element count expressions for arrays to be shift expresions and bitwise expressions * Add creation-time constants to uniformity analysis * Change texture built-in function parameters to remove references to module-scope let declarations * Clarify shift operations * Add unsigned conversion from abstract integer * Fixes gpuweb#2719 * Add conversion to u32 scalar and vector types from abstract integer scalar and vector respectively
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
<td>Reinterpretation of bits.<br> | ||
The result is the unique value in [=u32=] that is equal to (|e| mod 2<sup>32</sup>). | ||
<tr algorithm="scalar conversion from binary32 floating point to unsigned integer"> | ||
The result is the unique value in [=u32=] that has the same bit pattern as |e|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess AbstractInt values have a bit pattern, because we define bitwise operations on them.
This rephrasing would make it an error to try to stuff a too-big AbstractInt value into a u32. It would be overflow. Similarly for a negative abstract-int value. That makes sense to me.
@@ -4371,8 +4433,8 @@ For details on conversion to and from floating point types, see [[#floating-poin | |||
<tr algorithm="scalar reinterpretation from unsigned to signed"> | |||
<td>|e|: u32<td>`i32(`|e|`)`: i32 | |||
<td>Reinterpretation of bits.<br> | |||
The result is the unique value in [=i32=] that is equal to (|e| mod 2<sup>32</sup>). | |||
<tr algorithm="scalar conversion from binary32 floating point to signed integer"> | |||
The result is the unique value in [=i32=] that has the same bit pattern as |e|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing AbstractInt here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, discussed offline: The AbstractInt -> i32 conversion is already the default. So writing i32( ... )
around an AbstractInt already just works as intended.
Cool
WGSL meeting minutes 2022-04-12
|
* Allows vectors and matrices to have abstract components * Renames constexpr to creation-time expression and greatly expands functionality to include most expressions * to be creation-time expressions, all identifiers must be creation-time constants or creation-time functions * removes `const_expression` grammar (replacement for it) * Add new declaration type: creation-time constant * uses `const` keyword * usable at module and function scopes * Restrict `let` to function scope * Add `@const` attribute to declare creation-time constants * only usable for built-in functions currently * Define override expression in terms of creation-time expressions * Update fixed-size array declarations to allow creation-time expressions * Update texture functions to use creation-time expressions * Update builtin functions to specify which are usable with abstract types and which are usable with creation-time expressions * Update expressions to specify which are usable with abstract types * Clarify that `let` and `var` are always concrete * De-duplicate some builtin function table entries * Update some overload resolution exmaples * Clarify formulae for matrix arithmetic * Change element count expressions for arrays to be shift expresions and bitwise expressions * Add creation-time constants to uniformity analysis * Change texture built-in function parameters to remove references to module-scope let declarations * Clarify shift operations * Add unsigned conversion from abstract integer * Fixes #2719 * Add conversion to u32 scalar and vector types from abstract integer scalar and vector respectively
* Allows vectors and matrices to have abstract components * Renames constexpr to creation-time expression and greatly expands functionality to include most expressions * to be creation-time expressions, all identifiers must be creation-time constants or creation-time functions * removes `const_expression` grammar (replacement for it) * Add new declaration type: creation-time constant * uses `const` keyword * usable at module and function scopes * Restrict `let` to function scope * Add `@const` attribute to declare creation-time constants * only usable for built-in functions currently * Define override expression in terms of creation-time expressions * Update fixed-size array declarations to allow creation-time expressions * Update texture functions to use creation-time expressions * Update builtin functions to specify which are usable with abstract types and which are usable with creation-time expressions * Update expressions to specify which are usable with abstract types * Clarify that `let` and `var` are always concrete * De-duplicate some builtin function table entries * Update some overload resolution exmaples * Clarify formulae for matrix arithmetic * Change element count expressions for arrays to be shift expresions and bitwise expressions * Add creation-time constants to uniformity analysis * Change texture built-in function parameters to remove references to module-scope let declarations * Clarify shift operations * Add unsigned conversion from abstract integer * Fixes gpuweb#2719 * Add conversion to u32 scalar and vector types from abstract integer scalar and vector respectively
functionality to include most expressions
creation-time constants or creation-time functions
const_expression
grammar (replacement for it)const
keywordlet
to function scope@const
attribute to declare creation-time constantsexpressions
types and which are usable with creation-time expressions
let
andvar
are always concreteThis builds on #2227 and implements the consensus on constexpr from #1272. Take a look at the last commit.
Does not add support for specifying arguments as required to be creation-time expressions. Does not add staticAssert yet.
Some of the examples use a grammar ambiguity that was pre-existing (e.g.
vec3(...)
).