08/22/2020
多重采样
多重采样时为图像内每一个像素生成多个样本的过程。它用来消除锯齿,当正确使用时能大幅度提升图像质量。当进行多重采样时,颜色和深度-模板部件必须是多重采样。
开启管线的多重采样状态
// Setup multi sampling
VkPipelineMultisampleStateCreateInfo multisampleState{
};
multisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
// Number of samples to use for rasterization
multisampleState.rasterizationSamples = sampleCount;
if (vulkanDevice->features.sampleRateShading)
{
// MSAA with sample shading pipeline
// Sample shading enables per-sample shading to avoid shader aliasing and smooth out e.g. high frequency texture maps
// Note: This will trade performance for are more stable image
// Enable per-sample shading (instead of per-fragment)
multisampleState.sampleShadingEnable = VK_TRUE;
// Minimum fraction for sample shading
multisampleState.minSampleShading = 0.25f;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.MSAASampleShading));
}
- 采样数量- 由物理设备决定
- 是否开启Sample Shading - 由设备特性决定