[英]Determing the highest possible color and depth attachement sampled count in Vulkan
我是否需要将VkAttachmentDescription::samples
的值设置为 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;
另一方面, VkPhysicalDeviceLimits
结构包含字段framebufferColorSampleCounts
和framebufferDepthSampleCounts
,它们的类型是VkSampleCountFlags
,而这又只是uint32_t
的typedef
。
关于多重采样的 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
,并且从物理设备属性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 */;
VkSampleCountFlagsBits
枚举中的样本计数是附件中采样位数的可用设置的位掩码,因此在您的示例中,硬件支持一个或16个样本(不是 17 个!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.