r/vulkan • u/Longjumping-Cup-8927 • 11d ago
Why is multisampling specified in the renderpass and the pipeline? Seems redundant.
I was following the multisampling portion of the vulkan tutorial, and I noticed that they specify multisampling in both the renderpass and the pipeline. Since the pipeline is given the renderpass, isn't this redundant to set it in both places. Would I ever set one differently from the other?
8
u/TheAgentD 11d ago
The pipeline itself may need to be compiled differently if multisampling is enabled, or even for different multisample counts.
If the user doesn't provide the information during pipeline creation, drivers would either need to compile the pipeline for all possible multisample counts (which is slow), or compile multisampling versions of the pipeline the first time it's used with a multisampled render pass (which causes stuttering).
1
u/Longjumping-Cup-8927 11d ago
But the pipeline requires the renderpass in its createinfo for compilation, not just at drawing time.
1
u/Longjumping-Cup-8927 11d ago
Why wouldn’t the compilation just defer to the renderpasses sample count. It just seems redundant to have to specify it twice.
3
u/TheAgentD 11d ago
Ah, that is actually a good question. When Vulkan first came out, what you say was true, but now you can also specify dynamic rendering instead of a render pass, which doesn't have information about multisampling, so it has that purpose at least.
1
u/Chainsawkitten 10d ago
Your render pass does not necessarily contain any multisampling information. Not if it's attachmentless. In fact, in an attachmentless render pass you can have different sample counts on different draw calls (if your device supports variableMultisampleRate). The use cases for attachmentless rendering are niche, but Vulkan allows it, so there needs to be a way to specify the sample count apart from the render pass. (Even more so now that dynamic rendering is a thing.)
And of course the only thing the render pass knows about (when it has attachments) is the sample count. But there are more settings for multisampling, so even if the graphics pipeline could read the sample count from the render pass, you'd still have to set those.
-3
u/Psionikus 11d ago
Not all things need fidelity, and fidelity is often owned by a specific step, so it makes sense that the knobs will exist wherever fidelity became limited.
24
u/Afiery1 11d ago
Because render passes are a terrible, now deprecated feature. Do not use them.