Warm tip: This article is reproduced from serverfault.com, please click

graphics-确定Vulkan中可能的最高颜色和深度附件采样数

(graphics - Determing the highest possible color and depth attachement sampled count in Vulkan)

发布于 2020-12-04 15:26:51

我是否需要将VkAttachmentDescription::samples2的幂设置为2,还是允许任意值,只要它们不超过硬件支持的最大值?

我对此很困惑。samples字段的类型VkSampleCountFlagBits为,通过以下方式声明

typedef enum VkSampleCountFlagBits {
    VK_SAMPLE_COUNT_1_BIT = 0x00000001,
    VK_SAMPLE_COUNT_2_BIT = 0x00000002,
    VK_SAMPLE_COUNT_4_BIT = 0x00000004,
    VK_SAMPLE_COUNT_8_BIT = 0x00000008,
    VK_SAMPLE_COUNT_16_BIT = 0x00000010,
    VK_SAMPLE_COUNT_32_BIT = 0x00000020,
    VK_SAMPLE_COUNT_64_BIT = 0x00000040,
    VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkSampleCountFlagBits;

另一方面,该VkPhysicalDeviceLimitsstruct包含字段framebufferColorSampleCountsand和framebufferDepthSampleCounts,它们是类型的VkSampleCountFlags,而这些字段又仅仅是typedeffor uint32_t

多重采样vulkan教程页面确定了这些字段中的最高位,以计算最大可用采样数。我实际上不明白这一点。例如,如果VK_SAMPLE_COUNT_16_BIT并且VK_SAMPLE_COUNT_1_BIT都在这些字段中都设置了该怎么办?这是否意味着最大可用采样数至少为17?

我需要的是,给定一个在一天结束时做什么uint32_t requested_sampled_count,确定是否requested_sampled_count是一个可能值VkAttachmentDescription::samples两种颜色和深度附着物,如果不是的话,还有什么比小的最高可能值requested_sampled_count

编辑

假设我std::uint32_t sample_count从物理设备属性中给出了and,VkSampleCountFlags framebuffer_color_sample_counts并想要计算VkSampleCountFlagBits samples我是否需要以下方式?

if (sample_count > 64)
    /* error */;
if (sample_count > 32)
    samples = VK_SAMPLE_COUNT_32_BIT;
else if (sample_count > 16)
    samples = VK_SAMPLE_COUNT_16_BIT;
else if (sample_count > 8)
    samples = VK_SAMPLE_COUNT_8_BIT;
else if (sample_count > 4)
    samples = VK_SAMPLE_COUNT_4_BIT;
else if (sample_count > 2)
    samples = VK_SAMPLE_COUNT_2_BIT;
else if (sample_count == 1)
    samples = VK_SAMPLE_COUNT_1_BIT;
else
    /* error */;
Questioner
0xbadf00d
Viewed
0
stridecolossus 2020-12-05 01:25:49

在样品计数VkSampleCountFlagsBits枚举是的一个位掩码用于采样位在附件的数量的设置,所以在你的示例硬件支持一个16个样本(未17!)