Remove uses of GrPixelConfig in GrVkCaps and other vk files.
Bug: skia:6718 Change-Id: I2f0d38b2b7a68a424732ced56e8b6c7e5965a722 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/235023 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
parent
6db3b7b03e
commit
0fac86944d
@ -483,7 +483,11 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format
|
|||||||
|
|
||||||
SkASSERT(GrCaps::AreConfigsCompatible(desc.fConfig,
|
SkASSERT(GrCaps::AreConfigsCompatible(desc.fConfig,
|
||||||
caps->getConfigFromBackendFormat(format, colorType)));
|
caps->getConfigFromBackendFormat(format, colorType)));
|
||||||
SkASSERT(caps->areColorTypeAndFormatCompatible(colorType, format));
|
// TODO: This check should be removed once we get the swizzle outside of GrProxyProvider and
|
||||||
|
// either pass them to the proxy or store the on some view object.
|
||||||
|
if (!caps->areColorTypeAndFormatCompatible(colorType, format)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if (GrMipMapped::kYes == mipMapped) {
|
if (GrMipMapped::kYes == mipMapped) {
|
||||||
// SkMipMap doesn't include the base level in the level count so we have to add 1
|
// SkMipMap doesn't include the base level in the level count so we have to add 1
|
||||||
|
@ -3960,7 +3960,14 @@ static GrPixelConfig validate_sized_format(GrGLFormat format,
|
|||||||
|
|
||||||
bool GrGLCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
bool GrGLCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
const GrBackendFormat& format) const {
|
const GrBackendFormat& format) const {
|
||||||
return kUnknown_GrPixelConfig != validate_sized_format(format.asGLFormat(), ct, fStandard);
|
GrGLFormat glFormat = format.asGLFormat();
|
||||||
|
const auto& info = this->getFormatInfo(glFormat);
|
||||||
|
for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
|
||||||
|
if (info.fColorTypeInfos[i].fColorType == ct) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrPixelConfig GrGLCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
GrPixelConfig GrGLCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
||||||
@ -4097,12 +4104,6 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrGLCaps::getTestingCombinat
|
|||||||
GrBackendFormat::MakeGL(GR_GL_BGRA8, GR_GL_TEXTURE_2D) });
|
GrBackendFormat::MakeGL(GR_GL_BGRA8, GR_GL_TEXTURE_2D) });
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
for (auto combo : combos) {
|
|
||||||
SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return combos;
|
return combos;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -654,6 +654,37 @@ static constexpr VkFormat kVkFormats[] = {
|
|||||||
VK_FORMAT_R16G16_SFLOAT,
|
VK_FORMAT_R16G16_SFLOAT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void GrVkCaps::setColorType(GrColorType colorType, std::initializer_list<VkFormat> formats) {
|
||||||
|
#ifdef SK_DEBUG
|
||||||
|
for (size_t i = 0; i < kNumVkFormats; ++i) {
|
||||||
|
const auto& formatInfo = fFormatTable[i];
|
||||||
|
for (int j = 0; j < formatInfo.fColorTypeInfoCount; ++j) {
|
||||||
|
const auto& ctInfo = formatInfo.fColorTypeInfos[j];
|
||||||
|
if (ctInfo.fColorType == colorType &&
|
||||||
|
!SkToBool(ctInfo.fFlags & ColorTypeInfo::kWrappedOnly_Flag)) {
|
||||||
|
bool found = false;
|
||||||
|
for (auto it = formats.begin(); it != formats.end(); ++it) {
|
||||||
|
if (kVkFormats[i] == *it) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SkASSERT(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
int idx = static_cast<int>(colorType);
|
||||||
|
for (auto it = formats.begin(); it != formats.end(); ++it) {
|
||||||
|
const auto& info = this->getFormatInfo(*it);
|
||||||
|
for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
|
||||||
|
if (info.fColorTypeInfos[i].fColorType == colorType) {
|
||||||
|
fColorTypeToFormatTable[idx] = *it;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const GrVkCaps::FormatInfo& GrVkCaps::getFormatInfo(VkFormat format) const {
|
const GrVkCaps::FormatInfo& GrVkCaps::getFormatInfo(VkFormat format) const {
|
||||||
GrVkCaps* nonConstThis = const_cast<GrVkCaps*>(this);
|
GrVkCaps* nonConstThis = const_cast<GrVkCaps*>(this);
|
||||||
return nonConstThis->getFormatInfo(format);
|
return nonConstThis->getFormatInfo(format);
|
||||||
@ -676,26 +707,30 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
static_assert(SK_ARRAY_COUNT(kVkFormats) == GrVkCaps::kNumVkFormats,
|
static_assert(SK_ARRAY_COUNT(kVkFormats) == GrVkCaps::kNumVkFormats,
|
||||||
"Size of VkFormats array must match static value in header");
|
"Size of VkFormats array must match static value in header");
|
||||||
|
|
||||||
// Go through all the formats and init their support surface and data GrColorTypes.
|
std::fill_n(fColorTypeToFormatTable, kGrColorTypeCnt, VK_FORMAT_UNDEFINED);
|
||||||
|
|
||||||
|
// Go through all the formats and init their support surface and data GrColorTypes.
|
||||||
// Format: VK_FORMAT_R8G8B8A8_UNORM
|
// Format: VK_FORMAT_R8G8B8A8_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R8G8B8A8_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R8G8B8A8_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 2;
|
info.fColorTypeInfoCount = 2;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGBA_8888
|
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGBA_8888
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_8888;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_8888;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGB_888x
|
// Format: VK_FORMAT_R8G8B8A8_UNORM, Surface: kRGB_888x
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGB_888x;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGB_888x;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
||||||
ctInfo.fTextureSwizzle = GrSwizzle::RGB1();
|
ctInfo.fTextureSwizzle = GrSwizzle::RGB1();
|
||||||
}
|
}
|
||||||
@ -704,24 +739,27 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
|
|
||||||
// Format: VK_FORMAT_R8_UNORM
|
// Format: VK_FORMAT_R8_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R8_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R8_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R8_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 2;
|
info.fColorTypeInfoCount = 2;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R8_UNORM, Surface: kAlpha_8
|
// Format: VK_FORMAT_R8_UNORM, Surface: kAlpha_8
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kAlpha_8;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kAlpha_8;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
ctInfo.fTextureSwizzle = GrSwizzle::RRRR();
|
ctInfo.fTextureSwizzle = GrSwizzle::RRRR();
|
||||||
ctInfo.fOutputSwizzle = GrSwizzle::AAAA();
|
ctInfo.fOutputSwizzle = GrSwizzle::AAAA();
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R8_UNORM, Surface: kGray_8
|
// Format: VK_FORMAT_R8_UNORM, Surface: kGray_8
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kGray_8;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kGray_8;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
||||||
ctInfo.fTextureSwizzle = GrSwizzle("rrr1");
|
ctInfo.fTextureSwizzle = GrSwizzle("rrr1");
|
||||||
}
|
}
|
||||||
@ -729,70 +767,79 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
}
|
}
|
||||||
// Format: VK_FORMAT_B8G8R8A8_UNORM
|
// Format: VK_FORMAT_B8G8R8A8_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_B8G8R8A8_UNORM);
|
constexpr VkFormat format = VK_FORMAT_B8G8R8A8_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_B8G8R8A8_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_B8G8R8A8_UNORM, Surface: kBGRA_8888
|
// Format: VK_FORMAT_B8G8R8A8_UNORM, Surface: kBGRA_8888
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kBGRA_8888;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kBGRA_8888;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16
|
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R5G6B5_UNORM_PACK16);
|
constexpr VkFormat format = VK_FORMAT_R5G6B5_UNORM_PACK16;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R5G6B5_UNORM_PACK16);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16, Surface: kBGR_565
|
// Format: VK_FORMAT_R5G6B5_UNORM_PACK16, Surface: kBGR_565
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kBGR_565;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kBGR_565;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16G16B16A16_SFLOAT
|
// Format: VK_FORMAT_R16G16B16A16_SFLOAT
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16G16B16A16_SFLOAT);
|
constexpr VkFormat format = VK_FORMAT_R16G16B16A16_SFLOAT;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16G16B16A16_SFLOAT);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 2;
|
info.fColorTypeInfoCount = 2;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: GrColorType::kRGBA_F16
|
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: GrColorType::kRGBA_F16
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_F16;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_F16;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: GrColorType::kRGBA_F16_Clamped
|
// Format: VK_FORMAT_R16G16B16A16_SFLOAT, Surface: GrColorType::kRGBA_F16_Clamped
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_F16_Clamped;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_F16_Clamped;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16_SFLOAT
|
// Format: VK_FORMAT_R16_SFLOAT
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16_SFLOAT);
|
constexpr VkFormat format = VK_FORMAT_R16_SFLOAT;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16_SFLOAT);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16_SFLOAT, Surface: kAlpha_F16
|
// Format: VK_FORMAT_R16_SFLOAT, Surface: kAlpha_F16
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kAlpha_F16;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kAlpha_F16;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
ctInfo.fTextureSwizzle = GrSwizzle::RRRR();
|
ctInfo.fTextureSwizzle = GrSwizzle::RRRR();
|
||||||
ctInfo.fOutputSwizzle = GrSwizzle::AAAA();
|
ctInfo.fOutputSwizzle = GrSwizzle::AAAA();
|
||||||
@ -801,64 +848,72 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R8G8B8_UNORM
|
// Format: VK_FORMAT_R8G8B8_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R8G8B8_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R8G8B8_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R8G8B8_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R8G8B8_UNORM, Surface: kRGB_888x
|
// Format: VK_FORMAT_R8G8B8_UNORM, Surface: kRGB_888x
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGB_888x;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGB_888x;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R8G8_UNORM
|
// Format: VK_FORMAT_R8G8_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R8G8_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R8G8_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R8G8_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R8G8_UNORM, Surface: kRG_88
|
// Format: VK_FORMAT_R8G8_UNORM, Surface: kRG_88
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRG_88;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRG_88;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32
|
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_A2B10G10R10_UNORM_PACK32);
|
constexpr VkFormat format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_A2B10G10R10_UNORM_PACK32);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32, Surface: kRGBA_1010102
|
// Format: VK_FORMAT_A2B10G10R10_UNORM_PACK32, Surface: kRGBA_1010102
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_1010102;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_1010102;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16
|
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_B4G4R4A4_UNORM_PACK16);
|
constexpr VkFormat format = VK_FORMAT_B4G4R4A4_UNORM_PACK16;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_B4G4R4A4_UNORM_PACK16);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16, Surface: kABGR_4444
|
// Format: VK_FORMAT_B4G4R4A4_UNORM_PACK16, Surface: kABGR_4444
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kABGR_4444;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kABGR_4444;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
ctInfo.fTextureSwizzle = GrSwizzle::BGRA();
|
ctInfo.fTextureSwizzle = GrSwizzle::BGRA();
|
||||||
ctInfo.fOutputSwizzle = GrSwizzle::BGRA();
|
ctInfo.fOutputSwizzle = GrSwizzle::BGRA();
|
||||||
@ -867,41 +922,46 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16
|
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R4G4B4A4_UNORM_PACK16);
|
constexpr VkFormat format = VK_FORMAT_R4G4B4A4_UNORM_PACK16;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R4G4B4A4_UNORM_PACK16);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16, Surface: kABGR_4444
|
// Format: VK_FORMAT_R4G4B4A4_UNORM_PACK16, Surface: kABGR_4444
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kABGR_4444;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kABGR_4444;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R32G32B32A32_SFLOAT
|
// Format: VK_FORMAT_R32G32B32A32_SFLOAT
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R32G32B32A32_SFLOAT);
|
constexpr VkFormat format = VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R32G32B32A32_SFLOAT);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R32G32B32A32_SFLOAT, Surface: kRGBA_F32
|
// Format: VK_FORMAT_R32G32B32A32_SFLOAT, Surface: kRGBA_F32
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_F32;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_F32;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R8G8B8A8_SRGB
|
// Format: VK_FORMAT_R8G8B8A8_SRGB
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R8G8B8A8_SRGB);
|
constexpr VkFormat format = VK_FORMAT_R8G8B8A8_SRGB;
|
||||||
|
auto& info = this->getFormatInfo(format);
|
||||||
if (fSRGBSupport) {
|
if (fSRGBSupport) {
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R8G8B8A8_SRGB);
|
info.init(interface, physDev, properties, format);
|
||||||
}
|
}
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
@ -909,81 +969,91 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R8G8B8A8_SRGB, Surface: kRGBA_8888_SRGB
|
// Format: VK_FORMAT_R8G8B8A8_SRGB, Surface: kRGBA_8888_SRGB
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_8888_SRGB;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_8888_SRGB;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16_UNORM
|
// Format: VK_FORMAT_R16_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R16_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16_UNORM, Surface: kR_16
|
// Format: VK_FORMAT_R16_UNORM, Surface: kR_16
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kR_16;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kR_16;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16G16_UNORM
|
// Format: VK_FORMAT_R16G16_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16G16_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R16G16_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16G16_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16G16_UNORM, Surface: kRG_1616
|
// Format: VK_FORMAT_R16G16_UNORM, Surface: kRG_1616
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRG_1616;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRG_1616;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16G16B16A16_UNORM
|
// Format: VK_FORMAT_R16G16B16A16_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16G16B16A16_UNORM);
|
constexpr VkFormat format = VK_FORMAT_R16G16B16A16_UNORM;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16G16B16A16_UNORM);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16G16B16A16_UNORM, Surface: kRGBA_16161616
|
// Format: VK_FORMAT_R16G16B16A16_UNORM, Surface: kRGBA_16161616
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGBA_16161616;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGBA_16161616;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_R16G16_SFLOAT
|
// Format: VK_FORMAT_R16G16_SFLOAT
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_R16G16_SFLOAT);
|
constexpr VkFormat format = VK_FORMAT_R16G16_SFLOAT;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_R16G16_SFLOAT);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
info.fColorTypeInfos.reset(new ColorTypeInfo[info.fColorTypeInfoCount]());
|
||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_R16G16_SFLOAT, Surface: kRG_F16
|
// Format: VK_FORMAT_R16G16_SFLOAT, Surface: kRG_F16
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRG_F16;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRG_F16;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kRenderable_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
|
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(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) {
|
if (fSupportsYcbcrConversion) {
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM);
|
info.init(interface, physDev, properties, format);
|
||||||
}
|
}
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
@ -991,17 +1061,19 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, Surface: kRGB_888x
|
// Format: VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, Surface: kRGB_888x
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGB_888x;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGB_888x;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kWrappedOnly_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
|
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_G8_B8R8_2PLANE_420_UNORM);
|
constexpr VkFormat format = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||||
|
auto& info = this->getFormatInfo(format);
|
||||||
if (fSupportsYcbcrConversion) {
|
if (fSupportsYcbcrConversion) {
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_G8_B8R8_2PLANE_420_UNORM);
|
info.init(interface, physDev, properties, format);
|
||||||
}
|
}
|
||||||
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
if (SkToBool(info.fOptimalFlags & FormatInfo::kTexturable_Flag)) {
|
||||||
info.fColorTypeInfoCount = 1;
|
info.fColorTypeInfoCount = 1;
|
||||||
@ -1009,18 +1081,46 @@ void GrVkCaps::initFormatTable(const GrVkInterface* interface, VkPhysicalDevice
|
|||||||
int ctIdx = 0;
|
int ctIdx = 0;
|
||||||
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, Surface: kRGB_888x
|
// Format: VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, Surface: kRGB_888x
|
||||||
{
|
{
|
||||||
|
constexpr GrColorType ct = GrColorType::kRGB_888x;
|
||||||
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
auto& ctInfo = info.fColorTypeInfos[ctIdx++];
|
||||||
ctInfo.fColorType = GrColorType::kRGB_888x;
|
ctInfo.fColorType = ct;
|
||||||
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag;
|
ctInfo.fFlags = ColorTypeInfo::kUploadData_Flag | ColorTypeInfo::kWrappedOnly_Flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Format: VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
|
// Format: VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
|
||||||
{
|
{
|
||||||
auto& info = this->getFormatInfo(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK);
|
constexpr VkFormat format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
||||||
info.init(interface, physDev, properties, VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK);
|
auto& info = this->getFormatInfo(format);
|
||||||
|
info.init(interface, physDev, properties, format);
|
||||||
// No supported GrColorTypes.
|
// No supported GrColorTypes.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Map GrColorTypes (used for creating GrSurfaces) 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 GrcolorType.
|
||||||
|
|
||||||
|
this->setColorType(GrColorType::kAlpha_8, { VK_FORMAT_R8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kBGR_565, { VK_FORMAT_R5G6B5_UNORM_PACK16 });
|
||||||
|
this->setColorType(GrColorType::kABGR_4444, { VK_FORMAT_R4G4B4A4_UNORM_PACK16,
|
||||||
|
VK_FORMAT_B4G4R4A4_UNORM_PACK16 });
|
||||||
|
this->setColorType(GrColorType::kRGBA_8888, { VK_FORMAT_R8G8B8A8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRGBA_8888_SRGB, { VK_FORMAT_R8G8B8A8_SRGB });
|
||||||
|
this->setColorType(GrColorType::kRGB_888x, { VK_FORMAT_R8G8B8_UNORM,
|
||||||
|
VK_FORMAT_R8G8B8A8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRG_88, { VK_FORMAT_R8G8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kBGRA_8888, { VK_FORMAT_B8G8R8A8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRGBA_1010102, { VK_FORMAT_A2B10G10R10_UNORM_PACK32 });
|
||||||
|
this->setColorType(GrColorType::kGray_8, { VK_FORMAT_R8_UNORM });
|
||||||
|
this->setColorType(GrColorType::kAlpha_F16, { VK_FORMAT_R16_SFLOAT });
|
||||||
|
this->setColorType(GrColorType::kRGBA_F16, { VK_FORMAT_R16G16B16A16_SFLOAT });
|
||||||
|
this->setColorType(GrColorType::kRGBA_F16_Clamped, { VK_FORMAT_R16G16B16A16_SFLOAT });
|
||||||
|
this->setColorType(GrColorType::kRGBA_F32, { VK_FORMAT_R32G32B32A32_SFLOAT });
|
||||||
|
this->setColorType(GrColorType::kR_16, { VK_FORMAT_R16_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRG_1616, { VK_FORMAT_R16G16_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRGBA_16161616, { VK_FORMAT_R16G16B16A16_UNORM });
|
||||||
|
this->setColorType(GrColorType::kRG_F16, { VK_FORMAT_R16G16_SFLOAT });
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrVkCaps::FormatInfo::InitFormatFlags(VkFormatFeatureFlags vkFlags, uint16_t* flags) {
|
void GrVkCaps::FormatInfo::InitFormatFlags(VkFormatFeatureFlags vkFlags, uint16_t* flags) {
|
||||||
@ -1300,6 +1400,32 @@ bool GrVkCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GrVkCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
||||||
|
const GrBackendFormat& format) const {
|
||||||
|
VkFormat vkFormat;
|
||||||
|
if (!format.asVkFormat(&vkFormat)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const GrVkYcbcrConversionInfo* ycbcrInfo = format.getVkYcbcrConversionInfo();
|
||||||
|
SkASSERT(ycbcrInfo);
|
||||||
|
|
||||||
|
if (ycbcrInfo->isValid() && !GrVkFormatNeedsYcbcrSampler(vkFormat)) {
|
||||||
|
// Format may be undefined for external images, which are required to have YCbCr conversion.
|
||||||
|
if (VK_FORMAT_UNDEFINED == vkFormat) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& info = this->getFormatInfo(vkFormat);
|
||||||
|
for (int i = 0; i < info.fColorTypeInfoCount; ++i) {
|
||||||
|
if (info.fColorTypeInfos[i].fColorType == ct) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool hasYcbcrConversion) {
|
static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool hasYcbcrConversion) {
|
||||||
if (hasYcbcrConversion) {
|
if (hasYcbcrConversion) {
|
||||||
if (GrVkFormatNeedsYcbcrSampler(format)) {
|
if (GrVkFormatNeedsYcbcrSampler(format)) {
|
||||||
@ -1429,19 +1555,6 @@ static GrPixelConfig validate_image_info(VkFormat format, GrColorType ct, bool h
|
|||||||
return kUnknown_GrPixelConfig;
|
return kUnknown_GrPixelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrVkCaps::onAreColorTypeAndFormatCompatible(GrColorType ct,
|
|
||||||
const GrBackendFormat& format) const {
|
|
||||||
VkFormat vkFormat;
|
|
||||||
if (!format.asVkFormat(&vkFormat)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const GrVkYcbcrConversionInfo* ycbcrInfo = format.getVkYcbcrConversionInfo();
|
|
||||||
SkASSERT(ycbcrInfo);
|
|
||||||
|
|
||||||
return kUnknown_GrPixelConfig != validate_image_info(vkFormat, ct, ycbcrInfo->isValid());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GrPixelConfig GrVkCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
GrPixelConfig GrVkCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
|
||||||
GrColorType ct) const {
|
GrColorType ct) const {
|
||||||
VkFormat vkFormat;
|
VkFormat vkFormat;
|
||||||
@ -1481,12 +1594,8 @@ GrColorType GrVkCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& f
|
|||||||
|
|
||||||
GrBackendFormat GrVkCaps::onGetDefaultBackendFormat(GrColorType ct,
|
GrBackendFormat GrVkCaps::onGetDefaultBackendFormat(GrColorType ct,
|
||||||
GrRenderable renderable) const {
|
GrRenderable renderable) const {
|
||||||
GrPixelConfig config = GrColorTypeToPixelConfig(ct);
|
VkFormat format = this->getFormatFromColorType(ct);
|
||||||
if (config == kUnknown_GrPixelConfig) {
|
if (format == VK_FORMAT_UNDEFINED) {
|
||||||
return GrBackendFormat();
|
|
||||||
}
|
|
||||||
VkFormat format;
|
|
||||||
if (!GrPixelConfigToVkFormat(config, &format)) {
|
|
||||||
return GrBackendFormat();
|
return GrBackendFormat();
|
||||||
}
|
}
|
||||||
return GrBackendFormat::MakeVk(format);
|
return GrBackendFormat::MakeVk(format);
|
||||||
@ -1588,12 +1697,6 @@ std::vector<GrCaps::TestFormatColorTypeCombination> GrVkCaps::getTestingCombinat
|
|||||||
{ GrColorType::kRG_F16, GrBackendFormat::MakeVk(VK_FORMAT_R16G16_SFLOAT) },
|
{ GrColorType::kRG_F16, GrBackendFormat::MakeVk(VK_FORMAT_R16G16_SFLOAT) },
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
|
||||||
for (auto combo : combos) {
|
|
||||||
SkASSERT(this->onAreColorTypeAndFormatCompatible(combo.fColorType, combo.fFormat));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return combos;
|
return combos;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -161,6 +161,11 @@ public:
|
|||||||
|
|
||||||
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
|
GrBackendFormat getBackendFormatFromCompressionType(SkImage::CompressionType) const override;
|
||||||
|
|
||||||
|
VkFormat getFormatFromColorType(GrColorType colorType) const {
|
||||||
|
int idx = static_cast<int>(colorType);
|
||||||
|
return fColorTypeToFormatTable[idx];
|
||||||
|
}
|
||||||
|
|
||||||
bool canClearTextureOnCreation() const override;
|
bool canClearTextureOnCreation() const override;
|
||||||
|
|
||||||
GrSwizzle getTextureSwizzle(const GrBackendFormat&, GrColorType) const override;
|
GrSwizzle getTextureSwizzle(const GrBackendFormat&, GrColorType) const override;
|
||||||
@ -218,6 +223,9 @@ private:
|
|||||||
// Does Ganesh itself support rendering to this colorType & format pair. Renderability
|
// Does Ganesh itself support rendering to this colorType & format pair. Renderability
|
||||||
// still additionally depends on if the format itself is renderable.
|
// still additionally depends on if the format itself is renderable.
|
||||||
kRenderable_Flag = 0x2,
|
kRenderable_Flag = 0x2,
|
||||||
|
// Indicates that this colorType is supported only if we are wrapping a texture with
|
||||||
|
// the given format and colorType. We do not allow creation with this pair.
|
||||||
|
kWrappedOnly_Flag = 0x4,
|
||||||
};
|
};
|
||||||
uint32_t fFlags = 0;
|
uint32_t fFlags = 0;
|
||||||
|
|
||||||
@ -262,6 +270,9 @@ private:
|
|||||||
FormatInfo& getFormatInfo(VkFormat);
|
FormatInfo& getFormatInfo(VkFormat);
|
||||||
const FormatInfo& getFormatInfo(VkFormat) const;
|
const FormatInfo& getFormatInfo(VkFormat) const;
|
||||||
|
|
||||||
|
VkFormat fColorTypeToFormatTable[kGrColorTypeCnt];
|
||||||
|
void setColorType(GrColorType, std::initializer_list<VkFormat> formats);
|
||||||
|
|
||||||
StencilFormat fPreferredStencilFormat;
|
StencilFormat fPreferredStencilFormat;
|
||||||
|
|
||||||
SkSTArray<1, GrVkYcbcrConversionInfo> fYcbcrInfos;
|
SkSTArray<1, GrVkYcbcrConversionInfo> fYcbcrInfos;
|
||||||
|
@ -1929,14 +1929,7 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h
|
|||||||
return GrBackendRenderTarget();
|
return GrBackendRenderTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto config = GrColorTypeToPixelConfig(ct);
|
VkFormat vkFormat = this->vkCaps().getFormatFromColorType(ct);
|
||||||
if (kUnknown_GrPixelConfig == config) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
VkFormat vkFormat;
|
|
||||||
if (!GrPixelConfigToVkFormat(config, &vkFormat)) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
GrVkImageInfo info;
|
GrVkImageInfo info;
|
||||||
if (!this->createVkImageForBackendSurface(vkFormat, w, h, false, true, GrMipMapped::kNo,
|
if (!this->createVkImageForBackendSurface(vkFormat, w, h, false, true, GrMipMapped::kNo,
|
||||||
|
@ -139,8 +139,7 @@ sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeWrappedRenderTarget(GrVkGpu* gpu,
|
|||||||
SkASSERT(VK_NULL_HANDLE != info.fImage);
|
SkASSERT(VK_NULL_HANDLE != info.fImage);
|
||||||
|
|
||||||
SkASSERT(1 == info.fLevelCount);
|
SkASSERT(1 == info.fLevelCount);
|
||||||
VkFormat pixelFormat;
|
VkFormat pixelFormat = info.fFormat;
|
||||||
GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat);
|
|
||||||
|
|
||||||
VkImage colorImage;
|
VkImage colorImage;
|
||||||
|
|
||||||
|
@ -117,8 +117,7 @@ static Views create_views(GrVkGpu* gpu, const GrSurfaceDesc& desc, int sampleCnt
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
VkFormat pixelFormat;
|
VkFormat pixelFormat = info.fFormat;
|
||||||
GrPixelConfigToVkFormat(desc.fConfig, &pixelFormat);
|
|
||||||
|
|
||||||
VkImage colorImage;
|
VkImage colorImage;
|
||||||
|
|
||||||
|
@ -12,91 +12,6 @@
|
|||||||
#include "src/gpu/vk/GrVkGpu.h"
|
#include "src/gpu/vk/GrVkGpu.h"
|
||||||
#include "src/sksl/SkSLCompiler.h"
|
#include "src/sksl/SkSLCompiler.h"
|
||||||
|
|
||||||
bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) {
|
|
||||||
VkFormat dontCare;
|
|
||||||
if (!format) {
|
|
||||||
format = &dontCare;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (config) {
|
|
||||||
case kUnknown_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kRGBA_8888_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kRGB_888_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8G8B8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kRGB_888X_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kRG_88_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8G8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kBGRA_8888_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_B8G8R8A8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kSRGBA_8888_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8G8B8A8_SRGB;
|
|
||||||
return true;
|
|
||||||
case kRGBA_1010102_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_A2B10G10R10_UNORM_PACK32;
|
|
||||||
return true;
|
|
||||||
case kRGB_565_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R5G6B5_UNORM_PACK16;
|
|
||||||
return true;
|
|
||||||
case kRGBA_4444_GrPixelConfig:
|
|
||||||
// R4G4B4A4 is not required to be supported so we actually
|
|
||||||
// store the data is if it was B4G4R4A4 and swizzle in shaders
|
|
||||||
*format = VK_FORMAT_B4G4R4A4_UNORM_PACK16;
|
|
||||||
return true;
|
|
||||||
case kAlpha_8_GrPixelConfig: // fall through
|
|
||||||
case kAlpha_8_as_Red_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kGray_8_GrPixelConfig:
|
|
||||||
case kGray_8_as_Red_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R8_UNORM;
|
|
||||||
return true;
|
|
||||||
case kGray_8_as_Lum_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kRGBA_float_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R32G32B32A32_SFLOAT;
|
|
||||||
return true;
|
|
||||||
case kRGBA_half_GrPixelConfig:
|
|
||||||
case kRGBA_half_Clamped_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16G16B16A16_SFLOAT;
|
|
||||||
return true;
|
|
||||||
case kRGB_ETC1_GrPixelConfig:
|
|
||||||
// converting to ETC2 which is a superset of ETC1
|
|
||||||
*format = VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
|
||||||
return true;
|
|
||||||
case kAlpha_half_GrPixelConfig: // fall through
|
|
||||||
case kAlpha_half_as_Red_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16_SFLOAT;
|
|
||||||
return true;
|
|
||||||
case kAlpha_half_as_Lum_GrPixelConfig:
|
|
||||||
return false;
|
|
||||||
case kR_16_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16_UNORM;
|
|
||||||
return true;
|
|
||||||
case kRG_1616_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16G16_UNORM;
|
|
||||||
return true;
|
|
||||||
// Experimental (for Y416 and mutant P016/P010)
|
|
||||||
case kRGBA_16161616_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16G16B16A16_UNORM;
|
|
||||||
return true;
|
|
||||||
case kRG_half_GrPixelConfig:
|
|
||||||
*format = VK_FORMAT_R16G16_SFLOAT;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
SK_ABORT("Unexpected config");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
#ifdef SK_DEBUG
|
||||||
bool GrVkFormatColorTypePairIsValid(VkFormat format, GrColorType colorType) {
|
bool GrVkFormatColorTypePairIsValid(VkFormat format, GrColorType colorType) {
|
||||||
switch (format) {
|
switch (format) {
|
||||||
|
@ -29,11 +29,6 @@ class GrVkGpu;
|
|||||||
#define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X)
|
#define GR_VK_CALL_ERRCHECK(IFACE, X) (void) GR_VK_CALL(IFACE, X)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the vulkan texture format for the given GrPixelConfig
|
|
||||||
*/
|
|
||||||
bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format);
|
|
||||||
|
|
||||||
bool GrVkFormatIsSupported(VkFormat);
|
bool GrVkFormatIsSupported(VkFormat);
|
||||||
|
|
||||||
bool GrVkFormatNeedsYcbcrSampler(VkFormat format);
|
bool GrVkFormatNeedsYcbcrSampler(VkFormat format);
|
||||||
|
Loading…
Reference in New Issue
Block a user