-
Notifications
You must be signed in to change notification settings - Fork 353
Change offset to span.
#1339
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
Change offset to span.
#1339
Conversation
This CL removes the offset decoration from struct members and adds a `span` decoration instead. The span reduces the amount of action at a distance required when adding data members as each line is self contained. This also reduces the amount of typing required as the span is only required when the memory size does not patch the type size for a member. Fixes #1303
|
First pass at converting over to span. The change itself is already approved by the group, so once the text is good we should be good to land. |
wgsl/index.bs
Outdated
| * [[#matrix-types]] | ||
| * [[#array-types]] if the array type has a [=stride=] attribute and its element type is host-shareable | ||
| * [[#struct-types]] if each member is host-shareable and has an [=offset=] attribute | ||
| * [[#struct-types]] if each member is host-shareable and, if the size of the member isn't the same as the size of the type, has a [=span=] attribute |
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.
This is a little bit confusing: "the size of the member isn't the same as the size of the type". Are we really talking about the size of the member here? Or maybe about it's memory span?
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.
Actually, we should have a separate definition somewhere, defining a set of types that match this description
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.
Memory span. Number of bytes taken up by the thing in memory. Will attempt to clarify.
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.
Better?
| The number of bytes between the start of the structure and the location | ||
| of this member. | ||
| In the case where the memory size of a member does not match the size of the member type, a | ||
| `span` is required. The `span` must be the byte size of memory taken up by the current member and no larger. |
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 mention somewhere what values of the span are expected? This text says it must be "the byte size of memory taken up by the current member" but doesn't explain how to get that.
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.
Maybe? I think we can skip it for now, but this maybe an output from the compilers, or a table to show when needed?
Why not make it optional instead? If an author for some reason wants to tell us the offset they expect stuff to be at, we ought to be receptive of that information. If we make it optional, we'd have to make |
|
I think we should leave |
|
Comment from meeting: In |
|
Doing my share of work to help this case, I tried to crystallize the debate we had so far. Here are the plain and graph views. I'm definitely missing a lot of arguments here (was reconstructing from memory, need to re-read all the discussions, ideally, to populate it), since it appears to me that just slapping |
|
I think the concern with add the |
|
@dj2 right, but it's not like these layouts are magically going away if we aren't explicit about them. If we support "scalar" at any point, we'd still have to specify it in terms of constraints on the offsets/spans/whatever, i.e. it will technically be a part of the spec, so it might as well be just |
This CL removes the offset decoration from struct members and adds a
spandecoration instead. The span reduces the amount of action at adistance required when adding data members as each line is self
contained. This also reduces the amount of typing required as the span
is only required when the memory size does not patch the type size for a
member.
Fixes #1303