Skip to content

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Jan 30, 2021

Proposal.

Updates Extent3D as well, as it would be confusing if they didn't match.

Keeps a placeholder "depth" member with type undefined, to prevent accidental use of a silently-ignored dictionary entry.
Yes, this is weird, but WebIDL appears to allow it. If a browser implementation of WebIDL doesn't support it - Chromium's doesn't, unsurprisingly - it can be emulated by using another type (int or any, say) and then manually throwing a TypeError if the member is present.

See previous discussions:
#1372 (comment)
#1081 (comment)


Preview | Diff

Updates Extent3D as well, as it would be confusing if they didn't match.

Keeps a placeholder "depth" member with type undefined, to prevent
accidental use of a silently-ignored dictionary entry.
Yes, this is weird, but WebIDL appears to allow it. If a browser
implementation of WebIDL doesn't support it - Chromium's doesn't - it
can be emulated by using another type (int, say) and then manually
throwing a TypeError if the member is present.
@Kangz
Copy link
Contributor

Kangz commented Feb 1, 2021

I thought we discussed this before in the group and agreed to keep depth, but I can't find the minutes.

This proposal is a bit too much hand-holding for developers "remember that it is the depth or the array layer!" when instead it would be better to educate them that 2D arrays and 3D textures are mostly the same thing except for layout and the mip-levels in the depth dimension. The current unified "array depth" or "3D depth" is more elegant and causes less mental overhead for developers that know WebGPU (as in have used 2D arrays at least once).

Disallowing depth at the WebIDL is even more hand-holding an I don't think we want to have such "knowledge bandaids" in the API itself. At most it could be a console warning in browsers that want it, but it would be unfortunate to encode historical design process in the shape of the API.

@kvark
Copy link
Contributor

kvark commented Feb 1, 2021

I do appreciate the rename to a more clear one. It's not a big issue for general ergonomics since most textures will not have the depth, and those who do - better know for sure what they opt into.

As for disallowing "depth" at WebIDL - that seems like and overkill. If somebody doesn't read the spec, the examples, and accidentally uses "depth", the worst they are going to face is one iteration where they discover that their view creation fails and fix it. There are no spooky actions in distance here, we don't need to worry about this.

@kainino0x kainino0x changed the title Rename GPUExtent3DDict.depth to .depthOrLayers Rename GPUExtent3DDict.depth to .depthOrArrayLayers Feb 1, 2021
@kainino0x
Copy link
Contributor Author

Updated to .depthOrArrayLayers and removed the .depth funny business.

I intend to do the .depth thing in the TypeScript bindings to achieve the same benefit for TypeScript users. That is the more reasonable place to put things like that.

@kainino0x
Copy link
Contributor Author

the worst they are going to face is one iteration where they discover that their view creation fails and fix it. There are no spooky actions in distance here, we don't need to worry about this.

I forgot to reply about this, it would also change a multi-layer texture copy to copy only one layer (or slice). But I think it's okay. Browsers can even choose to implement warnings (by adding an any depth; field and checking it's not provided) if they want.

@kainino0x
Copy link
Contributor Author

meeting fyi: no objections :)

@kainino0x kainino0x merged commit f8fe453 into gpuweb:main Feb 8, 2021
@kainino0x kainino0x deleted the depthOrLayers branch February 8, 2021 20:11
bors bot added a commit to gfx-rs/wgpu that referenced this pull request Mar 2, 2021
1241: Update Extent3d::depth and Limits to latest upstream r=grovesNL a=kvark

**Connections**
- gpuweb/gpuweb#1390
- gpuweb/gpuweb#1328
- gpuweb/gpuweb#1163
- gpuweb/gpuweb#1274

**Description**
Just an API update up to spec.

**Testing**
Tested on wgpu-rs examples

Co-authored-by: Dzmitry Malyshau <[email protected]>
@kvark kvark mentioned this pull request Jan 10, 2022
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants