Skip to content

Allow inter-stage variable subsetting by prefix - #3073

Closed
kainino0x wants to merge 3 commits into
gpuweb:mainfrom
kainino0x:inter-stage-prefix
Closed

kainino0x wants to merge 3 commits into
gpuweb:mainfrom
kainino0x:inter-stage-prefix

Conversation

@kainino0x

@kainino0x kainino0x commented Jun 18, 2022 •

Copy link
Copy Markdown
Contributor

I think these are the rules described in #2038, but I can't find the actual rules for D3D in the D3D11 Functional Spec, so I need someone to help me verify these are correct (or just point me to the right docs/spec).

Here's what I do know, from the minutes:

JN: any inputs to later stage that are not system values needs to match in ordering the same subset from the previous stage. Inputting 3 attribs in PS coming from VS - need to be the first 3 attribs in the same order from VS>
MM: makes sense.
CW: all need to be present in FS?
JN: no. Can have outputs from earlier stage not in later stage.
MM: if consumer consumes 3rd attribute - it needs to consume the first 2 attribs too?
JN: yes. You can't skip attribs.
CW: assume float4 output 0, 1, 2. Want to use input 3 as float4 in frag shader - I need to declare 1, 2? Or want to use 2, don't need to declare 3?
JN: correct.
MM: think that makes sense.
CW: builtin values FS uses? SV_Position for example? Does position of SV_Position in input structure need to match its location in VS output structure?
JN: yes, if written by previous stage like SV_Position - assumed same order between stages. Is_FrontFace, for example, can be at the end.
MM: that's the trick - if producer produces 5 outputs and an SV_ value, and consumer wants middle output and SV_ value, consumer needs all values in their struct.
JN: correct. Well - doesn't need to be last - needs to be in same position on consumer side.
CW: ah we want to put it last because otherwise we have to declare it in FS.

In this PR, variables are ordered by location, and position is put at the end (not how the spec is written exactly, but it's the effect). That's based on this:

MM: Seems like we have a resolution, up to editors to spec this. Not dealing with resources, not dealing with bindgroups. Attribs are one-dimensional; shader interfaces strictly ordered, etc., so not intractable.
CW: problem - in D3D you can put SV_Position wherever you want. If you use it in frag shader you still need to spec everything before/after it. Have to decide how this'll work in WGSL. Does it always go in the end? Have to specify everything in FS then.
MM: makes sense. We also have static use rules. Shouldn't rely on source order.
CW: also entry points take things as arguments.
JN: how it is in HLSL too.
CW: ordering between structures-in-structures, parameters, etc.?
JN: also packing rules where vectors can combine. Here, concerned about packing WGSL args to match lower-level D3D linkages - vec4s.

  • Are there any other builtins which need to be placed at the end like this?

Fixes #2038

@kainino0x kainino0x added the copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.) label Jun 18, 2022
@kainino0x
kainino0x requested review from Jiawei-Shao and Kangz June 18, 2022 00:46
@github-actions

Copy link
Copy Markdown
Contributor

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

Comment thread spec/index.bs Resolved
@kainino0x
kainino0x requested a review from Kangz June 21, 2022 22:41
@github-actions

Copy link
Copy Markdown
Contributor

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

@Kangz Kangz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, thanks for writing this down!

@kainino0x

Copy link
Copy Markdown
Contributor Author

Spoke with @RafaelCintron this morning, hopefully we can get a documentation reference so I can double check our understanding.

@kainino0x kainino0x added the needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet label Jun 29, 2022
@kainino0x

Copy link
Copy Markdown
Contributor Author

Closing this as I have an alternative proposal in #2038.

@kainino0x kainino0x closed this Jun 29, 2022
@kainino0x
kainino0x deleted the inter-stage-prefix branch June 29, 2022 23:03
@kainino0x kainino0x changed the title Define inter-stage variable subsetting rules Allow inter-stage variable subsetting by prefix Jun 30, 2022
kainino0x added a commit to kainino0x/gpuweb that referenced this pull request Jun 30, 2022
@lokokung

Copy link
Copy Markdown
Contributor

Removing 'needs-cts-issue' as this is both superceded by #3122 and there is also an open CTS issue: gpuweb/cts#1554

@lokokung lokokung removed the needs-cts-issue This change requires tests (or would need tests if accepted), but may not have a CTS issue filed yet label Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shader stage input-output subsetting rules

3 participants