-
Notifications
You must be signed in to change notification settings - Fork 335
Refactor the GPURenderPipelineDescriptor according to aspects #1352
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
Conversation
On the last call you had an example that showed every possible descriptor property in one big struct. Could you link that again here or paste it into the comments? It's slightly tricky to get the complete picture from the various diffed chunks spread throughout the spec and it would serve as a useful reference for the intent. |
device.createRenderPipeline({
vertex: {
inputs: [{
arrayStride: 16,
stepMode: "vertex",
attributes: [{
offset: 0,
format: "float2",
}],
}],
module: module,
entryPoint: "vs_main",
},
primitive: {
topology: "triangle-strip",
stripIndexFormat: "uint16",
frontFace: "ccw",
cullMode: "back",
},
depthStencil: {
format: "depth24plus",
depthWriteEnabled: true,
depthCompare: "less",
depthBias: 2,
depthBiasSlopeScale: 1.0,
depthBiasClamp: 8.0,
stencilReadMask: 0xF,
stencilWriteMask: 0x1,
stencilFront: {
compare: "greater",
failOp: "keep",
depthFailOp: "invert",
passOp: "zero",
},
stencilBack: {},
},
multisample: {
count: 4,
mask: 0xF,
alphaToCoverage: true,
},
fragment: {
outputs: [{
format: 'rgba8unorm',
writeMask: 0xF,
blend: {
color: {
srcFactor: "one",
dstFactor: "src-alpha",
operation: "add",
},
alpha: {},
},
}],
module: module,
entryPoint: "fs_main",
},
}); |
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 looking really good! Thanks!
spec/index.bs
Outdated
|
||
<script type=idl> | ||
dictionary GPUFragmentState: GPUProgrammableStage { | ||
required sequence<GPUColorState> outputs; |
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.
RE: my suggestion about changing inputs
on the vertex stage, maybe this could be colorOutputs
to keep them more aligned?
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.
Sure! Let's come back to this once we figure out what needs to be done with inputs
, if anything
|
||
- [$validating GPUProgrammableStageDescriptor$]({{GPUShaderStage/VERTEX}}, | ||
|descriptor|.{{GPURenderPipelineDescriptor/vertexStage}}, | ||
- [$validating GPUProgrammableStage$]({{GPUShaderStage/VERTEX}}, |
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.
Since the vertexState
is a programmable stage now should this step be moved into the validating GPUVertexState
algorithm? Same for fragmentState
below.
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.
We can do it for sure! I think we can also consider this to be a follow-up.
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.
Much detailed review, thank you!
|
||
- [$validating GPUProgrammableStageDescriptor$]({{GPUShaderStage/VERTEX}}, | ||
|descriptor|.{{GPURenderPipelineDescriptor/vertexStage}}, | ||
- [$validating GPUProgrammableStage$]({{GPUShaderStage/VERTEX}}, |
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.
We can do it for sure! I think we can also consider this to be a follow-up.
spec/index.bs
Outdated
|
||
<script type=idl> | ||
dictionary GPUFragmentState: GPUProgrammableStage { | ||
required sequence<GPUColorState> outputs; |
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.
Sure! Let's come back to this once we figure out what needs to be done with inputs
, if anything
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 change is amazing! Hopefully we don't need to move stuff around the GPURenderPipelineDescriptor
a second time >_>
FYI I want to consider a change after this one to change |
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.
looks great!
In the last commit the changes are the following:
|
f186ef5
to
fa71b9b
Compare
Also, rebased and squashed. It's very easy to run into conflicts with this. |
I like the word Layout, and think State isn't really important, could they just be VertexBufferLayout and VertexAttribute?
sg but a merge commit would have been easier for incremental review if possible. |
That's perfect! π This change LGTM now.
Nit on Kai's follow up request: That would actually be |
Yeah, probably, unless we have a better name than |
Let's have the multisample discussion in a separate issue, perhaps? It sounds interesting, but I don't want it to drag this change. As for the merge commit - there was a conflict already. I generally resolve conflicts by rebasing, but in this case it's much easier to resolve it on the whole thing than trying to resolve conflicts on each commit one by one. Just squashed to save time. |
I don't think the longer names were necessary, but unless more people feel the same I don't think my opinion should block this change. |
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.
LGTM modulo that final bikeshedding (I don't prefer the new names over inputs/outputs but they're okay)
Let's have the multisample discussion in a separate issue, perhaps?
Yeah, was planning to open a PR after this lands.
My sole reason for advocating for a name like
We have some serious refactoring to do if "reduce the amount of typing required" is an API goal. π |
@kainino0x oh, wait, I misunderstood. I thought you wanted these longer names, based on #1352 (comment) |
@kvark It's not that I have anything against slightly longer names, I just am not sure whether these are actually clearer - e.g. inputBuffers doesn't clarify that it doesn't include uniform buffers (though this probably doesn't matter that much). But if Brandon thinks so I think it's a good signal. |
Now that this PR landed I started looking into this. I learned that in fact alpha-to-coverage and sample-rate-shading are not exclusive with one another, so this idea doesn't make sense. Sample-rate-shading means shading more than once per pixel, but can be fewer than once per sample (interpolation may occur for other samples, I think). In Vulkan I think the final coverage mask is the AND of all three mask values (pipeline sample mask, shader output sample mask, and alpha-to-coverage sample mask*), then only the relevant bits of the final mask are used (those for the samples covered by the shader invocation). * though there is no guarantee about the alpha-to-coverage mask produced. According to #267, D3D12 disables alpha-to-coverage if SV_Coverage is used. I think this is why in WebGPU we don't allow alpha-to-coverage with SV_Coverage (added in #724), though given the leniency of the alpha-to-coverage mask I think we could simply allow it and stay within spec. Additionally I learned that alpha-to-one is a separate (and optional) feature which is not turned on by enabling alpha-to-coverage. |
I should say, I don't think this is necessary. Being strict here is probably best as it sets expectations that the two aren't likely to actually work together. |
This CL adds unimplemented stub tests for the `trunc` builtin. Issues: gpuweb#1243
Groups the properties of a pipeline according to the aspects. Related things are kept together, even if they can affect multiple stages of a pipeline.
Closes #1307
Closes #936
I also want to re-order the sections of the pipeline, but this can be done as a follow-up in order to make this PR easier.
Preview | Diff