Sitelet https://github.com/gpuweb/gpuweb/pull/712
Skip to content

[wgsl] Define the void type - #712

Merged
dj2 merged 1 commit into
gpuweb:masterfrom
dneto0:wgsl-void
Apr 15, 2020
Merged

dj2 merged 1 commit into
gpuweb:masterfrom
dneto0:wgsl-void

Conversation

@dneto0

@dneto0 dneto0 commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

No description provided.

@dneto0
dneto0 requested a review from dj2 April 15, 2020 20:50
@dneto0 dneto0 added the wgsl WebGPU Shading Language Issues label Apr 15, 2020
@dj2
dj2 merged commit 5f9beea into gpuweb:master Apr 15, 2020
Comment thread wgsl/index.bs
The void type contains no values.
It is used where a type is required by the language but
where no values are produced or consumed.
For example, it is used for the return type of a function which does not produce a value.

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.

Isn't this the only place where the void type can be used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. I didn't want to lock it down too much, and we can revisit this.

In SPIR-V, an extended instruction can return void, e.g. OpenCL C has a "vstoren" builtin that maps to an extended instruction with result type of "void". See "vstoren" in https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.ExtendedInstructionSet.100.html
But the OpExtInst instruction always has a result type, and for that case it returns the void type.

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.

In the grammar itself, we only list it for the return type:

function_type_decl
  : type_decl
  | VOID

I don't think we have sufficiently strong evidence that Void needs to be used wider than this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the late reply. I just thought of this.

We haven't written out the type rules just yet. There may be many uses of void as a type, e.g. as the type attributed to a statement such as a for loop. So there could be uses as a type but not in the grammar itself.

@kdashg

kdashg commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

If void is just for 'nothing returned', we could consider moving towards the return-a-tuple syntax, and use fn foo() -> () {.

JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wgsl WebGPU Shading Language Issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants