Skip to content

WGSL: describe resource interface of a shader - #1214

Merged
dneto0 merged 2 commits into
gpuweb:mainfrom
dneto0:resources-split
Nov 17, 2020
Merged

dneto0 merged 2 commits into
gpuweb:mainfrom
dneto0:resources-split

Conversation

@dneto0

@dneto0 dneto0 commented Nov 9, 2020

Copy link
Copy Markdown
Contributor
  • define 'block' attribute on structure type
  • text from 'uniform' and 'storage' rows of storage classes table
    out to resource interface section
  • define 'set' and 'binding' attribute on structure type
  • relate resources in WGSL to WebGPU GPUBindingType

@github-actions

github-actions Bot commented Nov 9, 2020

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
059c982

@dneto0 dneto0 added for wgsl meeting wgsl WebGPU Shading Language Issues labels Nov 9, 2020
@dneto0 dneto0 added this to the MVP milestone Nov 9, 2020
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs Resolved
Comment thread wgsl/index.bs

Bindings must not alias within a shader stage:
two different variables in the resource interface of a given
shader must not have the same set and binding values, when considered as a pair of values.

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.

I have to check this no-overlap-bindings rule for samplers and their associated sampled textures.

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.

I think the only cases were:

  • buffer resources that alias the same memory. But I believe that won't be allowed in WebGPU
  • Vulkan has combined image+sampler, and you can make OpTypeSampler, OpTypeImage, and OpTypeSampledImage variables to reference that descriptor, all with the same set and binding. But I believe WebGPU won't have that.

So I think this i the right rule. Yay.

- define 'block' attribute on structure type
- text from 'uniform' and 'storage' rows of storage classes table
  out to resource interface section
- define 'set' and 'binding' attribute on structure type
- relate resources in WGSL to WebGPU GPUBindingType
* Add cross-referencd to description of block attribute
* Rewrite non-nesting validation rules for 'block'-decorated struct.
* Convert a Note to a TODO about the next MR
* Use not-yet defined terms 'read-write storage buffer' and 'read-only
  storage buffer' pending resolution of discussion on PR 1183
* Add a comparison_sampler row to the binding compatibility table
@github-actions

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
30befb3

Comment thread wgsl/index.bs
</table>


A structure type with the [=block=] attribute must not be:

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.

Can I declare a variable of that structure type locally in a function?
If I can do that, can I declare a variable of an array of these structures, locally?

Comment thread wgsl/index.bs
<tr><td>`builtin`<td>a Builtin Decoration Identifier (listed below)
<tr><td>`location`<td>u32 literal
<tr><td>`set`<td>u32 literal
<tr><td>`binding`<td>non-negative i32 literal<td>See [[#resource-interface]]

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.

Doesn't SPIR-V allow specialization constants here? If so, can we add an issue for allowing that in WGSL some time in the future as well?

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.

No. Set and binding are literals in SPIR-V.

Comment thread wgsl/index.bs

* [=uniform buffers=]
* [=storage buffers=]
* textures

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.

speaking of consistency, why are we separating the uniform/storage buffers into different resource, but not separating the sampled/storage textures?

@grorg

grorg commented Nov 17, 2020

Copy link
Copy Markdown
Contributor

Discussed at 2020-11-17 meeting.

@dneto0
dneto0 merged commit a074673 into gpuweb:main Nov 17, 2020
ben-clayton added a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
Prints all the unimplemented tests.
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