[英]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.