跳转至

vkGetPhysicalDeviceFormatProperties

函数原型

1
2
3
4
void vkGetPhysicalDeviceFormatProperties(
    VkPhysicalDevice                            physicalDevice,
    VkFormat                                    format,
    VkFormatProperties*                         pFormatProperties);

描述

查询物理设备支持的格式属性。

参数

  • physicalDevice : 查询的物理设备。
  • format : 查询的格式。
  • pFormatProperties : VkFormatProperties 结构体指针,返回物理设备支持的格式属性。

补充

VkFormatProperties 结构体定义:

1
2
3
4
5
typedef struct VkFormatProperties {
    VkFormatFeatureFlags    linearTilingFeatures;
    VkFormatFeatureFlags    optimalTilingFeatures;
    VkFormatFeatureFlags    bufferFeatures;
} VkFormatProperties;

返回值

代码示例

1
2
3
4
5
6
7
8
9
VkImageCreateInfo image_info = {};
const VkFormat depth_format = VK_FORMAT_D16_UNORM;
VkFormatProperties props;
vkGetPhysicalDeviceFormatProperties(gpus[0], depth_format, &props);
if (props.linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
    image_info.tiling = VK_IMAGE_TILING_LINEAR;
} else if (props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) {
    image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
}