What's mean "VkPipelineColorBlendAttachmentState contains the configuration per attached framebuffer"?

Viewed 230

I read the Color blending Vulkan tutorial.

and this page says :

The first struct, VkPipelineColorBlendAttachmentState contains the configuration per attached framebuffer and the second struct, VkPipelineColorBlendStateCreateInfo contains the global color blending settings.In our case we only have one framebuffer

The second structure references the array of structures for all of the framebuffers

However, in Framebuffers chapter, framebuffers were created as many as the number of imageView.

But the code associated with it is the same.

And per-framebuffer struct no framebuffer-related members.

How attach color blend attachment to framebuffer?

My guess is that automatically attachment VkFramebufferCreateInfo::pAttachments when command recording(render pass begin), it's right?

or VkSubpassDescription::pColorAttachments ?

because specification say:

The value of attachmentCount must be greater than the index of all color attachments that are not VK_ATTACHMENT_UNUSED in VkSubpassDescription::pColorAttachments or VkSubpassDescription2::pColorAttachments for the subpass in which this pipeline is used.

1 Answers

Sometimes, tutorials do not use proper wording. This is one of those times.

Recall that a pipeline is built against a specific subpass of a specific render pass. Also recall that subpasses have a list of (among other things) color attachments that represent the render targets for rendering operations in that subpass.

What the tutorial means is that VkPipelineColorBlendAttachmentState defines the blend state for a particular attachment in the subpass designated by the pipeline. The array of VkPipelineColorBlendAttachmentState structs mirrors the array of color attachments used in the subpass the pipeline is being built for. So the third element of VkPipelineColorBlendStateCreateInfo::pAttachments corresponds to the third element in VkSubpassDescription::pColorAttachments for the subpass the pipeline is being built for.

For some reason, this tutorial refers to these attachments as "attached framebuffer," as this is absolutely the wrong term to use. They're just attachments.

Framebuffers provide the images that will be used as attachments when you begin a render pass. But the pipeline doesn't (really) care what image object you use. It cares about what color attachment in the subpass you're talking about.

Related