Sitelet https://github.com/gpuweb/gpuweb/pull/1307
Skip to content

Refactor GPURenderPipelineDescriptor API - #1307

Closed
kvark wants to merge 7 commits into
gpuweb:mainfrom
kvark:render-api
Closed

kvark wants to merge 7 commits into
gpuweb:mainfrom
kvark:render-api

Conversation

@kvark

@kvark kvark commented Dec 14, 2020 •

Copy link
Copy Markdown
Contributor

Moved out of #1293 and reworked according to the latest input from the editors.
Closes #936

TL;DR:

  • adds GPUPrimitiveAssemblyStateDescriptor, which contains the primitive topology with the strip index format.
  • moves the sample count, mask, and alpha-to-coverage into the rasterization state
  • reorders the fields of GPURenderPipelineDescriptor according to the order in the pipeline
  • refactors the validation (but no new statements there)

Note: we probably want to move the alpha-to-coverage after the fragment shader


Preview | Diff

@github-actions

Copy link
Copy Markdown
Contributor

Previews, as seen at the time of posting this comment:
WebGPU | IDL
WGSL
77fd5b2

Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
@kainino0x
kainino0x requested a review from Kangz December 15, 2020 00:46
Kangz
Kangz previously approved these changes Dec 15, 2020
Comment thread spec/index.bs Outdated
@kvark

kvark commented Dec 16, 2020

Copy link
Copy Markdown
Contributor Author

The alpha-to-coverage now found a new home in the GPUOutputMergerStateDescriptor. I also renamed the other ones to be consistent (i.e. "rasterization" -> "rasterizer"). PTAL!

@kvark

kvark commented Dec 16, 2020

Copy link
Copy Markdown
Contributor Author

The whole lot of renames now follow in the tailing commits. Hopefully, we'll not need to mess with it for a while after that.

@kainino0x kainino0x 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.

Overall I like these new names.

Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
Comment thread spec/index.bs
GPUDepthStencilStateDescriptor depthStencilState;
required GPUOutputMergerStateDescriptor outputMergerState;
GPUVertexInputState vertexInput = {};
required GPUProgrammableStage vertexStage;

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.

The wording above calls everything a "stage" and calls vertex/fragment specifically "shaders". Should this, too? (This could affect compute pipelines too.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it would be unfortunate to say GPUprogrammableShader...
Perhaps, what we have here is fine? Non-programmable stages have "state", but programmable stages have shaders.
Would you see required GPUProgrammableStage vertexShader as an improvement?

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.

I think it would be fine, but I also think "vertexStage" is fine.

Comment thread spec/index.bs Outdated
@kainino0x

Copy link
Copy Markdown
Contributor

Overall I like these new names.

(And the pipeline organization is great!)

Comment thread spec/index.bs Outdated
GPURasterizerState rasterizer = {};
GPUProgrammableStage fragmentStage;
GPUDepthStencilState depthStencil;
required GPUOutputMergerState outputMerger;

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.

IMHO outputMerger is a bit weird, because looking at D3D12 (from which the terminology comes) OM is only used for OMSetStencilRef OMSetBlendColor OMSetDepthBounds and OMSetRenderTargets. The D3D12_GRAPHICS_PIPELINE_STATE_DESC has AlphaToCoverage in the BLEND_DESC.

The extra indirection with the outputMerge.colorOutputs is a bit big for something that's so useful. Maybe we could keep the colorOutputs directly in GPURenderPipelineDescriptor and put all the multisampling state together in a multisample sub-descriptor. It doesn't necessarily follow the ordering of the graphics pipeline, but puts all the information you care about for multisampling in the same place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that would basically sabotage #936 :(

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.

I like the current revision (.colorWrite.outputs), but if we wanted to remove the indirection, we could put alphaToCoverageEnabled inside the GPUColorOutputState and allow it to be set only on index 0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, that's an interesting option. I'd prefer to not go this way, since we may want to add more fields in the write output structure, e.g. with extensions, and we don't want to be forced to put them elsewhere.

Comment thread spec/index.bs Outdated
@Kangz

Kangz commented Dec 18, 2020

Copy link
Copy Markdown
Contributor

What about calling vertexBuffers vertexState and extracting them into the main descriptor? Also the indirection for colorOutputs.colors seems a bit gratuitous. It seems like things would match the developer's interest better with a multisampleState and colorStates as we had it before. The goal is that 1) it helps reduce typing a bit without less clarity 2) it puts state that's usually thought about together in the same sub-descriptor (alphaToCoverage with sampleCount for example).

@kainino0x

Copy link
Copy Markdown
Contributor

Resolution: Everyone seems happy with aspect based; @kvark to make a PR to propose it concretely.

@kvark kvark closed this in #1352 Jan 22, 2021
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This updates the invariant duplicate test to have both positive and
negative cases so we have a control that other syntax changes don't
hide issues with this test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-organize GPURenderPipelineDescriptor according to the structure of the GPU pipeline

3 participants