Skip to content

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented Nov 14, 2019

[EnforceRange] is the most-strict and least-surprising mode of number-to-integer conversion in WebIDL. (The default is modular, the other option is [Clamp].) [EnforceRange] rounds the (double-precision floating point) number to an integer, then throws if it's outside of the range of the integer type. It has the benefit that removing this attribute would be a non-breaking change (in that it would change from throwing to not-throwing).

I've been meaning to do this for a long time, but I didn't realize that it was an attribute on the type and not the fields/parameters themselves, or I might have done this before removing all the typedefs. 🙃

I'm not attached to using typedefs, it just makes it slightly more apparent if something diverges from this (IMO) (the word long will appear). This PR does not leave any unenforced integer types.

Austin did some quick measurements in Chrome's bindings, and this doesn't seem to impact performance in the non-failure case, for us.


Preview | Diff

@JusSn
Copy link
Contributor

JusSn commented Nov 18, 2019

This change, I like it. Another!

Copy link
Contributor

@kdashg kdashg left a comment

Choose a reason for hiding this comment

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

I don't like the verbose name. I might even prefer [EnforceRange] u32. Is there even a use for non-enforced vars?

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

Ideally, I'd prefer us to have semantic typedefs for all the enforced things, like we have for buffer addresses today - GPUBufferSize.

@kainino0x
Copy link
Contributor Author

kainino0x commented Nov 19, 2019 via email

@Kangz
Copy link
Contributor

Kangz commented Nov 25, 2019

Discussed and approved the semantics in the 2019-11-25 meeting. Needs bikeshedding on the name.

Copy link
Contributor Author

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

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

I've revised this PR. Please review!

spec/index.bs Outdated
typedef [EnforceRange] unsigned long GPUIntegerCoordinate;
typedef [EnforceRange] unsigned long GPUIndex32;
typedef [EnforceRange] unsigned long GPUSize32;
typedef [EnforceRange] long GPUSignedOffset32;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I tried not to go too overboard with the number of different types, so consolidated some of them into these generic ones.

@kainino0x
Copy link
Contributor Author

Is there even a use for non-enforced vars?

IMO, no.

Copy link
Contributor

@kdashg kdashg left a comment

Choose a reason for hiding this comment

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

I would rather see u32_strict (U32Strict? Uint32Strict?) or similar, rather than hiding the sizes behind semantic types.

@Kangz
Copy link
Contributor

Kangz commented Jan 6, 2020

This was discussed in the 2020-01-06 meeting

@kainino0x
Copy link
Contributor Author

I'd like to get some resolution from @kvark @jdashg so we can land this.

Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

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

:shipit:

@kdashg
Copy link
Contributor

kdashg commented Feb 11, 2020

Approved, but has rebase conflicts. @kainino0x

- Rename GPUBufferSize to GPUSize64 (it's also used for ArrayBuffer).

- Use GPUSize32 instead of GPUIntegerCoordinate for
  rowPitch/imageHeight. (They have the same definition though.)
@kainino0x
Copy link
Contributor Author

Merging after merging with master, and with minor nonfunctional changes (see the last commit)

@kainino0x kainino0x merged commit 56b4d3b into gpuweb:master Feb 11, 2020
@kainino0x kainino0x deleted the enforcerange branch February 11, 2020 03:13
pull bot pushed a commit to FreddyZeng/chromium that referenced this pull request Apr 24, 2020
Adds [EnforceRange] to most of the integer types in WebGPU according to
my spec change: gpuweb/gpuweb#498 .

Note that there is one place where it was not possible to match that
spec change, as that the spec change violates WebIDL (in spirit).

  - Interface `const` values for flags can't use [EnforceRange]'d types.

The upstream bug for that is gpuweb/gpuweb#549

There is a manual workaround in cts.html for an incompatibility between
the variant strings and run_web_tests:

  <!-- MANUALLY EDITED: run_web_tests doesn't like tests which end in
  '/', so the '/' is replaced with '%2F' manually for now -->

Bug: 1050909
Change-Id: Ic84f102d138204328fe0d4fb7cb46622c7104630
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2048998
Auto-Submit: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762254}
JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
* Add [EnforceRange] to all integers

* more integer types

* use GPUSize32 for first*

* Changes to naming and which types are used

- Rename GPUBufferSize to GPUSize64 (it's also used for ArrayBuffer).

- Use GPUSize32 instead of GPUIntegerCoordinate for
  rowPitch/imageHeight. (They have the same definition though.)
JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Jun 8, 2020
* Add [EnforceRange] to all integers

* more integer types

* use GPUSize32 for first*

* Changes to naming and which types are used

- Rename GPUBufferSize to GPUSize64 (it's also used for ArrayBuffer).

- Use GPUSize32 instead of GPUIntegerCoordinate for
  rowPitch/imageHeight. (They have the same definition though.)
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
* Implement api,operation,rendering,draw:arguments:*

* Address comments from code review

* Update src/webgpu/api/operation/rendering/draw.spec.ts
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.

5 participants