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

More detailed design of pipelines to start discussions - #29

Merged
Kangz merged 3 commits into
masterfrom
pipeline-objects
Sep 1, 2017
Merged

Kangz merged 3 commits into
masterfrom
pipeline-objects

Conversation

@Kangz

@Kangz Kangz commented Aug 23, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@Kangz

Kangz commented Aug 23, 2017

Copy link
Copy Markdown
Contributor Author

Note that you can use the "rich diff" to see the file formatted.

Comment thread design/Pipelines.md Outdated
For example a ```DepthStencilState``` object would be allocated and a pointer to it would be stored in the ```RenderPipelineDescriptor```.

Mismatch:
- Metal doesn’t have primitive restart.

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.

It does: https://developer.apple.com/documentation/metal/mtlrendercommandencoder/1515520-drawindexedprimitives

Primitive restart functionality is enabled with the largest unsigned integer index value, relative to indexType (0xFFFF for MTLIndexTypeUInt16 or 0xFFFFFFFF for MTLIndexTypeUInt32). This feature finishes drawing the current primitive at the specified index and starts drawing a new one with the next index.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What Metal actually doesn't have is a way to disable the primitive restart functionality.

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.

Thanks, for the pointers. Updated the design with this but it showed a new mismatch with D3D12.

Comment thread design/Pipelines.md
Mismatch:
- Metal doesn’t have primitive restart.
- Metal doesn’t have a sample mask.
- Vulkan can have some state like scissor and viewport set on the pipeline as an optimization on some GPUs.

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 don't think it's worth for us to take this into account, given how unique this ability is and how easy it is in Vulkan to create PSO without those states baked in.

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.

Agreed, added that all dynamic states are always set in the Vulkan.

Comment thread design/Pipelines.md
int subpassIndex;

// Fixed function state
DepthStencilState* depthStencil;

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 don't think we need to have parts of the PSO descriptors like DepthStencilState being separate objects

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.

For simplicity we assume most fixed-function state is created in separate object.

Added the following to explain it is a cosmetic decision that will be left for later.

This is part of the UX of the API and could be replaced with chained structure like Vulkan or member structure like D3D12.

Comment thread design/Pipelines.md Outdated
Translation to the backing APIs would be the following:
- **D3D12**: Translates to ```ID3D12::CreateComputePipelineState```
- **Metal**: Translates to ```MTLDevice::makeRenderPipelineState```
- **Vulkan**: Translates to ```vkCreateGraphicsPipelines```

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.

mismatch: Vulkan allows creating PSOs in bulk, and it's easy to emulate on other APIs

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.

Added

Comment thread design/Pipelines.md Outdated
- **D3D12**: Translates to a ```D3D12_INPUT_DESC```.
Each enabled attribute corresponds to a ```D3D12_INPUT_ELEMENT_DESC``` with ```InputSlot``` being the index of the attribute.
Other members of the ```D3D12_INPUT_ELEMENT_DESC``` are translated trivially.
The stride is looked up in the pipeline state before calls to ```ID3D12GraphicsCommandList::IASetVertexBuffers```.

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 d3d12 backend may need to defer the setup of vertex buffers until the actual draw call, since any PSO binding between the vertex buffer setup and the draw call would potentially change the strides (assuming we keep the strides in PSO)

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.

Good point, I need to add an NXT test for it as we have this wrong for now :)

Comment thread design/Pipelines.md Outdated
```depthTestEnable``` would be set to ```depthCompare != Always```.

Open question:
what about Vulkan’s ```VkPipelineDepthStencilStateCreateInfo::depthBoundTestEnable```?

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.

partially supported by d3d12, but I don't see it on Metal: https://msdn.microsoft.com/en-us/library/windows/desktop/mt492556(v=vs.85).aspx

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.

Done.

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

That's for the fixes, :shipit:

Comment thread design/Pipelines.md Outdated
- **Vulkan**: Translates to ```vkCreateGraphicsPipelines```
- **Vulkan**: Translates to ```vkCreateGraphicsPipelines```. ```VkPipelineInputAssemblyStateCreateInfo```'s ```primitiveRestartEnable``` is always set to true. All dynamic states are set on all pipelines.

Open question: should the type of the indices be set in ```RenderPipelineDescriptor```? If not, how is the D3D12 ```IBStripCutValue``` chosen?

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.

Good question. We don't want to be delaying the PSO creation ever, so my vote is to specify the index type in RenderPipelineDescriptor so that D3D12 can set the proper IBStripCutValue

@Kangz
Kangz merged commit 5913513 into master Sep 1, 2017
@Kangz
Kangz deleted the pipeline-objects branch September 1, 2017 20:27
@kainino0x kainino0x mentioned this pull request Oct 30, 2019
13 tasks done
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.

4 participants