Skip to content

Conversation

@dneto0
Copy link
Contributor

@dneto0 dneto0 commented May 8, 2020

Fixes #685

The generically zero-able types (or nullable types) correspond exactly with
storable types, so I tied nullability to the storable type concept.

Eliminate the concept of a "default" type. Instead define the null
value of a storable type.

Clarify that a variable declaration can have an initializer.

Specify the initial value of a variable, and it's the null value for
the store type if the declaration had no intializer.

This still leaves up in the air exactly when a variable is "created"
as we haven't specfiied an execution order or even the concept of
execution of a statement.

Initializers are only permitted for 3 storage classes

Remove "Initializers" section later on, as its content is now mostly
abosrbed into the "Variables" section.

Hint at future reorganization, to insert a "Evaluation and Execution"
section between "Types" and "Grammar" major sections.

@dneto0 dneto0 requested review from kdashg and litherum May 8, 2020 21:46
</xmp>
</div>

## Storable types ## {#storable-types}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this up above pointer types, since pointer types are not storable.

Fixes gpuweb#685

The generically zero-able types (or nullable types) correspond exactly with
storable types, so I tied nullability to the storable type concept.

Eliminate the concept of a "default" type.  Instead define the null
value of a storable type.

Clarify that a variable declaration can have an initializer.

Specify the initial value of a variable, and it's the null value for
the store type if the declaration had no intializer.

This still leaves up in the air exactly when a variable is "created"
as we haven't specfiied an execution order or even the concept of
execution of a statement.

Initializers are only permitted for 3 storage classes

Remove "Initializers" section later on, as its content is now mostly
abosrbed into the "Variables" section.

Hint at future reorganization, to insert a "Evaluation and Execution"
section between "Types" and "Grammar" major sections.
@dneto0
Copy link
Contributor Author

dneto0 commented May 8, 2020

This was a bit more sprawling a change than I had hoped. It touched variables and "default values" and add type rules.

It feels like we're missing a big section in the middle to describe actual execution, something between Types and the Grammar.

@Kangz Kangz added the wgsl WebGPU Shading Language Issues label May 11, 2020
@dneto0 dneto0 added the wgsl resolved Resolved - waiting for a change to the WGSL specification label May 14, 2020
@dneto0 dneto0 added this to the MVP milestone May 14, 2020
`mat3x4<f32>()` : mat3x4<f32><br>
`mat4x4<f32>()` : mat4x4<f32>
<td>Null value (OpConstantNull)
<tr>
Copy link
Member

Choose a reason for hiding this comment

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

Should we add struct and array in here as well for completeness?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I mean add a table for structs and arrays similar to the ones we have for other types add show the null value converts to OpConstantNull

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 747e677

@litherum
Copy link
Contributor

null is usually associated with pointers, and all of the values in this change are 0. Perhaps we should call these "zero values" instead of "null values"?

@dneto0
Copy link
Contributor Author

dneto0 commented May 19, 2020

null is usually associated with pointers, and all of the values in this change are 0. Perhaps we should call these "zero values" instead of "null values"?

I'd be ok with that, or with "nil".
Nothing fits completely perfectly: "false" being 0 is a convention from C, but still only a convention.

@dneto0
Copy link
Contributor Author

dneto0 commented May 19, 2020

One thing to keep in mind is that, for shader languages that have C-like pointers, the all-zero-bits pointer into workgroup storage (local or shared) is often a valid address; the nullptr has non-zero bit pattern. But we're not there yet, and can leave that conceptual challenge to the future.

@grorg
Copy link
Contributor

grorg commented May 19, 2020

Discussed at the 2020-05-19 meeting.

Resolution was to use zero.

dneto0 added 2 commits May 19, 2020 16:25
Sometimes, the English seems to read better when writing "zero-valued" instead
of just "zero".
@dneto0
Copy link
Contributor Author

dneto0 commented May 19, 2020

I believe fall feedback is addressed. PTAL

@dj2 dj2 merged commit acedfe5 into gpuweb:master Jun 3, 2020
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
grunt-http-server hasn't been updated in 4 years and depends on a broken
version of http-server that causes infinite redirects on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl resolved Resolved - waiting for a change to the WGSL specification wgsl WebGPU Shading Language Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax for "the zero value" for bool type, numeric types, and compositions of them

5 participants