Skip to content

wgsl: replace stride attribute with array type parameter#2103

Closed
dneto0 wants to merge 4 commits intogpuweb:mainfrom
dneto0:issue-1534-remove-stride
Closed

wgsl: replace stride attribute with array type parameter#2103
dneto0 wants to merge 4 commits intogpuweb:mainfrom
dneto0:issue-1534-remove-stride

Conversation

@dneto0
Copy link
Contributor

@dneto0 dneto0 commented Sep 13, 2021

  • Update related grammar rules and examples
  • Rename 'runtime-sized' array to 'dyanmically-sized'.
    Change its declaration syntax to use dynamic_array instead of
    array without an element count.
  • Add examples showing array type compatibility based on stride

Editorial:

  • Rearrange text in Array Types section
  • More consistently use 'E' for element array type placeholder

Part of #1534

Change-Id: I09082c257fbc325e20a0e28fe16f7744e882a61e

@dneto0 dneto0 added the wgsl WebGPU Shading Language Issues label Sep 13, 2021
@dneto0 dneto0 added this to the V1.0 milestone Sep 13, 2021
@dneto0
Copy link
Contributor Author

dneto0 commented Sep 13, 2021

We're very open to a name that's better than dynamic_array (!)

@github-actions
Copy link
Contributor

Previews, as seen when this build job started (d454ed4):
WebGPU | IDL
WGSL
Explainer

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.

(haven't finished the review)

wgsl/index.bs Outdated

// array<i32,5,4> and array<i32,5> are the same type because the implicit stride of
// array<i32,5> is 4.
var<private> g: array<i32,5,4>;
Copy link
Contributor

Choose a reason for hiding this comment

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

unfortunately, this doesn't read well :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternative syntaxes have been proposed and rejected, like

   array<i32,5,stride=4>

Do you have another alternative?

Copy link
Contributor

@alan-baker alan-baker Sep 29, 2021

Choose a reason for hiding this comment

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

How about:

// Both the g and h arrays instantiate the same type because h's implicit stride
// is the same as g's explicit stride.
var g : array<i32,5,4>; // Array of 5 i32s with a stride of 4-bytes
var h : array<i32,5>; // Array of 5 i32s with an implicit stride of 4-bytes

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a good suggestion here. Enrolling into named generic parameters is certainly one way, but it's a lot to chew for this (seemingly little) problem. Leaving <i32, 5, 4> is just looking confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From group discussion on 2021-10-12, we decided to try the 'stride=N' syntax.
Latest commit shows this.

@dneto0 dneto0 force-pushed the issue-1534-remove-stride branch from d454ed4 to fc2d250 Compare September 29, 2021 17:54
@dneto0
Copy link
Contributor Author

dneto0 commented Sep 29, 2021

Rebased against main.

@github-actions
Copy link
Contributor

Previews, as seen when this build job started (fc2d250):
WebGPU | IDL
WGSL
Explainer

@kdashg
Copy link
Contributor

kdashg commented Oct 12, 2021

WGSL meeting minutes 2021-10-12
  • DN: Part of overall attempt to remove attributes from types. Make the stride part of the array template type. But then spell fixed-size and runtime-sized array differently. Looking for high level approval of whether this is a good direction. Can bikeshed details later.
  • MM to ensure existence of an issue for not having stride
  • DM: I think we should probably not move stride around, if we might remove it, and so we might want to block on it.
  • MM: I think that’s perfect-as-enemy-of-good, and we should just take this and make other changes later.
  • DM: I still don’t like the array&lt;i32,5,4> number soup syntax
  • DN: We could do the python-like thing for a named argument for stride.
  • DN: Do we like having a named arg?
  • MM: My knee-jerk reaction is
  • DM: I think naming with named args is great, but that it’s a larger grammar change that I’d like to avoid. Basically a new language feature
  • DN: If I were to start from scratch within the param list, I would probably not split spelling a dynamic-vs-fixed array. Would that be better than what’s on the table right now?
  • DM: Yes
  • MM: If allowing a named stride, would be cool to have a named length too.
  • JG: Aren’t there non-grammatical differences between fixed-vs-dynamic? I like spelling things different if they behave differently.
  • DN: Ok yeah they do have differences, I see your point there.
  • DM: Since this problem might go away if MM gets us to get rid of strides, which lets us ship with fewer changes. Shouldn’t we block on that?
  • MM: Yeah I can put up that issue so we can talk about that first.

- Update related grammar rules and examples
- Rename 'runtime-sized' array to 'dyanmically-sized'.
  Change its declaration syntax to use `dynamic_array` instead of
  `array` without an element count.
- Add examples showing array type compatibility based on stride

Editorial:
- Rearrange text in Array Types section
- More consistently use 'E' for element array type placeholder

Part of gpuweb#1534

Change-Id: I09082c257fbc325e20a0e28fe16f7744e882a61e
@dneto0 dneto0 force-pushed the issue-1534-remove-stride branch from fc2d250 to 685ed9e Compare October 13, 2021 12:39
@dneto0
Copy link
Contributor Author

dneto0 commented Oct 13, 2021

685ed9e is rebased against main.

- Add new 'modifier word' kind of token which has special meaning only
 in certain contexts, and is otherwise is an identifier.
 Note: We should probably make lots of things like this: access mode,
  image format

- When stride is specified in source, spell it out as ',stride=N' instead
  of just an optional ',N'

- Modify the grammar rules for array type declarations, to match the
  prose.
@github-actions
Copy link
Contributor

Previews, as seen when this build job started (c2ec703):
WebGPU | IDL
WGSL
Explainer

@github-actions
Copy link
Contributor

Previews, as seen when this build job started (4bd7cd7):
WebGPU | IDL
WGSL
Explainer

@kdashg
Copy link
Contributor

kdashg commented Oct 20, 2021

WGSL meeting minutes 2021-10-19
  • Previously:
    • MM to ensure existence of an issue for not having stride
    • MM: Yeah I can put up that issue so we can talk about that first.
  • Updates:
    • Still:
      • spell runtime-sized array as ‘dynamic_array’.
    • New:
      • Introduced ‘modifier word’ kind of token, which has special meaning only in certain contexts and is otherwise interpreted as an identifier. (Should make ‘access mode’ and image formats into these, rather than keywords.)
      • Use ‘,stride=N’ syntax instead of ‘,N’ to specify explicit stride.
      • Updated grammar to match the prose.
  • Block on MM’s TBD issues

dneto0 added a commit to dneto0/gpuweb that referenced this pull request Nov 16, 2021
* Remove two paragraphs that are part of gpuweb#2103, the array-stride change.
dneto0 added a commit to dneto0/gpuweb that referenced this pull request Nov 16, 2021
dneto0 added a commit to dneto0/gpuweb that referenced this pull request Nov 25, 2021
* Remove two paragraphs that are part of gpuweb#2103, the array-stride change.
dneto0 added a commit to dneto0/gpuweb that referenced this pull request Nov 25, 2021
@kdashg
Copy link
Contributor

kdashg commented Jan 24, 2022

Is this still valid? @dneto0

@Kangz
Copy link
Contributor

Kangz commented Feb 1, 2022

Closing since strides have been removed.

@Kangz Kangz closed this Feb 1, 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