Abstract Pipeline creation (including pipeline layouts and root signatures)#1070
Conversation
241f8e7 to
01ee86c
Compare
492a638 to
a9184ae
Compare
|
|
||
| llvm::Expected<std::unique_ptr<PipelineState>> | ||
| createPipelineCs(llvm::StringRef Name, | ||
| const BindingsDesc & /*unused on metal*/, |
There was a problem hiding this comment.
Metal does store this info in reflection, and it does even have a typed builder. But since Metal IRConverter converts this into an arbitrary "buffer of bytes" (top-level argument buffer) that we can just bind, no type info is needed 🎉
|
Since this PR mostly seems to move (lots of) code around, I asked Claude to boil down all the semantic changes in the diff as these are omitted from the PR description. Let me know if the below is correct and matches the intent, or if it found nonsense, or if certain things weren't intended to be changed like that. It'll help with the review of close to 1200 lines :) Semantic changes in moved codeBeyond the refactoring (splitting functions, RAII, new abstract types), these are the behavioral differences I spotted between the old and new code: DX/Device.cpp
MTL/MTLDevice.cpp
VK/Device.cpp
|
Looks like something went wrong here. It seems like it wasn't enabled in DX12 when I initially worked on this branch but it got enabled in the mean-time. Let me enable depth stencil testing. |
0577089 to
87320f5
Compare
| PipelineCI.pColorBlendState = &BlendCI; | ||
| PipelineCI.pDynamicState = &DynamicCI; | ||
| PipelineCI.layout = PipelineLayout; | ||
| PipelineCI.renderPass = VK_NULL_HANDLE; |
There was a problem hiding this comment.
Claude:
VK dynamic rendering is the biggest risk. The pipeline is now created with
renderPass = VK_NULL_HANDLE+VkPipelineRenderingCreateInfo, but the command encoding path still uses the oldVkRenderPass-basedvkCmdBeginRenderPass. Mixing dynamic-rendering pipeline creation with legacy render pass commands is technically invalid per the Vulkan spec — pipelines created with dynamic rendering must be used withvkCmdBeginRendering, notvkCmdBeginRenderPass. This could silently work on some drivers and fail on others.
There was a problem hiding this comment.
Running with golden images and validation layer enabled (-DGOLDENIMAGE_DIR=/path/to/golden-images -DOFFLOADTEST_ENABLE_VALIDATION=ON):
Validation Error: [ VUID-vkCmdDraw-renderPass-02684 ] | MessageID = 0x50685725
vkCmdDraw(): subpassCount is incompatible between VkRenderPass 0xf000000000f
(from VkCommandBuffer 0x5625f3c3bf50) and VkRenderPass 0x0 (from VkPipeline
0x140000000014), 1 != 0
The Vulkan spec states: The current render pass must be compatible with the
renderPass member of the VkGraphicsPipelineCreateInfo structure specified when
creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS
(https://docs.vulkan.org/spec/latest/chapters/drawing.html#VUID-vkCmdDraw-renderPass-02684)
Objects: 3
[0] VkCommandBuffer 0x5625f3c3bf50
[1] VkRenderPass 0xf000000000f
[2] VkPipeline 0x140000000014
Validation Error: [ VUID-vkCmdDraw-renderPass-02684 ] | MessageID = 0x50685725
vkCmdDraw(): dependencyCount is incompatible between VkRenderPass 0xf000000000f
(from VkCommandBuffer 0x5625f3c3bf50) and VkRenderPass 0x0 (from VkPipeline
0x140000000014), 2 != 0
The Vulkan spec states: The current render pass must be compatible with the
renderPass member of the VkGraphicsPipelineCreateInfo structure specified when
creating the VkPipeline bound to VK_PIPELINE_BIND_POINT_GRAPHICS
(https://docs.vulkan.org/spec/latest/chapters/drawing.html#VUID-vkCmdDraw-renderPass-02684)
Objects: 3
[0] VkCommandBuffer 0x5625f3c3bf50
[1] VkRenderPass 0xf000000000f
[2] VkPipeline 0x140000000014
There was a problem hiding this comment.
I have removed the dynamic rendering feature. It's now using classic RenderPass objects.
MarijnS95
left a comment
There was a problem hiding this comment.
Nice, looks like after re-adding render passes (switching to "Dynamic Rendering" is a bigger feat that is better suited to its own isolated PR) this seems to be ready to go!
90977e5 to
28f495f
Compare
bogner
left a comment
There was a problem hiding this comment.
A few minor comments. The biggest one will be the comment about the error handling strategy in various places. Generally LGTM though, shouldn't need another review round from me once those are addressed.
4d1bb66 to
1e26ff8
Compare
1e26ff8 to
18fcc36
Compare
a60fab6 to
24837ea
Compare
|
CI failure is unrelated to this PR. |
Add an API-agnostic way of creating compute and graphics pipelines. This includes the creation of pipeline layouts and root signatures. In Metal, there is no real equivalent due to the use of a top-level argument buffer, so the BindingsDesc variable is ignored.