Aqoole_Hateenaの技術日記

vulkan+raytraceで色々描いてます

サポートされているsample count取得方法

multisamplingの機能を利用する場合の、supported sample count取得具体例(Android)

VkImageFormatProperties imageFormatProp = {};
vkGetPhysicalDeviceImageFormatProperties(physicalDevice, VK_FORMAT_R8G8B8A8_UNORM,
    VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_LINEAR, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
    VK_NULL_HANDLE, &imageFormatProp);
__android_log_print(ANDROID_LOG_INFO, "limits sample count", "%s", std::to_string(imageFormatProp.sampleCounts).c_str());

pipelineでのmultisamplingの指定方法については以下記事参照。
aqoole-hateena.hatenablog.com

VkImageFormatProperties

// Provided by VK_VERSION_1_0
typedef struct VkImageFormatProperties {
    VkExtent3D            maxExtent;
    uint32_t              maxMipLevels;
    uint32_t              maxArrayLayers;
    VkSampleCountFlags    sampleCounts;
    VkDeviceSize          maxResourceSize;
} VkImageFormatProperties;

sampleCounts is a bitmask of VkSampleCountFlagBits specifying all the supported sample counts for this image as described below.
VkImageFormatProperties(3)

sampleCountsにサポートされるsample countが格納されるのだが、bitmaskの形で情報が取得される。

VkSampleCountFlagBits

// Provided by VK_VERSION_1_0
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,
} VkSampleCountFlagBits;

VkSampleCountFlagBits(3)

vkGetPhysicalDeviceImageFormatProperties()

vkGetPhysicalDeviceImageFormatProperties - Lists physical device's image format capabilities
To query additional capabilities specific to image types, call:

// Provided by VK_VERSION_1_0
VkResult vkGetPhysicalDeviceImageFormatProperties(
    VkPhysicalDevice                            physicalDevice,
    VkFormat                                    format,
    VkImageType                                 type,
    VkImageTiling                               tiling,
    VkImageUsageFlags                           usage,
    VkImageCreateFlags                          flags,
    VkImageFormatProperties*                    pImageFormatProperties);

pImageFormatProperties is a pointer to a VkImageFormatProperties structure in which capabilities are returned.
vkGetPhysicalDeviceImageFormatProperties(3)

サポートされている情報の取得はvkGetPhysicalDeviceImageFormatProperties()関数で行う。