Skip to content

Determine the syntax for attributes #1067

Closed

Description

@kainino0x

The discussion started here:
#1046 (comment)

Activity

  1. added
    wgsl
    on Sep 11, 2020
  2. kainino0x commented on Sep 11, 2020

    @kainino0x
    ContributorAuthor

    jdashg:

    • [[workgroup_size N N N]] [[foo bar]] "LISPish"
    • [[workgroup_size N N N, foo bar]] "comma-delimited list"
    • [[workgroup_size (N N N), foo bar]] "paren-tuples"
      • Is [[foo (bar)]] valid?
    • [[workgroup_size [N N N], foo bar]] "square-bracket-tuples"
      • [N,N,N] feels like an array, but what if it were [N, cw|ccw]? Paren-tuples are more flexible, even if we don't have them elsewhere in the language yet.
      • Also [[workgroup_size [N N N]]] is gross, even if we can manage to parse it.
    • [[workgroup size(N N N), foo bar]] "pseudo-function attribute values"

    dneto0:

    On the "how to I write many attributes" front, early on we at Google decided that [[attr, attr2]] was better than [[attr]] [[attr2]]. It was less fussy and less typing.

    kainino0x:

    [[workgroup_size somesyntaxhere]] [[foo bar]]
    [[workgroup_size(x, y, z), foo(bar)]]
    @workgroup_size(x, y, z) @foo(bar)

    johnkslang:

    I recommend reading through https://en.cppreference.com/w/cpp/language/attributes and fully understanding its power before spending time trying to invent new syntax that might not work as well. Especially where both space and parenthesis have their own meaning.

    For HLSL, we discussed this and chose [[vk::binding(3, 2)]], where the arguments are required binding followed by optional set.

    Really seems worth following precedence here in C++, GLSL, HLSL, probably many others, and saving time as well.

    kainino0x:

    I'm in favor of using the C++ style (or a similar style from another language) and making it work nicely for what we have already (e.g. [[position]] or [[builtin::position]], but not [[builtin(position)]]).

  3. kvark commented on Sep 11, 2020

    @kvark
    Contributor

    [[workgroup_size(x, y, z), foo(bar)]] is my preference :)

  4. dj2 commented on Sep 14, 2020

    @dj2
    Member

    [[workgroup_size N N N, foo bar]] "comma-delimited list" would be my preference.

  5. dj2 commented on Sep 14, 2020

    @dj2
    Member

    Too many places referring to the same thing. I've changed to preferring the [[workgroup_size(1, 2, 3), stage(compute)]] format as well after seeing the [[stage compute, workgroup_size 8 1 1]] example in the entry point CL. I find the second harder to read.

  6. dneto0 commented on Sep 15, 2020

    @dneto0
    Contributor

    I'm fine with function-style syntax, taking the lead from C++.
    Basically, I buy the arguments from @johnkslang.
    E.g. it leaves an open path for namespaces.

  7. kainino0x commented on Sep 15, 2020

    @kainino0x
    ContributorAuthor

    Resolution: Use the C++ style. Allow both [[attr(x, y), attr(z)]] and [[attr(x, y)]] [[attr(z)]]. (No namespacing for now.)

  8. added a commit that references this issue on Sep 17, 2020
    08ba1ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgsl

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions