in src/gpu/graphite/vk/VulkanCaps.cpp [555:1108]
void VulkanCaps::initFormatTable(const skgpu::VulkanInterface* interface,
VkPhysicalDevice physDev,
const VkPhysicalDeviceProperties& properties) {
static_assert(std::size(kVkFormats) == VulkanCaps::kNumVkFormats,
"Size of VkFormats array must match static value in header");
std::fill_n(fColorTypeToFormatTable, kSkColorTypeCnt, VK_FORMAT_UNDEFINED);
// NOTE: VkFormat's naming convention orders channels from low address to high address when
// interpreting unpacked formats. For packed formats, the channels are ordered most significant
// to least significant (making them opposite of the unpacked).
// Go through all the formats and init their support surface and data ColorTypes.
// Format: VK_FORMAT_R8G8B8A8_UNORM
{
constexpr VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGBA_8888
{
constexpr SkColorType ct = SkColorType::kRGBA_8888_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle::RGB1();
}
}
}
// Format: VK_FORMAT_R8_UNORM
{
constexpr VkFormat format = VK_FORMAT_R8_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 3;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8_UNORM, Surface: kR_8
{
constexpr SkColorType ct = SkColorType::kR8_unorm_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
// Format: VK_FORMAT_R8_UNORM, Surface: kAlpha_8
{
constexpr SkColorType ct = SkColorType::kAlpha_8_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
}
// Format: VK_FORMAT_R8_UNORM, Surface: kGray_8
{
constexpr SkColorType ct = SkColorType::kGray_8_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle("rrr1");
}
}
}
// Format: VK_FORMAT_B8G8R8A8_UNORM
{
constexpr VkFormat format = VK_FORMAT_B8G8R8A8_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_B8G8R8A8_UNORM, Surface: kBGRA_8888
{
constexpr SkColorType ct = SkColorType::kBGRA_8888_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16
{
constexpr VkFormat format = VK_FORMAT_R5G6B5_UNORM_PACK16;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16, Surface: kRGB_565_SkColorType
{
constexpr SkColorType ct = SkColorType::kRGB_565_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R16G16B16A16_SFLOAT
{
constexpr VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: kRGBA_F16_SkColorType
{
constexpr SkColorType ct = SkColorType::kRGBA_F16_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: kRGB_F16F16F16x_SkColorType
{
constexpr SkColorType ct = SkColorType::kRGB_F16F16F16x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle::RGB1();
}
}
}
// Format: VK_FORMAT_R16_SFLOAT
{
constexpr VkFormat format = VK_FORMAT_R16_SFLOAT;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16_SFLOAT, Surface: kAlpha_F16
{
constexpr SkColorType ct = SkColorType::kA16_float_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
}
}
}
// Format: VK_FORMAT_R8G8B8_UNORM
{
constexpr VkFormat format = VK_FORMAT_R8G8B8_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8_UNORM, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
// This SkColorType is a lie, but we don't have a kRGB_888_SkColorType. The Vulkan
// format is 3 bpp so we must manualy convert to/from this and kRGB_888x when doing
// transfers. We signal this need for manual conversions in the
// supportedRead/WriteColorType calls.
ctInfo.fTransferColorType = SkColorType::kRGB_888x_SkColorType;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R8G8_UNORM
{
constexpr VkFormat format = VK_FORMAT_R8G8_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8_UNORM, Surface: kR8G8_unorm
{
constexpr SkColorType ct = SkColorType::kR8G8_unorm_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32
{
constexpr VkFormat format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 2;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32, Surface: kRGBA_1010102
{
constexpr SkColorType ct = SkColorType::kRGBA_1010102_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32, Surface: kRGB_101010x
{
constexpr SkColorType ct = SkColorType::kRGB_101010x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle::RGB1();
}
}
}
// Format: VK_FORMAT_A2R10G10B10_UNORM_PACK32
{
constexpr VkFormat format = VK_FORMAT_A2R10G10B10_UNORM_PACK32;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_A2R10G10B10_UNORM_PACK32, Surface: kBGRA_1010102
{
constexpr SkColorType ct = SkColorType::kBGRA_1010102_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16
{
constexpr VkFormat format = VK_FORMAT_B4G4R4A4_UNORM_PACK16;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16, Surface: kARGB_4444_SkColorType
{
constexpr SkColorType ct = SkColorType::kARGB_4444_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
// The color type is misnamed and really stores ABGR data, but there is no
// SkColorType that matches this actual ARGB VkFormat data. Swapping R and B when
// rendering into it has it match the reported transfer color type, but we have to
// swap R and B when sampling as well. This only works so long as we don't present
// textures of this format to a screen that would not know about this swap.
ctInfo.fReadSwizzle = skgpu::Swizzle::BGRA();
ctInfo.fWriteSwizzle = skgpu::Swizzle::BGRA();
}
}
}
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16
{
constexpr VkFormat format = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16, Surface: kARGB_4444_SkColorType
{
constexpr SkColorType ct = SkColorType::kARGB_4444_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R8G8B8A8_SRGB
{
constexpr VkFormat format = VK_FORMAT_R8G8B8A8_SRGB;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R8G8B8A8_SRGB, Surface: kRGBA_8888_SRGB
{
constexpr SkColorType ct = SkColorType::kSRGBA_8888_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = SkColorType::kSRGBA_8888_SkColorType;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_B8G8R8A8_SRGB
{
constexpr VkFormat format = VK_FORMAT_B8G8R8A8_SRGB;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_B8G8R8A8_SRGB, Surface: kRGBA_8888_SRGB
{
constexpr SkColorType ct = SkColorType::kSRGBA_8888_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
// Since the B and R channels are swapped and there's no BGRA sRGB color type,
// just disable read/writes back to the CPU.
ctInfo.fTransferColorType = SkColorType::kUnknown_SkColorType;
ctInfo.fFlags = ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R16_UNORM
{
constexpr VkFormat format = VK_FORMAT_R16_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16_UNORM, Surface: kAlpha_16
{
constexpr SkColorType ct = SkColorType::kA16_unorm_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
ctInfo.fReadSwizzle = skgpu::Swizzle("000r");
ctInfo.fWriteSwizzle = skgpu::Swizzle("a000");
}
}
}
// Format: VK_FORMAT_R16G16_UNORM
{
constexpr VkFormat format = VK_FORMAT_R16G16_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16_UNORM, Surface: kRG_1616
{
constexpr SkColorType ct = SkColorType::kR16G16_unorm_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R16G16B16A16_UNORM
{
constexpr VkFormat format = VK_FORMAT_R16G16B16A16_UNORM;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16B16A16_UNORM, Surface: kRGBA_16161616
{
constexpr SkColorType ct = SkColorType::kR16G16B16A16_unorm_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_R16G16_SFLOAT
{
constexpr VkFormat format = VK_FORMAT_R16G16_SFLOAT;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_R16G16_SFLOAT, Surface: kRG_F16
{
constexpr SkColorType ct = SkColorType::kR16G16_float_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
}
}
}
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
{
constexpr VkFormat format = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM;
auto& info = this->getFormatInfo(format);
if (fSupportsYcbcrConversion) {
info.init(interface, physDev, properties, format);
}
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
}
SkDEBUGCODE(info.fIsWrappedOnly = true;)
}
}
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
{
constexpr VkFormat format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
auto& info = this->getFormatInfo(format);
if (fSupportsYcbcrConversion) {
info.init(interface, physDev, properties, format);
}
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
}
SkDEBUGCODE(info.fIsWrappedOnly = true;)
}
}
// Format: VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
{
constexpr VkFormat format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
}
}
}
// Format: VK_FORMAT_BC1_RGB_UNORM_BLOCK
{
constexpr VkFormat format = VK_FORMAT_BC1_RGB_UNORM_BLOCK;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_BC1_RGB_UNORM_BLOCK, Surface: kRGB_888x
{
constexpr SkColorType ct = SkColorType::kRGB_888x_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
}
}
}
// Format: VK_FORMAT_BC1_RGBA_UNORM_BLOCK
{
constexpr VkFormat format = VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
auto& info = this->getFormatInfo(format);
info.init(interface, physDev, properties, format);
if (info.isTexturable(VK_IMAGE_TILING_OPTIMAL)) {
info.fColorTypeInfoCount = 1;
info.fColorTypeInfos = std::make_unique<ColorTypeInfo[]>(info.fColorTypeInfoCount);
int ctIdx = 0;
// Format: VK_FORMAT_BC1_RGBA_UNORM_BLOCK, Surface: kRGBA_8888
{
constexpr SkColorType ct = SkColorType::kRGBA_8888_SkColorType;
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
ctInfo.fColorType = ct;
ctInfo.fTransferColorType = ct;
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
}
}
}
////////////////////////////////////////////////////////////////////////////
// Map SkColorType (used for creating Surfaces) to VkFormats. The order in which the formats are
// passed into the setColorType function indicates the priority in selecting which format we use
// for a given SkColorType.
typedef SkColorType ct;
this->setColorType(ct::kAlpha_8_SkColorType, { VK_FORMAT_R8_UNORM });
this->setColorType(ct::kRGB_565_SkColorType, { VK_FORMAT_R5G6B5_UNORM_PACK16 });
this->setColorType(ct::kARGB_4444_SkColorType, { VK_FORMAT_R4G4B4A4_UNORM_PACK16,
VK_FORMAT_B4G4R4A4_UNORM_PACK16 });
this->setColorType(ct::kRGBA_8888_SkColorType, { VK_FORMAT_R8G8B8A8_UNORM });
this->setColorType(ct::kSRGBA_8888_SkColorType, { VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_B8G8R8A8_SRGB });
this->setColorType(ct::kRGB_888x_SkColorType, { VK_FORMAT_R8G8B8_UNORM,
VK_FORMAT_R8G8B8A8_UNORM });
this->setColorType(ct::kR8G8_unorm_SkColorType, { VK_FORMAT_R8G8_UNORM });
this->setColorType(ct::kBGRA_8888_SkColorType, { VK_FORMAT_B8G8R8A8_UNORM });
this->setColorType(ct::kRGBA_1010102_SkColorType, { VK_FORMAT_A2B10G10R10_UNORM_PACK32 });
this->setColorType(ct::kBGRA_1010102_SkColorType, { VK_FORMAT_A2R10G10B10_UNORM_PACK32 });
this->setColorType(ct::kRGB_101010x_SkColorType, { VK_FORMAT_A2B10G10R10_UNORM_PACK32 });
this->setColorType(ct::kGray_8_SkColorType, { VK_FORMAT_R8_UNORM });
this->setColorType(ct::kA16_float_SkColorType, { VK_FORMAT_R16_SFLOAT });
this->setColorType(ct::kRGBA_F16_SkColorType, { VK_FORMAT_R16G16B16A16_SFLOAT });
this->setColorType(ct::kRGB_F16F16F16x_SkColorType, { VK_FORMAT_R16G16B16A16_SFLOAT });
this->setColorType(ct::kA16_unorm_SkColorType, { VK_FORMAT_R16_UNORM });
this->setColorType(ct::kR16G16_unorm_SkColorType, { VK_FORMAT_R16G16_UNORM });
this->setColorType(ct::kR16G16B16A16_unorm_SkColorType, { VK_FORMAT_R16G16B16A16_UNORM });
this->setColorType(ct::kR16G16_float_SkColorType, { VK_FORMAT_R16G16_SFLOAT });
}