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
Refactor GPUBindGroupLayout to isolate binding type definitions #1223
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.
I only skimmed this so far, just a few IDL nits. But overall I think the API structure is great.
re: kind. We could just use type
, since we are removing the other field called type
. Semantically it would specify which "type" among the "types" allowed by the GPU*LayoutEntry type. (Maybe we need a good word for "(GPUBufferLayoutEntry|GPUSamplerLayoutEntry|GPUTextureLayoutEntry|GPUStorageTextureLayoutEntry)" though.)
spec/index.bs
Outdated
|
||
// Used for uniform buffer and storage buffer bindings. Must be undefined for other binding types. | ||
GPUSize64 minBufferBindingSize; | ||
// Used for uniform buffer and storage buffer bindings. Must be null for other binding types. |
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.
Fields are always optional unless they're required
(or have a default, = {}
). We don't need to make these null
able since the fields can be unset or undefined
. (e.g. { binding: 0, visibility: 0, buffer: {} }
would be valid).
spec/index.bs
Outdated
GPUStorageTextureAccess kind; | ||
GPUTextureFormat format; |
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.
These two should be required
spec/index.bs
Outdated
|
||
// Used for uniform buffer and storage buffer bindings. Must be undefined for other binding types. | ||
GPUSize64 minBufferBindingSize; | ||
// Used for uniform buffer and storage buffer bindings. Must be null for other binding types. |
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.
We should take this opportunity to move this stuff from comments to real prose. The reason it was comments was because this dictionary was so difficult to understand in the first place (understanding which fields were used for which binding types). Now that we're solving that problem, we can simply say just below here, "Exactly one of .buffer, .sampler, .texture, or .storageTexture must be specified. Which is specified, and value of that sub-entry, determines what type of resource can be bound. (Note: a value of {}
is valid if the type has no required members.)`
I was surprised to see Otherwise the "kind" naming could be replaced by "type" so that would be |
I suggested that they be separate. There's only some overlap between the options for sampled vs storage textures as they're quite different semantically. They both have |
Editors meeting: Agreed on new wording (samplers are "filtering" or "non-filtering", textures are "filterable" or "non-filterable"). Texture bindings are either "texture" (not "sampled texture" as multisampled textures can't be sampled) or "storage texture". Not quite decided on how multisampling works yet. Filing an issue about that. |
And we also decided to keep |
Updated to address the initial feedback, use the new naming that @kainino0x mentioned, and fix and remaining broken references. Verbiage is generally better now but still a bit inconsistent in places. Let me know if anything sounds odd or unwieldy to you! |
I'm still a bit lukewarm about
|
|
Same, both are ok with me. |
We were going to rename it to |
spec/index.bs
Outdated
enum GPUTextureType { | ||
"filterable", | ||
"unfilterable", | ||
"multisample", |
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.
idea: since they others describe what can be done ("-able") maybe this should be the same? e.g. "sample-addressable" or "multisample-addressable"
@kainino0x that was in #1198 (comment) |
I filed #1230. We can fix it in or after this PR, either way. |
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.
Amazing work here, thank you @toji for iterating on this!
@@ -1039,14 +1037,14 @@ a better limit is not specified. | |||
<tr><td><dfn>maxUniformBufferBindingSize</dfn> | |||
<td>{{GPUSize32}} <td>Higher <td>16384 | |||
<tr class=row-continuation><td colspan=4> | |||
The maximum {{GPUBufferBinding}}.{{GPUBufferBinding/size}} for bindings | |||
of type {{GPUBindingType/uniform-buffer}}. | |||
The maximum {{GPUBufferBinding}}.{{GPUBufferBinding/size}} for bindings for which the |
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.
need to file an issue (if we haven't already) to specify that this applies to the effective size, not given size. I.e. the size can be undefined
spec/index.bs
Outdated
<script type=idl> | ||
enum GPUTextureType { | ||
"filterable", | ||
"unfilterable", |
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 think there is a problem with this approach. When using non-float textures, it would be nice if the users could rely on the default GPUTextureType
and not specify it, because clearly it's redundant. Non-float textures can't be sampled in WGSL, so they naturally aren't filterable (and this term shouldn't even apply...). So we can't default this to filterable
.
How about this strawman:
enum GPUTextureType {
"float",
"unfilterable-float",
"depth-float",
"sint",
"uint",
};
dictionary GPUTextureLayoutEntry {
GPUTextureType type = "float";
GPUTextureViewDimension viewDimension = "2d";
bool multisampled = false;
};
Names are subject to change, of course :) The benefit of this is no need to specify redundant info for integer textures.
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.
Shouldn't be a problem, but I'll leave it to others a bit better versed in the underlying APIs to greenlight this before I make the change.
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.
+1 to @kvark's suggestion. I think we recently (re-)realized that D3D12 prevented any form of sampling of integer textures so the filterable / unfilterable distinction is only for float textures.
The names depth-float
and GPUTextureType
seem a bit generic though, so I'd be open to bikeshed them. (though that could be in a follow-up if this is forcing too many iterations)
I think this is on the main meeting agenda, but speculatively adding to the editors meeting agenda too. |
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.
Thank you for updating!
The last concern about GPUTextureType
still stands (we'll discuss it), but everything else looks great.
Updated to apply @kvark's suggestion after the structure of it was agreed on in the call (% a bit more name bikeshedding.) |
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.
GPUTextureComponentType
should now be removed
spec/index.bs
Outdated
<tr> | ||
<td>{{GPUTextureFormat/r32float}} | ||
<td>{{GPUTextureComponentType/"float"}} | ||
<td>{{GPUTextureSampleType/"unfilterable-float"}} | ||
<td>✓ | ||
<td>✓ | ||
<td><!-- Metal --> |
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.
Extra td (this comment should move next to "unfilterable-float"
"sint", | ||
"uint", | ||
}; | ||
|
||
dictionary GPUTextureBindingLayout { | ||
GPUTextureType type = "float"; | ||
GPUTextureSampleType type = "float"; |
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.
Should we call this field sampleType
or something?
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.
That would break the pattern of every other binding layout member having a type
, which is a nice bit of consistency. FWIW We currently have the type
member of GPUStorageTextureBindingLayout
be a GPUStorageTextureAccess
enum, so it's already not a 1:1 enum/member name mapping.
spec/index.bs
Outdated
@@ -2808,7 +2808,7 @@ A {{GPUBindGroupLayout}} object has the following internal slots: | |||
- |textureLayout|.{{GPUTextureBindingLayout/viewDimension}} is | |||
{{GPUTextureViewDimension/"2d"}}. | |||
- |textureLayout|.{{GPUTextureBindingLayout/type}} is not | |||
{{GPUTextureType/"depth-float"}}. | |||
{{GPUTextureSampleType/"depth"}} or {{GPUTextureSampleType/"float"}}. |
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'm just (re-)noticing this particular rule. Shouldn't it be possible to load samples out of a multisampled depth texture? The rule may have been added when we thought "depth-comparison" bindings could be used only for comparison and not for loading (EDIT: and that depth textures could be bound as "float"
).
This can be a followup but let's make sure to file an issue if we land with this outstanding.
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 wondered about that too after today's call. I'm happy to remove the depth
case here.
afdcf6d
to
d19a5ac
Compare
OK, this is excessively detailed, but here's a spreadsheet of the possible classes of textures and how you would use them in a layout. Note there's a new, smaller problem similar to the one @kvark identified (#1223 (comment)) which is that if you set multisampled:true, then leaving the GPUTextureSampleType as default ("float") is invalid ( |
tl;dr I think what we have now is fine, but maybe consider making (true,"float) valid and definitely consider cases we want to support in the future |
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 think the changes to the table are not complete. First, there is still this sentence to be removed:
The "Filter" column specifies whether textures of this format can be sampled in shaders with a sampler having ...
Secondly, for filterable formats we want to list both "float" and "unfilterable-float" as supported sample types.
Done! |
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.
Thank you!
1047: Update bind group layout API to match upstream r=cwfitzgerald a=kvark **Connections** Follows gpuweb/gpuweb#1076, gpuweb/gpuweb#1223 (gpuweb/gpuweb#1164), gpuweb/gpuweb#1255, and gpuweb/gpuweb#1256 **Description** Aligns our API closer to the latest changes in WebGPU upstream. We technically don't have to do this, but I believe in the end it would be best if our API gets close to upstream. Note: this is a sensitive change for the users, everybody will get their code broken. So please take a look at the API and see if something is missing or needs improvement, so that we don't have to go through the changes again afterwards. **Testing** Doesn't really need testing. Partially covered by the existing playtest. Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
1331: Validate filtering r=cwfitzgerald a=kvark **Connections** See gpuweb/gpuweb#1223 **Description** This PR implements validation of sampler filtering (property in BGL), as well as the ability to filter non-filterable textures. **Testing** Untested Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This PR adds unimplemented stubs for the `atanh` builtin. Issue: gpuweb#1223
Fixes #1164
This is currently a WIP because this change touches a very large number of references in the spec and I haven't yet updated them all. Wanted to get this pushed to the server for the weekend, though, and figured you might be interested in taking a peek. Of special interest is the updated binding type table and the bind group validation logic.
One thing to note early on: The usage of the term "kind" has felt rather awkward as I've been writing out some of the spec prose here. I don't have a suggested alternative, just point out that I've found it hard to write about naturally.
Preview | Diff