fmt(VK_FORMAT_R8G8_SINT, R8G8_SINT, .cpp = 2, .num_channels = 2),
fmt(VK_FORMAT_R8G8_SRGB, UNSUPPORTED), /* L8A8_UNORM_SRGB */
fmt(VK_FORMAT_R8G8B8_UNORM, R8G8B8X8_UNORM, .cpp = 3, .num_channels = 3),
- fmt(VK_FORMAT_R8G8B8_SNORM, R8G8B8_SNORM, .cpp = 4),
+ fmt(VK_FORMAT_R8G8B8_SNORM, R8G8B8_SNORM, .cpp = 3, .num_channels = 3),
fmt(VK_FORMAT_R8G8B8_USCALED, R8G8B8_USCALED, .cpp = 3, .num_channels = 3),
fmt(VK_FORMAT_R8G8B8_SSCALED, R8G8B8_SSCALED, .cpp = 3, .num_channels = 3),
fmt(VK_FORMAT_R8G8B8_UINT, R8G8B8_UINT, .cpp = 3, .num_channels = 3),
fmt(VK_FORMAT_R11G11B10_UFLOAT, R11G11B10_FLOAT, .cpp = 4, .num_channels = 3),
fmt(VK_FORMAT_R9G9B9E5_UFLOAT, R9G9B9E5_SHAREDEXP, .cpp = 4, .num_channels = 3),
- /* For depth/stencil formats, the .format and .cpp fields describe the
- * depth format. The field .has_stencil indicates whether or not there's a
- * stencil buffer.
- */
- fmt(VK_FORMAT_D16_UNORM, D16_UNORM, .cpp = 2, .num_channels = 1),
- fmt(VK_FORMAT_D24_UNORM, D24_UNORM_X8_UINT, .cpp = 4, .num_channels = 1),
- fmt(VK_FORMAT_D32_SFLOAT, D32_FLOAT, .cpp = 4, .num_channels = 1),
- fmt(VK_FORMAT_S8_UINT, UNSUPPORTED, .cpp = 0, .num_channels = 1, .has_stencil = true),
- fmt(VK_FORMAT_D16_UNORM_S8_UINT, D16_UNORM, .cpp = 2, .num_channels = 2, .has_stencil = true),
- fmt(VK_FORMAT_D24_UNORM_S8_UINT, D24_UNORM_X8_UINT, .cpp = 4, .num_channels = 2, .has_stencil = true),
- fmt(VK_FORMAT_D32_SFLOAT_S8_UINT, D32_FLOAT, .cpp = 4, .num_channels = 2, .has_stencil = true),
+ fmt(VK_FORMAT_D16_UNORM, R16_UNORM, .cpp = 2, .num_channels = 1, .depth_format = D16_UNORM),
+ fmt(VK_FORMAT_D24_UNORM, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 1, .depth_format = D24_UNORM_X8_UINT),
+ fmt(VK_FORMAT_D32_SFLOAT, R32_FLOAT, .cpp = 4, .num_channels = 1, .depth_format = D32_FLOAT),
+ fmt(VK_FORMAT_S8_UINT, R8_UINT, .cpp = 1, .num_channels = 1, .has_stencil = true),
+ fmt(VK_FORMAT_D16_UNORM_S8_UINT, R16_UNORM, .cpp = 2, .num_channels = 2, .depth_format = D16_UNORM, .has_stencil = true),
+ fmt(VK_FORMAT_D24_UNORM_S8_UINT, R24_UNORM_X8_TYPELESS, .cpp = 4, .num_channels = 2, .depth_format = D24_UNORM_X8_UINT, .has_stencil = true),
+ fmt(VK_FORMAT_D32_SFLOAT_S8_UINT, R32_FLOAT, .cpp = 4, .num_channels = 2, .depth_format = D32_FLOAT, .has_stencil = true),
fmt(VK_FORMAT_BC1_RGB_UNORM, UNSUPPORTED),
fmt(VK_FORMAT_BC1_RGB_SRGB, UNSUPPORTED),
fmt(VK_FORMAT_B10G10R10A2_SINT, B10G10R10A2_SINT, .cpp = 4, .num_channels = 4)
};
+#undef fmt
+
const struct anv_format *
anv_format_for_vk_format(VkFormat format)
{
extern const struct surface_format_info surface_formats[];
-VkResult anv_validate_GetFormatInfo(
- VkDevice _device,
+VkResult anv_validate_GetPhysicalDeviceFormatInfo(
+ VkPhysicalDevice physicalDevice,
VkFormat _format,
- VkFormatInfoType infoType,
- size_t* pDataSize,
- void* pData)
+ VkFormatProperties* pFormatInfo)
{
const struct anv_format *format = anv_format_for_vk_format(_format);
fprintf(stderr, "vkGetFormatInfo(%s)\n", format->name);
- return anv_GetFormatInfo(_device, _format, infoType, pDataSize, pData);
+ return anv_GetPhysicalDeviceFormatInfo(physicalDevice, _format, pFormatInfo);
}
-static void
-anv_format_get_properties(struct anv_device *device,
- const struct anv_format *format,
- VkFormatProperties *properties)
+VkResult anv_GetPhysicalDeviceFormatInfo(
+ VkPhysicalDevice physicalDevice,
+ VkFormat _format,
+ VkFormatProperties* pFormatInfo)
{
+ ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
const struct surface_format_info *info;
int gen;
- gen = device->info.gen * 10;
- if (device->info.is_haswell)
+ const struct anv_format *format = anv_format_for_vk_format(_format);
+ if (format == NULL)
+ return vk_error(VK_ERROR_INVALID_VALUE);
+
+ gen = physical_device->info->gen * 10;
+ if (physical_device->info->is_haswell)
gen += 5;
if (format->surface_format == UNSUPPORTED)
linear |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
}
- properties->linearTilingFeatures = linear;
- properties->optimalTilingFeatures = tiled;
- return;
+ pFormatInfo->linearTilingFeatures = linear;
+ pFormatInfo->optimalTilingFeatures = tiled;
- unsupported:
- properties->linearTilingFeatures = 0;
- properties->optimalTilingFeatures = 0;
-}
+ return VK_SUCCESS;
-VkResult anv_GetFormatInfo(
- VkDevice _device,
- VkFormat _format,
- VkFormatInfoType infoType,
- size_t* pDataSize,
- void* pData)
-{
- struct anv_device *device = (struct anv_device *) _device;
- const struct anv_format *format;
- VkFormatProperties *properties;
-
- format = anv_format_for_vk_format(_format);
- if (format == 0)
- return vk_error(VK_ERROR_INVALID_VALUE);
-
- switch (infoType) {
- case VK_FORMAT_INFO_TYPE_PROPERTIES:
- properties = (VkFormatProperties *)pData;
-
- *pDataSize = sizeof(*properties);
- if (pData == NULL)
- return VK_SUCCESS;
-
- anv_format_get_properties(device, format, properties);
- return VK_SUCCESS;
+ unsupported:
+ pFormatInfo->linearTilingFeatures = 0;
+ pFormatInfo->optimalTilingFeatures = 0;
- default:
- return vk_error(VK_ERROR_INVALID_VALUE);
- }
+ return VK_SUCCESS;
}